Documentation

Specifying Multiple Objectives

Let us first discuss the interface for managing multiple objectives. An empty model starts with one objective function, which is initially just 0.0. We'll refer to this as the primary objective. You can modify the primary objective in two ways: you can set the Obj attribute, or you can use the setObjective method from your language API (e.g., Model.setObjective in Python). For models with a single objective, this primary objective can be linear, quadratic, or piecewise linear. In general, attributes and methods that aren't specific to multi-objective optimization will work with the primary objective function.

To provide additional objectives, use the setObjectiveN method from your language API (e.g. Model.setObjectiveN in Python). Objectives are numbered 0 through NumObj-1. The order of the objectives is arbitrary, but you must provide a unique index for each one (specified using the index argument to setObjectiveN). You can query the number of objectives in your model using the NumObj attribute. Note that all objectives, including the primary one, must be linear for multi-objective models.

You can query and modify information about multiple objectives using the ObjNumber parameter, in conjunction with several model and variable attributes. For example, to retrieve the coefficient for variable x in objective <span>$</span>2<span>$</span>, you'd set the ObjNumber parameter to <span>$</span>2<span>$</span>, then query the ObjN attribute for x. Similarly, querying the ObjNName attribute after setting ObjNumber to <span>$</span>3<span>$</span> would give the name of objective <span>$</span>3<span>$</span>.

We should note that there is one important exception to our statement above that the order of objectives is arbitrary: objective <span>$</span>0<span>$</span> is treated as the primary objective. One consequence is that the original objective automatically becomes objective <span>$</span>0<span>$</span> when you add a second objective. Another is that querying the ObjN attribute is equivalent to querying the Obj attribute when ObjNumber is <span>$</span>0<span>$</span>.

Note that a model has a single objective sense (controlled by the ModelSense attribute). This means that you can't maximize the first objective and minimize the second. However, you can achieve the same result with a simple trick. Each objective has a weight, and these weights are allowed to be negative. Minimizing an objective function is equivalent to maximizing the negation of that function.

You can change the number of objectives in your model as many times as you like (by modifying the NumObj attribute). When you increase the objective count, the new objectives and their associated attributes are set to 0. When you decrease the count, objectives beyond the new count are discarded. If you set the number of objectives to zero, the model becomes a pure feasibility problem.

We have extended the LP and MPS file formats, so writing a model with multiple objectives to a file will capture those objectives. Similarly, if you read a model file that contains multiple objectives, then NumObj and ObjN will capture the objectives stored in the file. See the file format section for details.