ampl / mp

An open-source library for mathematical programming
https://mp.ampl.com
Other
229 stars 42 forks source link

Multi-objective senses vs. weights #240

Open glebbelov opened 6 months ago

glebbelov commented 6 months ago

It is unclear to me how to interpret objective senses vs weights in the multi-objective mode.

While solvers intepret the sign of the weight as the sense (actually even more than that, see below) --- both solver APIs as well as our ASL and MP drivers - this seems non-intuitive. Example test/end2end/cases/categorized/fast/multi_obj/obj_suf_01.mod:

var x >= 0.0, <= 1.0;
var y >= 0.0, <= 1.0;
var z >= 0.0, <= 1.0;

maximize XY_Z:
    x + y - z;

minimize Y:
    y;

subj to C1:
       x + y <= 1;

suffix objpriority IN, integer;
suffix objweight IN, >=-1e20, <=1e20;

let XY_Z.objpriority := 1;

let XY_Z.objweight := 1;
let Y.objweight := 1.5;

While our commercial solvers, ASL and MP, interpret the positive weights for both objectives as maximization for both, by intuition I'd say the weight 1.5 for the 2nd objective should not modify its sense. Actually the description of suffixes .objweight in the text for option multiobj does not say anything about the fact that the sign of the weight defines the sense. This is confused even more by the fact that a negative weight for a 2ndary objective changes its sense relatively to the 1st objective.

And accordingly, I expect the above example, run with multiobj=1, to produce _obj[2]==0, while all our current drivers produce 1.

glebbelov commented 6 months ago

This behaviour seems unsafe. Imagine that the user drops the 1st objective, but the 2nd objective in the model had a different sense. Then, to keep the meaning of the remaining objectives, their weights should be negated. If anyone uses weights, he might be not aware of this.

After discussion with @fdabrandao and @mapgccv, added the following option:

obj:multi:weight (multiobjweight, obj:multi:weights, multiobjweights)
      How to interpret each objective's weight sign:

      1 - relative to the sense of the 1st objective
      2 - relative to its own sense (default)

      With the 1st option (legacy behaviour), negative .objweight for
      objective i would make objective i's sense the opposite of the model's
      1st objective. Otherwise, it would make objective i's sense the opposite
      to its sense defined in the model.

It is referred to in obj:multi:

obj:multi (multiobj)
      0*/1: Whether to use multi-objective optimization.

      When obj:multi = 1 and several objectives are present, suffixes
      .objpriority, .objweight, .objreltol, and .objabstol on the objectives
      are relevant. Objectives with greater .objpriority values (integer
      values) have higher priority. Objectives with the same .objpriority are
      weighted by .objweight, according to the option obj:multi:weight.

      Objectives with positive .objabstol or .objreltol are allowed to be
      degraded by lower priority objectives by amounts not exceeding the
      .objabstol (absolute) and .objreltol (relative) limits.
4er4er4er commented 6 months ago

Best practice would be to only use objectives and weights that have an obvious interpretation:

  1. Objectives having the same priority are all minimize or all maximize.
  2. Weights are all positive (or at least nonnegative).

For the sake of completeness, MP supports other cases; but they are somewhat confusing, and they are rarely (if ever) needed in practical applications. In any case, users need to follow MP's multi-objective options, which work the same for all solvers, but which may be different from the multi-objective instructions that are given by solvers for their own APIs.

Would it help to add a FAQ for this? It could explain multi-objective optimization in more detail than can be given in the option listing. I would be willing to draft it.

glebbelov commented 6 months ago

@4er4er4er this would be helpful. Let me know if the FAQ should be referred to from the options help.

The new options are to be released in a few days.

4er4er4er commented 6 months ago

I'll need more time (due to travel), so I suggest going ahead with the current description of the new options, and we can add a FAQ reference at some later update.

glebbelov commented 5 months ago

@4er4er4er Solvers released (20240529 and later). Basic MO documentation added: https://mp.ampl.com/modeling-mo.html#multiple-objectives. We can extend this section or point to FAQ (I guess we need to create some because now we only have Troubleshooting https://mp.ampl.com/modeling-troublesh.html#.)