# Binary variable with two criteria in Gurobi (Java)

I have the following problem in Gurobi (Java).

I have a binary variable $$b$$ that is supposed to be $$1$$ or $$0$$ depending on my optimisation variable $$x$$. It should be true that $$b = 1$$ if $$c_1 \le x \le c_2$$, otherwise $$0$$. The values of $$c_1$$ and $$c_2$$ are constant.

I wanted to solve the whole thing using a constraint, which then determines my binary variable with the method model.addGenConstrIndicator, but it is still $$1$$ for values above $$c_2$$. Maybe someone can help me or has another idea.

Furthermore I have the problem, that even when i don't use the binary variable in my objective function my result and the value of $$x$$ will be changed by this constraint.

for (int t = 0; t < 3; t++)
{
for (int j = 0; j < 5; j++)
{
for (int m = 0; m < 12; m++)
{
constra = new GRBLinExpr();