Dummy variable change optimization result

Hi,

I have established a JuMP model (gurobi optimizer) and one constraint seems to be not respected:

@constraint(obj,OP_t == sum(sum(sum(((opex_trans[i,1,k,1]*Nsh[i,1,k,t]) + (opex_trans[i,1,k,2]*Np[i,1,k,t])) for i in 1:I) for k in 1:K) for t in 1:T))

with Nsh and Np two variables of shape [1:I,1:J,1:K, 1:T] and opex_trans a parameter of shape [1:I,1:J,1:K, 1:L, 1:T] and @objective(obj, Min, CAP_p+OP_p+CAP_t+OP_t+CAP_r+OP_r) as objective function.

After optimization, OP_t is 0 while all parameters and variables are non null and non negative.

However, if I add a dummy variable to my model, the contraint is respected and OP_t is non null.

@variable(obj, 0<=dummy)

I do not understand how this variable that is never used “fix my code” and why JuMP do not seem to respect the constraint otherwise.

Thanks in advance for your help and do not hesitate to ask for more clarification.

1 Like

My guess would be that the bound constraint forces obj to be nonnegative at every iteration and the solver takes another path in the search space. If you printed the optimization history without the extra variable, you would probably see the objective getting negative at some point.

Hi there! Since this is your first post, you should take a read of Please read: make it easier to help you. It’s easier to help if you can provide a reproducible example, instead of isolated lines.

After optimization, OP_t is 0 while all parameters and variables are non null and non negative.

Did you take a look at termination_status(obj) to see if Gurobi found a feasible solution? Apart from that, it’s hard to tell what’s going on without a reproducible example. Gurobi shouldn’t find a solution with the equality violated.