Skip to main content
4 votes
Accepted

How to model the constraints of min and max in cvxpy

Let constants $j_\min$ and $j_\max$ be the smallest and largest possible $j$ indices, respectively. Introduce binary decision variable $y_{ij}$ to indicate whether $x_{ij}>0$. Assuming $x_{ij}>...
RobPratt's user avatar
  • 32.3k
3 votes

Linear condition between two continuous variables

Let $L_x,U_x$ denote a lower and upper bound for $x$, and $L_y,U_y$ denote a lower and upper bound for $y$. Define an additional binary variable $\delta \in \{0,1\}$ and enforce the following: $$ y \...
Kuifje's user avatar
  • 13.5k
3 votes

Deriving linear constraints from logical notation

You can model the two implications as follows: $$ N\cdot y_{it} \le \sum_{k=1}^{t}x_{ik}\le t+(N-1-t)\cdot(1-y_{it}) $$
Kuifje's user avatar
  • 13.5k
2 votes

Linear condition between two continuous variables

It is worth noting that the desired relationship can be expressed as $x=\max(y,0)$. You want to model a disjunction of two rays from the origin. Impose finite bounds \begin{align} 0 \le x \le U \tag1\...
RobPratt's user avatar
  • 32.3k
2 votes

Restrict the number of non-zero variables to any constant in MILP

Define binary variable $y_i$ for each $i$. Let $\epsilon$ be a small constant close to $0$. You can enforce the desired constraints by adding the following: \begin{align} \epsilon y_i \le x_i &\le ...
Kuifje's user avatar
  • 13.5k
2 votes

Conditional binary programming

Suppose $0 \le b^n_{it} \le M^n_{it}$ for some constant $M^n_{it}$. Introduce binary decision variable $y_{it}$ to indicate whether $b^n_{it} > 0$. Now impose linear constraints \begin{align} y_{...
RobPratt's user avatar
  • 32.3k
1 vote

Schedule monotony constraints

Define a new binary variable $y_{its}$ that takes value $1$ if nurse $i$ works the same shift $s$ for $n$ consecutive days (exactly), starting on day $t$. You want to enforce: $$ \neg x_{i,t-1,s} \...
Kuifje's user avatar
  • 13.5k
1 vote

How to model this constraint in a better way?

Why don't you define the follwing variables $x_{ij}:=\{0,1\}$ if user i assigned to machine j to use these constraints, $\sum_j x_{ij}\geq 1$ for each user i at least one machine assigned to each ...
Majid Zohrehbandian's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible