Gurobi - Infeasible Constraint

167 Views Asked by At
start_time = time.time()
hours = 5
for i in range(hours):
print('---Running hour, ', i)
fsthr = i+35
lsthr = i + 1+ 35
network.lopf(network.snapshots[fsthr:lsthr], solver_name='gurobi', pyomo=False)                                                                                             
n=gp.Model('snapshot')

I am running an OPF model for the US for the year 2022. I had used 2022 actual data to get an idea. When i try to run the model, i get

WARNING:pypsa.linopf:Optimization failed with status warning and termination condition infeasible or unbounded.

How can i check what the constraint is?

2

There are 2 best solutions below

0
On

You can check the constraints of the network created by calling network.model.constraints and if you want the objective function you can call network.model.objective.

0
On

With gurobi, you can also run

n.model.compute_set_of_infeasible_constraints()

after solving.

(This only works with the new solver interface n.optimize(), not n.lopf())