assign_employee(j, t)… sum(i, x(i, j, t)) =e= 1;
How do I get Vacation, noassignment not to be bound as well =1
Set
i ‘employees’ / zhu, tsai, xu, lu, chen, wang /
j ‘workstation’ / zone1, zone2, zone3, zone4, vacation, noassignment /
t ‘days’/110/
work_zone / zone1, zone2, zone3, zone4/;
$onImplicitAssign
Parameter penalty(i, j);
penalty(‘zhu’, ‘zone1’) = 100; penalty(‘zhu’, ‘zone2’) = 100; penalty(‘zhu’,‘noassignment’) = 800;
penalty(‘tsai’, ‘zone2’) = 100; penalty(‘tsai’, ‘zone3’) = 100;penalty(‘tsai’,‘noassignment’) = 80;
penalty(‘xu’, ‘zone3’) = 100; penalty(‘xu’, ‘zone4’) = 100; penalty(‘xu’,‘noassignment’) = 80;
penalty(‘lu’, ‘zone1’) = 100; penalty(‘lu’, ‘zone4’) = 100;penalty(‘lu’,‘noassignment’) = 50;
penalty(‘chen’, ‘zone2’) = 100;penalty(‘chen’,‘noassignment’) = 50;
penalty(‘wang’, ‘zone3’) = 100;penalty(‘wang’,‘noassignment’) = 50;
Parameter M;
M = 1000;
Table L(i, j, t);
L(i, j, t) = 0;
L(‘zhu’, ‘vacation’, ‘1’) = 1;
L(‘tsai’, ‘vacation’, ‘2’) = 1;
L(‘lu’, ‘vacation’, ‘3’) = 1;
L(‘tsai’, ‘vacation’, ‘4’) = 1;
L(‘chen’, ‘vacation’, ‘5’) = 1;
L(‘chen’, ‘vacation’, ‘6’) = 1;
L(‘chen’, ‘vacation’, ‘7’) = 1;
L(‘xu’, ‘vacation’, ‘8’) = 1;
L(‘xu’, ‘vacation’, ‘9’) = 1;
L(‘zhu’, ‘vacation’, ‘10’) = 1;
display L;
Binary Variables
x(i, j, t)
y(i, j, t)
k(i, j, t)
u(i, j ,t)
q(i,work_zone,t);
Variable z;
Equations
assign_employee(j, t)
assign_workstation(i, t)
constraint(i, j, t)
constraint2(i, j, t)
constraint3(i, j, t)
table_L(i, j, t)
obj_function
;
assign_employee(j, t)… sum(i, x(i, j, t)) =e= 1;
assign_workstation(i, t)… sum(j, x(i, j, t)) =e= 1;
constraint(i, j, t)… x(i, j, t) + x(i, j, t+1) =g= -M(1 - y(i, j, t)) + 2;
constraint2(i, j, t)… x(i, j, t) + x(i, j, t+1) + x(i, j, t+2) =g= -M(1-k(i, j, t)) + 3;
constraint3(i, j, t)… y(i, j, t) + k(i, j, t) + u(i, j, t) =e= 1;
table_L(i, j, t)… x(i, j, t) =g= L(i, j, t);
obj_function… z =e= sum((i, j, t), penalty(i, j) * x(i, j, t) + k(i, j, t) * 10*(2) + y(i, j, t) * 10**(-2));
Model test / all /;
solve test using mip Maximizing z;
display x.l, x.m;**
Maybe you can try the following:
*work_zone / zone1, zone2, zone3, zone4/;
work_zone(j) / zone1, zone2, zone3, zone4/;
*assign_employee(j, t)… sum(i, x(i, j, t)) =e= 1;
assign_employee(j, t)$work_zone(j)… sum(i, x(i, j, t)) =e= 1;
Best/JG