# Too much time when i solve MISOCP with Gurobi

**URL:** <https://discourse.julialang.org/t/too-much-time-when-i-solve-misocp-with-gurobi/80644>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [May 7, 2022, 2:24am UTC](https://discourse.julialang.org/t/too-much-time-when-i-solve-misocp-with-gurobi/80644 "2022-05-07T02:24:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahon](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mahon](https://discourse.julialang.org/u/mahon)\
**Post date:** [May 7, 2022, 2:24am UTC](https://discourse.julialang.org/t/too-much-time-when-i-solve-misocp-with-gurobi/80644/1 "2022-05-07T02:24:38Z")

</div>

this is my model

```julia
julia> model
A JuMP Model
Minimization problem with:
Variables: 8915
Objective function type: AffExpr
`AffExpr`-in-`MathOptInterface.EqualTo{Float64}`: 2716 constraints
`AffExpr`-in-`MathOptInterface.GreaterThan{Float64}`: 813 constraints
`AffExpr`-in-`MathOptInterface.LessThan{Float64}`: 576 constraints
`Vector{AffExpr}`-in-`MathOptInterface.SecondOrderCone`: 768 constraints
`VariableRef`-in-`MathOptInterface.EqualTo{Float64}`: 2619 constraints
`VariableRef`-in-`MathOptInterface.GreaterThan{Float64}`: 3698 constraints
`VariableRef`-in-`MathOptInterface.LessThan{Float64}`: 3602 constraints
`VariableRef`-in-`MathOptInterface.ZeroOne`: 801 constraints
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Gurobi
Names registered in the model: E_ess, I, P, P_ch, P_dch, Pg, Q, Qg, SOCP, V, c10, c16, c17_1, c17_2, c17_3, c17_4, c17_5, c18, c18_3, c18_4, c18_5, c18_6, c22, c23_1, c23_2, c24_1, c24_3, ch, ch2, dch, dch2, p_ch, p_dch, p_wt, powerbalanced, q_SVC, qpowerbalanced, theta1_DE, theta1_IN, theta_CB, theta_DE, theta_IN, theta_OLTC, u, u1, u2, u_ch, u_dch, z, z1, z2, z3, z4, zx, zx1, zx2, zx3, zx4

```

but it takes exponential time , how can i make it faster

```julia
    Nodes | Current Node | Objective Bounds | Work
 Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time

     0 0 13.54863 0 141 - 13.54863 - - 0s
     0 0 15.86604 0 254 - 15.86604 - - 0s
     0 0 15.95797 0 301 - 15.95797 - - 0s
     0 0 15.97053 0 305 - 15.97053 - - 0s
     0 0 16.01988 0 292 - 16.01988 - - 1s
     0 0 16.02265 0 296 - 16.02265 - - 1s
     0 0 16.04140 0 266 - 16.04140 - - 1s
     0 0 16.04209 0 269 - 16.04209 - - 1s
     0 0 16.05020 0 244 - 16.05020 - - 1s
H 0 0 18.1401667 16.05246 11.5% - 1s
     0 0 16.05246 0 243 18.14017 16.05246 11.5% - 1s
     0 0 16.05420 0 259 18.14017 16.05420 11.5% - 2s
     0 0 16.05476 0 247 18.14017 16.05476 11.5% - 2s
     0 0 16.05506 0 275 18.14017 16.05506 11.5% - 2s
     0 0 16.05506 0 275 18.14017 16.05506 11.5% - 2s
     0 2 16.05506 0 275 18.14017 16.05506 11.5% - 3s
    84 98 17.84563 15 240 18.14017 16.18759 10.8% 201 5s
H 279 260 18.0158998 16.18759 10.1% 107 5s
H 454 366 18.0096778 16.24597 9.79% 106 7s
   461 369 17.95981 88 197 18.00968 16.24597 9.79% 106 10s
   469 374 16.80619 9 201 18.00968 16.40546 8.91% 104 15s
   477 380 17.95752 69 186 18.00968 16.40886 8.89% 102 20s
   484 386 16.43441 16 200 18.00968 16.43441 8.75% 151 32s
   497 397 16.69291 19 209 18.00968 16.48738 8.45% 161 35s
   571 443 17.28456 29 235 18.00968 16.52335 8.25% 174 40s
  .
  .
  .
 801954 130763 17.91647 42 132 17.94462 17.91041 0.19% 218 47687s
 802597 130806 cutoff 45 17.94462 17.91042 0.19% 218 47742s
 803147 130858 17.91256 41 132 17.94462 17.91043 0.19% 218 47785s

```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 7, 2022, 3:22am UTC](https://discourse.julialang.org/t/too-much-time-when-i-solve-misocp-with-gurobi/80644/2 "2022-05-07T03:22:26Z")

</div>

Do you have a reproducible example?

Otherwise you can set a time limit or change the optimality gap so that Gurobi terminates earlier. MISOCPs are hard to solve, even relatively small ones like this.

---

<div class="post-metadata">

**Author:** ![mahon](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mahon](https://discourse.julialang.org/u/mahon)\
**Post date:** [May 7, 2022, 3:34am UTC](https://discourse.julialang.org/t/too-much-time-when-i-solve-misocp-with-gurobi/80644/3 "2022-05-07T03:34:48Z")

</div>

i wan to change the optimality gap , how to code to achieve it? i didn`t find related function

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [May 7, 2022, 3:39am UTC](https://discourse.julialang.org/t/too-much-time-when-i-solve-misocp-with-gurobi/80644/4 "2022-05-07T03:39:32Z")

</div>

```julia
model = Model(Gurobi.Optimizer)
set_optimizer_attribute(model, "MIPGap", 0.05)

```

Gurobi parameters are here: [https://www.gurobi.com/documentation/9.5/refman/parameters.html](https://www.gurobi.com/documentation/9.5/refman/parameters.html)

---

<div class="post-metadata">

**Author:** ![mahon](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mahon](https://discourse.julialang.org/u/mahon)\
**Post date:** [May 7, 2022, 3:40am UTC](https://discourse.julialang.org/t/too-much-time-when-i-solve-misocp-with-gurobi/80644/5 "2022-05-07T03:40:22Z")

</div>

thank you very much
