I have this AMPL model
model;
param n >= 1 integer;
set V = 1..n;
set T = 1..n;
set R = {(i, j) in {V, V}: i <> j};
param capacity >= 0;
var m{V} binary;
var path{T, R} binary;
var u{T} binary;
minimize obj:
sum{t in T} u[t]
;
subject to max_capacity{t in T}:
u[t] = 1 ==>
sum{(i, j) in R} m[j] * path[t, i, j] <= capacity
;
but when I try to solve it using cplex it returns this message:
CPLEX 20.1.0.0: logical constraint _slogcon[1] is not an indicator constraint.
What does this message mean? Is there a simple way to fix the problem?
In AMPL like in OPL you could use CP.
using CP;
int n=10;
range V = 1..n;
range T = 1..n;
tuple t
{
int i;
int j;
}
{t} R={<i,j> | i,j in V:i!=j};
int capacity=4;
dvar boolean m[V];
dvar boolean path[T,R];
dvar boolean u[T];
minimize
sum(t in T) u[t]
;
subject to
{
forall(t in T)
(u[t] == 1) =>
(sum(<i,j> in R) m[j] * path[t, <i, j>] <= capacity);
}
;
works fine and relies on CPOptimizer
If you prefer to use MIP you can rewrite your logical constraint with bigM
int n=10;
range V = 1..n;
range T = 1..n;
tuple t
{
int i;
int j;
}
{t} R={<i,j> | i,j in V:i!=j};
int capacity=4;
float bigM=100;
dvar boolean m[V];
dvar boolean path[T,R];
dvar boolean u[T];
minimize
sum(t in T) u[t]
;
subject to
{
forall(t in T)
//(u[t] == 1) =>
(sum(<i,j> in R) m[j] * path[t, <i, j>] <= capacity*u[t]+bigM*(1-u[t]));
}
;
NB:
I used OPL because I love OPL but you can do the same with AMPL