# Conditional Statements in an LP model

I am currently working on a large workforce/manpower planning model for an aviation company. This model should decide whether to hire a new pilot or to let pilots fly overtime. It has two skillsets. Copilots and Captains. Captains can only be hired from the copilots.

Each Skillset contains 24 salary steps. Each step will earn more money than the previous step. Each Pilot will jump one step after one year so the pilots in the highest steps will be there the longest and will hence upgrade first from copilot to captain. If the model decides I will need a captain this month.

All the copilots from step 17 onward will be upgraded to the captains side but will be integrated in step 7 of the captains side. Step 16 will be integrated into step 6 and so forth until step 11 to 1 which will be upgraded to step 1 on the captains side. Also, the model should be forced to take the copilot of the highest step first. There are following sets in the model s E Skills {"co","cpt"} t E Month {Ranging from 1 to 12} i E Salary Steps{Ranging from 1 to 24}

I use following decision variables for the Balance constraint

$$W_{s,t,i} = Workforce$$

$$h_{s,t,i} =$$ hiring of a copilot or captain

$$u_{t,i} =$$ upgraded Pilots at month t from step i

I have following constraints:

$$h_{cpt,t,7} = u_{t,18} + u_{t,17}$$ this has to hold for all t

$$h_{cpt,t,6} = u_{t,16}$$

$$h_{cpt,t,5} = u_{t,15}$$

$$h_{cpt,t,4} = u_{t,14}$$

$$h_{cpt,t,3} = u_{t,13}$$

$$h_{cpt,t,2} = u_{t,12}$$

$$h_{cpt,t,1} = u_{t,i}$$ this has to hold for i <= 11

Furthermore the balance constraint:

$$w_{co,t,i} = w_{co,t-1,i} - u_{t,i} + h_{co,t,i}$$

$$w_{cpt,t,i} = w_{cpt,t-1,i} + h_{cpt,t,i}$$

Also:

$$h_{co,t,i} = 0$$ for all i > 1

$$h_{cpt,t,i} = 0$$ for all i > 7

Right now my model will take the pilots out of step 11 of the copilot skill and put it in the correct step of the captains side. Then it will use the copilots out of step 12 and put them in the right step of the captain salary scale. I want it that it should use first the copilots from step 18 and work the other way around. Disregard step 18 to 24 of the copilot salary scale the workforce will always be 0 in these steps. They are included because the captains salary scale has more steps.

• Welcome to OR.SE. Have you had any force to use you mentioned notations to define the model? May 25 at 8:50
• Hello. Sorry I Don't get your question.
May 25 at 11:31

If you want to sequence upgrading copilots into captain starting from level 18, followed by 17,...12 define binary variables $$z_{t,i} \ \forall i \in \{12,13,...18 \}$$
Then following constraints

(1) $$z_{t,i} \le u_{t,i}\le W_{max}z_{t,i} \quad \forall t \ \ \forall i \in \{12,13,...18 \}$$

(2) $$1-W_{s,t,i+1} \le z_{t,i}$$

(3) $$W_{s,t,i+1} \le W_{max}(1-z_{ti})$$

(4) $$z_{t,i} \le z_{t,i+1} \quad \forall t \ \ \forall i \in \{12,13,...17 \}$$

where $$W_{max}$$ is a big-M, a big number based on the model, could be max of copilot headcount.

Also, you may not need $$z_{18}$$ if you choose to initiate/warm start $$u_{1,18} = 1$$ and other balance constraints may take care to set $$u_{t,18} \ge 1$$ if $$W_{s,t,18} \gt 0$$ since $$u_{t,18}$$ will remain unconstrained.
In that case you may need to adjust the boundary of first constraint $$\forall i \in \{12,...17 \}$$.
It will save a variable & a constraint.

And.. if you modify constraints (2) & (3) as
(5) $$1-\sum_{i+1}^{18} W_{s,t,i+1} \le z_{t,i}$$

(6) $$\sum_{i+1}^{18} W_{s,t,i+1} \le W_{max}(1-z_{ti}) \quad \forall i \in \{12,...17 \}$$

Then you may skip constraint (4)

• Thanks for the answer but the solution provided doesn't work. I don't know if its my implementation or not. But I got following solution for the order. $U_{t, i} <= U_{t, i+1}$ for i E {1......18} But the problem arises if $W_{s,t,i} = 0$ And it should use every Copilot in $W_{s,t,18}$ before It uses copilots from $W_{s,t,17}$ and so on
• @Adri hope you are using a binary variable $z$ to control whether its $1$ or $0$. Because as per your balance constraints if $W_{sti}=0$ then $u_{ti}=0$ and then by my first constraint $z_{ti}=0$ & $z_{t,i+1}$ can be $0$ or $1$. May be check your balance constraints once more. May 25 at 14:33
• Yep i fixed my implementation. Now it works. But I have still the issue that it doesn't use the whole headcount of $W_{s,t,18}$ before it uses $W_{s,t,17}$. So for example if $W_{s,t,18} = 5$ and $W_{s,t,17} = 5$ The following logic should occur if I want to upgrade 4 copilots to captain. $U_{t, 18} =4$ and $U_{t, 17} = 0$ Currently it is $U_{t, 18} = 3$ and $U_{t, 17} = 1$