# Problem with Piecewise constraint in Gurobi

I am facing a problem in my model with piecewise constraints that is making my one of the decision variables equal to zero for every value.

My objective function is:

$$$$\min \sum_{t=1}^T p_{t} \cdot (1+r) \cdot y_{t}$$$$ where $$p$$ is the price, $$y$$ is the quantity (decision variable) and $$r$$ is the price surcharge. $$t$$ is the index for time periods.

and my constraints are:

$$$$M q_t > \sum_{i=0}^N \beta_{i} X_{it} - p_t (1+r) \quad \forall t=1,\dotsc,T$$$$

$$$$-M (1-q_t) \leq \sum_{i=0}^N \beta_{i} X_{it} - p_t (1+r)\quad \forall t=1,\dotsc,T$$$$

The problem is that the value of $$r$$ depends on which interval the value of $$y$$ (decision variable) lies as shown by the following piecewise function:

$$$$r_t (Y_t) = \begin{cases} % s_0 0 & \mathrm{if }\; Y_t \leq b_0 \\ % s_1 0.05 & \mathrm{if }\; b_0 < Y_t \leq b_1 \\ % s_2 0.1 & \mathrm{if }\; b_1 < Y_t \leq b_2\\[6pt] ... & \mathrm{if }\; ... \end{cases}$$$$ where $$b_0$$, $$b_1$$ etc. are set of quantity intervals = [0, 50, 100, 150, 200, 250]

I have written piecewise constraints in Gurobi (Python) as:

for t in range(1, T + 1):
[0, 50, 50, 100, 100, 150, 150, 200, 200, 250],
[0, 0, 0.05, 0.05, 0.1, 0.1, 0.15, 0.15, 0.2, 0.2]
)
m.addConstr(-M * (1 - q[t]) <= gp.quicksum(beta[i] * X[i, t]
for i in range(N + 1)) - p[t] * (1+r),
name = "price threshold 1"
)

for t in range(1, T + 1):
[0, 50, 50, 100, 100, 150, 150, 200, 200, 250],
[0, 0, 0.05, 0.05, 0.1, 0.1, 0.15, 0.15, 0.2, 0.2]
)
m.addConstr(M * q[t]) >= gp.quicksum(beta[i] * X[i, t]
for i in range(N + 1)) - p[t] * (1+r),
name = "price threshold 2"
)


where $$M$$ is big M, $$q[t]$$ is binary variable, $$X[i,t]$$ is a given/known value, $$\beta$$ is a binary variable and $$r$$ also a binary variable. There are also some other constraints but the problem is with these constraints. Although the model optimizes the program it makes all the values of $$\beta$$ variable equal to zero which shouldn't be the case.

Could anyone please guide me where I am making mistake, whether in writing piecewise constraint or some other thing?

Any help would be highly appreciated. Thanks in advance.