Hi,
Consider a model where a set is defined as follows:
set s /s1*s100/;
All the parameters and variables including objective function are defined in "s". For instance, OF(s), X(s), etc.
My problem is simple, but I cannot find a way to solve it.
I want to solve the problem for each "s" i.e., 100 times. However, as we know, GAMS can only solve problems in which the objective function has no domain.
How can I solve this problem?
Any help or useful suggestion is highly appreciated.
Thanks.
Objective Function with Domain
Re: Objective Function with Domain
Hi,
You need to do two things:
1) Work with a dynamic set sx(s) that contains only the elements of s you want in your single solve (it seems that in your case you just want one element).
2) Make an extra objective variable with in an extra constraint.
The code could look like this:
-Michael
You need to do two things:
1) Work with a dynamic set sx(s) that contains only the elements of s you want in your single solve (it seems that in your case you just want one element).
2) Make an extra objective variable with in an extra constraint.
The code could look like this:
Code: Select all
set s /s1*s100/, sx(s);
variable obj(s), objx;
equation defobj(s); defobj(sx).. obj(sx) =e= OF(sx) + X(sx);
equation defobjx; defobjx.. objx =e= sum(sx, obj(sx));
...
model m /all/;
loop(s,
option clear=sx; sx(s) = yes;
solve m using lp min objx;
);
Re: Objective Function with Domain
Dear Michael,
I really appreciate your very useful suggestion.
That was a great idea and my code is properly working.
Thanks a lot.
I really appreciate your very useful suggestion.
That was a great idea and my code is properly working.
Thanks a lot.
bussieck wrote: ↑6 years ago Hi,
You need to do two things:
1) Work with a dynamic set sx(s) that contains only the elements of s you want in your single solve (it seems that in your case you just want one element).
2) Make an extra objective variable with in an extra constraint.
The code could look like this:
-MichaelCode: Select all
set s /s1*s100/, sx(s); variable obj(s), objx; equation defobj(s); defobj(sx).. obj(sx) =e= OF(sx) + X(sx); equation defobjx; defobjx.. objx =e= sum(sx, obj(sx)); ... model m /all/; loop(s, option clear=sx; sx(s) = yes; solve m using lp min objx; );