# Optimization (Mathematical)

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

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

**Page:** 111

---

## [Building JuMP models through functions](https://discourse.julialang.org/t/building-jump-models-through-functions/24636)

<div class="topic-metadata">

**Author:** [@iharjunk](https://discourse.julialang.org/u/iharjunk)\
**Replies:** 5\
**Last updated:** [May 29, 2019, 10:48am UTC](https://discourse.julialang.org/t/building-jump-models-through-functions/24636 "2019-05-29T10:48:15Z")

</div>

Hello all, I would like to make my Julia/JuMP code more flexible and prepare it for larger test cases. For this I would need to Read in data from a given directory Build a model based on it - here since the model is l…

---

## [Custom types in ForwardDiff](https://discourse.julialang.org/t/custom-types-in-forwarddiff/24610)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 8\
**Last updated:** [May 25, 2019, 9:06pm UTC](https://discourse.julialang.org/t/custom-types-in-forwarddiff/24610 "2019-05-25T21:06:21Z")

</div>

This might be trivial but I am currently fighting with JuMP to accept my quality function for the minimisation procedure. I figured out that my custom type: struct Position \<: FieldVector{3, Float64} x::Float64 …

---

## [Function getindex does not accept keyword arguments](https://discourse.julialang.org/t/function-getindex-does-not-accept-keyword-arguments/24564)

<div class="topic-metadata">

**Author:** [@Octarosu](https://discourse.julialang.org/u/Octarosu)\
**Replies:** 1\
**Last updated:** [May 24, 2019, 1:21pm UTC](https://discourse.julialang.org/t/function-getindex-does-not-accept-keyword-arguments/24564 "2019-05-24T13:21:05Z")

</div>

Hello, I implemented this function for economic dispatch function solve\_ed(g\_max, g\_min, c\_g, c\_w, d, w\_f) #Define the economic dispatch (ED) model ed=Model() # Define decision variables @defVar(ed, 0 \<= g\[i=1:2…

---

## [Multi-cut Benders decomposition?](https://discourse.julialang.org/t/multi-cut-benders-decomposition/23472)

<div class="topic-metadata">

**Author:** [@deschase](https://discourse.julialang.org/u/deschase)\
**Replies:** 4\
**Last updated:** [May 23, 2019, 11:57am UTC](https://discourse.julialang.org/t/multi-cut-benders-decomposition/23472 "2019-05-23T11:57:57Z")

</div>

I have coded a Benders decomposition with JuMP, but it is currently running too slow for my needs. I have a way to speed up the process theoretically by collecting several solutions from the solver at each iteration of m…

---

## [JuMP (0.18): summing up elements of solution vector allocates memory?](https://discourse.julialang.org/t/jump-0-18-summing-up-elements-of-solution-vector-allocates-memory/24488)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 9\
**Last updated:** [May 22, 2019, 8:09pm UTC](https://discourse.julialang.org/t/jump-0-18-summing-up-elements-of-solution-vector-allocates-memory/24488 "2019-05-22T20:09:07Z")

</div>

Dear folks, I observe a strange behavior (note that the following snippets are embedded in a function): let x be some decision vector of size n. Then, sum\_x = 0.0 x\_val = getvalue( model\[:x\] ) println("typeof x\_val: ",…

---

## [Optim user-supplied gradient not working](https://discourse.julialang.org/t/optim-user-supplied-gradient-not-working/24417)

<div class="topic-metadata">

**Author:** [@tyleransom](https://discourse.julialang.org/u/tyleransom)\
**Replies:** 6\
**Last updated:** [May 21, 2019, 3:45pm UTC](https://discourse.julialang.org/t/optim-user-supplied-gradient-not-working/24417 "2019-05-21T15:45:56Z")

</div>

I’m estimating a maximum likelihood problem, and I’ve specified both the objective function and the gradient correctly. (I know this because I am able to reproduce estimates using the same exact data as a Stata example.) …

---

## [CouenneNL in version 1.1.1](https://discourse.julialang.org/t/couennenl-in-version-1-1-1/24405)

<div class="topic-metadata">

**Author:** [@Raminel](https://discourse.julialang.org/u/Raminel)\
**Replies:** 5\
**Last updated:** [May 21, 2019, 2:42pm UTC](https://discourse.julialang.org/t/couennenl-in-version-1-1-1/24405 "2019-05-21T14:42:15Z")

</div>

Hi, I am a new user of Julia and trying to solve my MINLP problem using CouenneNL. The problem is non convex so the solution I got from Ipopt is not reliable. How can I use CouenneNL in version v. 1.1.1?

---

## [Dynamic dimensions of optimization variable in JuMP](https://discourse.julialang.org/t/dynamic-dimensions-of-optimization-variable-in-jump/24399)

<div class="topic-metadata">

**Author:** [@lgo](https://discourse.julialang.org/u/lgo)\
**Replies:** 1\
**Last updated:** [May 20, 2019, 1:22pm UTC](https://discourse.julialang.org/t/dynamic-dimensions-of-optimization-variable-in-jump/24399 "2019-05-20T13:22:29Z")

</div>

Hello, Although my question itself is JuMP related, the underlying problem relates to metaprogramming in general: As the title suggests, I want to create a variable, which dimensions change depending on the numeric inp…

---

## [Use of MINLP in Julia](https://discourse.julialang.org/t/use-of-minlp-in-julia/22161)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 11\
**Last updated:** [May 18, 2019, 7:01pm UTC](https://discourse.julialang.org/t/use-of-minlp-in-julia/22161 "2019-05-18T19:01:27Z")

</div>

Hello people, all rigth? I need to solve a nonlinear integer nonconvex problem. The objective and constraints are nonlinear functions. First question: What the ideal package and solve to solve this problem? Is there …

---

## [SOS use on multidimensional arrays](https://discourse.julialang.org/t/sos-use-on-multidimensional-arrays/24282)

<div class="topic-metadata">

**Author:** [@iharjunk](https://discourse.julialang.org/u/iharjunk)\
**Replies:** 5\
**Last updated:** [May 17, 2019, 4:48am UTC](https://discourse.julialang.org/t/sos-use-on-multidimensional-arrays/24282 "2019-05-17T04:48:23Z")

</div>

Hello all! I am trying to use the new way of SOS2 constraints (MOI.SOS2) but since I have a 3-dimensional variable (the last dimension should be part of the SOS2 set), existing examples are not sufficient. Any hints how…

---

## [Getting constraint matrix and bound from JuMP model (JuMP 0.19)](https://discourse.julialang.org/t/getting-constraint-matrix-and-bound-from-jump-model-jump-0-19/24197)

<div class="topic-metadata">

**Author:** [@Jonathan\_Droxler](https://discourse.julialang.org/u/Jonathan_Droxler)\
**Replies:** 7\
**Last updated:** [May 14, 2019, 6:20pm UTC](https://discourse.julialang.org/t/getting-constraint-matrix-and-bound-from-jump-model-jump-0-19/24197 "2019-05-14T18:20:28Z")

</div>

Hi everyone, I just change to JuMP 0.19 and I get some problem with my code. I construct a big JuMP model with a lot of specific variables and constraints, and I want to extract constraint matrix and vectors from the m…

---

## [BARON - Setting branching priority](https://discourse.julialang.org/t/baron-setting-branching-priority/24213)

<div class="topic-metadata">

**Author:** [@EgidioLeo](https://discourse.julialang.org/u/EgidioLeo)\
**Replies:** 0\
**Last updated:** [May 14, 2019, 4:10pm UTC](https://discourse.julialang.org/t/baron-setting-branching-priority/24213 "2019-05-14T16:10:48Z")

</div>

Hi all! I am trying to set branching priority in BARON for some variables but I cannot find any related documentation. Any suggestions how to do this? Thank you in advance. Egidio

---

## [Repeated solution of a parametric rootfinding problem](https://discourse.julialang.org/t/repeated-solution-of-a-parametric-rootfinding-problem/24199)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [May 14, 2019, 9:44am UTC](https://discourse.julialang.org/t/repeated-solution-of-a-parametric-rootfinding-problem/24199 "2019-05-14T09:44:10Z")

</div>

For a given set of parameters \\theta, I am solving f(x, \\theta) \\approx 0 numerically for x(\\theta), then obtain simulated moments S(x(\\theta)) (which is stochastic), minimizing \\min\_x \\| S(x(\\theta)) - D \\| where D…

---

## [Optim package in parallel](https://discourse.julialang.org/t/optim-package-in-parallel/24168)

<div class="topic-metadata">

**Author:** [@drarnau](https://discourse.julialang.org/u/drarnau)\
**Replies:** 0\
**Last updated:** [May 13, 2019, 11:06am UTC](https://discourse.julialang.org/t/optim-package-in-parallel/24168 "2019-05-13T11:06:35Z")

</div>

Does anybody know if it is possible to run the Optim.jl package in parallel? Any example on how to do it?

---

## [Solving a piecewise linear system](https://discourse.julialang.org/t/solving-a-piecewise-linear-system/18856)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 23\
**Last updated:** [May 12, 2019, 3:06am UTC](https://discourse.julialang.org/t/solving-a-piecewise-linear-system/18856 "2019-05-12T03:06:23Z")

</div>

The help I need here is mostly conceptual, but I suspect that either JuMP.jl or Convex.jl could do this. Any suggestions or pointers to texts/tutorials would be appreciated, I just don’t know how to reformulate this. I …

---

## [Optimize not working with function that has find\_zero](https://discourse.julialang.org/t/optimize-not-working-with-function-that-has-find-zero/24043)

<div class="topic-metadata">

**Author:** [@jints07](https://discourse.julialang.org/u/jints07)\
**Replies:** 11\
**Last updated:** [May 9, 2019, 8:58pm UTC](https://discourse.julialang.org/t/optimize-not-working-with-function-that-has-find-zero/24043 "2019-05-09T20:58:36Z")

</div>

I have been using Julia on and off for over a year now. I know the basics but am not an expert by any means. I have had this problem many times in the past - some problem with forwardDiff not working because of floating …

---

## [JuMP problem with all\_variables](https://discourse.julialang.org/t/jump-problem-with-all-variables/24006)

<div class="topic-metadata">

**Author:** [@gbustosx](https://discourse.julialang.org/u/gbustosx)\
**Replies:** 2\
**Last updated:** [May 8, 2019, 7:42pm UTC](https://discourse.julialang.org/t/jump-problem-with-all-variables/24006 "2019-05-08T19:42:28Z")

</div>

Hi, I am trying to use all\_variables but I get the following error message: UndefVarError: all\_variables not defined Stacktrace: \[1\] getproperty(::Module, ::Symbol) at ./sysimg.jl:13 \[2\] top-level scope at In\[83\]:1 T…

---

## [JuMP 0.18: how to obtain the root relaxation of a branch and cut model?](https://discourse.julialang.org/t/jump-0-18-how-to-obtain-the-root-relaxation-of-a-branch-and-cut-model/23997)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 2\
**Last updated:** [May 8, 2019, 3:16pm UTC](https://discourse.julialang.org/t/jump-0-18-how-to-obtain-the-root-relaxation-of-a-branch-and-cut-model/23997 "2019-05-08T15:16:27Z")

</div>

Dear community, as the title suggests, I want to obtain the root relaxation of a branch & cut algorithm. More precisely, if the relaxation is fractional I like to add violated cuts and resolve as long as no violated cut…

---

## [Strange behavior with deepcopy](https://discourse.julialang.org/t/strange-behavior-with-deepcopy/23342)

<div class="topic-metadata">

**Author:** [@Thuener](https://discourse.julialang.org/u/Thuener)\
**Replies:** 6\
**Last updated:** [May 8, 2019, 10:15am UTC](https://discourse.julialang.org/t/strange-behavior-with-deepcopy/23342 "2019-05-08T10:15:45Z")

</div>

I’m getting a strange behavior with deepcopy. Deepcopy is still not supported? There is any way to copy JuMP model? using JuMP, Clp m = Model(solver = ClpSolver()) @variable(m, 0 \<= x \<= 2 ) @variable(m, 0 \<= y \<= 30 …

---

## [Optimizing a function with constraints in NLopt (want a different expression returned than optimized)](https://discourse.julialang.org/t/optimizing-a-function-with-constraints-in-nlopt-want-a-different-expression-returned-than-optimized/23916)

<div class="topic-metadata">

**Author:** [@CPPhysics](https://discourse.julialang.org/u/CPPhysics)\
**Replies:** 2\
**Last updated:** [May 6, 2019, 8:11pm UTC](https://discourse.julialang.org/t/optimizing-a-function-with-constraints-in-nlopt-want-a-different-expression-returned-than-optimized/23916 "2019-05-06T20:11:58Z")

</div>

Hello, I am optimizing a function utilizing Lagrange constraints, and I would like NLopt to optimize an expression with Lagrange constraints, but return the value of that expression without constraints. I added a flag to…

---

## [JuMP: Real Variable used in Complex expression](https://discourse.julialang.org/t/jump-real-variable-used-in-complex-expression/23832)

<div class="topic-metadata">

**Author:** [@eschoute](https://discourse.julialang.org/u/eschoute)\
**Replies:** 5\
**Last updated:** [May 6, 2019, 6:44pm UTC](https://discourse.julialang.org/t/jump-real-variable-used-in-complex-expression/23832 "2019-05-06T18:44:34Z")

</div>

Possibly related to How Define a Complex JuMP Variable I’m wondering if it’s possible to define objective functions and/or constraint functions take take in real variables and return a real number (i.e. f(x): ℝ^n → ℝ) b…

---

## [Encode matrix function which depends on optimization variables at each step](https://discourse.julialang.org/t/encode-matrix-function-which-depends-on-optimization-variables-at-each-step/23831)

<div class="topic-metadata">

**Author:** [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Replies:** 7\
**Last updated:** [May 5, 2019, 11:24pm UTC](https://discourse.julialang.org/t/encode-matrix-function-which-depends-on-optimization-variables-at-each-step/23831 "2019-05-05T23:24:28Z")

</div>

I’m considering a problem which involves constraints on a solution to a linear system whose coefficients depend on the optimization variables. So essentially, the constraints are functions of a matrix inverse involving t…

---

## [Integer optimisation with user's multivariate functions: Possible in Julia?](https://discourse.julialang.org/t/integer-optimisation-with-users-multivariate-functions-possible-in-julia/17924)

<div class="topic-metadata">

**Author:** [@Olegg](https://discourse.julialang.org/u/Olegg)\
**Replies:** 8\
**Last updated:** [May 5, 2019, 11:24pm UTC](https://discourse.julialang.org/t/integer-optimisation-with-users-multivariate-functions-possible-in-julia/17924 "2019-05-05T23:24:47Z")

</div>

My optimisation problem has convex multivariate constraints with matrix operations: inverse and determinant. The matrices are symmetric PSD from dim 2x2 up to 10x10. I’ve solved the continuous case in JuMP and Ipopt, w…

---

## [Modelling Frobenius norm of Matrix using one SecondOrderCone() constraint](https://discourse.julialang.org/t/modelling-frobenius-norm-of-matrix-using-one-secondordercone-constraint/23881)

<div class="topic-metadata">

**Author:** [@ryancorywright](https://discourse.julialang.org/u/ryancorywright)\
**Replies:** 2\
**Last updated:** [May 5, 2019, 9:21pm UTC](https://discourse.julialang.org/t/modelling-frobenius-norm-of-matrix-using-one-secondordercone-constraint/23881 "2019-05-05T21:21:40Z")

</div>

Hi all, I was wondering if it is possible to model the Frobenius norm of a matrix using a single second order cone constraint in JuMP 0.19 (perhaps by reshaping the matrix). In JuMP 0.18.5 this was possible via: @vari…

---

## [User guide for optimization in Julia](https://discourse.julialang.org/t/user-guide-for-optimization-in-julia/23852)

<div class="topic-metadata">

**Author:** [@RohiniShetty](https://discourse.julialang.org/u/RohiniShetty)\
**Replies:** 4\
**Last updated:** [May 5, 2019, 1:15am UTC](https://discourse.julialang.org/t/user-guide-for-optimization-in-julia/23852 "2019-05-05T01:15:56Z")

</div>

I am using Julia for the first time to work on an optimization project. Is there a manual or guide which has information wrt how to declare indices, parameters, decision variable, objective function, and constraints. Th…

---

## [JuMP 0.18 + CPLEX: How to force user cuts?](https://discourse.julialang.org/t/jump-0-18-cplex-how-to-force-user-cuts/23659)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 4\
**Last updated:** [May 1, 2019, 7:07am UTC](https://discourse.julialang.org/t/jump-0-18-cplex-how-to-force-user-cuts/23659 "2019-05-01T07:07:46Z")

</div>

Dear community, is there any way to force CPLEX to add all user cuts (i.e., passing the option CPX\_USECUT\_FORCE)? Here https://github.com/JuliaOpt/CPLEX.jl/blob/master/src/cpx\_callbacks.jl the option seems to be hard-c…

---

## [Best practice to solve optimization problem repeatedly in a function with MathOptInterface](https://discourse.julialang.org/t/best-practice-to-solve-optimization-problem-repeatedly-in-a-function-with-mathoptinterface/23592)

<div class="topic-metadata">

**Author:** [@Yuya-Furusawa](https://discourse.julialang.org/u/Yuya-Furusawa)\
**Replies:** 6\
**Last updated:** [April 28, 2019, 12:35pm UTC](https://discourse.julialang.org/t/best-practice-to-solve-optimization-problem-repeatedly-in-a-function-with-mathoptinterface/23592 "2019-04-28T12:35:05Z")

</div>

I want to create the function to solve multiple optimization problems with MathOptInterface, such as using MathOptInterface const MOI = MathOptInterface function opt(optimizer::MOI.AbstractOptimizer) ... for i …

---

## [Practice JuMP problem - scheduling LP questions](https://discourse.julialang.org/t/practice-jump-problem-scheduling-lp-questions/23390)

<div class="topic-metadata">

**Author:** [@Crghilardi](https://discourse.julialang.org/u/Crghilardi)\
**Replies:** 8\
**Last updated:** [April 24, 2019, 1:53pm UTC](https://discourse.julialang.org/t/practice-jump-problem-scheduling-lp-questions/23390 "2019-04-24T13:53:23Z")

</div>

I am practising by translating a python LP scheduling example using JuMP. I have been using a combination of the SteelT3 example and some older notebooks I found as guiding references, but have not been able to get ever…

---

## [Stop optimization problem when the objective is negative?](https://discourse.julialang.org/t/stop-optimization-problem-when-the-objective-is-negative/23330)

<div class="topic-metadata">

**Author:** [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Replies:** 4\
**Last updated:** [April 21, 2019, 11:10pm UTC](https://discourse.julialang.org/t/stop-optimization-problem-when-the-objective-is-negative/23330 "2019-04-21T23:10:55Z")

</div>

i have a Helmholtz function, that needs to be optimized, but i need to stop the optimization algorithm if the value of the objective function is negative, any ideas?, im using Optim.jl using Optim N = 10 c = rand(N) .- …

---

## [Nonlinear optimization using MathOptInterface - examples/learning](https://discourse.julialang.org/t/nonlinear-optimization-using-mathoptinterface-examples-learning/23261)

<div class="topic-metadata">

**Author:** [@cosmia](https://discourse.julialang.org/u/cosmia)\
**Replies:** 8\
**Last updated:** [April 19, 2019, 5:22am UTC](https://discourse.julialang.org/t/nonlinear-optimization-using-mathoptinterface-examples-learning/23261 "2019-04-19T05:22:25Z")

</div>

(sorry for the long post) Hi all, For the past 6 months or so, on and off, I’ve been trying to estimate a finite horizon dynamic discrete choice model. If you are not familiar with it, suffices to say that for every st…

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

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