problem with problem 149 - uncontrolled set entered as constant

Problems with syntax of GAMS
Post Reply
MarysPV
User
User
Posts: 2
Joined: 2 years ago

problem with problem 149 - uncontrolled set entered as constant

Post by MarysPV »

Hello, I have a problem solving problem 149. I believe that the algorithm cannot determine the initial value of X(J-1), which for J=1 is equal to 0, to which the difference value N(J) -S(J) is then added. Could I please have a question on how to fix this problem?

OPTION NLP = CONOPT
SET
J index_prome /1*5/;
PARAMETERS
S(J) SO /1 0.254, 2 0.318, 3 0.287, 4 0.275, 5 0.290/
N(J) NO /1 0.382, 2 0.300, 3 0.374, 4 0.296, 5 0.399/;
VARIABLE X(J);
EQUATIONS LOKAL;
LOKAL.. X(J)=E= X(J-1)+(N(J)- S(J)); - there are 4x 149 problem uncontrolled set entered as constant
DISPLAY X(J)
GFA
User
User
Posts: 50
Joined: 5 years ago

Re: problem with problem 149 - uncontrolled set entered as constant

Post by GFA »

Hi,

Have a look at: https://www.gams.com/33/docs/UG_Equations.html " Indexed Equations". You might need this addition:
LOKAL(J).. X(J)=E= X(J-1)+(N(J)- S(J));

By the way, in the display-statement referencing to indices is not needed. Also, when displaying variables you need to state the variable attribute. Do you for example want to display the lower/upper bound of the variable, or the level (.l - most likely), then use
DISPLAY X.L
See also: https://www.gams.com/latest/docs/UG_Var ... Attributes

Hope this helps.

Cheers,
GFA
MarysPV
User
User
Posts: 2
Joined: 2 years ago

Re: problem with problem 149 - uncontrolled set entered as constant

Post by MarysPV »

GFA wrote: 2 years ago Hi,

Have a look at: https://www.gams.com/33/docs/UG_Equations.html " Indexed Equations". You might need this addition:
LOKAL(J).. X(J)=E= X(J-1)+(N(J)- S(J));

By the way, in the display-statement referencing to indices is not needed. Also, when displaying variables you need to state the variable attribute. Do you for example want to display the lower/upper bound of the variable, or the level (.l - most likely), then use
DISPLAY X.L
See also: https://www.gams.com/latest/docs/UG_Var ... Attributes

Hope this helps.

Cheers,
GFA
Thanks for helping all is fixed, plus huge thanks for pointing other stuff to improve. Cheers, you made my day ;)
Post Reply