Hello. I am implementing L-shaped method (stochastic version of Benders decompostion) and have some question
回答済みI'm struggling to add feasibility cuts to get rid of the first stage solution which makes second stage problem is infeasible
Then I know that one should use dual unbounded ray to construct a feasibility cuts.
Then how can i get dual unbounded ray in Gurobi? Thanks.
-
I asked our new AI tool Gurobot to answer your question. Here is what it replied
To obtain dual unbounded rays in Gurobi for constructing feasibility cuts in two-stage optimization problems, you need to use the FarkasDual attribute. This attribute provides a certificate of infeasibility that can be used to construct feasibility cuts.
Here's how to access and use dual unbounded rays in Gurobi:
Step 1: Enable Infeasibility Information
First, you must set the InfUnbdInfo parameter to 1 before solving your model:
python
import gurobipy as gp # Create environment and model env = gp.Env() model = gp.Model(env=env) # Enable infeasibility/unboundedness information model.setParam('InfUnbdInfo', 1) # Build your model... # model.optimize()Step 2: Access the Dual Unbounded Ray
After solving an infeasible model, you can access the dual unbounded ray using the FarkasDual attribute:
python
if model.Status == gp.GRB.INFEASIBLE: # Get the dual unbounded ray (Farkas dual) farkas_dual = model.getAttr('FarkasDual', model.getConstrs()) farkas_proof = model.getAttr('FarkasProof')0 -
Note that if your subproblem is in dual form, and unbounded you will need the UnbdRay attribute.
0
サインインしてコメントを残してください。
コメント
2件のコメント