Pergunta

I have following problem in my model file: I would like to CPLEX solver first performs actions in brackets and then was multiplied. As is usual mathematics .... But when I run my model file with this constraint:

subject to c4a {e in E, k in K, o in O}:
f[k,o] = 0
==>     
    delta[e,k,o] - p[k,e] * (sum{l in K}(b[l,e]*(1-f[l,o]))) = 0 
else  
    delta[e,k,o] = 0;

where E,K,O are sets; delta, f are binary variables; and rest is parameter. I have problem which I describe before with this brackets: "(1-f[l,o])". When I try resolve example data file I receive following bug:

CPLEX 11.2.0: logical constraint _slogcon[1] is not an indicator constraint.
expand _slogcon[1];
subject to c4a['1_2',2,'o1']:f[2,'o1'] == 0 ==> delta['1_2',2,'o1'] - (3 - f[2,'o1'] - f[3,'o1'] - 
f[4,'o1']) == 0 else delta['1_2',2,'o1'] == 0;

Here you see that CPLEX solver on the first multiply elements from brackets by b[l,e] and then it try to adds them. My question is: how to avoid this situation?

Foi útil?

Solução

The expand command in AMPL simplifies constraint expressions. In particular, it combines like terms. For example:

var x;
var y;
subject to c: 2 * (x + y) + 3 * x = 0;
expand c;

prints

subject to c:
    5*x + 2*y = 0;

In your case AMPL uses distributivity of multiplication over addition/subtraction: a * (b - c) = a * b - a * c. This is necessary because CPLEX and many other solvers only accept constraint expressions in a certain form, e.g. a linear expression a1 * x1 + a2 * x2 + ... + an * xn and there is no way to pass arbitrary expression trees to it (at least using the C API in CPLEX).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top