Help To understand the code

Problems with modeling
Post Reply
sadiksha123
User
User
Posts: 5
Joined: 3 years ago

Help To understand the code

Post by sadiksha123 »

Chapter 4 (Gcode4.1) PSO Library

Main Equations given in the book
Screenshot 2021-02-03 111212.png
Screenshot 2021-02-03 111212.png (9.23 KiB) Viewed 1442 times
Equation in the GAMS code Gcode 4.1
Genconst3(i,t).. p(i,t+1) - p(i,t) =l= gendata(i,'RU0');

Genconst4(i,t).. p(i,t-1) - p(i,t) =l= gendata(i,'RD0');

why is the equation 4.5d p(i,t+1)-p(i,t) =l=gendata(i,'RU0' like this instead of p(i,t)-p(i,t-1)=l='RU0'
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Help To understand the code

Post by abhosekar »

Short answer is that it is a matter of choice, both can be made to work.

when you are dealing with indices like t, t-1 or t , t + 1 it is important to understand what happens at the end points (first and last t).
You can certainly write your equation as p(i,t)-p(i,t-1)=l=... and it will also be correct. What matters is how you declare equation.
Let's say your set t is /1*10/. In this case, you should have something in place of p(i,'0') as it is not defined naturally.
A general way to do it is as follows:

p(i,t) - p(i,t-1)$(ord(t) ne 1) - b$(ord(t) eq 1) =l= ....

where b is a parameter for p(i,'0') and will be included only got t =0. You can do the same for equations containing t +1.

Best way to test such things is by checking your .lst and solEq section. You can change number of rows displayed by setting option limrow=1000;

Hope this helps.

- Atharv
Post Reply