Minimum of Unrelated Parameters Topic is solved

Problems with syntax of GAMS
Post Reply
NiobiumFire2
User
User
Posts: 5
Joined: 5 months ago

Minimum of Unrelated Parameters

Post by NiobiumFire2 » 1 month ago

Hi everyone,

I am in need of a way to express the minimum of two parameters in a model constraint. The two parameters are not of the same set.

For example:

"equation(i, j).. t(i, j) =l= smin[x(i) * U(i), y(j) * U(j)] * z(i, j);"

where t and z are variables and x, y and U are parameters.

How can I achieve this without defining a new joint parameter, as I feel this will get very messy?

Thanks!

User avatar
bussieck
Moderator
Moderator
Posts: 208
Joined: 2 years ago

Re: Minimum of Unrelated Parameters

Post by bussieck » 1 month ago

You don't need an smin, a min is okay and since i and j are controlled by the equation this should work:

Code: Select all

equation(i, j).. t(i, j) =l= min[x(i) * U(i), y(j) * U(j)] * z(i, j);
-Michael

NiobiumFire2
User
User
Posts: 5
Joined: 5 months ago

Re: Minimum of Unrelated Parameters

Post by NiobiumFire2 » 1 month ago

bussieck wrote:
1 month ago
You don't need an smin, a min is okay and since i and j are controlled by the equation this should work:

Code: Select all

equation(i, j).. t(i, j) =l= min[x(i) * U(i), y(j) * U(j)] * z(i, j);
-Michael
Thank you for the reply Michael.

For some reason, when I use the min function, I get errors asking for a set at the start of the bracket: min[<set required>,... even though i and j are controlled. I'm not sure exactly what it wants.

Joel

User avatar
bussieck
Moderator
Moderator
Posts: 208
Joined: 2 years ago

Re: Minimum of Unrelated Parameters

Post by bussieck » 1 month ago

Not clear what happens, you probably should upload your entire model to allow us to see what's going on. The following (non-sense) model compile just fine:

Code: Select all

set i /1/; alias (i,j)
parameter x(i) /1 1/, U(i) /1 1/, y(i) /1 1/, t(i,j) /1.1 1/;
variable z(i,j),obj;

equation defobj, e(i, j);

e(i, j).. t(i, j) =l= min[x(i) * U(i), y(j) * U(j)] * z(i, j);
defobj.. obj =e= 0;

model m /all/;
solve m min obj us lp;
-Michael

NiobiumFire2
User
User
Posts: 5
Joined: 5 months ago

Re: Minimum of Unrelated Parameters

Post by NiobiumFire2 » 1 month ago

Hi Michael,

After playing around with the sample you posted I figured out the issue I was having: I had declared an identifier called "min" as a variable elsewhere in the model. I changed this identifier's name and the min function is working properly again.

Thanks for the help!
Joel

Post Reply