Fico Xpress / Mosel: Constraint not satisfied in optimal solution

538 Views Asked by At

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?

1

There are 1 best solutions below

3
On BEST ANSWER

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.