Help with Problem!

Skip to first unread message

Emily Abelev

Oct 14, 2023, 9:36:51 PM10/14/23
to AMPL Modeling Language

I need help with this problem. It is not returning with the answers I need.

You run a small company providing napkins for hotels. For
each of the next 5 days you know how many napkins you’ll
need: 80, 70, 120, 150, 100, respectively. Each morning
when delivering your napkins, you can pick up the used
ones (what you delivered previous day). If you send those
(or some of those) for a cleaning (for $a/napkin) than they
can be used as new ones at the next morning delivery. You
can also buy new napkins at $b/napkin any given day,
before you make the deliveries for that day. You can also
keep clean (new) napkins in your stock for $c/day/napkin
for following days. Initially you have 100 napkins in stock.
Create a model to find a cost minimal plan (of
buying/cleaning/storing) to fulfill your contract (for the
next 5 days).
Note that what you buy can be used for delivery
the same day!
Note that you cannot send more to the cleaner
than what you delivered the previous day!
You need to pick it up in the morning from the
hotel (when you deliver the clean ones for the day)
… take it to the cleaner in the afternoon … use it
following morning …

DAT File:

HW4 data file

set days := 1 2 3 4 5;

param Demand := #Demand of napkins per day for 5 days
1 80
2 70
3 120
4 150
5 100;

param a := 5; #param a, cleaning cost
param b := 10; #param b, new napkin cost
param c := 1; #param c, stock cost per day per napkin
param r := 100; #param r, initial napkin stock

MOD File:

HW4 model file

reset ;


set days;


param Demand{days} >=0;

param a;

param b;

param c;

param r;


var X{days} >=0; #Napkins to send for cleaning on day t

var Y{days} >=0; #Number of new napkins to buy on day t

var Z{days} >=0; #Number of napkins to keep in stock on day t


minimize TotalCost:

sum{d in days}

(a * X[d] + b * Y[d] + c * Z[d]);


subject to InitialStock:

Z[1] = r;

subject to CleaningConstraint{d in days}:

if d >=2 then X[d] <= X[d-1];

subject to NapkinBalance{d in days}:

Z[d] = Z[d-1] + Y[d] - Demand[d];


data HW4.dat;
option solver cplex;
solve ;


display {d in days} X[d];
display {d in days} Y[d];
display {d in days} Z[d];

Reply all
Reply to author
0 new messages