Kosovi
Kosovi

Reputation: 13

How can I fix error on finding max value in matrix MIP?

I stuck on finding max value each column by writing constraint in MIP. Unfortunately, the error was

Error 59 Endogenous prod smin smax require model type

Error 256 equation eq2.. VAR prod smin smax

Suppose I have EM(f,t,i) as the positive variable, which is the result from previous constraints like this

      i1 i2 i3 i4 i5
f1.t1  7  5  6  0  6
f1.t2  8  4  6  1  6
f1.t3  6  7  3  2  4
f2.t1  8  7  5  3  1
f2.t2  0  5  5  7  0
f2.t3  0  8  0  5  9

My current coding:

eq2(f,i).. last(i) =e= smax((t),EM(f,t,i));

So, I would like to fix the above coding and find the max value each column, and then collect in last(i) variable. My target should be

last(1) = 8, last(2) = 8, last(3) = 6, last(4) = 7, last(5) = 9

Please help me to achieve this MIP model. Thank you.

Upvotes: 1

Views: 40

Answers (1)

Erwin Kalvelagen
Erwin Kalvelagen

Reputation: 16782

To model

  y(i) = smax(j,x(i,j))

you need to do something like:

  y(i) >= x(i,j)               for all i,j
  y(i) <= x(i,j)+(1-δ(i,j))*M  for all i,j
  sum(j,δ(i,j)) = 1            for all i
  δ(i,j) ∈ {0,1}  (binary variables)

where M is a large enough constant. Often we can simplify things, but that depends on the rest of the model.

Upvotes: 1

Related Questions