I want to solve this problem : We have 100 cities where if there is a fire we need to call at least 1 police officier and 3 firefighters from place that are in distance of 100 km or less. The distance from city i to j is : Di The cost for keeping a firefighter in a city is A and the cost for the police officier is B.
$$ \sum_{i=1}^{100} A.X_i + B*Y_i $$ $$st \sum_{i=1}^{100} X_i*Y_{ij} >= 3 $$ $$ \sum_{i=1}^{100} Y_i*Y_{ij} >= 1$$
$$ \text{where} \space X_i \space \text{is indicator for placing firefighter in city I and} \space Y_i \space \text{is for police officier} $$
But I cannot manage to create a binary variable for the constraint of city of distance of 100 km or less , like let $Y_{ij}$ be the indicator if the distance is 100 km or less.
Your existing constraints are not linear, and you should not use both $Y_i$ and $Y_{i,j}$.
Let $E$ be the set of $(i,j)$ pairs where cities $i$ and $j$ are within distance 100 of each other. For $(i,j)\in E$, let $F_{i,j}$ indicate whether a firefighter from city $i$ serves city $j$, and let $P_{i,j}$ indicate whether a police officer from city $i$ serves city $j$. The desired linear constraints are \begin{align} \sum_{i: (i,j)\in E} F_{i,j} &\ge 3 &&\text{for all $j$} \\ \sum_{i: (i,j)\in E} P_{i,j} &\ge 1 &&\text{for all $j$} \\ F_{i,j} &\le X_i &&\text{for all $(i,j)\in E$} \\ P_{i,j} &\le Y_i &&\text{for all $(i,j)\in E$} \\ \end{align}