# Robust heuristic for binding SOC without exact solution

**URL:** https://discourse.julialang.org/t/robust-heuristic-for-binding-soc-without-exact-solution/58321
**Category:** Optimization (Mathematical)
**Created:** [March 31, 2021, 6:42pm UTC](https://discourse.julialang.org/t/robust-heuristic-for-binding-soc-without-exact-solution/58321 "2021-03-31T18:42:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![lgo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lgo/32/48751_2.png) [@lgo](https://discourse.julialang.org/u/lgo)
#### Post date: [March 31, 2021, 6:42pm UTC](https://discourse.julialang.org/t/robust-heuristic-for-binding-soc-without-exact-solution/58321/1 "2021-03-31T18:42:59Z")

</div>

I’m solving a large number of LPs with a single second-order cone constraint. For each of these problems, I want to check, if the SOC is binding. To keep the run-time short, I do not want to obtain an exact solution or compute duals. So, my code look something like this:

```julia
using Gurobi, JuMP
model = Model(Gurobi.Optimizer)

@variable(model, x[i=1:2])
soc= @constraint(model, x[1]^2 + x[2]^2 <= 50.0)
@objective(model, Max, x[1] + x[2] )

optimize!(model)
val = value(soc)
rhs = normalized_rhs(soc)
slack = val - rhs

```

Although `soc` is theoretical binding, its slack is always around `3e-6` due to imprecisions. When looking for an appopriate and robust heuristic to check if `soc` is binding, there were two things I wondered about specifically:

1. Is it a good idea to look at the slack or should I rather evaluate the ratio of `val` and `rhs`?
2. How sensitive is the slack (or ratio of `val` and `rhs`) to model properties like the objective value and solver parameters like the convergence or feasibility tolerance?

---

<div class="post-metadata">

### Author: ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)
#### Post date: [March 31, 2021, 8:56pm UTC](https://discourse.julialang.org/t/robust-heuristic-for-binding-soc-without-exact-solution/58321/2 "2021-03-31T20:56:21Z")

</div>

Numerical tolerances are hard, and the answer very much depends on the solver and methods you’re using. So, you might get a more informed answer from Gurobi support.

What you might try is solving the LP without the SOC, checking if the SOC is already satisfied (up to whatever tolerance is meaningful to you), and if not, add the SOC constraint and re-solve.

> I do not want to obtain an exact solution or compute duals

Minor point, but all SOC solvers I’m aware of compute duals either explicitly or implicitly as part of solving the problem.
