Looping over objective function possible?

Problems with modeling
Post Reply
Gaucho
User
User
Posts: 10
Joined: 4 years ago

Looping over objective function possible?

Post by Gaucho »

Hello everyone,

I want to change a parameter in steps of 0.1 with the objective function giving me the results of every step.
Is it even possible to generate more than one output of the objective function?

Kind regards
User avatar
bussieck
Moderator
Moderator
Posts: 1037
Joined: 7 years ago

Re: Looping over objective function possible?

Post by bussieck »

You can loop in GAMS. Lets say you want to solve your model over and over again with values for parameter p from 1 to 3 in steps of 0.1, the following code does that:

Code: Select all

...
set ps / p1*p30 /;
parameter objrep(ps);
loop(ps,
  p = 1 + (ord(ps)-1)/10;
  solve mymodel min z us lp;
  objrep(ps) = z.l;
);
...
-Michael
Gaucho
User
User
Posts: 10
Joined: 4 years ago

Re: Looping over objective function possible?

Post by Gaucho »

Thank you so much.
It worked!
Post Reply