Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 3696

For questions about mathematical optimization problems involving both continuous and binary or general integer variables.

2 votes

Any good MIP LaTeX template?

Another package worth mentioning is optidef. You can find some examples in this answer on TeX.SE.
joni's user avatar
  • 1,572
1 vote

mip - mapping of equality to boolean variable

If I understood correctly, you want to enforce $$ \begin{align} e_{1,w} = e_{2,w} \implies b_{w} = 1 \quad \text{for all } w, \tag{1} \\ e_{1,w} \neq e_{2,w} \implies b_{w} = 0 \quad \text{for all } w …
joni's user avatar
  • 1,572
10 votes
Accepted

How to formulate the constraint If $x = k$, then $y = c$?

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_ …
joni's user avatar
  • 1,572
7 votes
Accepted

Find the list with the fewest elements whose cumulative sum reaches threshold

Your model basically reads as $$ \begin{align*} \min \quad n \quad \text{s.t.} \quad \sum_{k = 0}^{n} l_{i,k} \geq b_i \cdot \epsilon, \quad \sum_{i \in L} b_i = 1, \end{align*} $$ where $l_{i,k}$ is …
joni's user avatar
  • 1,572
5 votes
1 answer
3k views

How to linearize the product of two integer variables?

Given two integer variables $L_x \leq x \leq U_x$ and $L_y \leq y \leq U_y$, how can we linearize the product $x \cdot y$?
joni's user avatar
  • 1,572
7 votes
Accepted

How to linearize the product of two integer variables?

A straightforward approach is to express the integer variables $x$ and $y$ in terms of binary variables. In case $L_x < 0$ or $L_y < 0$, we can use the two complement's representation, see this answer …
joni's user avatar
  • 1,572
11 votes
Accepted

How to represent an integer variable via binary variables?

I'm not entirely sure if this is the most elegant way to model things, but here's how integer numbers are represented in a computer: Let's take an integer variable $x \in \mathbb{Z}$ with $L \leq x \l …
joni's user avatar
  • 1,572
5 votes

How to formulate if-then for two sums in an integer program

Your constraint is equivalent to the contraposition $$ \sum_i y_i \leq b \implies \sum_i x_i \neq b. $$ By introducing additional binary variables $z_1, w_1, w_2, w_3$, it can be formulated as follows …
joni's user avatar
  • 1,572
7 votes

How to transform a logical constraint with integer variables?

The range of values of the variable $y$ is quite small, so you could use the binary representation $y = b_0 + 2b_1$ with two binary variables $b_0$ and $b_1$ instead of the integer variable $y$. Then …
joni's user avatar
  • 1,572
6 votes

Implementing Heuristic Callback in CPLEX C++ API for MILP

Disclaimer: It's been a while since I used Cplex' C++ API. According to your question, you probably rather want to use a generic callback and inject a feasible (heuristic) solution through Callback::C …
joni's user avatar
  • 1,572
0 votes

Using networkx predecessors in Pyomo initialize method

As you already guessed, these are rather coding issues than solver issues. Regarding the pyomo model: Both m.pred and m.PAIRS in your linked MWE are empty. DiGraph's predecessor method returns an iter …
joni's user avatar
  • 1,572
5 votes
Accepted

Can we add a certain binary row to a matrix which preserves total unimodularity?

Your conjecture is wrong as the following counterexample demonstrates. Consider $$ A = \begin{pmatrix} 1 & 0 & -1 \\ 1 & 1 & 0 \end{pmatrix} $$ and $$ b^\top = \begin{pmatrix} -1 & 1 & 0 \end{pmatrix} …
joni's user avatar
  • 1,572
4 votes

How to transfer an optimization problem written with GUROBI (in python) in a grammar that ca...

I think pySCIPOpt might be a good choice, provided you are willing to make minor changes to the code. The modelling interface is very similar to Gurobi and the underlying SCIP solver also supports ha …
joni's user avatar
  • 1,572
3 votes
Accepted

How to create A, b and c matrices from very large .lp file?

Since you linked to the documentation of the C++ API in the comments, I assume you are using C++. Typically, the constraint matrix A is sparse, so we use a sparse data structure. This requires signifi …
joni's user avatar
  • 1,572
3 votes
Accepted

Formulation of binary constraint with the least binary variables for linear programming

You want to impose the following two logical constraints: $$ \begin{align} \delta_{t-1} = 1 \wedge \delta_t = 0 &\implies \beta_t = 1 \tag{1} \\ \neg (\delta_{t-1} = 1 \wedge \delta_t = 0) &\implies \ …
joni's user avatar
  • 1,572

15 30 50 per page