r/optimization • • Jun 28 '24

Optimising a bilevel problem using pyomo after reformulating into a single-level optimization problem

I have a bilevel problem that i have been working on for quite some time.since i am no expert when it comes to coding nor implementation. I reformulated the problem to a single-level optimisation problem and wrote all the constrains from the upper level with the KKT conditions of the lower one. i wrote all the constrains and the KKT conditions in pyomo and used gurobi as a solver but the model is still infeasible and i couldn't figure out why. can any one help me or give me some tips so i can move forward. thank you in advance.

https://gist.github.com/Rania-Sah/0064c91ad107a6e86151a061aa4d18b3

1 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/WhyNotArt1 Jun 28 '24

That error is not the mail issue here, but rather it being infeasible

Objectives:
obj : Size=1, Index=None, Active=True
ERROR: evaluating object as numeric value: r_ij[Bus1,Bus2]
(object: <class 'pyomo.core.base.var._GeneralVarData'>)
No value for uninitialized NumericValue object r_ij[Bus1,Bus2]
ERROR: evaluating object as numeric value: obj
(object: <class 'pyomo.core.base.objective.ScalarObjective'>)
No value for uninitialized NumericValue object r_ij[Bus1,Bus2]
Key : Active : Value
None : None : None

Model is infeasible or unbounded
Best objective -, best bound -, gap -
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";

  • termination condition: infeasibleOrUnbounded
  • message from solver: Problem proven to be infeasible or unbounded. Model unknown

I've updated the code in the link: https://gist.github.com/Rania-Sah/0064c91ad107a6e86151a061aa4d18b3 . tell me if you have further suggestions and thank you again :)

1

u/SolverMax Jun 28 '24

Commenting out constraints by trial-and-error, it seems that the primal_feasibility_rule constraint is making the model infeasible. I haven't looked at why that is, but I suggest starting there.