Assigning the minimum value of variables Topic is solved

Problems with modeling
Post Reply
Babak1365
User
User
Posts: 2
Joined: 4 years ago

Assigning the minimum value of variables

Post by Babak1365 »

Hello,
I'm currently working on a model, and have a problem.
In my model a decision variable is calculated as follows:
Binary variable x;
Positive variable nd;
Positive variable ds;

C2(i,j).. ds(i,j) =e= x(i)*d(i,j);

Then I need to find the minimum of ds(i,j) for each j and assign it as nd(j). I wrote the following equation, but it is not working. It returns zero instead of the minimum value. :roll: :roll:
C3(i,j).. ds(i,j)=g= nd(j) ;

Can anyone help me?
Thanks in advance.
Fred
Posts: 372
Joined: 7 years ago

Re: Assigning the minimum value of variables

Post by Fred »

Hi,

Whether your formulation works depends on how nd(j) contributes to the objective function.
You probably declared nd(j) as positive variable (i.e. its lower bound is 0) and minimize it in your objective function. Hence, it is pushed down to zero by the solution algorithm and this does not violate your equation C3.

If you would maximize nd(j), your formulation would work because the solution algorithm pushes up nd(j) but equation C3 ensures that nd(j) is less than or equal to ds(i,j). So in an optimal solution nd(j) would take the minimum value of ds(i,j) for all j.

If you need a general formulation to compute the minimum, independent from the direction of your optimization, that could for example be modeled as follows

Code: Select all

binary variable isMin(i,j) '1 if for fixed j ds(i,j) is the minimum over all i';
e1(i,j).. nd(j) =l= ds(i,j);
e2(i,j).. nd(j) =g= ds(i,j) - bigM*(1-isMin(i,j));
e3(j)..   sum(i, isMin(i,j)) =e= 1;
bigM is a scalar that should be chosen sufficiently large but as small as possible.

I hope this helps!

Fred
Babak1365
User
User
Posts: 2
Joined: 4 years ago

Re: Assigning the minimum value of variables

Post by Babak1365 »

Hi Fred,
Thanks for your solution. It worked like a charm ! :D :D
Post Reply