# Optimization (Mathematical)

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

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

**Page:** 49

---

## [How to formulate the following constraints in JuMP](https://discourse.julialang.org/t/how-to-formulate-the-following-constraints-in-jump/95182)

<div class="topic-metadata">

**Author:** [@kevinqiao](https://discourse.julialang.org/u/kevinqiao)\
**Replies:** 4\
**Last updated:** [February 27, 2023, 2:37am UTC](https://discourse.julialang.org/t/how-to-formulate-the-following-constraints-in-jump/95182 "2023-02-27T02:37:05Z")

</div>

I have a following constraint \\left\\| \\begin{array}{c} x\\\\ y\\\\ \\end{array} \\right\\| \_2\\leqslant z \\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;(1) where x, y, and z are all non-negative variables, it’s said that (1) is a SO…

---

## [JuMP Multi-threading example](https://discourse.julialang.org/t/jump-multi-threading-example/95210)

<div class="topic-metadata">

**Author:** [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Replies:** 2\
**Last updated:** [February 26, 2023, 12:22am UTC](https://discourse.julialang.org/t/jump-multi-threading-example/95210 "2023-02-26T00:22:02Z")

</div>

In this JuMP example of multi-threading, why does the vector of solutions have 8 elements, while the for loop size is 10?

---

## [How to run Juniper.jl concurrently](https://discourse.julialang.org/t/how-to-run-juniper-jl-concurrently/75275)

<div class="topic-metadata">

**Author:** [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)\
**Replies:** 5\
**Last updated:** [February 24, 2023, 5:20pm UTC](https://discourse.julialang.org/t/how-to-run-juniper-jl-concurrently/75275 "2023-02-24T17:20:49Z")

</div>

Hi, is there a way to run Juniper concurrently ? Thanks, Manoj

---

## [JuMP.jl to solve NLP with higher exponents?](https://discourse.julialang.org/t/jump-jl-to-solve-nlp-with-higher-exponents/95086)

<div class="topic-metadata">

**Author:** [@Chad](https://discourse.julialang.org/u/Chad)\
**Replies:** 1\
**Last updated:** [February 23, 2023, 5:52pm UTC](https://discourse.julialang.org/t/jump-jl-to-solve-nlp-with-higher-exponents/95086 "2023-02-23T17:52:28Z")

</div>

Wondering what is the best solver for Non Linear programming for the objective function with exponent 4 and 5? I am trying to solve for a big graph of the order 20k vertices and 1M edges. Please advise any documentation…

---

## [Setting tolerances in JuMP - is there an Optimizer-independent way?](https://discourse.julialang.org/t/setting-tolerances-in-jump-is-there-an-optimizer-independent-way/95030)

<div class="topic-metadata">

**Author:** [@compleat](https://discourse.julialang.org/u/compleat)\
**Replies:** 4\
**Last updated:** [February 22, 2023, 10:14pm UTC](https://discourse.julialang.org/t/setting-tolerances-in-jump-is-there-an-optimizer-independent-way/95030 "2023-02-22T22:14:27Z")

</div>

Is there a simple Optimizer-independent way to set tolerances in JuMP? I searched the documentation and couldn’t find anything on setting tolerances \[I’m tired of multiplying my objective functions by large numbers …

---

## [JuMP Non-Linear Optimization](https://discourse.julialang.org/t/jump-non-linear-optimization/94020)

<div class="topic-metadata">

**Author:** [@mdogan](https://discourse.julialang.org/u/mdogan)\
**Replies:** 14\
**Last updated:** [February 22, 2023, 8:46pm UTC](https://discourse.julialang.org/t/jump-non-linear-optimization/94020 "2023-02-22T20:46:17Z")

</div>

I am trying to optimize the below equation, but it throws out an error. sqrt(transpose(x) \* \[0.00076204 0.00051972; 0.00051972 0.00546173\] \* x) model = Model(HiGHS.Optimizer) @variable(model, x\[1:2\]) @NLobjective(mode…

---

## [Does integral function related optimization supported in Julia?](https://discourse.julialang.org/t/does-integral-function-related-optimization-supported-in-julia/94836)

<div class="topic-metadata">

**Author:** [@Jian\_ZUO](https://discourse.julialang.org/u/Jian_ZUO)\
**Replies:** 12\
**Last updated:** [February 22, 2023, 7:22am UTC](https://discourse.julialang.org/t/does-integral-function-related-optimization-supported-in-julia/94836 "2023-02-22T07:22:11Z")

</div>

Hi all, I have a nonlinear optimization problem that involves integral functions, for instance: F(x, a) = $$\\int\_0^x a\*(x - 4y^3)dy + \\int\_0^x\\int\_0^3y (7s^2)dsdy$$ How can I define this objective (involves single a…

---

## [Is there any way to solve a containg Binvary variables Nonconvex problem?](https://discourse.julialang.org/t/is-there-any-way-to-solve-a-containg-binvary-variables-nonconvex-problem/94992)

<div class="topic-metadata">

**Author:** [@kevinqiao](https://discourse.julialang.org/u/kevinqiao)\
**Replies:** 6\
**Last updated:** [February 22, 2023, 5:27am UTC](https://discourse.julialang.org/t/is-there-any-way-to-solve-a-containg-binvary-variables-nonconvex-problem/94992 "2023-02-22T05:27:45Z")

</div>

Hi there, I’m solving a Nonconvex problem, and the nonconvex terms are: @constraint(gNet, gasPipeFlow\[pipeline, time\]^2 == ETA\*(gasNodePres\[AheadNode, time\]^2 - gasNodePres\[TailNode, time\]^2)) gasPipeFlow and gasNodeP…

---

## [How can I set solPrint from GAMS in JuMP?](https://discourse.julialang.org/t/how-can-i-set-solprint-from-gams-in-jump/94892)

<div class="topic-metadata">

**Author:** [@Saba\_ghasemi](https://discourse.julialang.org/u/Saba_ghasemi)\
**Replies:** 10\
**Last updated:** [February 21, 2023, 6:59pm UTC](https://discourse.julialang.org/t/how-can-i-set-solprint-from-gams-in-jump/94892 "2023-02-21T18:59:12Z")

</div>

I wanna set solPrint. set\_optimizer\_attribute(model, GAMS.SolPrint(), “0”) Do anyone know how to fix this?

---

## [JuMP(+Juniper) Error registering user-defined function](https://discourse.julialang.org/t/jump-juniper-error-registering-user-defined-function/94909)

<div class="topic-metadata">

**Author:** [@PrimulaBunce](https://discourse.julialang.org/u/PrimulaBunce)\
**Replies:** 2\
**Last updated:** [February 20, 2023, 7:46pm UTC](https://discourse.julialang.org/t/jump-juniper-error-registering-user-defined-function/94909 "2023-02-20T19:46:36Z")

</div>

Hi, I’m trying to register a user-defined function in JuMP and get the following error: ERROR: Unable to register the function :f\_objective. Common reasons for this include: \* The function takes \`f(x::Vector)\` as in…

---

## [Optimization.jl and constraints](https://discourse.julialang.org/t/optimization-jl-and-constraints/94519)

<div class="topic-metadata">

**Author:** [@ChauhanT](https://discourse.julialang.org/u/ChauhanT)\
**Replies:** 19\
**Last updated:** [February 20, 2023, 9:24am UTC](https://discourse.julialang.org/t/optimization-jl-and-constraints/94519 "2023-02-20T09:24:50Z")

</div>

Hi, I have an optimisation problem which I solve with Optimization.jl using IPNewton(). In order to reduce the space of solutions to a more physically reasonable set, I want to introduce some constraints. I do this usin…

---

## [Efficiency of MOI.CountBelongs](https://discourse.julialang.org/t/efficiency-of-moi-countbelongs/94819)

<div class="topic-metadata">

**Author:** [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Replies:** 3\
**Last updated:** [February 20, 2023, 1:03am UTC](https://discourse.julialang.org/t/efficiency-of-moi-countbelongs/94819 "2023-02-20T01:03:54Z")

</div>

In the JuMP code below, I want to count the number of occurrences of each possible integer in the variable matrix M. s is defined to be a Kx1 variable vector equal to M\[:\]. Is there any difference in efficiency between @…

---

## [Slicing a sparse variable created from list of tuples](https://discourse.julialang.org/t/slicing-a-sparse-variable-created-from-list-of-tuples/94853)

<div class="topic-metadata">

**Author:** [@felipecordera](https://discourse.julialang.org/u/felipecordera)\
**Replies:** 1\
**Last updated:** [February 19, 2023, 9:16pm UTC](https://discourse.julialang.org/t/slicing-a-sparse-variable-created-from-list-of-tuples/94853 "2023-02-19T21:16:20Z")

</div>

Hi everyone, I would like to do slicing on a sparse variable created from a list of tuples. In the next example (extracted from documentation), the same variable is created in two different ways. While it is possible t…

---

## [JuMP SCIP error](https://discourse.julialang.org/t/jump-scip-error/93958)

<div class="topic-metadata">

**Author:** [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Replies:** 8\
**Last updated:** [February 19, 2023, 9:12pm UTC](https://discourse.julialang.org/t/jump-scip-error/93958 "2023-02-19T21:12:36Z")

</div>

I get the error below when I try to solve a model in JuMP using SCIP. There is no error if I instead use HiGHS. $ julia Oscar.jl ERROR: LoadError: MathOptInterface.DeleteNotAllowed{MathOptInterface.VariableIndex}: Delet…

---

## [Julia bindings for Z3 SMT solver](https://discourse.julialang.org/t/julia-bindings-for-z3-smt-solver/38218)

<div class="topic-metadata">

**Author:** [@XVilka](https://discourse.julialang.org/u/XVilka)\
**Replies:** 20\
**Last updated:** [February 19, 2023, 4:46pm UTC](https://discourse.julialang.org/t/julia-bindings-for-z3-smt-solver/38218 "2023-02-19T16:46:00Z")

</div>

Recently I met the need to access Z3 from Julia program, searched a bit and found abandoned Julia bindings at zenna/Z3.jl. But they do not work with the recent versions and I asked Z3 developers themselves. As it turned …

---

## [JuMP function result\_count returns 1 when infinite solutions possible, which solver to use?](https://discourse.julialang.org/t/jump-function-result-count-returns-1-when-infinite-solutions-possible-which-solver-to-use/94880)

<div class="topic-metadata">

**Author:** [@Patrik](https://discourse.julialang.org/u/Patrik)\
**Replies:** 2\
**Last updated:** [February 19, 2023, 4:40pm UTC](https://discourse.julialang.org/t/jump-function-result-count-returns-1-when-infinite-solutions-possible-which-solver-to-use/94880 "2023-02-19T16:40:46Z")

</div>

Consider the following model of a simple LP problem: using JuMP, HiGHS m = Model(HiGHS.Optimizer) @variable(m, x1 \>= 0) @variable(m, x2 \<= 0) @objective(m, Max, 2x1-x2) @constraint(m, c1, 8x1-4x2\<=16) @constraint…

---

## [Nearest point in a convex hull](https://discourse.julialang.org/t/nearest-point-in-a-convex-hull/94849)

<div class="topic-metadata">

**Author:** [@fratrik](https://discourse.julialang.org/u/fratrik)\
**Replies:** 6\
**Last updated:** [February 19, 2023, 2:41pm UTC](https://discourse.julialang.org/t/nearest-point-in-a-convex-hull/94849 "2023-02-19T14:41:37Z")

</div>

Background: I’m using ScatteredInterpolation to approximate a higher-order value function as needed. The interpolation works reasonably well for points that are in some sense “inside” prior points that I’ve used. My pl…

---

## [Missing reference - JuMP variables](https://discourse.julialang.org/t/missing-reference-jump-variables/94865)

<div class="topic-metadata">

**Author:** [@kevinqiao](https://discourse.julialang.org/u/kevinqiao)\
**Replies:** 3\
**Last updated:** [February 19, 2023, 7:08am UTC](https://discourse.julialang.org/t/missing-reference-jump-variables/94865 "2023-02-19T07:08:55Z")

</div>

I’m using JuMP in vscode, and I add JuMP as using JuMP at the beginning of my code, and I define many variables like @variable(hNet, injectionTemp\[1:SCHTIME\]) @variable(hNet, inletTemp\[1:nNode, 1:SCHTIME\]) … while…

---

## [How to set iteration limit in JuMP by using KNITRO solver](https://discourse.julialang.org/t/how-to-set-iteration-limit-in-jump-by-using-knitro-solver/94822)

<div class="topic-metadata">

**Author:** [@kevinqiao](https://discourse.julialang.org/u/kevinqiao)\
**Replies:** 1\
**Last updated:** [February 18, 2023, 12:18pm UTC](https://discourse.julialang.org/t/how-to-set-iteration-limit-in-jump-by-using-knitro-solver/94822 "2023-02-18T12:18:17Z")

</div>

I use KNITRO as a nonlinear solver in JuMP, and the iteration is limited to 1e4, I want to set a new iteration limit, how to do it? And a function that can obtain the supported attributes in JuMP could be preferred, is …

---

## [Box-constrained optimization calls values outside of the box](https://discourse.julialang.org/t/box-constrained-optimization-calls-values-outside-of-the-box/94810)

<div class="topic-metadata">

**Author:** [@bclyons12](https://discourse.julialang.org/u/bclyons12)\
**Replies:** 1\
**Last updated:** [February 18, 2023, 7:09am UTC](https://discourse.julialang.org/t/box-constrained-optimization-calls-values-outside-of-the-box/94810 "2023-02-18T07:09:09Z")

</div>

I’m trying to use Optim.jl to minimize a function that has hard boundaries on the input using the Fminbox box-constrained optimization. When the minimum value is near or on the boundary, however, the optimizer can check …

---

## [A hacky guide to using automatic differentiation in nested optimization problems](https://discourse.julialang.org/t/a-hacky-guide-to-using-automatic-differentiation-in-nested-optimization-problems/39123)

<div class="topic-metadata">

**Author:** [@jeffreyesun](https://discourse.julialang.org/u/jeffreyesun)\
**Replies:** 25\
**Last updated:** [February 17, 2023, 3:32pm UTC](https://discourse.julialang.org/t/a-hacky-guide-to-using-automatic-differentiation-in-nested-optimization-problems/39123 "2023-02-17T15:32:11Z")

</div>

Unconstrained Optimization Automatic differentiation is amazing. But models in my field, economics, often include nested optimization problems. A simple example might look like this, where x is a vector or scalar. y = …

---

## [Alpine+JuMP for nonlinear integer programming problem with user-defined objective function](https://discourse.julialang.org/t/alpine-jump-for-nonlinear-integer-programming-problem-with-user-defined-objective-function/94693)

<div class="topic-metadata">

**Author:** [@PrimulaBunce](https://discourse.julialang.org/u/PrimulaBunce)\
**Replies:** 2\
**Last updated:** [February 16, 2023, 9:15am UTC](https://discourse.julialang.org/t/alpine-jump-for-nonlinear-integer-programming-problem-with-user-defined-objective-function/94693 "2023-02-16T09:15:04Z")

</div>

Hi, I am trying to use Alpine to solve an integer programming problem with a user-defined nonlinear objective function. When I run JuMP.optimize!(m) I get the following error. ERROR: type Symbol has no field head Stac…

---

## [Library loading failure when using Ipopt through JuMP](https://discourse.julialang.org/t/library-loading-failure-when-using-ipopt-through-jump/94695)

<div class="topic-metadata">

**Author:** [@zornsllama](https://discourse.julialang.org/u/zornsllama)\
**Replies:** 3\
**Last updated:** [February 16, 2023, 4:51am UTC](https://discourse.julialang.org/t/library-loading-failure-when-using-ipopt-through-jump/94695 "2023-02-16T04:51:12Z")

</div>

Hi, Until today, I was having no issues using Ipopt through JuMP. Today, however, when I run optimize!(model), I get the following error: Exception of type: DYNAMIC\_LIBRARY\_FAILURE in file "Common/IpLibraryLoader.cpp" …

---

## [Mosek does not support an objective function of type ScalarQuadraticFunction](https://discourse.julialang.org/t/mosek-does-not-support-an-objective-function-of-type-scalarquadraticfunction/94702)

<div class="topic-metadata">

**Author:** [@A\_M](https://discourse.julialang.org/u/A_M)\
**Replies:** 3\
**Last updated:** [February 16, 2023, 4:46am UTC](https://discourse.julialang.org/t/mosek-does-not-support-an-objective-function-of-type-scalarquadraticfunction/94702 "2023-02-16T04:46:58Z")

</div>

I am getting this error when I use a quadratic term in the objective while using Mosek. The solver does not support an objective function of type MathOptInterface.ScalarQuadraticFunction{Float64}. Is this something tha…

---

## [How to get a Models optimiser factory](https://discourse.julialang.org/t/how-to-get-a-models-optimiser-factory/94618)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 1\
**Last updated:** [February 14, 2023, 7:52pm UTC](https://discourse.julialang.org/t/how-to-get-a-models-optimiser-factory/94618 "2023-02-14T19:52:44Z")

</div>

How can I get a models optimiser factory? I’d like to be able to do: using JuMP, HiGHS m1 = Model(HiGHS.Optimizer) m2 = Model(optimizer\_factory(m1)) Although I’m not sure if I’m coming at this the wrong way. Here I’d l…

---

## [Modelling problem with JuMP](https://discourse.julialang.org/t/modelling-problem-with-jump/94520)

<div class="topic-metadata">

**Author:** [@Karajan](https://discourse.julialang.org/u/Karajan)\
**Replies:** 2\
**Last updated:** [February 14, 2023, 2:47pm UTC](https://discourse.julialang.org/t/modelling-problem-with-jump/94520 "2023-02-14T14:47:12Z")

</div>

Hi there! I have the following problem: I have n \>= 8 people who are supposed to do a “shift” (this is not for a job but for a hobby. I would hope HR people know how to properly do this :grin:). There is one shift each …

---

## [ProgressiveHedging.jl - Decision Variables](https://discourse.julialang.org/t/progressivehedging-jl-decision-variables/94414)

<div class="topic-metadata">

**Author:** [@Mariana](https://discourse.julialang.org/u/Mariana)\
**Replies:** 2\
**Last updated:** [February 13, 2023, 1:22pm UTC](https://discourse.julialang.org/t/progressivehedging-jl-decision-variables/94414 "2023-02-13T13:22:48Z")

</div>

Hello! I’m starting to use ProgressiveHedging.jl and testing it in a two-stage problem. However, both the first and second stages variables in my case present different dimensions. For example, I have 6 first-stage dec…

---

## [JuMP: get (warm)start value of an expression](https://discourse.julialang.org/t/jump-get-warm-start-value-of-an-expression/93259)

<div class="topic-metadata">

**Author:** [@john\_standard](https://discourse.julialang.org/u/john_standard)\
**Replies:** 3\
**Last updated:** [February 10, 2023, 8:24pm UTC](https://discourse.julialang.org/t/jump-get-warm-start-value-of-an-expression/93259 "2023-02-10T20:24:07Z")

</div>

Context I’m trying to write some utility functions to solve non linear control problems using JuMP. Following the Rocket control tutorial I set my state variables as JuMP variables and the dynamics as constraints. Howev…

---

## [NLopt :FORCED\_STOP after one iteration Gradient based optimization](https://discourse.julialang.org/t/nlopt-forced-stop-after-one-iteration-gradient-based-optimization/94383)

<div class="topic-metadata">

**Author:** [@SamerGerges](https://discourse.julialang.org/u/SamerGerges)\
**Replies:** 7\
**Last updated:** [February 10, 2023, 2:33am UTC](https://discourse.julialang.org/t/nlopt-forced-stop-after-one-iteration-gradient-based-optimization/94383 "2023-02-10T02:33:19Z")

</div>

Hello, I am using NLopt to solve an optimization problem with non-linear constraints. I provide the gradients for both the optimization function and the gradient function. Both functions provide the correct values of th…

---

## [How to test solvers in JuMP](https://discourse.julialang.org/t/how-to-test-solvers-in-jump/94250)

<div class="topic-metadata">

**Author:** [@kevinqiao](https://discourse.julialang.org/u/kevinqiao)\
**Replies:** 2\
**Last updated:** [February 10, 2023, 1:42am UTC](https://discourse.julialang.org/t/how-to-test-solvers-in-jump/94250 "2023-02-10T01:42:58Z")

</div>

I have installed JuMP and some solvers, how to test solvers in JuMP, as I want to verify the solvers work well and the correct solution can be obtained. Thanks in advance.

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

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