# Model cost for a state change in an integer program

I have a problem involving tool selection I am trying to model right now. (I am fairly new to this).

I have a series of manufacturing operations I need to perform for $i \in \{1,\dots,n\}$.

Each operation requires one of $4$ specific tools $k \in \{1,\dots,4\}$.

I have a machine that has two onboard tool holders $j \in \{1,\dots,2\}$ that each hold one tool at any time. If the tool required for the next process is not in one of the two onboard tool holders, the machine must go back to the tool carousel to swap out a tool. I would like to minimize the total number of tool changes $C$

$$\text{minimize} \quad \sum_{i=1}^{n} C_i$$

My decision variables are $X_{ijk} \in \{0,1\}$ (for every hole choose whether or not we will have a specific tool loaded in a specific slot). What I am struggling with is how to come up with a cost. How do I assign a cost to a change in state from $i$ to $i+1$ for a specific tool holder (a tool change) for each operation $i$?

• Updated my question to be formatted with Latex – mcragun Jul 15 '16 at 21:16

## 1 Answer

You need extra binary variables $y_{ik}$ that are set to $1$ if operation $i$ performed a change with tool $k$. Add the following constraints to link variables together

$$x_{i1k}+x_{i2k} \le 1+ y_{ik}\quad \forall i,k$$

If operation $i$ with tool $k$ uses holders $1$ and $2$, than variable $y_{ik}$ is activated.

Your objective function is now simply $\sum_{ik} y_{ik}$.