# Modelling Question

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?

• Do you see these ($link_1$, $link_1$) to linearize the variable as an index? Mar 1 at 13:25

Define set/list as $$S=\{1,2,3\}$$: basically indices of length N
$$\sum_{j=1}^3 jz_j = p$$
$$\sum_j z_j = 1$$
$$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}$$
• Your $z_j$ is Clement's $Y_j$, and your third and fourth constraints are too restrictive. Jan 29 at 17:26