I'm an engineering student and new user at CPLEX. When I ran my script, it says that one of my constraints is non convex. I know I should linearize it, but I don't know how.
x[i][j]
is a binary variable.
E[i]
is a continuous variable, that depends on x[i][j]
.
eev[i]
is an input (energy wasted on route i
).
edh[i]
is an input (energy wasted from i
to j
).
emax
is also an input, a constant. Is the initial battery level, its maximum.
This is part of a electric vehicle scheduling formulation and E[i]
is the energy remained on that vehicle after doing route i
.
How can I linearize the following constraint so it won't be non-convex:
E[j] <= (E[i]-edh[i][j]-eev[j])*x[i][j]+emax*(1-x[i][j])
I know how to linearize it if it was like this:
E[j] == (E[i]-edh[i][j]-eev[j])*x[i][j]+emax*(1-x[i][j])
But that is not what I need for my script.
Thank you a lot in advance!
You could change
E[j] <= (E[i]-edh[i][j]-eev[j])*x[i][j]+emax*(1-x[i][j])
into
E[j] <= E[i]*x[i][j]-edh[i][j]*x[i][j]-eev[j]*x[i][j]+emax*(1-x[i][j])
and in order to cope with E[i]*x[i][j] that is a product between a binary decision variable and another decision variable you could rely on
I provided 3 ways.
One of them is to turn
dvar int x in 2..10;
dvar boolean b;
maximize x;
subject to
{
b*x<=7;
}
into
dvar int x in 2..10;
dvar boolean b;
dvar int bx;
maximize x;
subject to
{
bx<=7;
2*b<=bx;
bx<=10*b;
bx<=x-2*(1-b);
bx>=x-10*(1-b);
}