Mixed Integer Programming Lot Sizing Problem in AMPL

119 views
Skip to first unread message

Piano Cover

unread,
Nov 30, 2019, 3:34:12 PM11/30/19
to AMPL Modeling Language
Can someone kindly let me know what is the problem with my code? When I run it I get the error message:
"Sorry, a demo license for AMPL is limited to 300 variables
and 300 constraints and objectives (after presolve) for nonlinear
problems.  You have 250 variables, 402 constraints, and 1 objective."

However, I don't think it should contain as many variables and constraints but it is giving me this result since I should select a set of the binary variables that only give me a value of 1 and eliminate zeros so that any the number of constraints is reduced to only 4 cities insted of 25, but I don't know how to do so. *Note: the objective function is on this form in order to have the problem as mixed-integer linear programming instead of non-linear.


The model file:


set Q; #quarters
set c; #cities

param d{i in c, j in c}; # distance between cities i and j
param D{i in c, q in Q}; # demand of each city in each quarter
param U{i in c, q in Q}; # produced capacity in city i in quarter q 
param ccp{i in c}; # contract cost for production facility in city i
param cp{q in Q}; # cost per unit produced in quarter q
param cw{q in Q}; # cost per unit warehoused at the end of quarter q
param t1 = .1; # transportation cost as a function of distance to warehouse
param t2 = .125; # the transportation cost as a function of the distance to city

var fp{i in c} binary; # 1 if production centers in city i was selected, 0 o.w. (total of 4 cities)
var fw{i in c} binary; # 1 if warehouse in city i was selected, 0 o.w. (total of 3 cities) 
var xp{i in c,q in Q}>=0 :=; # the numb of units to be produced in each production facility and quarter
var xw{i in c, q in Q}>=0; # the number of units in each warehouse’s inventory at the end of each quarter

minimize tot_cost:
(sum{i in c, q in Q} cp[q]*xp[i,q])*(sum{i in c}fp[i]) + (sum{i in c} ccp[i])*(sum{i in c}fp[i]) + (sum{q in Q,i in c} cw[q]*xw[i,q])*(sum{i in c}fw[i]) + (sum{i in c,j in c,q in Q} t1*d[i,j]*xp[i,q])*(sum{i in c}fp[i]) + (sum{i in c, j in c,q in Q} t2 *d[i,j]*xp[i,q])*(sum{i in c}fp[i]);

s.t.
Production_Cities: sum{i in c} fp[i] = 4;
WH_Cities: sum{i in c}fw[i] = 3;
relation{i in c, q in Q}: xp[i,q]<= 1000000 * fp[i]; # to relate binary variable fp with xp 
relation2{i in c, q in Q}: xw[i,q]<= 1000000 * fw[i];
Demand{i in c, q in Q}: xp[i,q]*fp[i] = D[i,q]; # quarterly demand of a city must be met exactly 
Capacity{i in c, q in Q}: xp[i,q]*fp[i] <=U[i,q]*fp[i]; #capacity limit

AMPL Google Group

unread,
Dec 1, 2019, 8:01:43 PM12/1/19
to AMPL Modeling Language
Your Demand constraint is nonlinear since it contains the multiplication of a variable by another variable. Thus the demo version has a limit of 300 constraints. The limit is based on the number of constraints that AMPL sends to the solver.

You can learn more about the variables and constraints that AMPL sent to the solver by giving the command "option show_stats 1;" before the first "solve;" in your AMPL session.


--
Robert Fourer
am...@googlegroups.com
{#HS:1020080316-61696#}
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ampl/a981228a-2880-4044-adff-58e40e0fd980%40googlegroups.com.

Piano Cover

unread,
Dec 2, 2019, 4:34:39 AM12/2/19
to AMPL Modeling Language

I figured out this problem and I downloaded the full version. There is still a problem getting to a solution since the demand is not linear and I need to solve it with cplex solver, is there a way to linearize the demand?
To unsubscribe from this group and stop receiving emails from it, send an email to am...@googlegroups.com.

AMPL Google Group

unread,
Dec 2, 2019, 9:19:08 PM12/2/19
to AMPL Modeling Language
Maybe you meant "xp[i,q] = fp[i] * D[i,q];". To check your constraints that use binary variables, try substituting 0 and 1 for the binary variable, and see whether you get what you expect. As an example, for the constraint I am suggesting,
  • When fp[i] = 0, the constraint becomes xp[i,q] = 0
  • When fp[i] = 1, the constraint becomes xp[i,q] = D[i,q]
Also, as in this example, you should first look for linear constraints that do not involve multiplying a variable by your binary variable.


--
Robert Fourer
am...@googlegroups.com
{#HS:1020080316-61696#}
On Mon, Dec 2, 2019 at 9:34 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
I figured out this problem and I downloaded the full version. There is still a problem getting to a solution since the demand is not linear and I need to solve it with cplex solver, is there a way to linearize the demand?

On Mon, Dec 2, 2019 at 1:01 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Your Demand constraint is nonlinear since it contains the multiplication of a variable by another variable. Thus the demo version has a limit of 300 constraints. The limit is based on the number of constraints that AMPL sends to the solver.

You can learn more about the variables and constraints that AMPL sent to the solver by giving the command "option show_stats 1;" before the first "solve;" in your AMPL session.


--
Robert Fourer
am...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages