I need help with this problem
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) create a .dat and .mod file
Here is my dat file
data
param n := 5;
param demand :=
1 80
2 70
3 120
4 150
5 100;
param cost_cleaning := 0.50; # Set the actual cleaning cost here
param cost_new := 0.75; # Set the actual cost of buying new napkins here
param cost_stock := 0.10; # Set the actual cost of storing napkins here
here is my mod file
param n; # Number of days
set Days := 5;
param demand{Days};
param cost_cleaning;
param cost_new;
param cost_stock;
param initial_stock := 100; # Initial stock of napkins
var x{Days} >= 0; # Number of napkins bought on each day
var y{Days} >= 0; # Number of napkins cleaned on each day
var s{Days} >= 0; # Number of napkins kept in stock after each day
Objective function: Minimize the total cost
minimize TotalCost:
cost_new * sum {d in Days} x[d] +
cost_cleaning * sum {d in Days} y[d] +
cost_stock * sum {d in Days} s[d];
subject to DemandConstraint {d in Days}:
s[d] + initial_stock + x[d] = demand[d] + y[d];
The number of napkins in stock cannot be negative
s.t. NonNegativeStock {d in Days}:
s[d] >= 0;
Variables representing buying and cleaning cannot be negative
s.t. NonNegativeBuys {d in Days}:
x[d] >= 0;
s.t. NonNegativeCleaning {d in Days}:
y[d] >= 0;
Solve the LP model
data SAHC-hw4.dat;
option solver cplex;
solve;
display x;
display y;
display s;
display TotalCost;
i keep getting this error
n is already defined
context: param >>> n; <<< # Number of days
ampl:
please help me ASAP