Wagner Whitin Problem - Error in constraint: "contraint A cannot hold: body <= -20 cannot be >= 20, difference = -40"

835 views
Skip to first unread message

g.kus...@gmail.com

unread,
Jan 4, 2016, 5:53:20 PM1/4/16
to AMPL Modeling Language
Hello and a happy new year to everyone!

I´m trying to solve a Wagner Whiting Problem with the gurobi-solver, but unfortunately keep getting the same error message over and over again. I would love if someone of you could help me with this.

My model looks like this:

#Declaration of paramaters and sets
param t; 
set PERIODS = 1..t; 
set MIN = 2..t;
param d {i in PERIODS}; #demand in period i
param s; #setup cost
param h; #storage cost
param M; 
param I0; #inventory at the end of period 0

#Declaration of variables
var q {i in PERIODS}; #lot size in period i
var x {i in PERIODS} binary;
var I {i in PERIODS}; #inventory at the end of period i

#Objective Function
minimize costs: sum {i in PERIODS} (s * x[i] + h * I[i]); 

#Constraits
subject to A: I[1] = I0 + q[1] - d[1];
subject to B {i in MIN}: I[i-1] + q[i] - d[i] = I[i];
subject to C {i in PERIODS}: q[i] <= M * x[i];
subject to D {i in PERIODS}: q[i] >= 0;
subject to E {i in PERIODS}: I[i] >= 0;


My data file looks like this:

data;
param t:= 4;
param d:= 1 20 2 10 3 20 4 30;
param s:= 100;
param h:= 2;
param M:= 10;
param I0:= 0;


What I get from AMPL is the following:

sw: ampl
ampl: model serie1.mod;
ampl: data serie1a.dat;
ampl: option solver gurobi;
ampl: solve;
presolve: constraint A cannot hold:
body <= -20 cannot be >= 20; difference = -40
ampl: 


Thank you so much in advance.

Best regards
GK



Robert Fourer

unread,
Jan 5, 2016, 12:57:59 AM1/5/16
to am...@googlegroups.com
The message

presolve: constraint A cannot hold:
body <= -20 cannot be >= 20; difference = -40

is telling you that AMPL's presolve phase has determined that no feasible solution to constraint A is possible, if all of the other constraints are satisfied. If you give the command "expand A;" you will see that after processing, AMPL converts constraint A as follows:

ampl: expand A;
subject to A:
-q[1] + I[1] = -20;

The "body" is the part "-q[1] + I[1]" (containing the variables) on the left. Clearly to satisfy the constraint, the body has to be <= -20 as given in the message. But the rest of the message is telling you that, based on the other constraints, AMPL's presolve has deduced that -q[1] + I[1] must be >= 20. This contradiction implies that no feasible solution is possible.

It may not be immediately obvious why the constraints imply -q[1] + I[1] >= 20, but if you examine the constraints closely you will be able to figure this out.

Bob Fourer
am...@googlegroups.com

=======

Timo S.

unread,
Jan 5, 2016, 4:25:38 PM1/5/16
to AMPL Modeling Language
Your constraint C connects the q variables with the binary x variables, which means: You can only produce if the machine is set up and vice versa. Now take a look at your param M in the data, you set M := 10. But in your first period you have a demand of 20. So the constraint A cannot hold, because you cannot produce more than 10 per period and the problem becomes infeasible.
Suggestion 1: Set M to something big (M is called Big-M in literature) like 100000000000000 and your problem will become feasible.
Suggestion 2: Think about how big M at least really must be.

Robert Fourer

unread,
Jan 5, 2016, 4:51:55 PM1/5/16
to am...@googlegroups.com

Setting M to something as large as 100000000000000 can cause other problems -- see my discussion of The Big M.  It's best to set M to a reasonably large value -- large enough to make the model valid, but not too much larger.

Bob Fourer
am...@googlegroups.com


From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of Timo S.


Sent: Tuesday, January 5, 2016 2:59 PM
To: AMPL Modeling Language

--
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 https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

g.kus...@gmail.com

unread,
Jan 5, 2016, 5:23:14 PM1/5/16
to AMPL Modeling Language
Thank you both so much, your advices really helped me to figure it out!

Amir Lm

unread,
Jun 9, 2016, 7:52:23 PM6/9/16
to AMPL Modeling Language, 4...@ampl.com
Hi Bob,
I have one small issue in my model that I was hoping to get some insight from you!
I developed a deterministic model which then being transferred to the stochastic form.
the deterministic model works perfectly fine, however, when I transfer it to stochastic programming form it gives me "Integer Infeasible" 
Attached please find the Deter. as well as Stoch. model
AMPL returns :

ampl: reset;
ampl: model FKS3.mod;
ampl: data FKS3.dat;
ampl: option solver cplex;
ampl: solve;
CPLEX 12.6.1.0: integer infeasible.
176 MIP simplex iterations
0 branch-and-bound nodes
No basis.

Thank you in advance for your time!
FKD3.mod
FKD3.dat
FKS3.mod
FKS3.dat
Reply all
Reply to author
Forward
0 new messages