# Calculate slacks for quadratic constraints

**URL:** <https://discourse.julialang.org/t/calculate-slacks-for-quadratic-constraints/3425>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [April 28, 2017, 10:09pm UTC](https://discourse.julialang.org/t/calculate-slacks-for-quadratic-constraints/3425 "2017-04-28T22:09:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adowling2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adowling2/32/539_2.png) [@adowling2](https://discourse.julialang.org/u/adowling2)\
**Post date:** [April 28, 2017, 10:09pm UTC](https://discourse.julialang.org/t/calculate-slacks-for-quadratic-constraints/3425/1 "2017-04-28T22:09:44Z")

</div>

I’d like to calculate the slacks for a quadratic constraint. Using MathProgBase.getconstrmatrix (see [old Google Groups post](https://groups.google.com/d/msg/julia-opt/onOWSbgy9ro/Ol0Hn5dABQAJ)) does not work for quadratic constraints. Any suggestions?

---

<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:** [April 29, 2017, 5:40pm UTC](https://discourse.julialang.org/t/calculate-slacks-for-quadratic-constraints/3425/2 "2017-04-29T17:40:45Z")

</div>

MathProgBase doesn’t currently have a method to query the quadratic parts of a model. Your options are:

1. Propose a new MathProgBase method and implement it for the solvers you need.
2. Write a dummy solver to capture the model data from `JuMP.build()`.
3. Extract the quadratic model data from JuMP’s data structures ([example](https://github.com/JuliaOpt/JuMP.jl/blob/bb49e19ecd3fae310edbbaf409ce7a117dd1d236/src/solvers.jl#L413)).
4. Remember which quadratic terms you added to the JuMP model in the first place.

---

<div class="post-metadata">

**Author:** ![adowling2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adowling2/32/539_2.png) [@adowling2](https://discourse.julialang.org/u/adowling2)\
**Post date:** [April 29, 2017, 5:45pm UTC](https://discourse.julialang.org/t/calculate-slacks-for-quadratic-constraints/3425/3 "2017-04-29T17:45:37Z")

</div>

@miles.lubin Thank you for the suggestion. I’ll try 2 and/or 3 and update with my progress.
