# Tag Info

2

With CPLEX you can use logical constraints. For instance with the OPL API you can write: dvar boolean q; dvar int a; dvar int b; subject to { q==(a+b>=2); } q is 0 iff a+b<=1

5

Introduce a binary variable $\delta \in \{0,1\}$ to indicate whether $q$ is positive or not. You want: $$\sum_{(i,j) \in A}f_{ij} \le |A| - 1 \quad \Longrightarrow \quad \delta=0$$ or the contrapositive: $$\delta=1 \quad \Longrightarrow \quad \sum_{(i,j) \in A}f_{ij} \ge |A|$$ which you can achieve with: $$\sum_{(i,j) \in A}f_{ij} \ge |A| \delta$$ ...

4

With CPLEX you can use logical constraints. In OPL for instance you can write float epsilon=0.01; dvar float X; dvar float Y; subject to { (X>=epsilon) => (X>=Y); } And if you wonder , logical constraints are available in OPL but also in all APIs. float epsilon=0.01; dvar float X; dvar float Y; subject to { (X>=epsilon) => (X>=Y); } ...

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$.

3

In OPL CPLEX you could start with int g=10; range G=1..g; range I=1..5; {int} Ng[G]=[{1,2},{3,4},{5},{},{}, {},{},{},{},{}]; dvar boolean u[G]; subject to { forall(i in I) sum(g in G:i in Ng[g]) u[g]==1; }

5

In OPL CPLEX this is very easy to read and write. Let me change https://github.com/AlexFleischerParis/zooopl/blob/master/zooifthen.mod to your exact question: (nbBus40==6)=>(nbBus30==3); means nbBus40==6 implies nbBus30==3 int nbKids=300; float costBus40=500; float costBus30=400; dvar int+ nbBus40; dvar int+ nbBus30; minimize costBus40*nbBus40 +...

3

Introduce binary variable $\delta$ and we can write following constraints \begin{align} k \cdot \delta + L_{x} \cdot (1-\delta) &\le x \le k \cdot \delta + U_{x} \cdot (1-\delta) \\ c \cdot \delta + L_{y} \cdot (1-\delta) &\le y \le c \cdot \delta + U_{y} \cdot (1-\delta) \\ \end{align} The way it works is when $\delta$ equals $1$, $x = k$ and $... 10 By introducing the binary helper variables$z_1,z_2,z_3,w_1,w_2,w_3, you can use the constraints \begin{align} L_y z_1 + c z_2 + (c+1)z_3 &\leq y \leq (c-1)z_1 + c z_2 + U_y z_3, \tag{1} \\ L_x w_1 + k w_2 + (k+1)w_3 &\leq x \leq (k-1)w_1 + k w_2 + U_x w_3, \tag{2}\\ z_1 + z_2 + z_3 &= 1, \tag{3}\\ w_1 + w_2 + w_3 &= 1, \tag{4}\\ z_1 + ... 4 You could try and get rid of variables Y_{p,t,j,c}: remove constraints (6)-(7); constraints (6) simply link x and Y variables, so removing them should not have any impact on the feasibility of the solution (assuming you remove Y variables) ; constraints (7) are not mandatory if my understanding is correct replace constraints (5) by \sum_{... 5 When defining multiple components in an objective function, you should take care of a couple of items: All elements (i.e.ea \cdot x_1$,$b\cdot x_2$etc.) should have the same unit. This sounds obvious, but I have seen adding kg and seconds together. Whenever possible, I would always normalize the sum of the coefficients to 1, so that you can think of ... 2 I have suggestions for your two recently added constraints. Your first one is: $$\text{board}(i_1,i_2,j_1,t,k) + \text{board}(i_1,i_2,j_2,t,k) \leq 1 + m[j_1][j_2]\\\forall i_1,i_2 \in V^2, \forall j_1,j_2 \in J^2, \forall t \in T, \forall k \in K \tag1$$ You do not need to impose$(1)$when$m[j_1][j_2] = 1\$ because it is redundant. You can also ...

-3

Can't speak on CP to model this but we have solved this by employing Graph Theory to model all the given constraints of yours and more on real data. Your constraints resemble the Hamiltonian Paths Problem and in our implementation we didn't have to go as far as employing CP, MIP or any solver because we understand the instance. The way I see it, it is a ...

Top 50 recent answers are included