# Optimization (Mathematical)

**URL:** https://discourse.julialang.org/c/domain/opt/13.md?page=95

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 96

---

## [PowerModelsAnnex QC\_OPF](https://discourse.julialang.org/t/powermodelsannex-qc-opf/43459)

<div class="topic-metadata">

**Author:** [@fnbillimoria](https://discourse.julialang.org/u/fnbillimoria)\
**Replies:** 2\
**Last updated:** [July 23, 2020, 1:21am UTC](https://discourse.julialang.org/t/powermodelsannex-qc-opf/43459 "2020-07-23T01:21:00Z")

</div>

I am looking through the PowerModelsAnnex.jl module and particularly the src/model/opf.jl file. I noted that there is a build of a quadratically constrained opf in there? (i.e. build\_qc\_opf) Could I please confirm what …

---

## [KKT condition solves the bilevel optimization problem](https://discourse.julialang.org/t/kkt-condition-solves-the-bilevel-optimization-problem/43289)

<div class="topic-metadata">

**Author:** [@dty](https://discourse.julialang.org/u/dty)\
**Replies:** 25\
**Last updated:** [July 22, 2020, 2:36pm UTC](https://discourse.julialang.org/t/kkt-condition-solves-the-bilevel-optimization-problem/43289 "2020-07-22T14:36:38Z")

</div>

Is there a package for solving bilevel optimization problems with KKT conditions? Specifically, the inequality constrained KKT conditions are linearized by the large M method. Finally, the two-layer problem is turned int…

---

## [JuMP print sub-expressions](https://discourse.julialang.org/t/jump-print-sub-expressions/43021)

<div class="topic-metadata">

**Author:** [@fnbillimoria](https://discourse.julialang.org/u/fnbillimoria)\
**Replies:** 3\
**Last updated:** [July 22, 2020, 1:48am UTC](https://discourse.julialang.org/t/jump-print-sub-expressions/43021 "2020-07-22T01:48:24Z")

</div>

Hello, I have created an optimisation problem in JuMP with a set constraints that is created from affine and non-linear expressions. When i print() the model, the constraints show up as below. Is there any way to prin…

---

## [PowerModels.jl data format](https://discourse.julialang.org/t/powermodels-jl-data-format/43460)

<div class="topic-metadata">

**Author:** [@fnbillimoria](https://discourse.julialang.org/u/fnbillimoria)\
**Replies:** 1\
**Last updated:** [July 22, 2020, 1:18am UTC](https://discourse.julialang.org/t/powermodels-jl-data-format/43460 "2020-07-22T01:18:11Z")

</div>

Hello, I wanted to query the branch data format for PowerModels.jl. I note that there are two fields in particular which are not mentioned in the matpower format, but do seem to be in some of the test cases. Particula…

---

## [Getting info from CPLEX output](https://discourse.julialang.org/t/getting-info-from-cplex-output/42582)

<div class="topic-metadata">

**Author:** [@Codzilla](https://discourse.julialang.org/u/Codzilla)\
**Replies:** 6\
**Last updated:** [July 21, 2020, 9:39am UTC](https://discourse.julialang.org/t/getting-info-from-cplex-output/42582 "2020-07-21T09:39:15Z")

</div>

I’m using JuMP to solve a large number of instancies with CPLEX and I would like to use the information output by CPLEX such as the number of Flow cuts applied or time spent during branch & bound. Is there any elegant wa…

---

## [How do I find \`m\` and \`b\` such that \`some\_function((x) -\> m\*x + b)\` is maximized?](https://discourse.julialang.org/t/how-do-i-find-m-and-b-such-that-some-function-x-m-x-b-is-maximized/43429)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 3\
**Last updated:** [July 21, 2020, 2:51pm UTC](https://discourse.julialang.org/t/how-do-i-find-m-and-b-such-that-some-function-x-m-x-b-is-maximized/43429 "2020-07-21T14:51:51Z")

</div>

I have the following Julia function which calculates the expected mean of some model. I want to find m and b such that EBuy(4, (x) -\> m\*x + b) is maximized. using Distributions function EBuy(λ, buy ; limDefault=10^2) …

---

## [Convert a VariableRef in JuMP objective function or constraint](https://discourse.julialang.org/t/convert-a-variableref-in-jump-objective-function-or-constraint/43408)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 1\
**Last updated:** [July 21, 2020, 1:08am UTC](https://discourse.julialang.org/t/convert-a-variableref-in-jump-objective-function-or-constraint/43408 "2020-07-21T01:08:42Z")

</div>

I have a model with decision variables like this model = Model(Cbc.Optimizer) @variable(model, x\[1:num\_groups, 1:size(data, 1)\], Bin) and I need to be able to use the values of x to return a submatrix from another mat…

---

## [Help setting up a problem with JuMP and/or Clustering.jl](https://discourse.julialang.org/t/help-setting-up-a-problem-with-jump-and-or-clustering-jl/43252)

<div class="topic-metadata">

**Author:** [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Replies:** 5\
**Last updated:** [July 19, 2020, 8:22pm UTC](https://discourse.julialang.org/t/help-setting-up-a-problem-with-jump-and-or-clustering-jl/43252 "2020-07-19T20:22:14Z")

</div>

Let’s say I want to divide all of the counties within a state into 4 groups and I want all of the counties in a group to be geographically contiguous. Furthermore, when I’m done, I want the total population of each of th…

---

## [JuMP Release Cadence](https://discourse.julialang.org/t/jump-release-cadence/43338)

<div class="topic-metadata">

**Author:** [@vtjeng](https://discourse.julialang.org/u/vtjeng)\
**Replies:** 2\
**Last updated:** [July 19, 2020, 5:54pm UTC](https://discourse.julialang.org/t/jump-release-cadence/43338 "2020-07-19T17:54:51Z")

</div>

Is there somewhere where I can track when the next release of JuMP is planned for? In this case, I’d like to know when https://github.com/jump-dev/JuMP.jl/pull/2275 will make it into a release (I’ve been holding off of …

---

## [A question about BilevelJuMP.jl](https://discourse.julialang.org/t/a-question-about-bileveljump-jl/43336)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [July 19, 2020, 5:49pm UTC](https://discourse.julialang.org/t/a-question-about-bileveljump-jl/43336 "2020-07-19T17:49:11Z")

</div>

using JuMP, BilevelJuMP, Xpress model = BilevelModel() @variable(Lower(model), x) @variable(Upper(model), y) @objective(Upper(model), Min, 3x + y) @constraints(Upper(model), begin x \<= 5 y \<= 8 y \>= 0 end)…

---

## [Error: JuMP constraint vs Array constraint (same size) --\> ArgumentError: Broadcasting](https://discourse.julialang.org/t/error-jump-constraint-vs-array-constraint-same-size-argumenterror-broadcasting/42812)

<div class="topic-metadata">

**Author:** [@PabloGalaz](https://discourse.julialang.org/u/PabloGalaz)\
**Replies:** 2\
**Last updated:** [July 18, 2020, 7:27pm UTC](https://discourse.julialang.org/t/error-jump-constraint-vs-array-constraint-same-size-argumenterror-broadcasting/42812 "2020-07-18T19:27:55Z")

</div>

Hello everyone, I’m using Julia v1.4.2 and JuMP v0.21.2 to solve a optimization problem. I want to compare a decision variable with an array of zeros and a calculated array (with other array and another decision variabl…

---

## [Julia Vscode new version issue with JuMP](https://discourse.julialang.org/t/julia-vscode-new-version-issue-with-jump/43134)

<div class="topic-metadata">

**Author:** [@afazevedo](https://discourse.julialang.org/u/afazevedo)\
**Replies:** 4\
**Last updated:** [July 17, 2020, 10:35am UTC](https://discourse.julialang.org/t/julia-vscode-new-version-issue-with-jump/43134 "2020-07-17T10:35:05Z")

</div>

I’m having a problem with SparsesAxisArray JuMP on Julia for Vscode. When I use @variable with this condition below, it reproduces an error using Gurobi, JuMP model = Model(Gurobi.Optimizer) n = 5 V = 1:n V0= 1:n+…

---

## [Help JuMP: we want to hear from people using JuMP to drive impactful changes to their business](https://discourse.julialang.org/t/help-jump-we-want-to-hear-from-people-using-jump-to-drive-impactful-changes-to-their-business/43191)

<div class="topic-metadata">

**Author:** [@odow](https://discourse.julialang.org/u/odow)\
**Replies:** 0\
**Last updated:** [July 16, 2020, 7:15pm UTC](https://discourse.julialang.org/t/help-jump-we-want-to-hear-from-people-using-jump-to-drive-impactful-changes-to-their-business/43191 "2020-07-16T19:15:28Z")

</div>

Dear all, JuMP is in the running for an award and we need your help. Have you used JuMP (either prototyping, or in deployment) to drive impactful changes to your business or organization? If so, would you be interest…

---

## [Help understanding MOI bridges, Even Proof-of-concept doesn't work](https://discourse.julialang.org/t/help-understanding-moi-bridges-even-proof-of-concept-doesnt-work/43152)

<div class="topic-metadata">

**Author:** [@votroto](https://discourse.julialang.org/u/votroto)\
**Replies:** 3\
**Last updated:** [July 16, 2020, 1:52pm UTC](https://discourse.julialang.org/t/help-understanding-moi-bridges-even-proof-of-concept-doesnt-work/43152 "2020-07-16T13:52:26Z")

</div>

Hi, I’ve been playing around with MOI bridges, but I can’t get even the simplest thing to work. Let’s imagine I want to create a bridge that simply ignores any PSD constraints: module MWE using MathOptInterface const M…

---

## [Locally solved](https://discourse.julialang.org/t/locally-solved/43179)

<div class="topic-metadata">

**Author:** [@mayar](https://discourse.julialang.org/u/mayar)\
**Replies:** 2\
**Last updated:** [July 16, 2020, 1:49pm UTC](https://discourse.julialang.org/t/locally-solved/43179 "2020-07-16T13:49:10Z")

</div>

hello there, I have used Ipopt with JuMP to solve an NLP problem and I got locally solved as a termination status…I tried changing the starting point but the results never changed What can I do to get an Optimal Soluti…

---

## [JuMP.all\_constraints not listing GenericQuadExpr constraints](https://discourse.julialang.org/t/jump-all-constraints-not-listing-genericquadexpr-constraints/43103)

<div class="topic-metadata">

**Author:** [@adow031](https://discourse.julialang.org/u/adow031)\
**Replies:** 8\
**Last updated:** [July 15, 2020, 11:16pm UTC](https://discourse.julialang.org/t/jump-all-constraints-not-listing-genericquadexpr-constraints/43103 "2020-07-15T23:16:35Z")

</div>

I have a quadratic program, and was trying to list all the constraints. However, all\_constraints, wouldn’t list any of the constraints of type GenericQuadExpr. Below is a small example exhibiting the problem. m = Model(…

---

## [Error with SCIP when reoptimize after adding a constraint](https://discourse.julialang.org/t/error-with-scip-when-reoptimize-after-adding-a-constraint/43112)

<div class="topic-metadata">

**Author:** [@remi-garcia](https://discourse.julialang.org/u/remi-garcia)\
**Replies:** 2\
**Last updated:** [July 15, 2020, 6:20pm UTC](https://discourse.julialang.org/t/error-with-scip-when-reoptimize-after-adding-a-constraint/43112 "2020-07-15T18:20:32Z")

</div>

Hi, I don’t understand why SCIP throws an error when I reoptimize a model after adding a constraint. Error: """ using JuMP; using SCIP; model = Model(SCIP.Optimizer); @variable(model, x);@variable(model, y);@variable(…

---

## [Key 2 not found error](https://discourse.julialang.org/t/key-2-not-found-error/43105)

<div class="topic-metadata">

**Author:** [@mayar](https://discourse.julialang.org/u/mayar)\
**Replies:** 3\
**Last updated:** [July 15, 2020, 10:30am UTC](https://discourse.julialang.org/t/key-2-not-found-error/43105 "2020-07-15T10:30:42Z")

</div>

Hello, What does this error mean? “Key 2 not found” Nodes\_set=\[1,2,3\] Gen\_set=\[1,3\] Pd=\[0,-4,0\] JuMP.@variable(m, 0.1 ≤ p\[i in Gen\_set\] ≤ 2) JuMP.@variable(m, pij\[i = Nodes\_set, j = Nodes\_set\]) JuMP.@constraint(m, Pnod…

---

## [How to wrap using JuMP inside a function](https://discourse.julialang.org/t/how-to-wrap-using-jump-inside-a-function/43004)

<div class="topic-metadata">

**Author:** [@asavasci](https://discourse.julialang.org/u/asavasci)\
**Replies:** 3\
**Last updated:** [July 15, 2020, 10:06am UTC](https://discourse.julialang.org/t/how-to-wrap-using-jump-inside-a-function/43004 "2020-07-15T10:06:32Z")

</div>

I want to place “using JuMP” inside a function as follows function test() using JuMP ... end However, it gives an error syntax: "using" expression not at top level, is there a way to work around it?

---

## [Extending JuMP.@constraint macro: misunderstanding scope?](https://discourse.julialang.org/t/extending-jump-constraint-macro-misunderstanding-scope/43046)

<div class="topic-metadata">

**Author:** [@gobs](https://discourse.julialang.org/u/gobs)\
**Replies:** 2\
**Last updated:** [July 15, 2020, 8:11am UTC](https://discourse.julialang.org/t/extending-jump-constraint-macro-misunderstanding-scope/43046 "2020-07-15T08:11:53Z")

</div>

I’ve been toying with the idea of extending the JuMP.@constraint macro to make my code somewhat more concise. Here’s an example of what I currently do: con1 = @constraint(gep.model, \[i=1:10\], x\[i\] \>= 0) # Make an anonym…

---

## [Polynomial optimization: not getting the correct solution with extractatoms](https://discourse.julialang.org/t/polynomial-optimization-not-getting-the-correct-solution-with-extractatoms/42635)

<div class="topic-metadata">

**Author:** [@aliceee](https://discourse.julialang.org/u/aliceee)\
**Replies:** 2\
**Last updated:** [July 13, 2020, 5:40pm UTC](https://discourse.julialang.org/t/polynomial-optimization-not-getting-the-correct-solution-with-extractatoms/42635 "2020-07-13T17:40:14Z")

</div>

Hi, I’m trying to get the optimal solution of a polynomial optimization problem by calculating the dual. # Create symbolic variables (not JuMP decision variables) @polyvar x1 x2 # Create a Sum of Squares JuMP model with…

---

## [Example of nonlinear optimization with Ipopt](https://discourse.julialang.org/t/example-of-nonlinear-optimization-with-ipopt/42954)

<div class="topic-metadata">

**Author:** [@mayar](https://discourse.julialang.org/u/mayar)\
**Replies:** 3\
**Last updated:** [July 12, 2020, 6:55pm UTC](https://discourse.julialang.org/t/example-of-nonlinear-optimization-with-ipopt/42954 "2020-07-12T18:55:41Z")

</div>

hello can you provide me with an example or link to an example on NL optimization with Ipopt Thank you

---

## [Gurobi "Objective Q not PSD " for Convex quadratic problem](https://discourse.julialang.org/t/gurobi-objective-q-not-psd-for-convex-quadratic-problem/42689)

<div class="topic-metadata">

**Author:** [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)\
**Replies:** 5\
**Last updated:** [July 11, 2020, 2:42am UTC](https://discourse.julialang.org/t/gurobi-objective-q-not-psd-for-convex-quadratic-problem/42689 "2020-07-11T02:42:10Z")

</div>

I got this error when using Gurobi 9.0.1 in Julia 1.3.1: Gurobi.GurobiError(10020, "Objective Q not PSD (diagonal adjustment of 5.8e-01 would be required)") However, I’m sure that my problem is convex, as you can see fr…

---

## [Model constraint error](https://discourse.julialang.org/t/model-constraint-error/42850)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 2\
**Last updated:** [July 10, 2020, 4:45pm UTC](https://discourse.julialang.org/t/model-constraint-error/42850 "2020-07-10T16:45:46Z")

</div>

How to solve this error? BoundsError: attempt to access 2×2 Array{Int64,2} at index \[1, 3\] using JuMP, Cbc Model1 = Model(with\_optimizer(Cbc.Optimizer)) t = 4 w = 2 T = 1:t W = 1:w WH = \[2489 1447; 11073 5414\] @vari…

---

## [How to use Gurobi variable hints in JuMP 0.21](https://discourse.julialang.org/t/how-to-use-gurobi-variable-hints-in-jump-0-21/42764)

<div class="topic-metadata">

**Author:** [@ryancorywright](https://discourse.julialang.org/u/ryancorywright)\
**Replies:** 3\
**Last updated:** [July 9, 2020, 4:33pm UTC](https://discourse.julialang.org/t/how-to-use-gurobi-variable-hints-in-jump-0-21/42764 "2020-07-09T16:33:27Z")

</div>

Hi, I was wondering whether it was possible to access the Gurobi variable hint attributes VarHintVal using JuMP, or failing that by accessing a lower level model. As a concrete working example, suppose that I’m solving…

---

## [Ipopt with JuMP -- Restoration Failure Crashing Julia](https://discourse.julialang.org/t/ipopt-with-jump-restoration-failure-crashing-julia/42753)

<div class="topic-metadata">

**Author:** [@Dominic\_Pazzula](https://discourse.julialang.org/u/Dominic_Pazzula)\
**Replies:** 9\
**Last updated:** [July 9, 2020, 3:13pm UTC](https://discourse.julialang.org/t/ipopt-with-jump-restoration-failure-crashing-julia/42753 "2020-07-09T15:13:18Z")

</div>

I have some code calling Ipopt through JuMP. I’m in the testing phase and have a small and large-ish problem. Small problem runs without issue. The large problem hits a Restoration Failure (ok, I can work to fix that)…

---

## [How to define a JuMP variable in a specific discrete set?](https://discourse.julialang.org/t/how-to-define-a-jump-variable-in-a-specific-discrete-set/42754)

<div class="topic-metadata">

**Author:** [@ZdM87](https://discourse.julialang.org/u/ZdM87)\
**Replies:** 2\
**Last updated:** [July 8, 2020, 11:00pm UTC](https://discourse.julialang.org/t/how-to-define-a-jump-variable-in-a-specific-discrete-set/42754 "2020-07-08T23:00:55Z")

</div>

I have an integer variable that takes values in {2, 5, 6, 8, 10}. How do I define this in JuMP? For an integer variable, I do @variable(model, x, Int) but this will take all integer variables. I can set the upper and …

---

## [Correct syntax for Ipopt and JuMP request?](https://discourse.julialang.org/t/correct-syntax-for-ipopt-and-jump-request/42743)

<div class="topic-metadata">

**Author:** [@zazizoma](https://discourse.julialang.org/u/zazizoma)\
**Replies:** 2\
**Last updated:** [July 8, 2020, 10:49pm UTC](https://discourse.julialang.org/t/correct-syntax-for-ipopt-and-jump-request/42743 "2020-07-08T22:49:54Z")

</div>

Hello, I’m attempting to maximize f(x, y) = c\_1xy^\\gamma - c\_2y using Ipopt, JuMP and Julia 1.4.2. Both x and y have upper and lower bounds. I need to suppress Ipopt output as the routine is running in a loop. This m…

---

## [JuMP variable bound by bin variable](https://discourse.julialang.org/t/jump-variable-bound-by-bin-variable/42480)

<div class="topic-metadata">

**Author:** [@RaulBritto](https://discourse.julialang.org/u/RaulBritto)\
**Replies:** 2\
**Last updated:** [July 3, 2020, 5:31pm UTC](https://discourse.julialang.org/t/jump-variable-bound-by-bin-variable/42480 "2020-07-03T17:31:04Z")

</div>

Hello, I trying to optimize using JuMP with GLPK. The model has the vectors of variables: y is a binary vector. Each y\[ j \] represents when thefeature is actived or deactived. x is float vector. Each variable x\[ j…

---

## [Force model to discard basis](https://discourse.julialang.org/t/force-model-to-discard-basis/41104)

<div class="topic-metadata">

**Author:** [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Replies:** 10\
**Last updated:** [July 8, 2020, 2:53pm UTC](https://discourse.julialang.org/t/force-model-to-discard-basis/41104 "2020-07-08T14:53:50Z")

</div>

I am wondering if there is a JuMP/MOI way (this is, solver-agnostic) to discard the simplex basis that is implicitly carried by a Model after an LP was solved by the first time. My problem is that I have a large model t…

[Previous page](https://discourse.julialang.org/c/domain/opt/13.md?page=94)

[Next page](https://discourse.julialang.org/c/domain/opt/13.md?page=96)
