2
$\begingroup$

Say I have 3 sources. D1, D2, D3. their capacity is 100, 200, 400. I want to create some constraints such that First D1 is depleted then D2 and then D3. But the catch is you cant use min or max function in constraints as it will make system nonlinear.

I tried the following

D1x1 + D2x2 + D3*x3 = D

0 <= D1 <= 100 0 <= D2 <= 200 0 <= D3 <= 400

xi are binary

x1 <= x2 <= x3

D1 <= D

D2 <= D - 100x1

D3 <= D - 100x1- 200x2

But it the last 3 equations create conflict and infeasibility in edge cases. How to proceed.

P.S. - to convert D1*x1 to linear I used this

https://orinanobworld.blogspot.com/2010/10/binary-variables-and-quadratic-terms.html

$\endgroup$

1 Answer 1

3
$\begingroup$

You could model it as follows: Let $c_i$ the capacity of source $i$. Let $x_i$ the amount of demand source $i$ fills. Further, you can introduce variable $y_i$ that is binary and takes value 0 if $x_i < c_i$. You can now add the the following constraints:

\begin{align} & c_i \cdot y_i \leq x_i & \forall i \in S, \tag1 \\ & x_i \leq c_i \cdot y_{i-1} & \forall i \in S\setminus1 \tag2 \\ \end{align}

The first constraint ensures that $y_i$ is $0$, if source $i$ is not fully depleted. The second constraint ensures that $x_i$ is only started to be used, if $i-1$ is fully depleted, i.e., $y_{i-1}=1$. It does not apply for the first source ($i=1$), you should therefore still include $x_1 \leq c_1$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.