# Representing a Multi-Level Categorical Variable using Big-M Method in Linear programming

I'm working with a statistical linear model where I have a variable, ( N ), representing the percentage of charging of a battery. Based on ( N ), I derive another variable, Charging_level, with the following conditions:

- If $$N = 0$$, Charging_level = 0.
- If $$0 < N \leq 20$$, Charging_level = 1.
- If $$20 < N \leq 40$$, Charging_level = 2.
- If $$40 < N \leq 80$$, Charging_level = 3.
- If $$80 < N \leq 100$$, Charging_level = 4.


I have 4 distinct levels of charging: 1, 2, 3, and 4. The statiscal model use indicator variables (coefficients per level), where one level is set to 1 and the others are set to 0, and hence can provide prediction.

I should note that I am optimizing over N (tradeoff between charging to full and other budget constraints), I'm seeking an efficient way to represent the Charging_level variable. I've come across the Big-M method, which I know is used for basic if-else conditions, but I'm unsure how to apply it to my scenario with multiple levels.

Is there a straightforward method for representing this multi-level categorical variable using the Big-M method? Or are there alternative approaches that might be more suitable?

Introduce a small constant tolerance $$\epsilon>0$$ and five binary decision variables $$z_0,\dots,z_4$$, and impose linear constraints \begin{align} \sum_{i=0}^4 z_i &=1 \\ 0z_0+\epsilon z_1+(20+\epsilon)z_2+(40+\epsilon)z_3+ (80+\epsilon)z_4 \le N &\le 0z_0+20z_1+40z_2+80z_3+ 100z_4 \\ \sum_{i=0}^4 i z_i &=\text{Charging_level} \end{align}
• This models both implications, right ? (e.g., $N=0 \iff \mbox{charging_level}=0$) Aug 8 at 7:42