set CARGOES;
set COMPARTMENTS;
param weight_capacity{COMPARTMENTS};
param space_capacity{COMPARTMENTS};
param weight{CARGOES};
param volume{CARGOES};
param profit{CARGOES};
var x{i in CARGOES, j in COMPARTMENTS} >=0;
# tons of cargo i in compartment j
var y >=0, <=1;
# weight proportion for compartments
maximize total_profit: sum{i in CARGOES, j in COMPARTMENTS} profit[i] * x[i,j];
subject to Cargo_constraints{i in CARGOES}:
sum{j in COMPARTMENTS} x[i,j] <= weight[i];
subject to Space_capacity_constraints{j in COMPARTMENTS}:
sum{i in CARGOES} volume[i] * x[i,j] <= space_capacity[j];
subject to Weight_proportion_constraints{j in COMPARTMENTS}:
sum{i in CARGOES} x[i,j] = weight_capacity[j] * y;
data;
set CARGOES:= 1 2 3 4;
set COMPARTMENTS:= front center back;
param: weight_capacity space_capacity :=
front 12 7000
center 18 9000
back 10 5000 ;
param: weight volume profit :=
1 20 500 320
2 16 700 400
3 25 600 360
4 13 400 290;