set periods := 1 .. 4;
param demand{periods};
param prod_capacity{periods};
param prod_cost{periods};
param hold_capacity{periods};
param hold_cost{periods};
var prod_level{periods} >=0 integer;
var inventory_level{periods} >=0 integer;
minimize total_cost: sum{i in periods} prod_cost[i]*prod_level[i] +
sum{i in periods} hold_cost[i]*inventory_level[i];
subject to prod_limit{i in periods}:
prod_level[i] <= prod_capacity[i];
subject to inventory_limit{i in periods}:
inventory_level[i] <= hold_capacity[i];
subject to initial_inventory:
inventory_level[1] = 0;
subject to balance{i in 1..3}:
inventory_level[i] + prod_level[i] = demand[i] + inventory_level[i+1];
subject to balance_last_period:
inventory_level[4] + prod_level[4] = demand[4];
data;
param demand:=
1 3
2 4
3 3
4 2;
param prod_capacity:=
1 4
2 5
3 5
4 4;
param prod_cost:=
1 15
2 20
3 18
4 17;
param hold_capacity:=
1 10
2 10
3 10
4 10;
param hold_cost:=
1 2
2 3
3 3
4 2;