# Writing integer programming math statements

I am currently in a linear programming class, and we are on the topic of integer programming. I am asked to write certain relationships in "integer mathematical formulation" with binary ($$y_i$$), integer ($$x_i$$), and continuous ($$x_i$$) variables.

For example, if I want to choose at most $$3$$ projects from a possible $$5$$, I could write that as follows

$$\sum_{i=0}^5 y_i \leq 3$$

My prompt is talking about needing $$4$$ tanks in a facility. There are $$5$$ different design choices (so the index goes from $$1$$ to $$5$$). One of the specific relationships I am asked to formulate is:

Your design must place at least $$2$$ different types of tanks in he facility, out of the possible $$5$$.

I am having trouble figuring out how to write that up in mathematical formulation, and which type of variable could be used (I'm thinking binary, but an integer variable could be used to store how many of each tank we can use, since there is infinite availability of each type). Any insight is appreciated.

• You wrote "binary ($y_i$), integer ($x_i$), and continuous ($x_i$)". Why use $x$ twice? Did you mean $z$? – Rodrigo de Azevedo Feb 21 at 6:36
• I suppose it's just the convention of the notation I am learning. If a variable is integer, then it is denoted as an additional constraint e.g. $x_1, x_2\,as\,integer$. – albell26 Feb 21 at 19:12

## 1 Answer

Let's say the number of tanks of type $$i$$ is $$x_i$$, for $$i=1,2,3,4,5$$, with the constraint $$x_1+x_2+x_3+x_4+x_5 = 4$$ Taking advantage of the fact that $$x_i \le 4$$, we can then introduce binary variables $$y_i$$ for $$i=1,2,3,4,5$$ with constraints $$y_i \le x_i \le 4 y_i$$ This forces $$y_i = \begin{cases} 0 \qquad \text{if } x_i = 0 \\ 1 \qquad \text{otherwise} \end{cases}$$ so the restriction on the number of types can be introduced by the constraint $$y_1+y_2+y_3+y_4+y_5 \ge 2$$