3
$\begingroup$

Let $W^C_t$, $W_t$ be binary variables and $p$ an integer variable with $1 \leq p \leq 3$

The variables are related through the following equation:

$$W^C_t = \sum_{\theta=1}^{p} W_{t-\theta}$$

I can linearise this equation by introducing indicator variables $Y_1, Y_2, Y_3$ and requiring:

IF $Y_1=1$ THEN $W^C_t = W_{t-1}$

IF $Y_2=1$ THEN $W^C_t = W_{t-1} + W_{t-2} $

IF $Y_3=1$ THEN $W^C_t = W_{t-1} + W_{t-2} + W_{t-3}$

$Y_1 + Y_2 + Y_3 = 1$

This approach may, depending on the problem, to a large amount of constraints.

The question is, is there a better way to model the equation?

$\endgroup$
1
  • 1
    $\begingroup$ Do you see these ($link_1$, $link_1$) to linearize the variable as an index? $\endgroup$
    – A.Omidi
    Mar 1, 2023 at 13:25

1 Answer 1

-1
$\begingroup$

Define set/list as $S=\{1,2,3\}$: basically indices of length N
Then add constraints
$\sum_{j=1}^3 jz_j = p $
$ \sum_j z_j = 1$
Then use
$ z_j \le \sum_{k=1}^j W_{t-k} \ \forall j \in S$
$\sum_{k: (k\gt j)} W_{t-k} \le z_{k} \ \forall j \in S$
$ W_{t}^C = \sum_{\theta=1}^N W_{t-\theta}$

$\endgroup$
1
  • 3
    $\begingroup$ Your $z_j$ is Clement's $Y_j$, and your third and fourth constraints are too restrictive. $\endgroup$
    – RobPratt
    Jan 29, 2023 at 17:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.