Use a Multi-Objective Approach
In this article we will compare a multi-objective approach to separately solving single objectives.
Let’s take for an example a problem trying to find a healthy diet for a reasonable price. First let’s define our objectives:
Minimize calories: I’m trying to lose some weight, so my healthy diet should be low in calories.
Minimize price: A reasonable price means that it doesn’t have to be the absolute minimum, but should be within a close range.
Of course, I want to include minimum/maximum requirements for nutrients such as proteins.
Multi-Objective Approach
Let’s use the multi-objective feature available since AIMMS 4.65 and CPLEX 12.9.
1Procedure SolveMultiObj {
2 Body: {
3 ep_GMP := gmp::Instance::Generate( DietProblem );
4
5 p_retcode := GMP::Column::SetAsMultiObjective(
6 GMP : ep_GMP,
7 column : TotalCost,
8 priority : 2,
9 weight : 1,
10 abstol : 0,
11 reltol : 0.1);
12 if not p_retcode then raise error "Unable to set TotalCost as an objective" ; endif ;
13
14 p_retcode := GMP::Column::SetAsMultiObjective(
15 GMP : ep_GMP,
16 column : TotalCalories,
17 priority : 1,
18 weight : 1,
19 abstol : 0,
20 reltol : 0.0);
21 if not p_retcode then raise error "Unable to set TotalCalories as an objective" ; endif ;
22
23 GMP::Instance::Solve( ep_GMP );
24 }
25}
There are several remarks on the above:
Because the
TotalCost
objective has a higher priority value, it will be solved first.Because the
reltol
argument on line 11 has value 0.1, subsequent solves will not increase the total cost by more than 10%.
Single Objective Approach
To be able to compare the multi-objective procedure to traditional single objective solves, there are also two solution procedures in this application:
MainExecution
, a traditional single objective solve minimizing total cost.SolveMinCalo
, a traditional single objective solve minimizing total calories.
Comparing Results
The application has both WinUI and WebUI interfaces, but WebUI is featured in the following screenshots.
![../../_images/mintotcost.png](../../_images/mintotcost.png)
Fig. 35 Results after minimizing total cost
![../../_images/mintotcalo.png](../../_images/mintotcalo.png)
Fig. 36 Results after minimizing total calories
![../../_images/multiobj.png](../../_images/multiobj.png)
Fig. 37 Results after running multi objective
The objectives are summarized in the table below:
Cost |
Calories |
|
Minimize total cost |
21.85 |
2698.40 |
Minimize total calories |
29.80 |
2546.40 |
Multi objective |
23.85 |
2576.40 |
As you can see, the multi-objective values are not as good as either of the individual objective values, but the multi-objective approach provides a good balance.
You may also find the CPLEX log interesting, as found in the file log/cplex 12.9.sta
.
(See also Retrieve Solver Log Files in AIMMS Developer.)
1Solve problem 'DietProblem' with 9 rows, 15 columns (0 binaries, 9 generals), and 83 nonzeros.
2
3MIP - Integer optimal solution: Objective = 2.1849999998e+01
4Solution time = 0.09 sec. Iterations = 20 Nodes = 0
5
6
7Solve problem 'MinCaloDietProblem' with 9 rows, 15 columns (0 binaries, 9 generals), and 83 nonzeros.
8
9MIP - Integer optimal solution: Objective = 2.5464000000e+03
10Solution time = 0.02 sec. Iterations = 13 Nodes = 0
11
12
13Solve problem 'DietProblem' with 8 rows, 14 columns (0 binaries, 9 generals), and 73 nonzeros.
14
15Multi-objective solve log . . .
16
17Starting optimization #1 with priority 2.
18
19
20
21Finished optimization #1 with priority 2.
22Objective = 2.1849999998e+01, Nodes = 0, Time = 0.05 sec. (0.45 ticks)
23Cumulative statistics: Nodes = 0, Time 0.05 sec. (0.45 ticks)
24
25
26Starting optimization #2 with priority 1.
27
28
29
30Finished optimization #2 with priority 1.
31Objective = 2.5764000000e+03, Nodes = 0, Time = 0.02 sec. (0.43 ticks)
32Cumulative statistics: Nodes = 0, Time 0.06 sec. (0.89 ticks)
33
34
35
36MIP - Multi-objective optimal
37Solution time = 0.08 sec. Iterations = 43 Nodes = 0
A breakdown of above log:
lines 1 - 4 for the first solve (minimize total cost)
lines 7 - 10 for the second solve (minimize total calories)
lines 13 - 37 for the multi objective solve.
Project download
The project can be downloaded below.