Closed zinetullinruslan closed 2 years ago
Quadratic constraints are no accepted in the lower level. This is due the reformulation techniques that we use that replaces the lower level problem by its analytical kkt conditions. So the lower level problem is limited to quadratic objective and linear or conic constraints.
Your case is specially worse, since it seems that you are adding a quadratic equality. This is non-convex so there is no hope at all. Even for the convex case this package is still far from supporting quadratic constraints in the lower level.
Can you reformulate?
Thank you for your comment, i understand now that QP constraints in lower part are not allowed. Is it possible to move PnL expressions into upper model? I would add constraints of the form sum(V_con x sale price) - sum(V_tr x cost of transportation) - sum(V_prod x production cost) - sum(V_trans x P_trans) >= 0 for individual producers. The only "problematic" part is the last term which combines V_trans from lower model and P_trans from the upper one.
I've tried to find practical examples on similar topics. I thought this kind of problem (price is variable and set by leader, volumes are responding to the price, objective is to minimize cost or maximize profits, all ~ v x p) is quite usual for bilevel type of models. Would appreciate any concrete examples (generic price setting problem, toll setting) where such problems are solved.
Best regards, Ruslan
You can have quadratic constraints on the upper, but if you simply move a constraint from lower to upper you will be completely changing the semantics of your problem, you might end up with a completely different problem, whose solution is even the opposite. In some cases, it might be that that moving is ok, but these far from the common cases.
Yes, it is common to have:
(price is variable and set by leader, volumes are responding to the price, objective is to minimize cost or maximize profits, all ~ v x p
These products should be either in the lower objective or in the upper problem.
Unfortunately, I will not be able to help you with modeling your problem in the abstract level. If you have a bilevel problem I can tell if it is compliant with this package and I can help you if you have any trouble passing from LaTex maths to the Julia code.
Hello Joaquim, i abandoned the idea of using Bilevel formulation in this case because the original idea of implementing competition via constraints did not succeed. By setting objective to the sum of all player profits i skewed the logic a bit, some of the players got nothing at all sponsoring few players with huge profits.
I managed to solve the competition problem via iterative price setting outside of LP, thank you for your help.
Hello guys,
first of all thank you for great efforts put into this library! I am trying to solve following problem using BilevelJuMP:
The question which i want to answer is which price should each individual port set in order to maximize the profit, taking into account that producers will reallocate volumes if transshipment rate gets too high.
Model variables are: 0 <= V_prd <= V_prd^max - production volumes 0 <= V_con <= V_con^max - consumption volumes 0 <= V_tr <= V_tr^max - transportation volumes between locations 0 <= V_trans <= V_trans^max - transshipment volumes 0 <= P_trans <= P_trans^max - transshipment price
Total port transshipment volume V_trans is sum(V_tr) over all links leaving port.
All volumes are added to the lower part of the model and only prices P_trans are added to the upper part. Objective of the lower model is quadratic due to presence of last V x P term: Max(sum(V_con Price_sell)- sum(V_trCost_tr) - sum(V_prdCost_prd)- sum(V_transP_trans)) Objective of the upper model is also quadratic Max(sum(V_trans * P_trans))
Can it be that i am missing some important part of the puzzle and that bilevel opt would not help to find optimal P_trans? I simply start the optimization transshipment rates go to upper boundary and drive producers into negative PnLs. I wanted to force all producer PnLs to be non-negative by introducing PnL=sum of all terms attributed to individual producer but then i am running into error caused by quadratic terms in PnL variable calculation Constraints of function MathOptInterface.ScalarQuadraticFunction{Float64} in the Set MathOptInterface.EqualTo{Float64} are not implementederror@error.jl:42 Why can't i define quadratic constraints in lower part of the model? PnL calculation involves volumes from lower part of the model and prices from the upper part. I tried adding these constraints to the lower part of the model with error message above.
Here is my module status [485130c0] BilevelJuMP v0.4.2 [336ed68f] CSV v0.10.4 [944b1d66] CodecZlib v0.7.0 [a93c6f00] DataFrames v1.3.2 [59287772] Formatting v0.4.2 [682c06a0] JSON v0.21.3 [4076af6c] JuMP v0.21.10 [b8f27783] MathOptInterface v0.9.22 [f28f55f0] Memento v1.3.0 [d96e819e] Parameters v0.12.3 [014a38d5] QuadraticToBinary v0.2.4 [2a0f44e3] Base64 [ade2ca70] Dates
On a side notice, is there a way to dump complete Bilevel model into some human-readable form like LP for inspection? I found no documentation regarding that and JuMP.write_to_file does not seem to work.