Modulo Help

Hi all,

We are working on a project trying where machines require a certain number of employees to run, for this constraint we were trying to use the mod function but it seems to be acting oddly. We are saying (mod(# of employees working on the machine)/(required number of employees for the machine)) =e= 0.

When I run this constraint set equal to a variable, the variable gets set to 0 which is great, but if i set it directly equal to 0, it forces the # of employees working on the machine to be 0 for some reason. It is not letting me upload the document but below is copy/pasted code:

Sets
MP ‘Machine Proposal’ /112/
B ‘Bikes’ /1
5/
;

Scalars
S ‘Starting Number of Employees’ /45/
D ‘Hours per day’ /8/
DM ‘Days in a month’ /20/
HC ‘Hiring Cost’ /.1/
FC ‘Firing Cost’ /.03/
;

Parameters
C(MP) ‘Cost of machine MP’
/
1 1.5
2 1.65
3 1.7
4 1.15
5 1.52
6 2.28
7 7
8 0.5
9 1
10 3
11 0.3
12 1.6
/
B1(MP) ‘Production of Bike 1 on Machine MP’
/
1 10
2 10
3 0
4 5
5 0
6 10
7 10
8 3
9 0
10 7
11 0
12 0
/
B2(MP) ‘Production of Bike 2 on Machine MP’
/
1 0
2 5
3 10
4 5
5 0
6 10
7 10
8 2
9 0
10 4
11 0
12 2
/
B3(MP) ‘Production of Bike 3 on Machine MP’
/
1 0
2 10
3 10
4 5
5 0
6 5
7 10
8 1
9 3
10 0
11 0
12 0
/
B4(MP) ‘Production of Bike 4 on Machine MP’
/
1 5
2 0
3 10
4 5
5 0
6 5
7 10
8 0
9 3
10 0
11 0
12 10
/
B5(MP) ‘Production of Bike 5 on Machine MP’
/
1 5
2 0
3 0
4 5
5 10
6 5
7 10
8 0
9 2
10 4
11 5
12 0
/
EM(MP) ‘Employees required to run Machine MP’
/
1 2
2 3
3 3
4 4
5 1
6 3
7 2
8 2
9 3
10 0
11 2
12 1
/
R(B) ‘Required production per month of Bike B’
/
1 32000
2 30000
3 25000
4 22000
5 26000
/
;

Variables
Z ‘Objective Function - Minimized Cost’
K1
K2
K3
K4
K5
K6
K7
K8
K9
;

Integer Variables
H ‘Number of employees to hire’
F ‘Number of employees to fire’
E1 ‘Employees on shift 1’
E2 ‘Employees on shift 2’
E3 ‘Employees on shift 3’
M(MP) ‘How many of machine MP to purchase’
P1B(B) ‘Production on shift 1 of Bike MP’
P2B(B) ‘Production on shift 2 of Bike MP’
P3B(B) ‘Production on shift 3 of Bike MP’
E1M(MP) ‘Employees on shift 1 working on machine MP’
E2M(MP) ‘Employees on shift 2 working on machine MP’
E3M(MP) ‘Employees on shift 3 working on machine MP’
;

Equations
DailyProductionB1 ‘Summation of production from shifts 1,2,3 of Bike 1’
DailyProductionB2 ‘Summation of production from shifts 1,2,3 of Bike 2’
DailyProductionB3 ‘Summation of production from shifts 1,2,3 of Bike 3’
DailyProductionB4 ‘Summation of production from shifts 1,2,3 of Bike 4’
DailyProductionB5 ‘Summation of production from shifts 1,2,3 of Bike 5’
Shift1ProductionB1 ‘Hourly production of Bike 1 from shift 1’
Shift1ProductionB2 ‘Hourly production of Bike 2 from shift 1’
Shift1ProductionB3 ‘Hourly production of Bike 3 from shift 1’
Shift1ProductionB4 ‘Hourly production of Bike 4 from shift 1’
Shift1ProductionB5 ‘Hourly production of Bike 5 from shift 1’
Shift2ProductionB1 ‘Hourly production of Bike 1 from shift 2’
Shift2ProductionB2 ‘Hourly production of Bike 2 from shift 2’
Shift2ProductionB3 ‘Hourly production of Bike 3 from shift 2’
Shift2ProductionB4 ‘Hourly production of Bike 4 from shift 2’
Shift2ProductionB5 ‘Hourly production of Bike 5 from shift 2’
Shift3ProductionB1 ‘Hourly production of Bike 1 from shift 3’
Shift3ProductionB2 ‘Hourly production of Bike 2 from shift 3’
Shift3ProductionB3 ‘Hourly production of Bike 3 from shift 3’
Shift3ProductionB4 ‘Hourly production of Bike 4 from shift 3’
Shift3ProductionB5 ‘Hourly production of Bike 5 from shift 3’
EmployeesOnShift1 ‘Employees working on all machines must be less than total employees on shift’
EmployeesOnShift2 ‘Employees working on all machines must be less than total employees on shift’
EmployeesOnShift3 ‘Employees working on all machines must be less than total employees on shift’
Shift2Employees ‘Shift 2 employees = Shift 3 employees + 5’
Shift1Employees ‘Shift 1 employees = Shift 2 employees + 5’
TotalEmployees ‘Calculated total of employees’
Shift1MachineRatio(MP) ‘Verify there are enough machines for number of employees working’
Shift2MachineRatio(MP) ‘Verify there are enough machines for number of employees working’
Shift3MachineRatio(MP) ‘Verify there are enough machines for number of employees working’
FullShift1Machine4 ‘Verify machine has all required employees to operate on shift 1’
*TEST
Objective ‘Minimization Cost of Machines Purchased’
;

DailyProductionB1… D*(P1B(‘1’)+P2B(‘1’)+P3B(‘1’)) =g= R(‘1’)/DM;
DailyProductionB2… D*(P1B(‘2’)+P2B(‘2’)+P3B(‘2’)) =g= R(‘2’)/DM;
DailyProductionB3… D*(P1B(‘3’)+P2B(‘3’)+P3B(‘3’)) =g= R(‘3’)/DM;
DailyProductionB4… D*(P1B(‘4’)+P2B(‘4’)+P3B(‘4’)) =g= R(‘4’)/DM;
DailyProductionB5… D*(P1B(‘5’)+P2B(‘5’)+P3B(‘5’)) =g= R(‘5’)/DM;
Shift1ProductionB1… P1B(‘1’) =e= (B1(‘1’)/EM(‘1’)*E1M(‘1’)) + (B1(‘2’)/EM(‘2’)*E1M(‘2’)) + (B1(‘3’)/EM(‘3’)*E1M(‘3’)) + (B1(‘4’)/EM(‘4’)*E1M(‘4’)) + (B1(‘5’)/EM(‘5’)*E1M(‘5’)) + (B1(‘6’)/EM(‘6’)*E1M(‘6’)) + (B1(‘7’)/EM(‘7’)*E1M(‘7’)) + (B1(‘8’)/EM(‘8’)*E1M(‘8’)) + (B1(‘9’)/EM(‘9’)*E1M(‘9’)) + (B1(‘10’)*M(‘10’)) + (B1(‘11’)/EM(‘11’)*E1M(‘11’)) + (B1(‘12’)/EM(‘12’)*E1M(‘12’));
Shift1ProductionB2… P1B(‘2’) =e= (B2(‘1’)/EM(‘1’)*E1M(‘1’)) + (B2(‘2’)/EM(‘2’)*E1M(‘2’)) + (B2(‘3’)/EM(‘3’)*E1M(‘3’)) + (B2(‘4’)/EM(‘4’)*E1M(‘4’)) + (B2(‘5’)/EM(‘5’)*E1M(‘5’)) + (B2(‘6’)/EM(‘6’)*E1M(‘6’)) + (B2(‘7’)/EM(‘7’)*E1M(‘7’)) + (B2(‘8’)/EM(‘8’)*E1M(‘8’)) + (B2(‘9’)/EM(‘9’)*E1M(‘9’)) + (B2(‘10’)*M(‘10’)) + (B2(‘11’)/EM(‘11’)*E1M(‘11’)) + (B2(‘12’)/EM(‘12’)*E1M(‘12’));
Shift1ProductionB3… P1B(‘3’) =e= (B3(‘1’)/EM(‘1’)*E1M(‘1’)) + (B3(‘2’)/EM(‘2’)*E1M(‘2’)) + (B3(‘3’)/EM(‘3’)*E1M(‘3’)) + (B3(‘4’)/EM(‘4’)*E1M(‘4’)) + (B3(‘5’)/EM(‘5’)*E1M(‘5’)) + (B3(‘6’)/EM(‘6’)*E1M(‘6’)) + (B3(‘7’)/EM(‘7’)*E1M(‘7’)) + (B3(‘8’)/EM(‘8’)*E1M(‘8’)) + (B3(‘9’)/EM(‘9’)*E1M(‘9’)) + (B3(‘10’)*M(‘10’)) + (B3(‘11’)/EM(‘11’)*E1M(‘11’)) + (B3(‘12’)/EM(‘12’)*E1M(‘12’));
Shift1ProductionB4… P1B(‘4’) =e= (B4(‘1’)/EM(‘1’)*E1M(‘1’)) + (B4(‘2’)/EM(‘2’)*E1M(‘2’)) + (B4(‘3’)/EM(‘3’)*E1M(‘3’)) + (B4(‘4’)/EM(‘4’)*E1M(‘4’)) + (B4(‘5’)/EM(‘5’)*E1M(‘5’)) + (B4(‘6’)/EM(‘6’)*E1M(‘6’)) + (B4(‘7’)/EM(‘7’)*E1M(‘7’)) + (B4(‘8’)/EM(‘8’)*E1M(‘8’)) + (B4(‘9’)/EM(‘9’)*E1M(‘9’)) + (B4(‘10’)*M(‘10’)) + (B4(‘11’)/EM(‘11’)*E1M(‘11’)) + (B4(‘12’)/EM(‘12’)*E1M(‘12’));
Shift1ProductionB5… P1B(‘5’) =e= (B5(‘1’)/EM(‘1’)*E1M(‘1’)) + (B5(‘2’)/EM(‘2’)*E1M(‘2’)) + (B5(‘3’)/EM(‘3’)*E1M(‘3’)) + (B5(‘4’)/EM(‘4’)*E1M(‘4’)) + (B5(‘5’)/EM(‘5’)*E1M(‘5’)) + (B5(‘6’)/EM(‘6’)*E1M(‘6’)) + (B5(‘7’)/EM(‘7’)*E1M(‘7’)) + (B5(‘8’)/EM(‘8’)*E1M(‘8’)) + (B5(‘9’)/EM(‘9’)*E1M(‘9’)) + (B5(‘10’)*M(‘10’)) + (B5(‘11’)/EM(‘11’)*E1M(‘11’)) + (B5(‘12’)/EM(‘12’)*E1M(‘12’));
Shift2ProductionB1… P2B(‘1’) =e= (B1(‘1’)/EM(‘1’)*E2M(‘1’)) + (B1(‘2’)/EM(‘2’)*E2M(‘2’)) + (B1(‘3’)/EM(‘3’)*E2M(‘3’)) + (B1(‘4’)/EM(‘4’)*E2M(‘4’)) + (B1(‘5’)/EM(‘5’)*E2M(‘5’)) + (B1(‘6’)/EM(‘6’)*E2M(‘6’)) + (B1(‘7’)/EM(‘7’)*E2M(‘7’)) + (B1(‘8’)/EM(‘8’)*E2M(‘8’)) + (B1(‘9’)/EM(‘9’)*E2M(‘9’)) + (B1(‘10’)*M(‘10’)) + (B1(‘11’)/EM(‘11’)*E2M(‘11’)) + (B1(‘12’)/EM(‘12’)*E2M(‘12’));
Shift2ProductionB2… P2B(‘2’) =e= (B2(‘1’)/EM(‘1’)*E2M(‘1’)) + (B2(‘2’)/EM(‘2’)*E2M(‘2’)) + (B2(‘3’)/EM(‘3’)*E2M(‘3’)) + (B2(‘4’)/EM(‘4’)*E2M(‘4’)) + (B2(‘5’)/EM(‘5’)*E2M(‘5’)) + (B2(‘6’)/EM(‘6’)*E2M(‘6’)) + (B2(‘7’)/EM(‘7’)*E2M(‘7’)) + (B2(‘8’)/EM(‘8’)*E2M(‘8’)) + (B2(‘9’)/EM(‘9’)*E2M(‘9’)) + (B2(‘10’)*M(‘10’)) + (B2(‘11’)/EM(‘11’)*E2M(‘11’)) + (B2(‘12’)/EM(‘12’)*E2M(‘12’));
Shift2ProductionB3… P2B(‘3’) =e= (B3(‘1’)/EM(‘1’)*E2M(‘1’)) + (B3(‘2’)/EM(‘2’)*E2M(‘2’)) + (B3(‘3’)/EM(‘3’)*E2M(‘3’)) + (B3(‘4’)/EM(‘4’)*E2M(‘4’)) + (B3(‘5’)/EM(‘5’)*E2M(‘5’)) + (B3(‘6’)/EM(‘6’)*E2M(‘6’)) + (B3(‘7’)/EM(‘7’)*E2M(‘7’)) + (B3(‘8’)/EM(‘8’)*E2M(‘8’)) + (B3(‘9’)/EM(‘9’)*E2M(‘9’)) + (B3(‘10’)*M(‘10’)) + (B3(‘11’)/EM(‘11’)*E2M(‘11’)) + (B3(‘12’)/EM(‘12’)*E2M(‘12’));
Shift2ProductionB4… P2B(‘4’) =e= (B4(‘1’)/EM(‘1’)*E2M(‘1’)) + (B4(‘2’)/EM(‘2’)*E2M(‘2’)) + (B4(‘3’)/EM(‘3’)*E2M(‘3’)) + (B4(‘4’)/EM(‘4’)*E2M(‘4’)) + (B4(‘5’)/EM(‘5’)*E2M(‘5’)) + (B4(‘6’)/EM(‘6’)*E2M(‘6’)) + (B4(‘7’)/EM(‘7’)*E2M(‘7’)) + (B4(‘8’)/EM(‘8’)*E2M(‘8’)) + (B4(‘9’)/EM(‘9’)*E2M(‘9’)) + (B4(‘10’)*M(‘10’)) + (B4(‘11’)/EM(‘11’)*E2M(‘11’)) + (B4(‘12’)/EM(‘12’)*E2M(‘12’));
Shift2ProductionB5… P2B(‘5’) =e= (B5(‘1’)/EM(‘1’)*E2M(‘1’)) + (B5(‘2’)/EM(‘2’)*E2M(‘2’)) + (B5(‘3’)/EM(‘3’)*E2M(‘3’)) + (B5(‘4’)/EM(‘4’)*E2M(‘4’)) + (B5(‘5’)/EM(‘5’)*E2M(‘5’)) + (B5(‘6’)/EM(‘6’)*E2M(‘6’)) + (B5(‘7’)/EM(‘7’)*E2M(‘7’)) + (B5(‘8’)/EM(‘8’)*E2M(‘8’)) + (B5(‘9’)/EM(‘9’)*E2M(‘9’)) + (B5(‘10’)*M(‘10’)) + (B5(‘11’)/EM(‘11’)*E2M(‘11’)) + (B5(‘12’)/EM(‘12’)*E2M(‘12’));
Shift3ProductionB1… P3B(‘1’) =e= (B1(‘1’)/EM(‘1’)*E3M(‘1’)) + (B1(‘2’)/EM(‘2’)*E3M(‘2’)) + (B1(‘3’)/EM(‘3’)*E3M(‘3’)) + (B1(‘4’)/EM(‘4’)*E3M(‘4’)) + (B1(‘5’)/EM(‘5’)*E3M(‘5’)) + (B1(‘6’)/EM(‘6’)*E3M(‘6’)) + (B1(‘7’)/EM(‘7’)*E3M(‘7’)) + (B1(‘8’)/EM(‘8’)*E3M(‘8’)) + (B1(‘9’)/EM(‘9’)*E3M(‘9’)) + (B1(‘10’)*M(‘10’)) + (B1(‘11’)/EM(‘11’)*E3M(‘11’)) + (B1(‘12’)/EM(‘12’)*E3M(‘12’));
Shift3ProductionB2… P3B(‘2’) =e= (B2(‘1’)/EM(‘1’)*E3M(‘1’)) + (B2(‘2’)/EM(‘2’)*E3M(‘2’)) + (B2(‘3’)/EM(‘3’)*E3M(‘3’)) + (B2(‘4’)/EM(‘4’)*E3M(‘4’)) + (B2(‘5’)/EM(‘5’)*E3M(‘5’)) + (B2(‘6’)/EM(‘6’)*E3M(‘6’)) + (B2(‘7’)/EM(‘7’)*E3M(‘7’)) + (B2(‘8’)/EM(‘8’)*E3M(‘8’)) + (B2(‘9’)/EM(‘9’)*E3M(‘9’)) + (B2(‘10’)*M(‘10’)) + (B2(‘11’)/EM(‘11’)*E3M(‘11’)) + (B2(‘12’)/EM(‘12’)*E3M(‘12’));
Shift3ProductionB3… P3B(‘3’) =e= (B3(‘1’)/EM(‘1’)*E3M(‘1’)) + (B3(‘2’)/EM(‘2’)*E3M(‘2’)) + (B3(‘3’)/EM(‘3’)*E3M(‘3’)) + (B3(‘4’)/EM(‘4’)*E3M(‘4’)) + (B3(‘5’)/EM(‘5’)*E3M(‘5’)) + (B3(‘6’)/EM(‘6’)*E3M(‘6’)) + (B3(‘7’)/EM(‘7’)*E3M(‘7’)) + (B3(‘8’)/EM(‘8’)*E3M(‘8’)) + (B3(‘9’)/EM(‘9’)*E3M(‘9’)) + (B3(‘10’)*M(‘10’)) + (B3(‘11’)/EM(‘11’)*E3M(‘11’)) + (B3(‘12’)/EM(‘12’)*E3M(‘12’));
Shift3ProductionB4… P3B(‘4’) =e= (B4(‘1’)/EM(‘1’)*E3M(‘1’)) + (B4(‘2’)/EM(‘2’)*E3M(‘2’)) + (B4(‘3’)/EM(‘3’)*E3M(‘3’)) + (B4(‘4’)/EM(‘4’)*E3M(‘4’)) + (B4(‘5’)/EM(‘5’)*E3M(‘5’)) + (B4(‘6’)/EM(‘6’)*E3M(‘6’)) + (B4(‘7’)/EM(‘7’)*E3M(‘7’)) + (B4(‘8’)/EM(‘8’)*E3M(‘8’)) + (B4(‘9’)/EM(‘9’)*E3M(‘9’)) + (B4(‘10’)*M(‘10’)) + (B4(‘11’)/EM(‘11’)*E3M(‘11’)) + (B4(‘12’)/EM(‘12’)*E3M(‘12’));
Shift3ProductionB5… P3B(‘5’) =e= (B5(‘1’)/EM(‘1’)*E3M(‘1’)) + (B5(‘2’)/EM(‘2’)*E3M(‘2’)) + (B5(‘3’)/EM(‘3’)*E3M(‘3’)) + (B5(‘4’)/EM(‘4’)*E3M(‘4’)) + (B5(‘5’)/EM(‘5’)*E3M(‘5’)) + (B5(‘6’)/EM(‘6’)*E3M(‘6’)) + (B5(‘7’)/EM(‘7’)*E3M(‘7’)) + (B5(‘8’)/EM(‘8’)*E3M(‘8’)) + (B5(‘9’)/EM(‘9’)*E3M(‘9’)) + (B5(‘10’)*M(‘10’)) + (B5(‘11’)/EM(‘11’)*E3M(‘11’)) + (B5(‘12’)/EM(‘12’)*E3M(‘12’));
EmployeesOnShift1… E1 =g= sum(MP, E1M(MP));
EmployeesOnShift2… E2 =g= sum(MP, E2M(MP));
EmployeesOnShift3… E3 =g= sum(MP, E3M(MP));
Shift2Employees… E2 =e= E3 + 5;
Shift1Employees… E1 =e= E2 + 5;
TotalEmployees… S + H - F =e= E1 + E2 + E3;
Shift1MachineRatio(MP)(ord(MP)<>10).. M(MP) =g= (1/EM(MP))*E1M(MP); Shift2MachineRatio(MP)(ord(MP)<>10)… M(MP) =g= (1/EM(MP))*E2M(MP);
Shift3MachineRatio(MP)$(ord(MP)<>10)… M(MP) =g= (1/EM(MP))*E3M(MP);
FullShift1Machine4… (mod(E1M(‘4’),EM(‘4’))) =e= K4;
TEST… K4 =e= 0;
Objective… Z =e= sum(MP, C(MP)M(MP)) + HCH + FC
F;

Model BigFoot /all/;

*Option
*limrow = 12;

Solve BigFoot using minlp minimizing Z;

Display M.l, K4.l, E1.l, E2.l, E3.l, E1M.l, E2M.l, E3M.l;