1

Consider the following minimization problem:

declarations
A,B,C: range
Objective:linctr 
ct1: array(a,b,c) of  linctr
ct2: linctr
z: array (a,b,c) of real
x: array (a,b,c) of mpvar
end-declarations

initializations
    ...
end-initializations

forall(a in A, b in B, c in C) create(x(a,b,c))

Objective := sum(a in A, b in B, c in C) z(a,b,c) * x(a,b,c)

forall(a in A, b in B, c in C) ct1(a,b,c):= (a,b,c) is_binary
forall(a in A) ct2:= sum(b in B, c in C) x(a,b,c) = 1

minimize(Objective)

The 3-dimensional array of decision variables is supposed to be constrained such that for each index on the first dimension A, constraint ct2 asserts that only one x(1,b,c), only one x(2,b,c), etc. equals 1.

However, Xpress returns an optimal solution where ct2 is violated such that x(1,2,3) = 1 and x(1,4,6) = 1.

Does someone see why that constraint is violated?

Mike Lang
  • 65
  • 5

1 Answers1

0

There are multiple issues in this piece of code.

First, to make x(a,b,c) binary, you don't need a constraint. You can do this:

forall(a in A, b in B, c in C) x(a,b,c) is_binary

Second, since you want to write ct2 for every element of A, you should define it on the set of A like this:

ct2: array(A) of linctr

Then make the constraint definition like this:

forall(a in A) ct2(a):= sum(b in B, c in C) x(a,b,c) = 1

This way it will be defined for every element of A. Previously ct2 was only implemented on the last element of range A.

Baykal
  • 569
  • 2
  • 10
  • 15
  • thank you very much @Baykal for the answer. I adjusted the code as you suggested. However, now Im getting solutions where all x(a,b,c) are 0, which violates the constraint ct2(a). Could this be another issue in the code? or rather the data? – Mike Lang Jan 11 '19 at 10:09
  • Your solution is likely to be infeasible. Can you put this right before you call the minimize(Objective): setparam(XPRS_VERBOSE, true). This will give a lot more logs on the screen, and will tell you if your model is infeasible. – Baykal Jan 12 '19 at 15:41
  • Thank you @Baykal for the help! It helped me figure it out. – Mike Lang Jan 19 '19 at 10:51