# Optimization (Mathematical)

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

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

**Page:** 121

---

## [How to get the variable value inside a JuMP model to insert it into a function?](https://discourse.julialang.org/t/how-to-get-the-variable-value-inside-a-jump-model-to-insert-it-into-a-function/11108)

<div class="topic-metadata">

**Author:** [@cfrodriguez](https://discourse.julialang.org/u/cfrodriguez)\
**Replies:** 2\
**Last updated:** [May 24, 2018, 12:03am UTC](https://discourse.julialang.org/t/how-to-get-the-variable-value-inside-a-jump-model-to-insert-it-into-a-function/11108 "2018-05-24T00:03:39Z")

</div>

Hi everyone! I order to avoid unnecessary variables, I need to get a JuMP variable value in each iteration from model to insert it into a function and use it in a @NLexpression. The function is function fy1(x1,x2,x3,x…

---

## [Ipopt solver: no method matching setvartype!](https://discourse.julialang.org/t/ipopt-solver-no-method-matching-setvartype/11091)

<div class="topic-metadata">

**Author:** [@tfk17lstm](https://discourse.julialang.org/u/tfk17lstm)\
**Replies:** 1\
**Last updated:** [May 23, 2018, 11:45pm UTC](https://discourse.julialang.org/t/ipopt-solver-no-method-matching-setvartype/11091 "2018-05-23T23:45:29Z")

</div>

Dear colleagues, I was using juliabox (because for the moment I can no install solvers in my julia) and I am using the same model that I use for my model with linear costs. This is the model: #dispatch with quadratic co…

---

## [Piecewise Linearlization of Quadratic functions](https://discourse.julialang.org/t/piecewise-linearlization-of-quadratic-functions/10988)

<div class="topic-metadata">

**Author:** [@tfk17lstm](https://discourse.julialang.org/u/tfk17lstm)\
**Replies:** 5\
**Last updated:** [May 22, 2018, 7:06am UTC](https://discourse.julialang.org/t/piecewise-linearlization-of-quadratic-functions/10988 "2018-05-22T07:06:29Z")

</div>

Dear colleagues, I have managed to implement the unit commitment problem with JuMP adding the time varying constrains that I mentioned in my last post. I was using the Cbc solver and I would like to know if JuMP has a f…

---

## [Constraint optimization without gradient](https://discourse.julialang.org/t/constraint-optimization-without-gradient/11040)

<div class="topic-metadata">

**Author:** [@sarnatas](https://discourse.julialang.org/u/sarnatas)\
**Replies:** 3\
**Last updated:** [May 21, 2018, 12:23pm UTC](https://discourse.julialang.org/t/constraint-optimization-without-gradient/11040 "2018-05-21T12:23:23Z")

</div>

Hello, I am very new in Julia, so sorry in advance for my questions. I have some issues about the optimize function from Optim.jl package. First of all, I was not able to find a complete list with description of every…

---

## [Juno slow to execute JumP models](https://discourse.julialang.org/t/juno-slow-to-execute-jump-models/10981)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 4\
**Last updated:** [May 18, 2018, 11:47am UTC](https://discourse.julialang.org/t/juno-slow-to-execute-jump-models/10981 "2018-05-18T11:47:18Z")

</div>

I have been using Atom to execute the file that contains my LP problem. However, it has been becoming too slow and usually I have to force close of Atom because it bugs. My specifications are: Windows 7 and Juno for Ju…

---

## [Pushing into a dictionary by accumulating the values of JumpVariables](https://discourse.julialang.org/t/pushing-into-a-dictionary-by-accumulating-the-values-of-jumpvariables/10952)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 3\
**Last updated:** [May 18, 2018, 9:03am UTC](https://discourse.julialang.org/t/pushing-into-a-dictionary-by-accumulating-the-values-of-jumpvariables/10952 "2018-05-18T09:03:29Z")

</div>

I have been using Jump to model a LP. The variable in my problem can be represented as follow: x\_prod\[year, hour, site, product\] In my obj function I need something like that, for all the sites existing sum(annual\_p…

---

## [Time varying constrained optimization](https://discourse.julialang.org/t/time-varying-constrained-optimization/10926)

<div class="topic-metadata">

**Author:** [@tfk17lstm](https://discourse.julialang.org/u/tfk17lstm)\
**Replies:** 8\
**Last updated:** [May 17, 2018, 9:00am UTC](https://discourse.julialang.org/t/time-varying-constrained-optimization/10926 "2018-05-17T09:00:51Z")

</div>

Dear Julia community, This is Edgar a completely newbie in Julia that has been looking for an alternative to R and Matlab for solving optimization problems. After reading some examples available at JuliaOpt I think that…

---

## [LP Barrier solve times scaling badly with number of threads](https://discourse.julialang.org/t/lp-barrier-solve-times-scaling-badly-with-number-of-threads/10907)

<div class="topic-metadata">

**Author:** [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Replies:** 1\
**Last updated:** [May 16, 2018, 1:43am UTC](https://discourse.julialang.org/t/lp-barrier-solve-times-scaling-badly-with-number-of-threads/10907 "2018-05-16T01:43:23Z")

</div>

This is probably not Julia related but could conceivably be due to an issue with CPLEX.jl, so I hope it’s OK that I ask my question here in the optimization subforum. I have a linear programming model written in JuMP tha…

---

## [Passing a function as an objective function in JuMP](https://discourse.julialang.org/t/passing-a-function-as-an-objective-function-in-jump/10745)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 2\
**Last updated:** [May 9, 2018, 9:08am UTC](https://discourse.julialang.org/t/passing-a-function-as-an-objective-function-in-jump/10745 "2018-05-09T09:08:48Z")

</div>

Anyone knows if it is possible and how to pass a function as an objective function in JuMP? I have read the documentation but i haven’t find anything about it. I have many sum as objective and I would like to write it i…

---

## [Efficient linear algebra for large-scale problems in JuMP](https://discourse.julialang.org/t/efficient-linear-algebra-for-large-scale-problems-in-jump/10715)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 6\
**Last updated:** [May 8, 2018, 2:38pm UTC](https://discourse.julialang.org/t/efficient-linear-algebra-for-large-scale-problems-in-jump/10715 "2018-05-08T14:38:55Z")

</div>

Hello all. I’ve finally had a chance to sit down and look carefully at some of the code in JuMP 0.19. In my work I very frequently have to do problems with \\sim 10^6 variables. Obviously implementing these involves a…

---

## [I'm building a database using 'csv', I need to have the program read the tables and calculate the constraint and goal indices, to get the optimal solution, which commands should I use?](https://discourse.julialang.org/t/im-building-a-database-using-csv-i-need-to-have-the-program-read-the-tables-and-calculate-the-constraint-and-goal-indices-to-get-the-optimal-solution-which-commands-should-i-use/10759)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 2\
**Last updated:** [May 7, 2018, 2:04pm UTC](https://discourse.julialang.org/t/im-building-a-database-using-csv-i-need-to-have-the-program-read-the-tables-and-calculate-the-constraint-and-goal-indices-to-get-the-optimal-solution-which-commands-should-i-use/10759 "2018-05-07T14:04:39Z")

</div>

I’m building a database using ‘csv’, I need to have the program read the tables and calculate the constraint and goal indices, to get the optimal solution, which commands should I use?

---

## [\[JuMP\] Get variable name from a model to use on another](https://discourse.julialang.org/t/jump-get-variable-name-from-a-model-to-use-on-another/10692)

<div class="topic-metadata">

**Author:** [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Replies:** 3\
**Last updated:** [May 5, 2018, 7:51pm UTC](https://discourse.julialang.org/t/jump-get-variable-name-from-a-model-to-use-on-another/10692 "2018-05-05T19:51:04Z")

</div>

On JuMP, I have a model m = Model() @variable(m, x\[1:2\]) By passing m to a function, can I obtain the variable x to define a new model with x?

---

## [\[JuMP\] Creating a Nonlinear Least Squares model](https://discourse.julialang.org/t/jump-creating-a-nonlinear-least-squares-model/10706)

<div class="topic-metadata">

**Author:** [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Replies:** 2\
**Last updated:** [May 5, 2018, 7:50pm UTC](https://discourse.julialang.org/t/jump-creating-a-nonlinear-least-squares-model/10706 "2018-05-05T19:50:37Z")

</div>

Related to this PR and this post . We are trying to make a Nonlinear Least Squares model using JuMP, so that the matrices are sparse. From @miles.lubin suggestion, I’m building a model passing the residuals as NLexpressi…

---

## [How to insert a IF inside a declaration of a variable JuMP](https://discourse.julialang.org/t/how-to-insert-a-if-inside-a-declaration-of-a-variable-jump/10673)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 5\
**Last updated:** [May 3, 2018, 11:40am UTC](https://discourse.julialang.org/t/how-to-insert-a-if-inside-a-declaration-of-a-variable-jump/10673 "2018-05-03T11:40:06Z")

</div>

In order to avoid the creation of variables that are not really necessary in my problem, I’d like to insert a IF in the declaration of the variables. Like this : @variable(model, x\_prod\[l in localization, inst in inst\_…

---

## [Gurobi 8.0](https://discourse.julialang.org/t/gurobi-8-0/10606)

<div class="topic-metadata">

**Author:** [@Frank\_Kampas](https://discourse.julialang.org/u/Frank_Kampas)\
**Replies:** 2\
**Last updated:** [April 29, 2018, 3:54pm UTC](https://discourse.julialang.org/t/gurobi-8-0/10606 "2018-04-29T15:54:55Z")

</div>

What’s the process to switch to the new Gurobi release (8.0) ?

---

## [Optim.jl optimize over Distances.jl metric](https://discourse.julialang.org/t/optim-jl-optimize-over-distances-jl-metric/10542)

<div class="topic-metadata">

**Author:** [@mcbaron](https://discourse.julialang.org/u/mcbaron)\
**Replies:** 4\
**Last updated:** [April 26, 2018, 11:45am UTC](https://discourse.julialang.org/t/optim-jl-optimize-over-distances-jl-metric/10542 "2018-04-26T11:45:12Z")

</div>

Hello all! I’m wondering what’s the most efficient way to go about optimizing over a specific distance metric. As of right now, I have two vectors, x, y and bhattacharyya(x, y) as loaded from Distances.jl. I’d like to …

---

## [Registering Analytical Derivative with ReverseDiff/ForwardDiff](https://discourse.julialang.org/t/registering-analytical-derivative-with-reversediff-forwarddiff/10543)

<div class="topic-metadata">

**Author:** [@crinders](https://discourse.julialang.org/u/crinders)\
**Replies:** 4\
**Last updated:** [April 25, 2018, 7:56pm UTC](https://discourse.julialang.org/t/registering-analytical-derivative-with-reversediff-forwarddiff/10543 "2018-04-25T19:56:48Z")

</div>

Is there a way to register a derivative function similar to JuMP’s usage in ForwardDiff or ReverseDiff? I have a small function which solves a simple optimization problem using svd, which isn’t automatically differentiat…

---

## [Slow generation of a large LP model in JuMP](https://discourse.julialang.org/t/slow-generation-of-a-large-lp-model-in-jump/3034)

<div class="topic-metadata">

**Author:** [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Replies:** 11\
**Last updated:** [April 24, 2018, 10:24pm UTC](https://discourse.julialang.org/t/slow-generation-of-a-large-lp-model-in-jump/3034 "2018-04-24T22:24:14Z")

</div>

\[Wall of text incoming, beware!\] I’m a Julia novice and have been playing around with JuMP over the last month or so. All my small scale test models worked beautifully, so I finally decided to dive into the deep end of …

---

## [Solving system equations using Knitro](https://discourse.julialang.org/t/solving-system-equations-using-knitro/10490)

<div class="topic-metadata">

**Author:** [@LinOslo](https://discourse.julialang.org/u/LinOslo)\
**Replies:** 3\
**Last updated:** [April 23, 2018, 8:51pm UTC](https://discourse.julialang.org/t/solving-system-equations-using-knitro/10490 "2018-04-23T20:51:01Z")

</div>

I’m solving a system equation using KNITRO. For example the system takes the form: x+3yˆ3-7+18=0 sin(yexp(x)-1)=0 I want to use self-defined functions (instead of using ‘in-line’ functions as in JuMP). Therefore in Ju…

---

## [Different ways to declare a constraint](https://discourse.julialang.org/t/different-ways-to-declare-a-constraint/10415)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 3\
**Last updated:** [April 19, 2018, 9:58am UTC](https://discourse.julialang.org/t/different-ways-to-declare-a-constraint/10415 "2018-04-19T09:58:36Z")

</div>

Hello, I’m taking my first steps into Julia and I’m trying to modelate a LP. I wrote the following constraint: @constraint(m, ctte\_equilibre\[r in set\_regions, tec in tech\_by\_site\[r\], dy in div\_years, y in years, t in t…

---

## [Managing unnecessary 0's in JuMP](https://discourse.julialang.org/t/managing-unnecessary-0s-in-jump/10414)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 4\
**Last updated:** [April 18, 2018, 4:27pm UTC](https://discourse.julialang.org/t/managing-unnecessary-0s-in-jump/10414 "2018-04-18T16:27:37Z")

</div>

I have a rather ugly quadratic objective function that requires a fair amount of manipulation of variables, and I suspect that one of the things that’s making this process incredibly slow is that I have lots of GenericAf…

---

## [Is it possible that passing user defined gradient slows down the solver](https://discourse.julialang.org/t/is-it-possible-that-passing-user-defined-gradient-slows-down-the-solver/10311)

<div class="topic-metadata">

**Author:** [@Ksun46](https://discourse.julialang.org/u/Ksun46)\
**Replies:** 5\
**Last updated:** [April 18, 2018, 2:34am UTC](https://discourse.julialang.org/t/is-it-possible-that-passing-user-defined-gradient-slows-down-the-solver/10311 "2018-04-18T02:34:31Z")

</div>

Hi all, I am using JuMP with Ipopt and encounter this problem. For example, I have a constraint looks like x^2 + y^2 \<= 1. Originally I just add this constraints to the model. But when I try to define a function f(x, y)…

---

## [Accessing the root node solution](https://discourse.julialang.org/t/accessing-the-root-node-solution/10371)

<div class="topic-metadata">

**Author:** [@varun7rs](https://discourse.julialang.org/u/varun7rs)\
**Replies:** 6\
**Last updated:** [April 17, 2018, 5:16am UTC](https://discourse.julialang.org/t/accessing-the-root-node-solution/10371 "2018-04-17T05:16:05Z")

</div>

I’m working on a heuristic that takes in a fractional solution and applies randomised rounding operations to get a feasible solution. In order to obtain the fractional solution, I tried solving the LP but the computation…

---

## [How to create a huge set of variables (500k or more) in JUMP](https://discourse.julialang.org/t/how-to-create-a-huge-set-of-variables-500k-or-more-in-jump/10325)

<div class="topic-metadata">

**Author:** [@jayce\_ram](https://discourse.julialang.org/u/jayce_ram)\
**Replies:** 4\
**Last updated:** [April 15, 2018, 5:26am UTC](https://discourse.julialang.org/t/how-to-create-a-huge-set-of-variables-500k-or-more-in-jump/10325 "2018-04-15T05:26:45Z")

</div>

Hello everybody, I’m completely new in Jump and I have a very large LP to solve. The number of variables depend of the input data. My variables are too nested, for example, for each given installation, there’s an associa…

---

## [Newton optimization with Optim doing strange things](https://discourse.julialang.org/t/newton-optimization-with-optim-doing-strange-things/10008)

<div class="topic-metadata">

**Author:** [@bdeonovic](https://discourse.julialang.org/u/bdeonovic)\
**Replies:** 36\
**Last updated:** [April 12, 2018, 7:46am UTC](https://discourse.julialang.org/t/newton-optimization-with-optim-doing-strange-things/10008 "2018-04-12T07:46:18Z")

</div>

I’m having some issues with optimizing an objective with Newton from Optim. I started a brief discussion on slack which has led me to isolate the problem: Okay I am getting closer to the issue. So consider gradient and …

---

## [Optim.jl OnceDifferentiable Baby Steps](https://discourse.julialang.org/t/optim-jl-oncedifferentiable-baby-steps/10185)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 19\
**Last updated:** [April 8, 2018, 5:22pm UTC](https://discourse.julialang.org/t/optim-jl-oncedifferentiable-baby-steps/10185 "2018-04-08T17:22:52Z")

</div>

Automatic differentiation seems a little like magic. ?OnceDifferentiable is not very informative. Experimenting with it, I want to see, e.g., what happens if my function uses abs(). As always, I want to start with …

---

## [Quasi Maximum Likelihood implementation with Optim.jl](https://discourse.julialang.org/t/quasi-maximum-likelihood-implementation-with-optim-jl/9757)

<div class="topic-metadata">

**Author:** [@AnttiSim](https://discourse.julialang.org/u/AnttiSim)\
**Replies:** 21\
**Last updated:** [April 6, 2018, 8:45am UTC](https://discourse.julialang.org/t/quasi-maximum-likelihood-implementation-with-optim-jl/9757 "2018-04-06T08:45:14Z")

</div>

Hi, I am trying to implement a QML estimation problem with a system of censored equations. I am trying this with Julia’s Optim library. However, I have not been able to build a working model. I get an error message: Me…

---

## [SAMIN Example in Optim.jl not working](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 6\
**Last updated:** [April 6, 2018, 8:35am UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187 "2018-04-06T08:35:53Z")

</div>

From Simulated Annealing w/ bounds - Optim.jl julia\> using Optim, OptimTestProblems julia\> prob = OptimTestProblems.UnconstrainedProblems.examples\["Rosenbrock"\]; julia\> res = Optim.optimize(prob.f, prob.initial\_x, …

---

## [JuMP NL Baby Steps](https://discourse.julialang.org/t/jump-nl-baby-steps/10168)

<div class="topic-metadata">

**Author:** [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Replies:** 4\
**Last updated:** [April 5, 2018, 4:50pm UTC](https://discourse.julialang.org/t/jump-nl-baby-steps/10168 "2018-04-05T16:50:15Z")

</div>

I am now diving into another interesting Julia 0.6.2 area—non-linear non-quadratic (unconstrained) optimization with JuMP 0.18.1. The documentation is partly nice and easy, partly difficult. This is because the differe…

---

## [Optim with occasionally non-finite values](https://discourse.julialang.org/t/optim-with-occasionally-non-finite-values/10174)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 1\
**Last updated:** [April 5, 2018, 4:44pm UTC](https://discourse.julialang.org/t/optim-with-occasionally-non-finite-values/10174 "2018-04-05T16:44:33Z")

</div>

I am maximizing a somewhat difficult likelihood function, for which the values are occasionally non-finite. I run into stack traces like ERROR: AssertionError: isfinite(phid) && isfinite(gphi) Stacktrace: \[1\] bisect!(:…

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

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