Consider the following trivial, theoretical model:

$$ \max x+2y+3z \qquad s.t. $$ $$ x \leq b_x $$ $$ y \leq b_y $$ $$ z \leq b_z $$ $$ x+y+z = 1 $$ $$ x,y,z \in \{0, 1\} $$

and $b_x$, $b_y$ and $b_z$ integer, non-negative parameters. Whenever the parameter $b_z \geq 1$ the trivial solution would be $z=1, x=y=0$. Let us assume I have hypotethical reasons to "prefer" $x$ over $z$, and $z$ over $y$; say, when $b_x$, $b_y$ and $b_z$ are greater/equal 1, return $x=1, y=z=0$ as solution. In other words, I would maximize the objective function under a "preference constraint" on variables. Is it possible to express such a constraint as a MIP/MILP?

For example, imposing $z \leq x$ and $y \leq z$ would do the trick when both $b_x$ and $b_z$ are greater/equal 1, but when $b_x = 0$, $b_z \geq 1$ and $b_y \geq 1$ it would return $x=y=z=0$, whereas the optimal solution for me according to my preference would be $z=1, x=y=0$. Similarly, with $b_x = b_z = 0$ and $b_y\geq 1$ the optimal solution from solving the problem would be again $x=y=z=0$ whereas what I want according to my preference would be $y=1, x=z=0$. So my attempt $z \leq x$ and $y \leq z$ clearly does not work.

I am looking for a generalizable solution for any number of variables and any preference, not just for a solution to this specific case.

  • 3
    $\begingroup$ Why not express the preferences in the objective function? $\endgroup$
    – RobPratt
    Commented Mar 2, 2023 at 23:04
  • $\begingroup$ @RobPratt you mean changing the objective completely or adding a term to the current objective? I want to maximize the objective $x+2y+3z$ (let's say it represents a profit) under the constraint that, when possible, $x$ should be selected before $z$. $\endgroup$
    – Libra
    Commented Mar 3, 2023 at 7:42
  • 2
    $\begingroup$ Then it sounds like you have a primary objective of maximizing preference and a secondary objective of maximizing profit. You might consider the lexicographic approach to this multiobjective problem. $\endgroup$
    – RobPratt
    Commented Mar 3, 2023 at 13:37

1 Answer 1


How is this following constraint
Either $b_z + y \le b_x+z +b_y\le x + b_z +yb_y$ Or let's break it
$b_x+z \le x + b_z$
$b_z + y \le z +b_y $

  • $\begingroup$ It does not seems to work. When $b_x = b_z = 0$ and $b_y = m$ it gives $0+y \leq 0 + 0 + m \leq 0 + 0$, that is $y\leq m \leq 0$. I am looking for a general solution, not just a solution to this specific example. Thanks. $\endgroup$
    – Libra
    Commented Mar 2, 2023 at 22:57
  • $\begingroup$ Ok let me break it up then $\endgroup$ Commented Mar 2, 2023 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.