# Optimization (Mathematical)

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

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

**Page:** 81

---

## [CPLEX Julia/JuMP Connection Problem](https://discourse.julialang.org/t/cplex-julia-jump-connection-problem/60724)

<div class="topic-metadata">

**Author:** [@Armando\_Gabriel\_Guar](https://discourse.julialang.org/u/Armando_Gabriel_Guar)\
**Replies:** 6\
**Last updated:** [May 10, 2021, 5:31am UTC](https://discourse.julialang.org/t/cplex-julia-jump-connection-problem/60724 "2021-05-10T05:31:34Z")

</div>

Dear Julia Guys, I am having a lot of trouble to make cplex run with julia/jump, (Gurobi has been seamless and works perfect). I installed the package and when running the sentence “using CPLEX”, I get the following mes…

---

## [JuMP package download issue: Some dependencies errored](https://discourse.julialang.org/t/jump-package-download-issue-some-dependencies-errored/60832)

<div class="topic-metadata">

**Author:** [@trathi](https://discourse.julialang.org/u/trathi)\
**Replies:** 4\
**Last updated:** [May 9, 2021, 9:30pm UTC](https://discourse.julialang.org/t/jump-package-download-issue-some-dependencies-errored/60832 "2021-05-09T21:30:50Z")

</div>

I just downloaded the latest version of JuMP v0.21.8 and while precompiling some of the dependencies failed. Any reason why? However, the command build JuMP runs without any error. I am using Julia 1.6.1.

---

## [JuMP only for formulation and CPLEX.jl (or Gurobi.jl) as callable library wrapper?](https://discourse.julialang.org/t/jump-only-for-formulation-and-cplex-jl-or-gurobi-jl-as-callable-library-wrapper/60662)

<div class="topic-metadata">

**Author:** [@rocarvaj](https://discourse.julialang.org/u/rocarvaj)\
**Replies:** 2\
**Last updated:** [May 6, 2021, 6:36pm UTC](https://discourse.julialang.org/t/jump-only-for-formulation-and-cplex-jl-or-gurobi-jl-as-callable-library-wrapper/60662 "2021-05-06T18:36:13Z")

</div>

Hello! I’ve read the documentation for both JuMP and CPLEX.jl (the readme page on Github) but I just want to be 100% if it is possible to do the following: Formulate a MILP (using only constraints supported by the sol…

---

## [Interpolations.jl Discrete CDF to PDF](https://discourse.julialang.org/t/interpolations-jl-discrete-cdf-to-pdf/60124)

<div class="topic-metadata">

**Author:** [@bicepjai](https://discourse.julialang.org/u/bicepjai)\
**Replies:** 10\
**Last updated:** [May 4, 2021, 5:51pm UTC](https://discourse.julialang.org/t/interpolations-jl-discrete-cdf-to-pdf/60124 "2021-05-04T17:51:31Z")

</div>

Say we have discrete CDF values (percentiles from the field for one metric) such as percentile 1 =\> 1.4 … percentile 10 =\> 10.3 … percentile 50 =\> 50.3 … percentile 80 =\> 70.3 … percentile 100 =\> 90.3 I am co…

---

## [Global, non-convex, smooth and differentiable optimisation?](https://discourse.julialang.org/t/global-non-convex-smooth-and-differentiable-optimisation/60460)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 18\
**Last updated:** [May 4, 2021, 8:14am UTC](https://discourse.julialang.org/t/global-non-convex-smooth-and-differentiable-optimisation/60460 "2021-05-04T08:14:26Z")

</div>

I do have a loss function that : Is expressed as \\lVert \\mathbf y - \\mathbf A'\\mathbf p(\\mathbf x)\\rVert\_2^2, where \\mathbf y is a simple vector, \\mathbf A is a simple matrix (lower-triangular), and p\_1,...,p\_m are nas…

---

## [JuMP - defining problem by composing functions/expressions and mapping over collection](https://discourse.julialang.org/t/jump-defining-problem-by-composing-functions-expressions-and-mapping-over-collection/52568)

<div class="topic-metadata">

**Author:** [@NickRedwood](https://discourse.julialang.org/u/NickRedwood)\
**Replies:** 13\
**Last updated:** [May 4, 2021, 5:01am UTC](https://discourse.julialang.org/t/jump-defining-problem-by-composing-functions-expressions-and-mapping-over-collection/52568 "2021-05-04T05:01:15Z")

</div>

Hi, I’m new to both Julia and JuMP. Experience in C#, Scala and I like functional programming. Would love some help to get in to Julia optimisation. How do I compose functions or expressions in JuMP? I can make a trivia…

---

## [Help in using Callbacks](https://discourse.julialang.org/t/help-in-using-callbacks/60482)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 1\
**Last updated:** [May 3, 2021, 7:19pm UTC](https://discourse.julialang.org/t/help-in-using-callbacks/60482 "2021-05-03T19:19:07Z")

</div>

Could someone please give me readings or small examples on how GLPK solver callbacks work? I would like to test on the model I’m building but I don’t know where to start. Thanks!

---

## [How to get ALL decision variables value?](https://discourse.julialang.org/t/how-to-get-all-decision-variables-value/60442)

<div class="topic-metadata">

**Author:** [@iiitr](https://discourse.julialang.org/u/iiitr)\
**Replies:** 6\
**Last updated:** [May 3, 2021, 7:18pm UTC](https://discourse.julialang.org/t/how-to-get-all-decision-variables-value/60442 "2021-05-03T19:18:19Z")

</div>

Hi all, I am new in Julia and JuMP.jl I have many decision variables, like, x1, x1, …x999, … if I want to obtain the value of all decision variables now, I may only use the codes as follows: x1 = value.(x1) x2 = val…

---

## [Expression #= none:3 =# should not be used as a variable name](https://discourse.julialang.org/t/expression-none-3-should-not-be-used-as-a-variable-name/60422)

<div class="topic-metadata">

**Author:** [@BYS](https://discourse.julialang.org/u/BYS)\
**Replies:** 4\
**Last updated:** [May 3, 2021, 1:48am UTC](https://discourse.julialang.org/t/expression-none-3-should-not-be-used-as-a-variable-name/60422 "2021-05-03T01:48:16Z")

</div>

If I write using JuMP @variable(pro,begin t1\>=1 t2\>=2 t3\>=3 end) I find a error like this ERROR: LoadError: Expression #= none:3 =# should not be used as a variable name. Use the "anonymous" syntax #= no…

---

## [Which optimization package should I use?](https://discourse.julialang.org/t/which-optimization-package-should-i-use/60230)

<div class="topic-metadata">

**Author:** [@Piotr](https://discourse.julialang.org/u/Piotr)\
**Replies:** 13\
**Last updated:** [May 1, 2021, 3:05pm UTC](https://discourse.julialang.org/t/which-optimization-package-should-i-use/60230 "2021-05-01T15:05:25Z")

</div>

Hello everyone, I have an optimization (minimization) problem\* in Julia to solve and I’m a looking for a package with which, most importantly, I can do it fast. Specifically: the problem is in two variables (but it m…

---

## [No method matching promote\_shape](https://discourse.julialang.org/t/no-method-matching-promote-shape/60021)

<div class="topic-metadata">

**Author:** [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Replies:** 7\
**Last updated:** [April 29, 2021, 6:07am UTC](https://discourse.julialang.org/t/no-method-matching-promote-shape/60021 "2021-04-29T06:07:48Z")

</div>

Here is a small example. using JuMP,Mosek,MosekTools u=rand(3,1) M\_SDP = Model(Mosek.Optimizer) #set\_silent(model) #set\_optimizer\_attribute(M\_SDP, "MSK\_IPAR\_LOG", 0) @variable(M\_SDP,buro\[1:3,1\]) # Z \>= 0, PSD @variable…

---

## [Access infeasible optimization results ( GLPK with semicontinuous variable )](https://discourse.julialang.org/t/access-infeasible-optimization-results-glpk-with-semicontinuous-variable/59972)

<div class="topic-metadata">

**Author:** [@Runhong\_Huang](https://discourse.julialang.org/u/Runhong_Huang)\
**Replies:** 6\
**Last updated:** [April 28, 2021, 9:29pm UTC](https://discourse.julialang.org/t/access-infeasible-optimization-results-glpk-with-semicontinuous-variable/59972 "2021-04-28T21:29:03Z")

</div>

Hi all, I have a question regarding accessing infeasible optimization results. For example, the following optimization does not have a feasible solution. However, despite the infeasibility, it is still able to give the…

---

## [Ipopt Set Attribute](https://discourse.julialang.org/t/ipopt-set-attribute/59982)

<div class="topic-metadata">

**Author:** [@user1200](https://discourse.julialang.org/u/user1200)\
**Replies:** 4\
**Last updated:** [April 28, 2021, 9:28pm UTC](https://discourse.julialang.org/t/ipopt-set-attribute/59982 "2021-04-28T21:28:14Z")

</div>

Hello I got little issue with model = Model(with\_optimizer(Ipopt.Optimizer, tol=1e-9)) #or set\_optimizer\_attribute(model, “constr\_viol\_tol”, 0) #throws this error when called optimize! It is a valid option, but …

---

## [Dual{::ForwardDiff...} type error when JuMP tries autodiff User-defined Function](https://discourse.julialang.org/t/dual-forwarddiff-type-error-when-jump-tries-autodiff-user-defined-function/25639)

<div class="topic-metadata">

**Author:** [@KestutisMa](https://discourse.julialang.org/u/KestutisMa)\
**Replies:** 20\
**Last updated:** [April 28, 2021, 9:26pm UTC](https://discourse.julialang.org/t/dual-forwarddiff-type-error-when-jump-tries-autodiff-user-defined-function/25639 "2021-04-28T21:26:08Z")

</div>

Hi, I am trying to optimize User-defined function with and I got this error: ERROR: LoadError: MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{getfield(JuMP, Symbol("##84#86")){typeof(min\_f)},…

---

## [ForwardDiff and Floats](https://discourse.julialang.org/t/forwarddiff-and-floats/47596)

<div class="topic-metadata">

**Author:** [@danicaratelli](https://discourse.julialang.org/u/danicaratelli)\
**Replies:** 13\
**Last updated:** [April 28, 2021, 2:18pm UTC](https://discourse.julialang.org/t/forwarddiff-and-floats/47596 "2021-04-28T14:18:58Z")

</div>

Hello, I am trying to use Ipopt in JuMP to solve a minimization problem with automatic differentiation. I am aware that I need to specify the types of the inputs as Real rather than Float64 but it’s not clear to me to …

---

## [How to invert variables in the objective of an optimization model](https://discourse.julialang.org/t/how-to-invert-variables-in-the-objective-of-an-optimization-model/60154)

<div class="topic-metadata">

**Author:** [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Replies:** 2\
**Last updated:** [April 28, 2021, 10:16am UTC](https://discourse.julialang.org/t/how-to-invert-variables-in-the-objective-of-an-optimization-model/60154 "2021-04-28T10:16:38Z")

</div>

The optimization problem is： minimize log detP^−1 subject to ||Pu+ buro||\\2≤ 1, where P is a semidefinite matrix, buro is Variable, u is known. The code is: using Convex, SCS, LinearAlgebra if VERSION \< v"1.2.0-DEV.…

---

## [Conditional inside a function to be optimized](https://discourse.julialang.org/t/conditional-inside-a-function-to-be-optimized/48563)

<div class="topic-metadata">

**Author:** [@danuzco](https://discourse.julialang.org/u/danuzco)\
**Replies:** 18\
**Last updated:** [April 28, 2021, 9:18am UTC](https://discourse.julialang.org/t/conditional-inside-a-function-to-be-optimized/48563 "2021-04-28T09:18:41Z")

</div>

I’m trying to maximize this function function C\_opt(s) pax, pby = OffsetArray( zeros(Float64, (2,2)), (0:1,0:1) ), OffsetArray( zeros(Float64, (2,2)), (0:1,0:1) ) Cmax = 0 for l=0:15 pax\[0,…

---

## [Constraint nonlinear problem](https://discourse.julialang.org/t/constraint-nonlinear-problem/60033)

<div class="topic-metadata">

**Author:** [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)\
**Replies:** 7\
**Last updated:** [April 28, 2021, 8:04am UTC](https://discourse.julialang.org/t/constraint-nonlinear-problem/60033 "2021-04-28T08:04:23Z")

</div>

I have tried GalacticOptim.jl but I did not manage to get the constraints to work. using GalacticOptim, Optim using Plots rosenbrock(x, p) = (p\[1\] - x\[1\])^2 + p\[2\] \* (x\[2\] - x\[1\]^2)^2 x0 = zeros(2) p = \[1.0, 100.0\] c…

---

## [Optimizing user-defined objective functions with no direct expression](https://discourse.julialang.org/t/optimizing-user-defined-objective-functions-with-no-direct-expression/60096)

<div class="topic-metadata">

**Author:** [@Fathya.Salih](https://discourse.julialang.org/u/Fathya.Salih)\
**Replies:** 1\
**Last updated:** [April 27, 2021, 6:48pm UTC](https://discourse.julialang.org/t/optimizing-user-defined-objective-functions-with-no-direct-expression/60096 "2021-04-27T18:48:40Z")

</div>

I have a Monte Carlo simulation that takes in a set of variables x1, x2, etc. and returns a number of counters that can be used to calculate the actual objective function f() I wanted to use JuMP to optimize the dimensi…

---

## [Solver argument (MosekModel) must be an AbstractMathProgSolver](https://discourse.julialang.org/t/solver-argument-mosekmodel-must-be-an-abstractmathprogsolver/59967)

<div class="topic-metadata">

**Author:** [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Replies:** 6\
**Last updated:** [April 26, 2021, 7:20am UTC](https://discourse.julialang.org/t/solver-argument-mosekmodel-must-be-an-abstractmathprogsolver/59967 "2021-04-26T07:20:33Z")

</div>

This is an SDP problem or Mosek problem. using JuMP, Mosek, Plots, MosekTools # 生成一个200x200的稠密随机对称矩阵Q Q = randn(200,200) Q = Q + Q' # 负责进行抽样实验的函数 function SampleBQP(Q,N) naive\_fval = zeros(N,1) GW\_fval = zeros(N…

---

## [Why is Optim.optimize() throwing an exception if I provide initial\_invH?](https://discourse.julialang.org/t/why-is-optim-optimize-throwing-an-exception-if-i-provide-initial-invh/59872)

<div class="topic-metadata">

**Author:** [@marcus-waldman](https://discourse.julialang.org/u/marcus-waldman)\
**Replies:** 4\
**Last updated:** [April 25, 2021, 10:06am UTC](https://discourse.julialang.org/t/why-is-optim-optimize-throwing-an-exception-if-i-provide-initial-invh/59872 "2021-04-25T10:06:59Z")

</div>

I’m trying to implement the EM algorithm to estimate parameters in a large model The EM algorithm requires a lot of back and forth updating some parameters of interest and then optimizing an objective function based on t…

---

## [Error building \`Gurobi\`](https://discourse.julialang.org/t/error-building-gurobi/59852)

<div class="topic-metadata">

**Author:** [@zlq178](https://discourse.julialang.org/u/zlq178)\
**Replies:** 6\
**Last updated:** [April 25, 2021, 7:38am UTC](https://discourse.julialang.org/t/error-building-gurobi/59852 "2021-04-25T07:38:00Z")

</div>

I have installed Gurobi.jl(v"0.8.1"), When I build it, some wrong happened. Julia version:JuliaPro 1.5.1-1. What should I do next? Thank you for your help. julia\>ENV\["GUROBI\_HOME"\] = "C:\\\\gurobi911\\\\win64" julia\>import…

---

## [Should models revert to "unoptimized" if they are modified?](https://discourse.julialang.org/t/should-models-revert-to-unoptimized-if-they-are-modified/59627)

<div class="topic-metadata">

**Author:** [@gleyland](https://discourse.julialang.org/u/gleyland)\
**Replies:** 4\
**Last updated:** [April 23, 2021, 9:22pm UTC](https://discourse.julialang.org/t/should-models-revert-to-unoptimized-if-they-are-modified/59627 "2021-04-23T21:22:05Z")

</div>

If I optimize! a model with GLPK, then add a constraint, I can still access the solution: using JuMP, GLPK, Clp; M = Model(); @variable M A\[1:2\] \>= 0; @constraint M limit1 sum(a for a in A) \<= 1; @objective M Max sum(a …

---

## [AMPL to jump](https://discourse.julialang.org/t/ampl-to-jump/56760)

<div class="topic-metadata">

**Author:** [@aaldik](https://discourse.julialang.org/u/aaldik)\
**Replies:** 4\
**Last updated:** [April 22, 2021, 7:31pm UTC](https://discourse.julialang.org/t/ampl-to-jump/56760 "2021-04-22T19:31:29Z")

</div>

Dears I have a question regarding solving a problem that was written in AMPL using Jump. Is there a specific function that allows for translating an ampl file into a recognized file by jump? what is the most efficient w…

---

## [Providing Objective, Gradient and Hessian to the Ipopt wrapper using a single function?](https://discourse.julialang.org/t/providing-objective-gradient-and-hessian-to-the-ipopt-wrapper-using-a-single-function/59675)

<div class="topic-metadata">

**Author:** [@dadada\_dadada](https://discourse.julialang.org/u/dadada_dadada)\
**Replies:** 12\
**Last updated:** [April 22, 2021, 1:30pm UTC](https://discourse.julialang.org/t/providing-objective-gradient-and-hessian-to-the-ipopt-wrapper-using-a-single-function/59675 "2021-04-22T13:30:23Z")

</div>

Hello, I want to provide analytic expressions for the objective function, the gradient and the Hessian of the problem using a single function instead of three different functions. I am using Ipopt via the C wrapper in h…

---

## [DiffEqFlux.sciml\_train fails with save\_idxs keyword](https://discourse.julialang.org/t/diffeqflux-sciml-train-fails-with-save-idxs-keyword/56864)

<div class="topic-metadata">

**Author:** [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Replies:** 3\
**Last updated:** [April 22, 2021, 7:39am UTC](https://discourse.julialang.org/t/diffeqflux-sciml-train-fails-with-save-idxs-keyword/56864 "2021-04-22T07:39:05Z")

</div>

Training via DiffEqFlux fails when save\_idxs keyword is used within the loss function. Differentiation seems to be the problem. Evaluation of the loss function works fine. MWE is taken from the docs using DifferentialE…

---

## [Solving a constraint lasso](https://discourse.julialang.org/t/solving-a-constraint-lasso/59727)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 2\
**Last updated:** [April 21, 2021, 3:33pm UTC](https://discourse.julialang.org/t/solving-a-constraint-lasso/59727 "2021-04-21T15:33:25Z")

</div>

Hi, Recently i had the problem of solving a constraint lasso, much like the one described in this paper. The paper refers to a julia package, ConstrainedLasso.jl, that is unfornutely not updated since julia 0.6. With so…

---

## [Adding a SOS2 constraint for a variable which is defined over a DenseAxisArray?](https://discourse.julialang.org/t/adding-a-sos2-constraint-for-a-variable-which-is-defined-over-a-denseaxisarray/59637)

<div class="topic-metadata">

**Author:** [@Mastomaki](https://discourse.julialang.org/u/Mastomaki)\
**Replies:** 2\
**Last updated:** [April 21, 2021, 8:21am UTC](https://discourse.julialang.org/t/adding-a-sos2-constraint-for-a-variable-which-is-defined-over-a-denseaxisarray/59637 "2021-04-21T08:21:48Z")

</div>

Hello! I wonder how to add a SOS2 constraint with JuMP for a variable which is defined over a DenseAxisArray or SparseAxisArray? For example: using JuMP mymod = Model(); #sets node = \["n1", "n2", "n3"\] #declare var…

---

## [Adding variables with the Clp solver in MathOptInterface](https://discourse.julialang.org/t/adding-variables-with-the-clp-solver-in-mathoptinterface/59540)

<div class="topic-metadata">

**Author:** [@leejm516](https://discourse.julialang.org/u/leejm516)\
**Replies:** 4\
**Last updated:** [April 21, 2021, 5:55am UTC](https://discourse.julialang.org/t/adding-variables-with-the-clp-solver-in-mathoptinterface/59540 "2021-04-21T05:55:11Z")

</div>

Hi, I am trying to be familiar with MathOptInterface, in order to revise a package that has been written with MathProgBase. When I tried to add a variable into the Clp model, I got the following error. julia\> using M…

---

## [Bounding Correlation Coefficients for Multiple Problems with JuMP](https://discourse.julialang.org/t/bounding-correlation-coefficients-for-multiple-problems-with-jump/59690)

<div class="topic-metadata">

**Author:** [@phantom](https://discourse.julialang.org/u/phantom)\
**Replies:** 1\
**Last updated:** [April 20, 2021, 7:57pm UTC](https://discourse.julialang.org/t/bounding-correlation-coefficients-for-multiple-problems-with-jump/59690 "2021-04-20T19:57:56Z")

</div>

Hi this is a very elementary questions but I’m still trying to understand the code from this example for the correlation problem. The example I am using is the bounding correlation coefficients problem from “Convex Opti…

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

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