Second-order cone constraints in pyomo with mosek

18 views
Skip to first unread message

Bochen Stone

unread,
Apr 4, 2025, 8:28:22 AMApr 4
to Pyomo Forum

Hope you have a good day.

Recently, I created a coupled power-transportation model using Pyomo and solved this integrated model using ADMM. Where the power system model (Distflow Model) is solved by Gurobi.

I want to obtain dual variables in the power system model, so I set pyo.Suffix(direction=pyo.Suffix.IMPORT). But the iterative process often exits because Gurobi reports an error: failed to compute QCP dual solution due to inaccurate barrier solution. Try decreasing BarQCPConvTol for more accuracy. Unable to retrieve attribute 'Pi'.

Then, I changed to Cplex to solve this SOC, and it can stably solve this problem, but sometimes it also fails again.

I also tried Mosek, but it seems like the solver cannot identify the second-order cone constriants with formulation of $P^2_{ij}+Q^2_{ij}\leq V_iI_{ij}$ and reports that: Constraint 'x259'(102) is not convex. Q should be positive semidefinite in a constraint with finite upper bound.

I really have no idea how to solve these problems. Is something wrong with my problem? Is there way to explicitly formulate second-order cone constraints that can be identify by Mosek?

I apologize for my ignorance. Any you can give me help would be appreciated.

Bochen

Ahmad Heidari

unread,
Apr 4, 2025, 12:27:45 PMApr 4
to Pyomo Forum
Hello Bochen,

I hope you are doing well.

Sometimes, some solvers (Gurobi, as well) cannot retrieve the constraints' dual values since the problem is not linear. You can relax the binary and integer variables using the code snippet below (I have used the code below to find the dual values of an NCUC problem in the power systems):

#-------------------------------------------------------------------------------------------------------

# Relax all integer variables to continuous
for v in model.component_objects(Var, active=True):
    for index in v:
        if v[index].domain is Binary or v[index].domain is Integers:
            v[index].domain = Reals # Change from Binary/Integers to Reals

# Fixing binary variables
for g in model.I:
    for t in model.T:
        model.Z[g,t].fix(value(model.Z[g,t]))
for g in model.I:
    for t in model.T:
        model.Y[g,t].fix(value(model.Y[g,t]))
for g in model.I:
    for t in model.T:
        model.U[g,t].fix(value(model.U[g,t]))

# Calling the dual suffix
model.dual = Suffix(direction=Suffix.IMPORT_EXPORT)

# Solving the relaxed version of the problem
solver = SolverFactory('gurobi')
results_model_relaxed = solver.solve(model, tee=False)

#-------------------------------------------------------------------------------------------------------

Please let me know if further information is needed.

Bochen Stone

unread,
Apr 6, 2025, 9:38:45 AMApr 6
to Pyomo Forum
Hello Ahmad,

Thank you for your suggestion.

The problem was successfully solved by Gurobi by appropriately tuning solver parameters.

Thank you again.

Ahmad Heidari

unread,
Apr 6, 2025, 11:21:44 AMApr 6
to pyomo...@googlegroups.com
Bochen, 

Great news. I am happy you could solve the issue with tuning the solver’s parameters. 



--
You received this message because you are subscribed to a topic in the Google Groups "Pyomo Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyomo-forum/5ADDFDVkc9Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyomo-forum...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pyomo-forum/f81c6b4f-c2f4-4258-a5d0-1a8d647cbe8en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages