Hello everybody,

I have a study of a suitcase problem.

There is a suitcase which is 20 kg and there is the items with values and utilities, I should put it in it.

set

i item /oliveoil,olive,tomatosauce,jam,meat,butter,honey,cheese/;

parameters

we(i) weight

/oliveoil 4.5

olive 0.5

tomatosauce 3

jam 0.45

meat 1

butter 2

honey 0.75

cheese 2 /,

v(i) value

/oliveoil 188

olive 12.95

tomatosauce 37.50

jam 16.90

meat 120

butter 150

honey 75

cheese 70/,

u(i) utility

/oliveoil 0.0555

olive 0.1388

tomatosauce 0.2222

jam 0.1111

meat 0.1944

butter 0.0833

honey 0.1666

cheese 0.0277/;

scalar W capacity of bag /20/

L limit of utility /0.05/ ;

positive variables

X(i);

free variables

Z aim function ;

equations

aim,

weight,

preference;

aim… Z =e= sum(i, v(i) *u(i) *X(i));

weight… sum(i, we(i) *X(i)) =l= W;

preference… if u(i) =g= L, Z=1 ;

model suitcase /all/;

solve suitcase using MIP maximizing Z;

There is always a problem with if code. Unless I write the if, the code is running but in the solution, I should have put only meat.

Can someone help me what is wrong with my equations and how can I fix it?

Sincerely

Mel