I'm trying to run this code to determine the quantity of each product to buy (x1, x2, x3). They each have a profit of (1.5, 3.2, 2.7) respectively per unit produced however, they all need to go through a quality assurance process. There are 4 processes. the table of hours it takes for the process of each unit of product is given below:
Processes Apples(x1) Grapes(x2) Pears(x3)
1 0.45 0.55 0.70
2 0.76 0.45 0.40
3 0.33 0.63 0.72
4 0.54 0.77 0.48
The two constraints are:
1) Each process is given 3000 hours max.
2) Each product must go through minimum 2 processes.
The objective is to maximize profit.
Here is my .mod file:
set product;
set quality;
param prof{product};
param hrs:=3000;
param qual_hrs_per{quality, product};
var ifprocess{q in quality} binary;
var quantity{p in product}>=0,integer;
maximize
prf: sum{p in product}prof[p]*quantity[p];
subject to
process_chosen: sum{q in quality}ifprocess[q]>=2;
maxhours1: sum{p in product}qual_hrs_per[1,p]*ifprocess[1]*quantity[p]<= hrs;
maxhours2: sum{p in product}qual_hrs_per[2,p]*ifprocess[2]*quantity[p]<= hrs;
maxhours3: sum{p in product}qual_hrs_per[3,p]*ifprocess[3]*quantity[p]<= hrs;
maxhours4: sum{p in product}qual_hrs_per[4,p]*ifprocess[4]*quantity[p]<= hrs;
Here is my .dat file:
set product:= Apples Grapes Pears;
set quality:= 1 2 3 4;
param prof:= Apples 1.5 Grapes 3.2 Pears 2.7;
param qual_hrs_per: Apples Grapes Pears:=
1 0.45 0.55 0.70
2 0.76 0.45 0.40
3 0.33 0.63 0.72
4 0.54 0.77 0.48;
When I run it I get the error "QP Hessian is not positive semi-definite." I'm not 100% sure i'm using the binary variable correctly.
Any help would be great!