Solving models with a multi-criteria objective

CP Optimizer can solve models with a multi-criteria objective.

The truckfleet example illustrates this feature. The model and data files can be found in:

Install_dir\opl\examples\opl\truckfleet

where Install_dir is your installation directory.

In the model truckfleet.mod, there are two criteria for the minimize objective, e1 and e2, as shown in the code extract.

// Objective: first criterion for minimizing the cost for configuring and loading trucks 
//            second criterion for minimizing the number of trucks
dexpr int e1 = sum(t in Trucks) (truckCost[truckConfigs[t]]*(load[t]!=0))
  + sum(t in Trucks) transitionCost[t];
dexpr int e2 = numUsed;

minimize staticLex(e1, e2);  // trying to minimize cost first

If you declare a multi-criteria objective in a model, the important keyword to use is staticLex.

Note: When you use staticLex with a multi-criteria objective, the objective function cannot contain arithmetic operations. For example, minimize staticLex(e1,e2) + x1 will not be accepted.

Solving in the IDE

When you solve the model in the IDE, you see the result for each criterion in the Problem Browser and the Solutions tab.

Result for each criterion in the Problem Browser and the Solutions tab.

Note: In the Statistics tab, only the value for the first criterion is displayed.

Solving with oplrun

When you solve a model that contains a multi-criteria objective with oplrun, you see the results for the criteria in the command prompt. For the truckfleet example, you see OBJECTIVE: 26; 13

Result for each criterion in the command prompt.

Modifying the example

The truckfleet model contains an alternative objective, with the criteria in a different order, and giving different results.

//minimize staticLex(e2, e1); // trying to minimize numUsed first

You can move the comment symbol to the other minimize statement and run the model again. This time you will see:

Solution with objective 9; 36