11

This is not true in practice. Moreover, this is something almost impossible to guess without experimenting. Indeed, adding constraints (proven to be mathematical valid, or just guessed by your flair and feeling of the business) to a mathematical optimization model that is solved by constraint programming techniques or integer programming techniques should be ...


11

My approach would be: $$\begin{align} \min\>&- f(\color{darkred}x)+\sum_j \color{darkblue}p^-_j \color{darkred}s^-_j +\sum_j \color{darkblue}p^+_j \color{darkred}s^+_j\\ &\sum_i \color{darkblue}a_{i,j}\color{darkred}x_{i,j} = 10 -\color{darkred}s^-_j + \color{darkred}s^+_j&&\forall j\\ &\color{darkred}s^-_j,\color{...


10

Again, you need to introduce binaries: $\delta_t$ takes values $1$ if and only if the device is switched off at time $t$ $\alpha_t$ is the binary associated with variable $x_t$ $\beta_t$ is the binary associated with variable $y_t$ The condition can be written in conjunctive normal form as follows: $$ (\alpha_{t-1}\wedge \lnot \alpha_{t} \wedge \lnot \...


10

Let $x_{p,\ell}$ be the continuous variables in your table. Introduce integer variables $y_{p,\ell}$ and binary variables $z_{p,\ell}$, and impose linear constraints \begin{align} -z_{p,\ell} \le x_{p,\ell} - y_{p,\ell} &\le z_{p,\ell} &&\text{for all $p$ and $\ell$} \tag1 \\ \sum_\ell z_{p,\ell} &\le 1 &&\text{for all $p$} \tag2 \...


9

Using the max operator, your objective function has directional derivatives but is not smoothly differentiable. For instance, if $x$ is scalar and $g(x) = x-2$, then at $x=2$ the max term has directional derivative 0 in the direction of decreasing $x$ and $c$ in the direction of increasing $x$. For a gradient-based algorithm, this makes the value of the ...


9

Introduce binary variable $Z$ and linear constraints \begin{align} X - \epsilon &\le (\bar{X} - \epsilon) Z \tag1 \\ Y - X &\le (\bar{Y} - 0) (1-Z) \tag2 \\ \end{align} Constraint $(1)$ enforces $X > \epsilon \implies Z = 1$. Constraint $(2)$ enforces $Z = 1 \implies X \ge Y$.


8

@Kuifje's formulation is correct. Here's a somewhat automatic derivation via conjunctive normal form: $$ \lnot \bigwedge_{i=1}^n \omega_i \\ \bigvee_{i=1}^n \lnot \omega_i \\ \sum_{i=1}^n (1 - \omega_i) \ge 1 \\ \sum_{i=1}^n \omega_i \le n-1 \\ $$


8

How about $$\omega_1 + \cdots + \omega_n \le n-1 $$ This way, at most all variables but one of them can take value $1$ simultaneously. In the context of knapsack problems, if each variable models the selection of a given item and that the sum of the weights of the items exceed the knapsack capacity, these inequalities are called cover inequalities.


8

For each $j$, you want to enforce $x_i \ge 1$ for at least one $i\in S_j$. Introduce binary variable $y_i$ to indicate whether $x_i=1$, and impose linear constraints \begin{align} \sum_{i \in S_j} y_i &\ge 1 &&\text{for all $j$} \\ y_i &\le x_i &&\text{for all $i$} \\ \end{align}


8

The constraint is not convex, and is not transformable to a convex constraint without substantively changing it. The additive linear term $dx$ is irrelevant to convexity. So let's ignore it and look at the simple case of $a = b = c = 1$. The Hessian of $\frac{{ax}}{{\ln (b + cy)}}$ at $x = y = 1$ has one positive and one negative eigenvalue. Hence $\frac{{ax}...


7

To make constraint (2) soft, you can proceed as follows. Transform the constraint into two inequalities (2a) and (2b), add non negative variables $\varepsilon_{kj}$, $k\in \{1,2\}$ to allow violation, and minimize the violation in the cost function : $$ \max\limits_{x\in \mathbb{R^{m\times n}}}\quad f(x) - \sum_{k,j}\varepsilon_{kj} $$ subject to \begin{...


7

Introduce a binary variable $y_{i,j}$ and linear constraints \begin{align} x_{i,j} &\le M y_{i,j} \tag1 \\ y_{i,j} + y_{j,i} &\le 1 \tag2 \end{align} Constraint $(1)$ enforces $x_{i,j} > 0 \implies y_{i,j} = 1$. Constraint $(2)$ enforces $y_{i,j} = 1 \implies y_{j,i} = 0$. Constraint $(1)$ (with the roles of $i$ and $j$ interchanged) enforces $y_{...


7

If I understand correctly, the following enforces your desired behavior: \begin{align} y_1 &= d_1 \\ y_2 &= d_2 \\ y_3 &= d_3 \\ y_4 &\ge d_1 + d_2 - 1\\ y_5 &\ge d_1 + d_2 + d_3 - 2\\ \end{align} If you also want to enforce $y_4 \implies (d_1 \land d_2)$ and $y_5 \implies (d_1 \land d_2 \land d_3)$, then include these additional ...


7

Introduce binary variables $z_1$, $z_2$, and $z_3$, and impose linear constraints \begin{align} z_1+z_2 +z_3&= 1 \tag1\\ 1z_1+bz_2+(b+1)z_3 \le y &\le (b-1)z_1+bz_2+Uz_3 \tag2\\ z_2&\le x\tag3 \end{align} Constraints $(1)$ and $(2)$ enforce the three disjoint cases $y<b$, $y=b$, and $y>b$. Constraint $(3)$ enforces $x=0\implies z_2=0$, and $...


6

Neither. You should delete $d_{u,c}$ from the model whenever $\omega_{u,c} < t_\min$.


6

Assuming your index goes from 0 to $n$ you can do $k = \sum_{i = 0}^{n}i \cdot p_i$ where $k$ is the desired index.


6

My interpretation is that you want $y$ to be $i$ if $p_i=1$. You can do that with a simple multiplication $y=c^Tp$ where the constant vector $c$ is given by $c_i=i$.


6

No, it is an intrinsically non-convex constraint. Just take a diagonal matrix, and the feasible set would be the coordinate axes, i.e. nonconvex and highly ill-conditioned as the feasible set has measure 0.


6

You need to introduce a binary variable for buying, $b$, and one for selling, $s$. Make sure $b$ and $s$ are active when $varBuyWater$ and $varSellWater$ are positive, respectively: $$ varBuyWater \le M_1 b \\ varSellWater \le M_2 s \\ $$ $M_1$ and $M_2$ are upper bounds on variables $varBuyWater$ and $varSellWater$. And impose that both binaries cannot ...


6

A variable that can assume values of zero or between some lower and upper bound is called a semi-continuous variable. Most high-end solvers have direct support for this type of variable. If not supported, you can model this with an additional binary variable: $$\begin{align} & \color{darkblue}L\cdot \color{darkred}\delta \le \color{darkred}x \le \color{...


5

These are called Generalized Upper Bound (GUB) constraints.


5

What about the following model: Let $P$ be the set of players. Each player $p$ has a type $t_p$, expected score $s_p$, team $m_p$ and cost $c_p$. Let $x_p$ be a binary decision variable equal to 1 if $p$ is chosen for the team, $0$ otherwise. The constraints are: Must choose 15 players - note that in this case this constraint is redundant and can be omitted,...


5

You can model this as follows. Let $y(t)\in \{0,1\}$ be a binary variable that is activated if the heating device is switched off at time $t\in \{1,...,288\}$ (and was active at time $t-1$). This variable is activated every time $x(t-1)=1$ and $x(t)=0$: $$ x(t-1) \le x(t) + y(t)\quad \forall t=1,...,288 $$ So if $x(t-1)=1$, either $x(t)$ also takes value $1$ ...


5

Shameless plug: I recently gave a webinar on diagnosing infeasibility. Here's what your example looks like in SAS: proc optmodel; var A >= 0; var B >= 0; max z = 20*A + 30*B; con c1: A <= 60; con c2: B <= 50; con c3: A+2*B >= 220; solve with lp / iis=true; expand / iis; quit; The resulting IIS contains all three ...


5

It is not totally unimodular. A necessary condition is that even the $1\times 1$ submatrices have determinant in $\{-1,0,1\}$. That is, individual entries must be in $\{-1,0,1\}$.


5

If you are maximizing $y_t$ (or any increasing function of $y_t$) and using "standard" inequalities, you need something to preclude the solver from setting $y_t$ to $+\infty$. You can use the following constraints: \begin{align*} y_t &\le 0 +M(1-\delta) \tag{1}\\ y_t &\le y_{t-1}+a_t-z_t +M\delta \tag{2}\\ \delta &\in \{0,1\} \end{...


4

In cases like that, I usually add a variable to the constraint (slack or surplus, depending on the direction off the inequality) measuring the infeasibility. The variable should then have a large unfavorable coefficient in the objective (positive for minimization and negative for maximization) so it takes the smallest possible value.


4

You can introduce a binary variable $x_k$ and linear constraints \begin{align} \sum_k x_k &\ge N\tag1\\ -t_k+T_k&\le M_k(1-x_k) &&\text{for $k\in K$}\tag2 \end{align} Here, the “big-M” constant $M_k$ is a small upper bound on $-t_k+T_k$. Because $t_k\ge 0$, you can take $M_k=T_k$, and the constraint simplifies to $t_k\ge T_k x_k$. Constraint $...


4

I think you do need some variable that keeps track of the configuration a machine is in at a given process plan position. This could be a variable $C_{wcj}$ that is $1$ if machine $w$ is in configuration $c$ at process plan position $j$. Then the following three constraints give you that: Each machine is in exactly one configuration at each process plan ...


4

When I get your problem correctly you want to enforce every $X_i$ to be activated when any $Y_j$ is activated and every $Y_j$ to be activated when any $Z_k$ is activated. This can be achieved by adding constraints: $$ \begin{align} X_i &\geq Y_j &\forall i\in I, j\in J\\ Y_j &\geq Z_k &\forall j\in J, k\in K\\ \end{align} $$ Here the first ...


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