Description
This example demonstrates how to solve a multi-objective knapsack model and is based on EPSCMMIP in the model library. The example allows to set the number of items, the number of weight dimensions and the number of objectives through double dash parameters: --NBITM=<number of items> --NBDIM=<number of dimensions in the weight vector> --NBOBJ=<number of objectives or value dimensions> Keywords: multi-objective optimization, knapsack
Category : GAMS Data Utilities library
Main file : moo01.gms includes : moo01.gms
$title Solve scalable multi-objective knapsack model (moo01,SEQ=151)
$onText
This example demonstrates how to solve a multi-objective knapsack model
and is based on EPSCMMIP in the model library.
The example allows to set the number of items, the number of weight
dimensions and the number of objectives through double dash parameters:
--NBITM=<number of items>
--NBDIM=<number of dimensions in the weight vector>
--NBOBJ=<number of objectives or value dimensions>
Keywords: multi-objective optimization, knapsack
$offText
$if not set NBITM $set NBITM 50
$if not set NBDIM $set NBDIM 2
$if not set NBOBJ $set NBOBJ 2
$if not set GRIDPOINTS $set GRIDPOINTS 20
$if not set PARALLEL_JOBS $set PARALLEL_JOBS 1
Set
i 'items' / i1*i%NBITM% /
j 'weight dimensions' / j1*j%NBDIM% /
k 'value dimensions' / k1*k%NBOBJ% /
p 'pareto points' / point1*point1000 /;
Parameter
a(i,j) 'weights of item i'
c(i,k) 'values of item i'
b(j) 'knapsack capacity for weight j'
dir(k) 'direction of the objective functions 1 for max and -1 for min' / #k 1/
pareto_obj(p,k) 'objective values of the pareto points'
;
a(i,j) = UniformInt(1,100);
c(i,k) = UniformInt(1,100);
b(j) = UniformInt(1,100) * %NBITM%/4;
Variable
Z(k) 'objective variables'
X(i) 'decision variables';
Binary Variable X;
Equation
objfun(k) 'objective functions'
con(j) 'capacity constraints';
objfun(k).. sum(i, c(i,k)*X(i)) =e= Z(k);
con(j).. sum(i, a(i,j)*X(i)) =l= b(j);
Model example / all /;
$onEcho > cplex.opt
threads 1
$offEcho
$libInclude moo EpsConstraint example MIP k dir Z p pareto_obj -gridpoints=%GRIDPOINTS% -parallel_jobs=%PARALLEL_JOBS% -solver=cplex -optfile_init=1 -optfile_main=1
display pareto_obj;