-
Notifications
You must be signed in to change notification settings - Fork 1
/
mulprod.mod
77 lines (69 loc) · 2.13 KB
/
mulprod.mod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// --------------------------------------------------------------------------
// Licensed Materials - Property of IBM
//
// 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55
// Copyright IBM Corporation 1998, 2013. All Rights Reserved.
//
// Note to U.S. Government Users Restricted Rights:
// Use, duplication or disclosure restricted by GSA ADP Schedule
// Contract with IBM Corp.
// --------------------------------------------------------------------------
{string} Products = ...;
{string} Resources = ...;
int NbPeriods = ...;
range Periods = 1..NbPeriods;
float Consumption[Resources][Products] = ...;
float Capacity[Resources] = ...;
float Demand[Products][Periods] = ...;
float InsideCost[Products] = ...;
float OutsideCost[Products] = ...;
float Inventory[Products] = ...;
float InvCost[Products] = ...;
range Periods0 = 0..NbPeriods;
dvar float+ Inside[Products][Periods];
dvar float+ Outside[Products][Periods];
dvar float+ Inv[Products][Periods0];
minimize
sum( p in Products, t in Periods )
(InsideCost[p]*Inside[p][t] +
OutsideCost[p]*Outside[p][t] +
InvCost[p]*Inv[p][t]);
subject to {
forall( r in Resources, t in Periods )
ctCapacity:
sum( p in Products )
Consumption[r][p] * Inside[p][t] <= Capacity[r];
forall( p in Products , t in Periods )
ctDemand:
Inv[p][t-1] + Inside[p][t] + Outside[p][t] == Demand[p][t] + Inv[p][t];
forall( p in Products )
ctInventory:
Inv[p][0] == Inventory[p];
};
tuple plan {
float inside;
float outside;
float inv;
}
plan Plan[p in Products][t in Periods] = <Inside[p,t],Outside[p,t],Inv[p,t]>;
execute DISPLAY {
writeln("plan=",Plan);
}
tuple InsideSolutionT{
string Products;
int Periods;
float value;
};
{InsideSolutionT} InsideSolution = {<i0,i1,Inside[i0][i1]> | i0 in Products,i1 in Periods};
tuple OutsideSolutionT{
string Products;
int Periods;
float value;
};
{OutsideSolutionT} OutsideSolution = {<i0,i1,Outside[i0][i1]> | i0 in Products,i1 in Periods};
tuple InvSolutionT{
string Products;
int Periods0;
float value;
};
{InvSolutionT} InvSolution = {<i0,i1,Inv[i0][i1]> | i0 in Products,i1 in Periods0};