-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaggregate_planning.mod
136 lines (106 loc) · 3.64 KB
/
aggregate_planning.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
set TIME;
set TIME_SHIFT;
set INIT;
set END;
var EMPLOYEES{i in TIME_SHIFT} integer >= 0;
var FIRED_EMPLOYEES{i in TIME} integer >= 0;
var HIRED_EMPLOYEES{i in TIME} integer >= 0;
var INVENTORY{i in TIME_SHIFT} integer >= 0;
var OVERTIME{i in TIME} integer >= 0;
var BACKORDER{i in TIME_SHIFT} integer >= 0;
var INTERNAL{i in TIME} integer >= 0;
var OUTSRC{i in TIME} integer >= 0;
/* Cost of Materials */
param cm;
/* Cost of Holding Inventory */
param ci;
/* Cost if Backorders */
param cb;
param ct;
/* Cost of Firing an Employee */
param cf;
/* Cost of Hiring and Training an employee */
param ch;
/* Cost of an Employee */
param cw;
/* Cost of Overtime */
param co;
/* Cost of Outsourcing */
param cc;
/* Number of hours for producing goods */
param L;
/* Number of hours worked by employee */
param H;
/* Maximum overtime hours */
param M;
param init_employees;
param init_backorders;
param init_inventory;
param end_inventory_min;
param end_backlog_max;
param end_employees_min;
param end_employees_max;
param price_elasticity;
param discount{i in TIME};
param base_demand{i in TIME};
param demand{i in TIME} integer := base_demand[i] + base_demand[i]*price_elasticity*discount[i];
minimize cost: sum{i in TIME} (cw*EMPLOYEES[i] + ch*HIRED_EMPLOYEES[i] + cf*FIRED_EMPLOYEES[i] + co*OVERTIME[i] + ci*INVENTORY[i] + cb*BACKORDER[i] + cm*INTERNAL[i] + cc*OUTSRC[i]);
s.t. cap_constraint{i in TIME}:L*INTERNAL[i] - H*EMPLOYEES[i] - OVERTIME[i] <= 0;
s.t. workforce{i in TIME}: EMPLOYEES[i] - EMPLOYEES[i - 1] - HIRED_EMPLOYEES[i] + FIRED_EMPLOYEES[i] = 0;
s.t. inventory{i in TIME}: INVENTORY[i] - INVENTORY[i - 1] - INTERNAL[i] - OUTSRC[i] + demand[i] + BACKORDER[i-1] - BACKORDER[i] = 0;
s.t. overtime{i in TIME}:OVERTIME[i] - M*EMPLOYEES[i] <= 0;
s.t. init_workforce_constraint{i in INIT}: EMPLOYEES[i] = init_employees;
s.t. init_inventory_constraint{i in INIT}: INVENTORY[i] = init_inventory;
s.t. init_backorder_constraint{i in INIT}: BACKORDER[i] = init_backorders;
s.t. end_workforce_constraint{i in END}: EMPLOYEES[i] <= end_employees_max;
s.t. end_workforce_constraint_min{i in END}: EMPLOYEES[i] >= end_employees_min;
s.t. end_inventory_constraint{i in END}: INVENTORY[i] >= end_inventory_min;
s.t. end_backorder_constraint{i in END}: BACKORDER[i] <= end_backlog_max;
solve;
printf '\n Results #############\n';
printf 'Total Cost : ';
printf '%.2f', cost;
printf '\n';
printf 'Regular Labor Cost : ';
printf '%.2f', sum{i in TIME} EMPLOYEES[i]*cw;
printf '\n';
printf 'Overtime Cost : ';
printf '%.2f', sum{i in TIME} OVERTIME[i]*co;
printf '\n';
printf 'Cost of Hiring : ';
printf '%.2f', sum{i in TIME} HIRED_EMPLOYEES[i]*ch;
printf '\n';
printf 'Cost of Firing : ';
printf '%.2f', sum{i in TIME} FIRED_EMPLOYEES[i]*cf;
printf '\n';
printf 'Cost of Inventory: ';
printf '%.2f', sum{i in TIME} INVENTORY[i]*ci;
printf '\n';
printf 'Cost of Stockouts: ';
printf '%.2f', sum{i in TIME} BACKORDER[i]*cb;
printf '\n';
printf 'Cost of Materials: ';
printf '%.2f', sum{i in TIME} INTERNAL[i]*cm;
printf '\n';
printf 'Cost of Outsourcing: ';
printf '%.2f', sum{i in TIME} OUTSRC[i]*cc;
printf '\n';
printf 'Number of Employees hired: ';
printf '%d', sum{i in TIME} HIRED_EMPLOYEES[i];
printf '\n';
printf 'Number of Employees fired: ';
printf '%d', sum{i in TIME} FIRED_EMPLOYEES[i];
printf '\n';
printf 'Number of Overtime: ';
printf '%d', sum{i in TIME} OVERTIME[i];
printf '\n';
printf 'Number of Items Backlogged: ';
printf '%d', sum{i in TIME} BACKORDER[i];
printf '\n';
printf 'Number of Items Produced: ';
printf '%d', sum{i in TIME} INTERNAL[i];
printf '\n';
printf 'Number of Items Outsourced: ';
printf '%d', sum{i in TIME} OUTSRC[i];
printf '\n';
printf '#############\n\n';