Objective Function with Domain

Problems with modeling
Post Reply
Only_God
User
User
Posts: 11
Joined: 6 years ago

Objective Function with Domain

Post by Only_God »

Dear GAMS users,
Hi,
As you know objective function in GAMS should be a free variable without domain.
However, I have a model in which the objective function is defined over the all elements of a set.
For instance, assume that
set s /s1*s100/;
The objective function is OF(s).
Indeed, for each s, the model should be run and the value of objective function should be recorded.
How can I do this? Would you please help me?
Any useful helps is welcome.
Sincerely yours.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Objective Function with Domain

Post by Renger »

Hi
Just use a loop

loop(s,

solve mymodel using nlp maximizing OBJ;

results("OBJ",s) = OBJ.L;

);

display results;

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Only_God
User
User
Posts: 11
Joined: 6 years ago

Re: Objective Function with Domain

Post by Only_God »

Dear Renger,
Thanks for your answer.
My problem was already solved by the helpful reply of Michael in the previous post using the dynamic set.
However, please note that I cannot use your way because OBJ is defined over the set s.
Sincerely yours.
Renger wrote: 6 years ago Hi
Just use a loop

loop(s,

solve mymodel using nlp maximizing OBJ;

results("OBJ",s) = OBJ.L;

);

display results;

Cheers
Renger
Post Reply