Logical constraints and piecewise linear constraints

194 views
Skip to first unread message

jinh...@gmail.com

unread,
Dec 7, 2013, 11:49:18 PM12/7/13
to am...@googlegroups.com
I am using AMPL (the cplex solver) to solve my problem. I figured out how to use piecewise linear constraints and it works fine. Here is my piecewise linear constraints.

subject to piecewiselinear {i in worker,j in task, k in 1..card(time)}:
    << {q in 1..Nbkpts[k]-1}  Bpoint[i,j,k,q];
    {q in 0..Nbkpts[k]-1}(1.2*(1-exp(-1*(Bpoint[i,j,k,q+1])/L))-1.2*(1-exp(-1*(Bpoint[i,j,k,q])/L)))>> XX[i,j,k] >= u[i,j,k];


But after I add the logical constraints to the piecewise linear constraints, Ampl give me some error messages.
The new logical constrains are:

subject to piecewiselinear {i in worker,j in task, k in 1..card(time)} :
sum{t in 1..k} y[i,j,t]=0 ==>  (<< {q in 1..Nbkpts[k]-1}  Bpoint[i,j,k,q];
    {q in 0..Nbkpts[k]-1}(1.2*(1-exp(-1*(Bpoint[i,j,k,q+1])/L))-1.2*(1-exp(-1*(Bpoint[i,j,k,q])/L)))>> XX[i,j,k] >= u[i,j,k]) else
     ( << {q in 1..Nbkpts[k]-1}  Bpoint[i,j,k,q];
    {q in 0..Nbkpts[k]-1}(1.2*(1-exp(-1*(Bpoint[i,j,k,q+1])/(L-0.6)))-1.2*(1-exp(-1*(Bpoint[i,j,k,q])/(L-0.6))))>> XX[i,j,k] >= u[i,j,k]);


The error message:
CPLEX 12.4.0.0: logical constraint _slogcon[1] is not an indicator constraint.

The expand _slogcon[1] command gives me:
subject to piecewiselinear[1,1,1]:
y[1,1,1] == 0 ==> (<<2, 4, 6; 0.856194, 0.245304, 0.0702807, 0.0201358
>> XX[1,1,1]) - u[1,1,1] >= 0 else (<<2, 4, 6; 1.0376, 0.140424, 
0.0190043, 0.00257195>> XX[1,1,1]) - u[1,1,1] >= 0;


The basic idea of the logical constrains are, if sum{t in 1..k} y[i,j,t]>0, I would like to decrease the L value by 0.6.

By the way, y[i,j,t] is a binary variable.

What am I doing wrong?

Thanks very much!




Robert Fourer

unread,
Dec 9, 2013, 1:39:09 PM12/9/13
to am...@googlegroups.com

The standard CPLEX interface does not recognize most logical constraints.  There is only an exception for "indicator" constraints that have the general form

 

   binaryvar = 0 ==> linear-constraint1 else linear-constraint2

 

and simple variations of this (such as with binaryvar = 1).  The linear constraints in this form cannot contain piecewise-linear expressions.  Also this form does not allow constraints like

 

   sum {t in 1..k} y[i,j,t] = 0 ==> ...

 

since in general the expression to the left of the ==> operator will not have the simple form binaryvar = 0.

 

To use the standard CPLEX interface, you'll have to think about how to linearize these constraints.  For the left-hand side you could define a binary variable that is 0 if sum {t in 1..k} y[i,j,t] = 0; for the right-hand side you could substitute a variable for the piecewise-linear expression and then add a constraint to define that variable to equal the piecewise-linear expression.

 

Alternatively you could experiment with the IBM ILOG CP interface described at www.ampl.com/NEW/LOGIC; if you set

 

   option ilogcp_options 'optimizer cplex';

 

then you can send more general logical expressions to CPLEX.  In that case you are relying on CPLEX to do more reformulations automatically, which may or may not be better than doing the reformulations directly in your model.

 

Bob Fourer

am...@googlegroups.com

 

 

From: am...@googlegroups.com [mailto:am...@googlegroups.com]

On Behalf Of jinh...@gmail.com
Sent: Saturday, December 7, 2013 10:49 PM
To: am...@googlegroups.com
Subject: [AMPL 7787] Logical constraints and piecewise linear constraints

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages