# Optimization (Mathematical)

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

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

**Page:** 87

---

## [How to find the index of a Dense Axis Array?](https://discourse.julialang.org/t/how-to-find-the-index-of-a-dense-axis-array/53204)

<div class="topic-metadata">

**Author:** [@fredih](https://discourse.julialang.org/u/fredih)\
**Replies:** 3\
**Last updated:** [January 13, 2021, 12:35pm UTC](https://discourse.julialang.org/t/how-to-find-the-index-of-a-dense-axis-array/53204 "2021-01-13T12:35:46Z")

</div>

Hello! I know I can use something like findall(x-\>x==1, myArray) to find the indices of elements of value 1 inside myArray. However, my variables in my optimization problem are DenseAxisArrays, as they are indexed with…

---

## [Poor linear relaxation](https://discourse.julialang.org/t/poor-linear-relaxation/53170)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 1\
**Last updated:** [January 11, 2021, 8:12pm UTC](https://discourse.julialang.org/t/poor-linear-relaxation/53170 "2021-01-11T20:12:20Z")

</div>

Dear users, I have a MIP problem whose linear relaxation is very poor. Observe the report of CPLEX below: (Gap greater to 999.99%, then the symbol “–”). Does have any parameter in CPLEX to set to improve these perf…

---

## [Last mile of BlackBoxOptim](https://discourse.julialang.org/t/last-mile-of-blackboxoptim/53171)

<div class="topic-metadata">

**Author:** [@zxjroger](https://discourse.julialang.org/u/zxjroger)\
**Replies:** 0\
**Last updated:** [January 11, 2021, 6:05pm UTC](https://discourse.julialang.org/t/last-mile-of-blackboxoptim/53171 "2021-01-11T18:05:17Z")

</div>

I am doing Monte Carlo study of the simulated method of moments estimator for my economic model. Since the objective function is not differentiable, I am using adaptive\_de\_rand\_1\_bin\_radiuslimited in BlackBoxOptim.jl as …

---

## [Using Julia to solve semidefinite programming problem that has vector solutions](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134)

<div class="topic-metadata">

**Author:** [@cheng\_chen](https://discourse.julialang.org/u/cheng_chen)\
**Replies:** 6\
**Last updated:** [January 11, 2021, 6:50am UTC](https://discourse.julialang.org/t/using-julia-to-solve-semidefinite-programming-problem-that-has-vector-solutions/53134 "2021-01-11T06:50:02Z")

</div>

Hi everyone! I need to use Julia to solve a SDP. What would you suggest to use to solve the SDP? I tried Convex and JuMP with ProxSDP, I couldn’t get it to work.

---

## [Suppress license output from solver in JuMP.Model](https://discourse.julialang.org/t/suppress-license-output-from-solver-in-jump-model/20828)

<div class="topic-metadata">

**Author:** [@torgo](https://discourse.julialang.org/u/torgo)\
**Replies:** 13\
**Last updated:** [January 11, 2021, 1:24am UTC](https://discourse.julialang.org/t/suppress-license-output-from-solver-in-jump-model/20828 "2021-01-11T01:24:41Z")

</div>

using JuMP, Gurobi m = Model(solver=GurobiSolver(OutputFlag=0)) I have a program where the second line gets called frequently. Every time it does, this gets printed to stdout: Academic license - for non-commercial use…

---

## [ForwardDiff.jl \\ Optim.jl and recompilation for any vector size](https://discourse.julialang.org/t/forwarddiff-jl-optim-jl-and-recompilation-for-any-vector-size/53104)

<div class="topic-metadata">

**Author:** [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Replies:** 4\
**Last updated:** [January 10, 2021, 5:54pm UTC](https://discourse.julialang.org/t/forwarddiff-jl-optim-jl-and-recompilation-for-any-vector-size/53104 "2021-01-10T17:54:21Z")

</div>

I try to optimize function with different variable vector size. And I think that for each task type method is compilated again. Main function is type-stable as I think by @code\_warntype and @code\_typed. And probably eac…

---

## [Adding (simple) user-defined functions causes significant slowdown in JuMP + Ipopt](https://discourse.julialang.org/t/adding-simple-user-defined-functions-causes-significant-slowdown-in-jump-ipopt/52971)

<div class="topic-metadata">

**Author:** [@boranzhao](https://discourse.julialang.org/u/boranzhao)\
**Replies:** 4\
**Last updated:** [January 8, 2021, 2:17pm UTC](https://discourse.julialang.org/t/adding-simple-user-defined-functions-causes-significant-slowdown-in-jump-ipopt/52971 "2021-01-08T14:17:57Z")

</div>

Hello, I created a nonlinear programming problem (for model predictive control) using JuMP, and solved it using Ipopt. However, I found that, if I included an (even very simple) user-defined function in the defining th…

---

## [Early stopping with Optim when the validation loss increases](https://discourse.julialang.org/t/early-stopping-with-optim-when-the-validation-loss-increases/53008)

<div class="topic-metadata">

**Author:** [@sobhan](https://discourse.julialang.org/u/sobhan)\
**Replies:** 1\
**Last updated:** [January 7, 2021, 10:17pm UTC](https://discourse.julialang.org/t/early-stopping-with-optim-when-the-validation-loss-increases/53008 "2021-01-07T22:17:56Z")

</div>

I’m using Optim.jl to train a model but it keeps overfiting. is there nice way of implementing a early stopping callback that has the current x? I tried setting the callback in Optim.Options but i only get the iteration…

---

## [Quadratic Programming with CPLEX and JuMP](https://discourse.julialang.org/t/quadratic-programming-with-cplex-and-jump/52950)

<div class="topic-metadata">

**Author:** [@ahmadreza-marandi](https://discourse.julialang.org/u/ahmadreza-marandi)\
**Replies:** 4\
**Last updated:** [January 7, 2021, 7:35am UTC](https://discourse.julialang.org/t/quadratic-programming-with-cplex-and-jump/52950 "2021-01-07T07:35:22Z")

</div>

It has been a while that CPLEX can solve nonconvex quadratic programming problems. But I am wondering if that has been considered in JuMP. The reason I am asking is that I coded the following: Q=\[-50.0 0.0 0.0 …

---

## [Relaxing binary variable](https://discourse.julialang.org/t/relaxing-binary-variable/52965)

<div class="topic-metadata">

**Author:** [@JohnZ](https://discourse.julialang.org/u/JohnZ)\
**Replies:** 4\
**Last updated:** [January 7, 2021, 12:22am UTC](https://discourse.julialang.org/t/relaxing-binary-variable/52965 "2021-01-07T00:22:52Z")

</div>

In a model, I want to relax one binary variable. relax\_integrality(model) relaxes all variables of the model, so I think the right way to go will be to use unset\_binary as shown in the example below. model = Model() @v…

---

## [How to define an optimizer package?](https://discourse.julialang.org/t/how-to-define-an-optimizer-package/51534)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 6\
**Last updated:** [January 6, 2021, 5:38pm UTC](https://discourse.julialang.org/t/how-to-define-an-optimizer-package/51534 "2021-01-06T17:38:32Z")

</div>

Whenever I try to compile the solver declaration the following error appears using JuMP, JuMPeR, Cbc, MathOptInterface ModelD = Model(with\_optimizer(Cbc.Optimizer)) Error message: UndefVarError: with\_optimizer not defin…

---

## [Problem using NLopt in JuMP model](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499)

<div class="topic-metadata">

**Author:** [@Emmanouil\_Bakirtzis](https://discourse.julialang.org/u/Emmanouil_Bakirtzis)\
**Replies:** 11\
**Last updated:** [January 5, 2021, 2:55pm UTC](https://discourse.julialang.org/t/problem-using-nlopt-in-jump-model/52499 "2021-01-05T14:55:23Z")

</div>

Hi, I am trying to create a JuMP model using NLopt solver in Julia 1.5.3 using JuMP using NLopt model = Model(NLopt.Optimizer) but I get the following error ERROR: UndefVarError: Optimizer not defined Stacktrace: \[…

---

## [NLsolve and OffsetArrays](https://discourse.julialang.org/t/nlsolve-and-offsetarrays/52740)

<div class="topic-metadata">

**Author:** [@cricci](https://discourse.julialang.org/u/cricci)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 12:45pm UTC](https://discourse.julialang.org/t/nlsolve-and-offsetarrays/52740 "2021-01-04T12:45:42Z")

</div>

Does the package NLsolve support the use of OffsetArrays? It looks to me it does not. using NLsolve using OffsetArrays function f!(F,x) F\[1\] = 3\*x\[1\]-cos(x\[2\]\*x\[3\])-1/2 F\[2\] = x\[1\]^2-81\*(x\[2\]+0.1)^2+sin(x\[3\])…

---

## [JuMP: allunique as a constraint?](https://discourse.julialang.org/t/jump-allunique-as-a-constraint/9569)

<div class="topic-metadata">

**Author:** [@yoeljacobsen](https://discourse.julialang.org/u/yoeljacobsen)\
**Replies:** 7\
**Last updated:** [January 4, 2021, 11:01am UTC](https://discourse.julialang.org/t/jump-allunique-as-a-constraint/9569 "2021-01-04T11:01:51Z")

</div>

How may I write a constraint for a list of variables requiring all to have unique integer values?

---

## [@NLconstraint with a sum, array and scalar variables](https://discourse.julialang.org/t/nlconstraint-with-a-sum-array-and-scalar-variables/52710)

<div class="topic-metadata">

**Author:** [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Replies:** 5\
**Last updated:** [January 4, 2021, 8:47am UTC](https://discourse.julialang.org/t/nlconstraint-with-a-sum-array-and-scalar-variables/52710 "2021-01-04T08:47:18Z")

</div>

Hello and happy new year! Below is a toy problem. It deals with a mix of 4 chemicals. The quantities of the chemicals are given in the array xs. The temperature of the mix is the only unknow, subject to the constrai…

---

## [JuMP - variable depending on other variable](https://discourse.julialang.org/t/jump-variable-depending-on-other-variable/52529)

<div class="topic-metadata">

**Author:** [@TheMEGuy](https://discourse.julialang.org/u/TheMEGuy)\
**Replies:** 2\
**Last updated:** [January 1, 2021, 11:15pm UTC](https://discourse.julialang.org/t/jump-variable-depending-on-other-variable/52529 "2021-01-01T23:15:03Z")

</div>

Hi, I have a variable that is supposed to be a matrix. Its size should depend on another variable, which also should be optimized, or at least changed throughout the optimization process: @variable(model, n,lower\_bound…

---

## [Is there a way to compute the AD Hessian of a function using purely Zygote functions and not ForwardDiff?](https://discourse.julialang.org/t/is-there-a-way-to-compute-the-ad-hessian-of-a-function-using-purely-zygote-functions-and-not-forwarddiff/52704)

<div class="topic-metadata">

**Author:** [@tholdem](https://discourse.julialang.org/u/tholdem)\
**Replies:** 1\
**Last updated:** [January 1, 2021, 7:01pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compute-the-ad-hessian-of-a-function-using-purely-zygote-functions-and-not-forwarddiff/52704 "2021-01-01T19:01:19Z")

</div>

To solve the issue raised in this post, I’ve been trying to write a Jacobian function using Zygote functions only so I can compute the AD Hessian of my function without using Dual type from ForwardDiff, which doesn’t wor…

---

## [How can I extract MOI expression from a linear JuMP obj expression](https://discourse.julialang.org/t/how-can-i-extract-moi-expression-from-a-linear-jump-obj-expression/52689)

<div class="topic-metadata">

**Author:** [@Mahbubar06](https://discourse.julialang.org/u/Mahbubar06)\
**Replies:** 2\
**Last updated:** [January 1, 2021, 2:34pm UTC](https://discourse.julialang.org/t/how-can-i-extract-moi-expression-from-a-linear-jump-obj-expression/52689 "2021-01-01T14:34:51Z")

</div>

Hello, I am struggling to generate an MOI (MathOptInterface) expression from a linear JuMP expression. I have a JuMP model as follows. m = Model(Ipopt.Optimizer) @variable(m, 0 \<= x\[1:3\] \<= 10) @constraint(m, sum(x\[i\]…

---

## [Convex.jl - LoadError: UndefVarError: AbstractExpr not defined](https://discourse.julialang.org/t/convex-jl-loaderror-undefvarerror-abstractexpr-not-defined/52679)

<div class="topic-metadata">

**Author:** [@cm0](https://discourse.julialang.org/u/cm0)\
**Replies:** 3\
**Last updated:** [January 1, 2021, 11:04am UTC](https://discourse.julialang.org/t/convex-jl-loaderror-undefvarerror-abstractexpr-not-defined/52679 "2021-01-01T11:04:56Z")

</div>

I am using Julia 1.5.3 but running some old code based on Julia 0.6.4 and ran into the following problem: LoadError: LoadError: UndefVarError: AbstractExpr not defined. The problem seems to be AbstractExpr no longer bei…

---

## [3D bin packaging using Convex.jl](https://discourse.julialang.org/t/3d-bin-packaging-using-convex-jl/52571)

<div class="topic-metadata">

**Author:** [@adropintheriver](https://discourse.julialang.org/u/adropintheriver)\
**Replies:** 0\
**Last updated:** [December 29, 2020, 12:36pm UTC](https://discourse.julialang.org/t/3d-bin-packaging-using-convex-jl/52571 "2020-12-29T12:36:08Z")

</div>

Intent :Write a convex function that takes a set of points of shape (m,n) basically convexhull points by reading a CAD model. The function must return a Variable(from Convex.jl) of shape/size of the original vector (to…

---

## [Can I extend other functions to make it compatible with Convex.jl (element-wise operation)](https://discourse.julialang.org/t/can-i-extend-other-functions-to-make-it-compatible-with-convex-jl-element-wise-operation/52565)

<div class="topic-metadata">

**Author:** [@iHany](https://discourse.julialang.org/u/iHany)\
**Replies:** 0\
**Last updated:** [December 29, 2020, 10:15am UTC](https://discourse.julialang.org/t/can-i-extend-other-functions-to-make-it-compatible-with-convex-jl-element-wise-operation/52565 "2020-12-29T10:15:22Z")

</div>

I’m using Convex.jl for convex optimisation. When constructing a function that I need to optimise, I used to extend methods of Convex to make it compatible with other functions, for example, # extend Convex method func…

---

## [Maximum Likelihood: Normal Linear Model](https://discourse.julialang.org/t/maximum-likelihood-normal-linear-model/11664)

<div class="topic-metadata">

**Author:** [@Donald\_Lacombe](https://discourse.julialang.org/u/Donald_Lacombe)\
**Replies:** 31\
**Last updated:** [December 25, 2020, 2:14am UTC](https://discourse.julialang.org/t/maximum-likelihood-normal-linear-model/11664 "2020-12-25T02:14:34Z")

</div>

Hello, I’m trying to optimize a simple normal linear model likelihood function and have two questions. The code I am using is below: using Optim nobs = 500 nvar = 1 β = ones(nvar)\*3.0 x = \[ones(nobs) randn(nobs,nvar-1…

---

## [Getting INVALID\_MODEL error while solving RMSE](https://discourse.julialang.org/t/getting-invalid-model-error-while-solving-rmse/52153)

<div class="topic-metadata">

**Author:** [@gaadis](https://discourse.julialang.org/u/gaadis)\
**Replies:** 8\
**Last updated:** [December 24, 2020, 2:12pm UTC](https://discourse.julialang.org/t/getting-invalid-model-error-while-solving-rmse/52153 "2020-12-24T14:12:28Z")

</div>

I’m attempting to minimize an RMSE where the optimized coefficients alpha and beta give a forecasted value (xnext) from the original value (x\_k). Initially it did not let me add the square root in the objective function…

---

## [Reduce memory allocation for repeatedly solving problem using Optim.jl](https://discourse.julialang.org/t/reduce-memory-allocation-for-repeatedly-solving-problem-using-optim-jl/52292)

<div class="topic-metadata">

**Author:** [@MFairley](https://discourse.julialang.org/u/MFairley)\
**Replies:** 0\
**Last updated:** [December 23, 2020, 8:16pm UTC](https://discourse.julialang.org/t/reduce-memory-allocation-for-repeatedly-solving-problem-using-optim-jl/52292 "2020-12-23T20:16:29Z")

</div>

I’m trying to re-solve a problem with different parameter values many times using Optim.jl. My current code allocates a lot of memory because a new TwiceDifferentiable and TwiceDifferentiableConstraints is created for ev…

---

## [TypeError: non-boolean (Term{Bool}) used in boolean context when trying to modelingtoolkitize a DifferentialEquations.jl SDEProblem](https://discourse.julialang.org/t/typeerror-non-boolean-term-bool-used-in-boolean-context-when-trying-to-modelingtoolkitize-a-differentialequations-jl-sdeproblem/51130)

<div class="topic-metadata">

**Author:** [@claudio20497](https://discourse.julialang.org/u/claudio20497)\
**Replies:** 3\
**Last updated:** [December 22, 2020, 2:16pm UTC](https://discourse.julialang.org/t/typeerror-non-boolean-term-bool-used-in-boolean-context-when-trying-to-modelingtoolkitize-a-differentialequations-jl-sdeproblem/51130 "2020-12-22T14:16:37Z")

</div>

Hello, This issue is maybe related to this one although the solution could be totally different. If this is the wrong place to post it, please tell me and I’ll be happy to move it. So the goal would be to optimize a Di…

---

## [Unable to optimize using Alpine.jl](https://discourse.julialang.org/t/unable-to-optimize-using-alpine-jl/52088)

<div class="topic-metadata">

**Author:** [@hassanis](https://discourse.julialang.org/u/hassanis)\
**Replies:** 2\
**Last updated:** [December 19, 2020, 6:48pm UTC](https://discourse.julialang.org/t/unable-to-optimize-using-alpine-jl/52088 "2020-12-19T18:48:15Z")

</div>

I’m havinng trouble using Alpine.jl. I know that it’s compatible with MOI now, and the new version was presented at INFORMS this year. Yet, when I try using it, I get the following error: MethodError: no method matching…

---

## [Model Predictive Controller only works for certain values](https://discourse.julialang.org/t/model-predictive-controller-only-works-for-certain-values/51916)

<div class="topic-metadata">

**Author:** [@LukasLundgren96](https://discourse.julialang.org/u/LukasLundgren96)\
**Replies:** 8\
**Last updated:** [December 18, 2020, 3:43pm UTC](https://discourse.julialang.org/t/model-predictive-controller-only-works-for-certain-values/51916 "2020-12-18T15:43:23Z")

</div>

I am using JuMP and Ipopt to solve an online optimization for a Furuta pendulum. Quite quickly I got it running in simulation but for the real pendulum I had some trouble. The trouble was solved by substituting one of th…

---

## [Find Taylor Series of a Function](https://discourse.julialang.org/t/find-taylor-series-of-a-function/51847)

<div class="topic-metadata">

**Author:** [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Replies:** 11\
**Last updated:** [December 16, 2020, 3:52am UTC](https://discourse.julialang.org/t/find-taylor-series-of-a-function/51847 "2020-12-16T03:52:52Z")

</div>

I’m completely at a loss for finding the Taylor Series of a function using TaylorSeries.jl using TaylorSeries using QuadGK f(x)=cos(x) t=Taylor1(f(pi/2),2) quadgk(x-\>cos(t), 22pi/45,pi/2;order=2)

---

## [Dimension mismatch. "Cannot sum matrices" when doing a product](https://discourse.julialang.org/t/dimension-mismatch-cannot-sum-matrices-when-doing-a-product/51869)

<div class="topic-metadata">

**Author:** [@prit](https://discourse.julialang.org/u/prit)\
**Replies:** 1\
**Last updated:** [December 15, 2020, 9:17pm UTC](https://discourse.julialang.org/t/dimension-mismatch-cannot-sum-matrices-when-doing-a-product/51869 "2020-12-15T21:17:36Z")

</div>

I have the following code: using JuMP using MosekTools K = 3 N = 2 penalties = \[1.0, 3.9, 8.7\] function fac1(r::Number, i::Number, l::Number) fac1 = 1.0 for m in 0:r-1 fac1 \*= (i-m)\*(l-m) end ret…

---

## [Promote operation; report this](https://discourse.julialang.org/t/promote-operation-report-this/51871)

<div class="topic-metadata">

**Author:** [@prit](https://discourse.julialang.org/u/prit)\
**Replies:** 1\
**Last updated:** [December 15, 2020, 3:35pm UTC](https://discourse.julialang.org/t/promote-operation-report-this/51871 "2020-12-15T15:35:29Z")

</div>

I have the following code in which a constraint is giving a “promote operation error”: using JuMP using MosekTools K = 3 N = 2 penalties = \[1.0, 3.9, 8.7\] function fac1(r::Number, i::Number, l::Number) fac1 = 1.0 …

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

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