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!
Minimum of Unrelated Parameters Topic is solved
Re: Minimum of Unrelated Parameters
You don't need an smin, a min is okay and since i and j are controlled by the equation this should work:
Michael
Code: Select all
equation(i, j).. t(i, j) =l= min[x(i) * U(i), y(j) * U(j)] * z(i, j);

 User
 Posts: 5
 Joined: 8 months ago
Re: Minimum of Unrelated Parameters
Thank you for the reply Michael.bussieck wrote: ↑4 months agoYou don't need an smin, a min is okay and since i and j are controlled by the equation this should work:
MichaelCode: Select all
equation(i, j).. t(i, j) =l= min[x(i) * U(i), y(j) * U(j)] * z(i, j);
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
Re: Minimum of Unrelated Parameters
Not clear what happens, you probably should upload your entire model to allow us to see what's going on. The following (nonsense) model compile just fine:
Michael
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;

 User
 Posts: 5
 Joined: 8 months ago
Re: Minimum of Unrelated Parameters
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
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