# Optimization (Mathematical)

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

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

**Page:** 97

---

## [Large memory allocation in ForwardDiff](https://discourse.julialang.org/t/large-memory-allocation-in-forwarddiff/42581)

<div class="topic-metadata">

**Author:** [@shiroghost](https://discourse.julialang.org/u/shiroghost)\
**Replies:** 14\
**Last updated:** [July 7, 2020, 3:06pm UTC](https://discourse.julialang.org/t/large-memory-allocation-in-forwarddiff/42581 "2020-07-07T15:06:43Z")

</div>

Hi all, I am a bit new to Julia, so I am sure that I should have a type stability problem somewhere, but I cannot find the mistake… I am trying to determine a simple hessian of a user supplied function. The user gives …

---

## [Using ForwardDiff on qr factorization](https://discourse.julialang.org/t/using-forwarddiff-on-qr-factorization/42625)

<div class="topic-metadata">

**Author:** [@aross](https://discourse.julialang.org/u/aross)\
**Replies:** 11\
**Last updated:** [July 7, 2020, 6:45am UTC](https://discourse.julialang.org/t/using-forwarddiff-on-qr-factorization/42625 "2020-07-07T06:45:09Z")

</div>

I am doing a linear least-squares optimization on a function by using QR factorization. I wish to find the gradient so that I can optimize a different parameter, but I am running into trouble when passing qr() to Forward…

---

## [Polynomial optimization problem can't deal with redundant constraints](https://discourse.julialang.org/t/polynomial-optimization-problem-cant-deal-with-redundant-constraints/41839)

<div class="topic-metadata">

**Author:** [@aliceee](https://discourse.julialang.org/u/aliceee)\
**Replies:** 1\
**Last updated:** [June 25, 2020, 7:12am UTC](https://discourse.julialang.org/t/polynomial-optimization-problem-cant-deal-with-redundant-constraints/41839 "2020-06-25T07:12:44Z")

</div>

I’m exploring the following polynomial optimization problem: using SumOfSquares using DynamicPolynomials using MosekTools # Create symbolic variables (not JuMP decision variables) @polyvar x1 x2 # Create a Sum of Squa…

---

## [Optimization problem with Julia - Launch sequence](https://discourse.julialang.org/t/optimization-problem-with-julia-launch-sequence/42311)

<div class="topic-metadata">

**Author:** [@beske](https://discourse.julialang.org/u/beske)\
**Replies:** 14\
**Last updated:** [July 3, 2020, 11:01pm UTC](https://discourse.julialang.org/t/optimization-problem-with-julia-launch-sequence/42311 "2020-07-03T23:01:58Z")

</div>

Say you have n different shops in which you want to launch a product for n different months, and you want to maximize profits. The problem is determining the order of the launch sequence of the product when the price in …

---

## [Using complements in JuMP](https://discourse.julialang.org/t/using-complements-in-jump/42486)

<div class="topic-metadata">

**Author:** [@jovansam](https://discourse.julialang.org/u/jovansam)\
**Replies:** 5\
**Last updated:** [July 3, 2020, 6:47pm UTC](https://discourse.julialang.org/t/using-complements-in-jump/42486 "2020-07-03T18:47:03Z")

</div>

I am trying to use complements in Julia-JuMP. I appreciate the work put into this wonderful package, the manual is not detailed enough unfortunately. A working example that uses this feature in an optimization problem w…

---

## [Objective function error](https://discourse.julialang.org/t/objective-function-error/42482)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 2\
**Last updated:** [July 3, 2020, 6:18pm UTC](https://discourse.julialang.org/t/objective-function-error/42482 "2020-07-03T18:18:41Z")

</div>

I need to reproduce that model. using JuMP, Cbc Model1 = Model(with\_optimizer(Cbc.Optimizer)) a = 2 t = 2 w = 2 A = 1:a T = 1:t W = 1:w CR = \[11, 11\] @variable(Model1,r\[A,T\], lower\_bound=0) @variable(Model1,o\[A…

---

## [Start value Gurobi error](https://discourse.julialang.org/t/start-value-gurobi-error/42437)

<div class="topic-metadata">

**Author:** [@Miguel\_Goncalves](https://discourse.julialang.org/u/Miguel_Goncalves)\
**Replies:** 6\
**Last updated:** [July 2, 2020, 5:10pm UTC](https://discourse.julialang.org/t/start-value-gurobi-error/42437 "2020-07-02T17:10:48Z")

</div>

I am a casual/academic user of optimization with Julia/JuMP, and I noticed there is the possibility to include initial solution setting the function set\_start\_value, but I just want to set initially some variables of my …

---

## [A question about module](https://discourse.julialang.org/t/a-question-about-module/42415)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [July 2, 2020, 7:56am UTC](https://discourse.julialang.org/t/a-question-about-module/42415 "2020-07-02T07:56:24Z")

</div>

want to use another script’s module in one script,it always tell me “a” is not defind, module asd export a a=2 end include("Julia测试.jl") print(a) thanks!!

---

## [How to set up NLconstraints from multi-output user-defined function?](https://discourse.julialang.org/t/how-to-set-up-nlconstraints-from-multi-output-user-defined-function/42309)

<div class="topic-metadata">

**Author:** [@Liang\_Chen](https://discourse.julialang.org/u/Liang_Chen)\
**Replies:** 5\
**Last updated:** [July 1, 2020, 2:31pm UTC](https://discourse.julialang.org/t/how-to-set-up-nlconstraints-from-multi-output-user-defined-function/42309 "2020-07-01T14:31:22Z")

</div>

I have a non-linear user-defined function, y = myfun(x), where the output y is a 1\*2 array. I am going to use the output y to construct constraints. I will have 2 constraint equations since y has 2 components and each c…

---

## [Solve large number of linear inequalities with dynamic arrays](https://discourse.julialang.org/t/solve-large-number-of-linear-inequalities-with-dynamic-arrays/41821)

<div class="topic-metadata">

**Author:** [@LHR](https://discourse.julialang.org/u/LHR)\
**Replies:** 3\
**Last updated:** [July 1, 2020, 1:15am UTC](https://discourse.julialang.org/t/solve-large-number-of-linear-inequalities-with-dynamic-arrays/41821 "2020-07-01T01:15:59Z")

</div>

Hi, I am trying to make a script to remove dominated strategies from a pay-off matrix G for a game-theoretical problem that I have (2-player game, finite discrete strategy sets). The goal is to automate the iterative e…

---

## [Least squares with multi-dimensional output type](https://discourse.julialang.org/t/least-squares-with-multi-dimensional-output-type/42283)

<div class="topic-metadata">

**Author:** [@akahs](https://discourse.julialang.org/u/akahs)\
**Replies:** 3\
**Last updated:** [July 1, 2020, 12:22am UTC](https://discourse.julialang.org/t/least-squares-with-multi-dimensional-output-type/42283 "2020-07-01T00:22:53Z")

</div>

I am trying to use LsqFit to find out a 2D geometric transformation parameter, say a mapping from (x,y) to (xp,yp): x = \[x for x=-2.:2. for y=-2.:2.\] y = \[y for x=-2.:2. for y=-2.:2.\] in\_data = \[x y\] k = -0.02 @. xp = x…

---

## [Set depending of an index](https://discourse.julialang.org/t/set-depending-of-an-index/42322)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 1\
**Last updated:** [June 30, 2020, 7:41pm UTC](https://discourse.julialang.org/t/set-depending-of-an-index/42322 "2020-06-30T19:41:33Z")

</div>

Dear all, I have a constraint in a integer program like @constraint(modelo,\[j in J,i in I\], sum(x\[i,k,h\] for h in H for k in S\_j) \<= 1 ) My problem is how can I write this constraint by using the set S\_j. For exa…

---

## [How to build a constraint with summation?](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 15\
**Last updated:** [June 29, 2020, 9:19pm UTC](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618 "2020-06-29T21:19:34Z")

</div>

I need to mount this restriction But the following error is appearing when I compile the function: syntax: incomplete: premature end of input I’m doing like this using JuMP, Cbc Model1 = Model(with\_optimizer(Cbc.Op…

---

## [Question regarding TIME\_LIMIT status](https://discourse.julialang.org/t/question-regarding-time-limit-status/42258)

<div class="topic-metadata">

**Author:** [@arkanver](https://discourse.julialang.org/u/arkanver)\
**Replies:** 2\
**Last updated:** [June 29, 2020, 7:09pm UTC](https://discourse.julialang.org/t/question-regarding-time-limit-status/42258 "2020-06-29T19:09:21Z")

</div>

Hi, I am trying to solve some optimization problems using JuMP + CPLEX. Since some problems take a long time I define a time limit of 3600 seconds for my model : model = Model(CPLEX.Optimizer) set\_optimizer\_attribute…

---

## [Julia: NLsolve providing different solution each run and sometimes returns NaN?](https://discourse.julialang.org/t/julia-nlsolve-providing-different-solution-each-run-and-sometimes-returns-nan/42191)

<div class="topic-metadata">

**Author:** [@RasmusDamgaard](https://discourse.julialang.org/u/RasmusDamgaard)\
**Replies:** 1\
**Last updated:** [June 29, 2020, 10:54am UTC](https://discourse.julialang.org/t/julia-nlsolve-providing-different-solution-each-run-and-sometimes-returns-nan/42191 "2020-06-29T10:54:01Z")

</div>

Hi, Note: I have cross-posted this to stackexchange: optimization - Julia: NLsolve providing different solution each run and sometimes returns NaN? - Stack Overflow I am trying to replicate some matlab code as a part o…

---

## [An Idea for Optimization as if Solving ODE](https://discourse.julialang.org/t/an-idea-for-optimization-as-if-solving-ode/42195)

<div class="topic-metadata">

**Author:** [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)\
**Replies:** 25\
**Last updated:** [June 29, 2020, 4:39am UTC](https://discourse.julialang.org/t/an-idea-for-optimization-as-if-solving-ode/42195 "2020-06-29T04:39:50Z")

</div>

There are plenty of methods to solve a minimization problem. Many of them iteratively solves for the parameters by decrementing them by a fraction (determined by a learning rate) of the partial derivatives of the objecti…

---

## ["UndefVarError: with\_optimizer not defined" using GLPK](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-using-glpk/42220)

<div class="topic-metadata">

**Author:** [@Ernesto\_Diaz](https://discourse.julialang.org/u/Ernesto_Diaz)\
**Replies:** 6\
**Last updated:** [June 29, 2020, 3:35am UTC](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-using-glpk/42220 "2020-06-29T03:35:29Z")

</div>

I have JuMP v.0.18.6 . I think the message “UndefVarError: with\_optimizer not defined” is showed because I need JuMP v.0.19, but when I wrote Pkg.update(“JuMP”) JuMP wasn´t update.

---

## [A question ahout PCA](https://discourse.julialang.org/t/a-question-ahout-pca/42100)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 9\
**Last updated:** [June 29, 2020, 1:04am UTC](https://discourse.julialang.org/t/a-question-ahout-pca/42100 "2020-06-29T01:04:23Z")

</div>

After applying PCA algorithm, how to display its principal component?thanks!!

---

## [Help speeding up finite horizon dynamic programming problem](https://discourse.julialang.org/t/help-speeding-up-finite-horizon-dynamic-programming-problem/22782)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 33\
**Last updated:** [June 29, 2020, 12:50am UTC](https://discourse.julialang.org/t/help-speeding-up-finite-horizon-dynamic-programming-problem/22782 "2020-06-29T00:50:01Z")

</div>

I am struggling to speed up the computation of solutions for a finite horizon dynamic programming problem. I am using interpolation to avoid computing the value function outside of points in the grid. Right now it takes …

---

## [Gurobi on Julia 1.4](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131)

<div class="topic-metadata">

**Author:** [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Replies:** 9\
**Last updated:** [June 27, 2020, 8:35pm UTC](https://discourse.julialang.org/t/gurobi-on-julia-1-4/42131 "2020-06-27T20:35:48Z")

</div>

I’m trying to upgrade Julia to 1.4 from 1.3, but Gurobi package is giving me the following error. Could anybody confirm whether it’s related to my own setting or not? Any comments would be appreciated. I only have thre…

---

## [Rewriting JuMP code in MathOptInterface](https://discourse.julialang.org/t/rewriting-jump-code-in-mathoptinterface/42061)

<div class="topic-metadata">

**Author:** [@GeneralPoxter](https://discourse.julialang.org/u/GeneralPoxter)\
**Replies:** 5\
**Last updated:** [June 27, 2020, 4:59pm UTC](https://discourse.julialang.org/t/rewriting-jump-code-in-mathoptinterface/42061 "2020-06-27T16:59:32Z")

</div>

Say I wanted to add a variable x which represents an m x n matrix whose elements are constrianed. In JuMP, the code would simply be: @variable(model, 0 \<= x\[i=1:m, j=1:n\] \<= 1) However, I am not sure how to translate …

---

## [Conjugate Gradient optimization with set of functions](https://discourse.julialang.org/t/conjugate-gradient-optimization-with-set-of-functions/42070)

<div class="topic-metadata">

**Author:** [@sergevic](https://discourse.julialang.org/u/sergevic)\
**Replies:** 9\
**Last updated:** [June 27, 2020, 3:40am UTC](https://discourse.julialang.org/t/conjugate-gradient-optimization-with-set-of-functions/42070 "2020-06-27T03:40:20Z")

</div>

This post is related to a previous post of mine and I prefered to expose the problem separatey. I have to optimize a set of functions with conjugate gradient optimization, but I have to define the whole set of functions …

---

## [Solver time](https://discourse.julialang.org/t/solver-time/42114)

<div class="topic-metadata">

**Author:** [@lausilvag](https://discourse.julialang.org/u/lausilvag)\
**Replies:** 1\
**Last updated:** [June 26, 2020, 7:20pm UTC](https://discourse.julialang.org/t/solver-time/42114 "2020-06-26T19:20:03Z")

</div>

Hi! I have the following problem t3 = time() Z\_OP = Model(with\_optimizer(CPLEX.Optimizer)) t4 = time() if RE ==2 @variable(Z\_OP, 0 \<= x\[l,m\] \<= 1 ) else @variable(Z\_OP, x\[l,m\], Bin) end t5 = time() for i = 1:si…

---

## [Rational{Int64} variables in JuMP?](https://discourse.julialang.org/t/rational-int64-variables-in-jump/42048)

<div class="topic-metadata">

**Author:** [@GeneralPoxter](https://discourse.julialang.org/u/GeneralPoxter)\
**Replies:** 7\
**Last updated:** [June 26, 2020, 9:51am UTC](https://discourse.julialang.org/t/rational-int64-variables-in-jump/42048 "2020-06-26T09:51:36Z")

</div>

I’ve been trying to make an array of rationals using the @variable macro in JuMP, but I can’t seem to find out how to constrain the array to only rational values. Does JuMP allow you to build variables with Rational typ…

---

## [Improve CBC solve time](https://discourse.julialang.org/t/improve-cbc-solve-time/42082)

<div class="topic-metadata">

**Author:** [@GeneralPoxter](https://discourse.julialang.org/u/GeneralPoxter)\
**Replies:** 2\
**Last updated:** [June 26, 2020, 3:00am UTC](https://discourse.julialang.org/t/improve-cbc-solve-time/42082 "2020-06-26T03:00:20Z")

</div>

While watching the output of the CBC optimizer, I noticed that after a while, the optimizer would get “stuck” on a best solution, even though I set the primal tolerance and allowable gap to relatively low values. I also…

---

## [A question about sort](https://discourse.julialang.org/t/a-question-about-sort/42035)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 4\
**Last updated:** [June 25, 2020, 1:24pm UTC](https://discourse.julialang.org/t/a-question-about-sort/42035 "2020-06-25T13:24:20Z")

</div>

How do I sort by the imaginary part of a complex matrix?what function? thanks!

---

## [A question about fft function](https://discourse.julialang.org/t/a-question-about-fft-function/42026)

<div class="topic-metadata">

**Author:** [@abcde](https://discourse.julialang.org/u/abcde)\
**Replies:** 1\
**Last updated:** [June 25, 2020, 7:24am UTC](https://discourse.julialang.org/t/a-question-about-fft-function/42026 "2020-06-25T07:24:25Z")

</div>

it does not work ,why? a=\[1 ,2 ,3 ,4\] b=\[7 8 9 5\] foo=x-\>fft(x,2) foo.(b) #print(fft(b,2))

---

## [Is there a way to set Ipopt's intemediate callback from JuMP?](https://discourse.julialang.org/t/is-there-a-way-to-set-ipopts-intemediate-callback-from-jump/41976)

<div class="topic-metadata">

**Author:** [@pjssilva](https://discourse.julialang.org/u/pjssilva)\
**Replies:** 3\
**Last updated:** [June 24, 2020, 1:03pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-set-ipopts-intemediate-callback-from-jump/41976 "2020-06-24T13:03:11Z")

</div>

Hello, I was looking at the Ipopt.jl MOI interface and I could not find an easy way to set the intermediate callback (to stop iteration if needed). Is there any workaround? Maybe grab the Ipopt Optimizer struct directly…

---

## [Have you used the IIS/conflict-refiner feature of a solver? How would you like to access it from JuMP?](https://discourse.julialang.org/t/have-you-used-the-iis-conflict-refiner-feature-of-a-solver-how-would-you-like-to-access-it-from-jump/41862)

<div class="topic-metadata">

**Author:** [@dourouc05](https://discourse.julialang.org/u/dourouc05)\
**Replies:** 0\
**Last updated:** [June 22, 2020, 1:51pm UTC](https://discourse.julialang.org/t/have-you-used-the-iis-conflict-refiner-feature-of-a-solver-how-would-you-like-to-access-it-from-jump/41862 "2020-06-22T13:51:42Z")

</div>

Hi all, Right now, the plumbing work has been performed in the JuMP ecosystem to let you access the IIS/conflict-refiner functionality of your solver. More precisely, there is a low-level interface in MathOptInterface t…

---

## [Genetic Algorithms with julia](https://discourse.julialang.org/t/genetic-algorithms-with-julia/41844)

<div class="topic-metadata">

**Author:** [@mayar](https://discourse.julialang.org/u/mayar)\
**Replies:** 3\
**Last updated:** [June 22, 2020, 12:03pm UTC](https://discourse.julialang.org/t/genetic-algorithms-with-julia/41844 "2020-06-22T12:03:12Z")

</div>

hello all, I wish to solve a multi objective optimization problem with GA also I have never worked with GA before and I want to learn more about what are the packages that I can find useful? What are the pros of cons of…

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

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