## CHOOSING A SPECIFIC OPTIMAL SOLUTION FROM A PARETO FRONT GENERATED IN GAMS Topic is solved

Problems with syntax of GAMS
charlesuko
User Posts: 3
Joined: 8 months ago

### CHOOSING A SPECIFIC OPTIMAL SOLUTION FROM A PARETO FRONT GENERATED IN GAMS

I am solving a multi-objective MILP problem similar to the one below. The Pareto front generates 21 different optimal solutions that satisfy objectives of1 and of2. How do I return or access the values of x1 and x2 for let's say optimal solution 11 on the pareto front? If I want to access these results or return them to matlab. E.g How do I access a particular value in the 11th iteration?
The code below is from the Pareto optimal front determination example by Alireza Soroudi on the GAMS site.

Code: Select all

``````Variable of1, of2, x1, x2;
Equation eq1, eq2, eq3, eq4;

eq1.. 4*x1 - 0.5*sqr(x2) =e= of1;
eq2.. -sqr(x1) + 5*x2    =e= of2;
eq3.. 2*x1 + 3*x2        =l= 10;
eq4.. 2*x1 -   x2        =g=  0;

x1.lo = 1; x1.up = 2;
x2.lo = 1; x2.up = 3;

Model pareto1 / all /;

Set counter / c1*c21 /;
Scalar E;
Parameter report(counter,*), ranges(*);

solve pareto1 using nlp maximizing of1;
ranges('OF1max') = of1.l;
ranges('OF2min') = of2.l;

solve pareto1 using nlp maximizing of2;
ranges('OF2max') = of2.l;
ranges('OF1min') = of1.l;

loop(counter,
E = (ranges('OF2max') - ranges('OF2min'))*(ord(counter) - 1)/(card(counter) - 1) + ranges('OF2min');
of2.lo = E;
solve pareto1 using nlp maximizing of2;
report(counter,'OF1') = of1.l;
report(counter,'OF2') = of2.l;
report(counter,'E')   = E;
);
display report;``````

Fred
Posts: 151
Joined: 2 years ago

### Re: CHOOSING A SPECIFIC OPTIMAL SOLUTION FROM A PARETO FRONT GENERATED IN GAMS

Hi,

You could store the values of x1 and x2 in a parameter, similar to how it is done for the objective values in the example, e.g.

Code: Select all

``````loop(counter,
E = (ranges('OF2max') - ranges('OF2min'))*(ord(counter) - 1)/(card(counter) - 1) + ranges('OF2min');
of2.lo = E;
solve pareto1 using nlp maximizing of1;
report(counter,'OF1') = of1.l;
report(counter,'OF2') = of2.l;
report(counter,'x1')  = x1.l;
report(counter,'x2')  = x2.l;
report(counter,'E')   = E;
);
``````
As an alternative, you could also use GAMS i option savepoint=2 to store the results of every solve in a gdx file (https://www.gams.com/latest/docs/UG_Gam ... Osavepoint).

It seems to me that there is a mnior mistake in the example. Setting the lower bound for of2 and then maximizing of2 in the loop does not result in a pareto frontier but in 21 identical solutions. Hence, I changed this to maximizing of1.

I hope this helps!

Fred

charlesuko
User Posts: 3
Joined: 8 months ago

### Re: CHOOSING A SPECIFIC OPTIMAL SOLUTION FROM A PARETO FRONT GENERATED IN GAMS

Thanks Fred! I was able to use savepoint to get the answer that I wanted.