# Optimization (Mathematical)

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

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

**Page:** 77

---

## [Least squares fitting that accounts for covariance matrix of all input parameters](https://discourse.julialang.org/t/least-squares-fitting-that-accounts-for-covariance-matrix-of-all-input-parameters/64775)

<div class="topic-metadata">

**Author:** [@nluetts](https://discourse.julialang.org/u/nluetts)\
**Replies:** 22\
**Last updated:** [August 4, 2021, 10:24am UTC](https://discourse.julialang.org/t/least-squares-fitting-that-accounts-for-covariance-matrix-of-all-input-parameters/64775 "2021-08-04T10:24:39Z")

</div>

Hi, I am thinking about writing a package that implements a generalized least squares fitting method or perhaps seek to contribute somewhere where it might fit. Before I write more than my prototype, I wanted to double …

---

## [Using Zygote with custom CUDA kernels](https://discourse.julialang.org/t/using-zygote-with-custom-cuda-kernels/65688)

<div class="topic-metadata">

**Author:** [@oscarknagg](https://discourse.julialang.org/u/oscarknagg)\
**Replies:** 3\
**Last updated:** [August 3, 2021, 1:11pm UTC](https://discourse.julialang.org/t/using-zygote-with-custom-cuda-kernels/65688 "2021-08-03T13:11:37Z")

</div>

Hi all. I’m wondering if it’s possible to use Zygote to automatically differentiate CUDA kernels that I’ve defined. A minimal (not-quite working) example is below. My actual use case is not as trivial but this is essenti…

---

## [Problem optimizing a 2 variable function (Optim .jl)](https://discourse.julialang.org/t/problem-optimizing-a-2-variable-function-optim-jl/65655)

<div class="topic-metadata">

**Author:** [@AndresCasillas](https://discourse.julialang.org/u/AndresCasillas)\
**Replies:** 4\
**Last updated:** [August 2, 2021, 2:05pm UTC](https://discourse.julialang.org/t/problem-optimizing-a-2-variable-function-optim-jl/65655 "2021-08-02T14:05:50Z")

</div>

Hi! I want to optimize a 2 variable function using Optim.jl. I’ve read the documentation but I still can’t figure it out. I hope someone can help me. (I’m using Optim and using MittagLeffler on a Jupyter notebook with Ju…

---

## [Nonlinear callback cplex](https://discourse.julialang.org/t/nonlinear-callback-cplex/65660)

<div class="topic-metadata">

**Author:** [@Luca](https://discourse.julialang.org/u/Luca)\
**Replies:** 1\
**Last updated:** [August 2, 2021, 8:41am UTC](https://discourse.julialang.org/t/nonlinear-callback-cplex/65660 "2021-08-02T08:41:13Z")

</div>

Dear all, I would like to implement non linear lazy constraint for a cplex model. For instance I would like to implement the following code: using CPLEX, JuMP model = Model(CPLEX.Optimizer) @variable(model, x \<= 10, In…

---

## [Variables multiplication with JuMP.jl](https://discourse.julialang.org/t/variables-multiplication-with-jump-jl/65661)

<div class="topic-metadata">

**Author:** [@ver\_kh](https://discourse.julialang.org/u/ver_kh)\
**Replies:** 1\
**Last updated:** [August 2, 2021, 8:40am UTC](https://discourse.julialang.org/t/variables-multiplication-with-jump-jl/65661 "2021-08-02T08:40:30Z")

</div>

Hi all, I’m trying to multiply three JuMP variables within a function but getting an error: LoadError: Cannot multiply a quadratic expression by a variable Here is the simplified version of code: using JuMP, Ipopt f…

---

## [Moving from LMI toolbox (Matlab) to JuliaOpt](https://discourse.julialang.org/t/moving-from-lmi-toolbox-matlab-to-juliaopt/21001)

<div class="topic-metadata">

**Author:** [@glemieux](https://discourse.julialang.org/u/glemieux)\
**Replies:** 18\
**Last updated:** [July 31, 2021, 5:31pm UTC](https://discourse.julialang.org/t/moving-from-lmi-toolbox-matlab-to-juliaopt/21001 "2021-07-31T17:31:09Z")

</div>

Does anyone have experience in moving from Matlab’s LMI toolbox to the various JuliaOpt packages? I’m taking a non-linear dynamics course (AAE666 at Purdue) and we’ve just been introduced to linear matrix inequalities i…

---

## [Pluralisation of @NLparameter](https://discourse.julialang.org/t/pluralisation-of-nlparameter/61060)

<div class="topic-metadata">

**Author:** [@path-doc](https://discourse.julialang.org/u/path-doc)\
**Replies:** 4\
**Last updated:** [July 30, 2021, 9:49pm UTC](https://discourse.julialang.org/t/pluralisation-of-nlparameter/61060 "2021-07-30T21:49:20Z")

</div>

Hi I’m enjoying using JuMP, is there any reason why there is no pluralisation of @NLparameter ? I’ve had a peek at the macro file and the format of variables, constraints and expressions are the same. What would be th…

---

## [JuMP & SumOfSquares generate SDPs with ~18x more constraints than YALMIP](https://discourse.julialang.org/t/jump-sumofsquares-generate-sdps-with-18x-more-constraints-than-yalmip/65377)

<div class="topic-metadata">

**Author:** [@ciba12](https://discourse.julialang.org/u/ciba12)\
**Replies:** 15\
**Last updated:** [July 30, 2021, 1:45pm UTC](https://discourse.julialang.org/t/jump-sumofsquares-generate-sdps-with-18x-more-constraints-than-yalmip/65377 "2021-07-30T13:45:13Z")

</div>

Hi, I am attempting to rewrite MATLAB code, which is slow due to Yalmip’s parsing speed. The resulting problem that gets sent to the solver from JuMP is much larger (and slower to solve) than Yalmip’s output. I don’t t…

---

## [Problem with Ntuple and VariableRef when using NLconstraint in JuMP](https://discourse.julialang.org/t/problem-with-ntuple-and-variableref-when-using-nlconstraint-in-jump/65200)

<div class="topic-metadata">

**Author:** [@ylish](https://discourse.julialang.org/u/ylish)\
**Replies:** 4\
**Last updated:** [July 30, 2021, 11:27am UTC](https://discourse.julialang.org/t/problem-with-ntuple-and-variableref-when-using-nlconstraint-in-jump/65200 "2021-07-30T11:27:11Z")

</div>

Hi everybody, Below is a simplified part of my code, which attempts to do nonlinear optimization using JuMP . I have both cost and constraints which require vector input. However I am having issues with NLconstraint. Wo…

---

## [How to remove overhead due to nested optimization with Optim package](https://discourse.julialang.org/t/how-to-remove-overhead-due-to-nested-optimization-with-optim-package/65439)

<div class="topic-metadata">

**Author:** [@Joris\_Pinkse](https://discourse.julialang.org/u/Joris_Pinkse)\
**Replies:** 7\
**Last updated:** [July 29, 2021, 7:36pm UTC](https://discourse.julialang.org/t/how-to-remove-overhead-due-to-nested-optimization-with-optim-package/65439 "2021-07-29T19:36:52Z")

</div>

Consider minimizing f(x, y1, y2) using a nested procedure. In an inner loop y1, y2 are minimized as a function of x and in the outer loop f( x, y1(x), y2(x) ) is minimized where y1(x), y2(x) are the solutions to the inn…

---

## [Getting started: MIP variables and datastructure](https://discourse.julialang.org/t/getting-started-mip-variables-and-datastructure/63766)

<div class="topic-metadata">

**Author:** [@Annette\_F](https://discourse.julialang.org/u/Annette_F)\
**Replies:** 11\
**Last updated:** [July 29, 2021, 11:42am UTC](https://discourse.julialang.org/t/getting-started-mip-variables-and-datastructure/63766 "2021-07-29T11:42:33Z")

</div>

Hi all, In short; I’m trying to find if and how I can formulate a MIP on a datastructure. I have a set of orders ( with handling time, start location, end location and each location a timewindow ) And I want to combin…

---

## [\`num\_constraints\` to return the total number of constraints](https://discourse.julialang.org/t/num-constraints-to-return-the-total-number-of-constraints/65488)

<div class="topic-metadata">

**Author:** [@raphaelsaavedra](https://discourse.julialang.org/u/raphaelsaavedra)\
**Replies:** 2\
**Last updated:** [July 29, 2021, 11:08am UTC](https://discourse.julialang.org/t/num-constraints-to-return-the-total-number-of-constraints/65488 "2021-07-29T11:08:37Z")

</div>

Apparently num\_constraints only accepts concrete types, which means it’s not straightforward to return the total number of constraints in the model. Is there a straightforward way of doing this, or do we need to resort t…

---

## [My ConstraintSolver.jl page](https://discourse.julialang.org/t/my-constraintsolver-jl-page/65430)

<div class="topic-metadata">

**Author:** [@Hakan\_Kjellerstrand](https://discourse.julialang.org/u/Hakan_Kjellerstrand)\
**Replies:** 2\
**Last updated:** [July 28, 2021, 12:17pm UTC](https://discourse.julialang.org/t/my-constraintsolver-jl-page/65430 "2021-07-28T12:17:38Z")

</div>

One of my (other) Julia-related interests is Ole Kröger’s Home · ConstraintSolver . My ConstraintSolver.jl models are here: My Julia ConstraintSolver.jl page , also available at https://github.com/hakank/hakank/tree/mas…

---

## [Generic Affine Expression in a constraint](https://discourse.julialang.org/t/generic-affine-expression-in-a-constraint/65275)

<div class="topic-metadata">

**Author:** [@Daniel\_Villamar](https://discourse.julialang.org/u/Daniel_Villamar)\
**Replies:** 1\
**Last updated:** [July 26, 2021, 9:00am UTC](https://discourse.julialang.org/t/generic-affine-expression-in-a-constraint/65275 "2021-07-26T09:00:34Z")

</div>

I am having a hard time with a NL model that I am creating. My model uses matrices and therefore my variable and constraints are arrays. I want to create an array of constraints that includes some calculations with my v…

---

## [JuMP is slow in generating block PSD constraints](https://discourse.julialang.org/t/jump-is-slow-in-generating-block-psd-constraints/65186)

<div class="topic-metadata">

**Author:** [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Replies:** 2\
**Last updated:** [July 24, 2021, 2:48pm UTC](https://discourse.julialang.org/t/jump-is-slow-in-generating-block-psd-constraints/65186 "2021-07-24T14:48:41Z")

</div>

Could an expert help me speed up the following code? In particular, Have I used the performance tips (https://jump.dev/JuMP.jl/stable/tutorials/Getting%20started/performance\_tips/) correctly? That is only generate exp…

---

## [Convergence in Optim questions](https://discourse.julialang.org/t/convergence-in-optim-questions/65139)

<div class="topic-metadata">

**Author:** [@Michael\_Barmann](https://discourse.julialang.org/u/Michael_Barmann)\
**Replies:** 3\
**Last updated:** [July 23, 2021, 7:56pm UTC](https://discourse.julialang.org/t/convergence-in-optim-questions/65139 "2021-07-23T19:56:52Z")

</div>

I have a few questions regarding convergence in Optim: When an optimization finishes and prints the convergence report, at the top it says either “success” or “failure”. Does this refer to whether or not the algorithm …

---

## [Newton solution from PowerModels.jl](https://discourse.julialang.org/t/newton-solution-from-powermodels-jl/64356)

<div class="topic-metadata">

**Author:** [@Mariana](https://discourse.julialang.org/u/Mariana)\
**Replies:** 11\
**Last updated:** [July 23, 2021, 6:08pm UTC](https://discourse.julialang.org/t/newton-solution-from-powermodels-jl/64356 "2021-07-23T18:08:00Z")

</div>

Hello. I’m using PowerModels.jl to run some power flow studies and I’m interested in comparing the results obtained from the JuMP solution to the Newton solution. In most cases, those results are the same; however, when…

---

## [Sudden stop of parallel optimization with JuMP and Juniper](https://discourse.julialang.org/t/sudden-stop-of-parallel-optimization-with-jump-and-juniper/65031)

<div class="topic-metadata">

**Author:** [@jairorua](https://discourse.julialang.org/u/jairorua)\
**Replies:** 8\
**Last updated:** [July 23, 2021, 7:06am UTC](https://discourse.julialang.org/t/sudden-stop-of-parallel-optimization-with-jump-and-juniper/65031 "2021-07-23T07:06:14Z")

</div>

I have an MINLP problem that I model and solve in parallel in JuMP using Juniper with Cbc and IPOPT as mip and nlp solvers, respectively. I cannot provide an MWE, but my code works fine with shorter simulations (this mig…

---

## [ANN: JuMP-dev 2021](https://discourse.julialang.org/t/ann-jump-dev-2021/60406)

<div class="topic-metadata">

**Author:** [@odow](https://discourse.julialang.org/u/odow)\
**Replies:** 5\
**Last updated:** [July 23, 2021, 6:19am UTC](https://discourse.julialang.org/t/ann-jump-dev-2021/60406 "2021-07-23T06:19:21Z")

</div>

Dear all, We are pleased to announce that JuMP-dev 2021 will be co-located with JuliaCon 2021! The purpose of JuMP-dev is to bring together students, researchers, and practitioners with interests in the software aspect…

---

## [Question regarding size of variable with JuMP and Ipopt](https://discourse.julialang.org/t/question-regarding-size-of-variable-with-jump-and-ipopt/65128)

<div class="topic-metadata">

**Author:** [@ylish](https://discourse.julialang.org/u/ylish)\
**Replies:** 11\
**Last updated:** [July 22, 2021, 11:55pm UTC](https://discourse.julialang.org/t/question-regarding-size-of-variable-with-jump-and-ipopt/65128 "2021-07-22T23:55:58Z")

</div>

Hello everybody, I am new to JuMP and optimization using Julia and I am wondering if someone could explain to me why the following occurs. If I run the toy problem below with size\_overall = 100 it takes some time, call …

---

## [Layout pv panel optimization](https://discourse.julialang.org/t/layout-pv-panel-optimization/64505)

<div class="topic-metadata">

**Author:** [@alfajar\_nugraha](https://discourse.julialang.org/u/alfajar_nugraha)\
**Replies:** 8\
**Last updated:** [July 22, 2021, 8:54am UTC](https://discourse.julialang.org/t/layout-pv-panel-optimization/64505 "2021-07-22T08:54:17Z")

</div>

matrix for layout pv panel optimization

---

## [Getting NaN output from JuMP variable after solving](https://discourse.julialang.org/t/getting-nan-output-from-jump-variable-after-solving/65026)

<div class="topic-metadata">

**Author:** [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)\
**Replies:** 4\
**Last updated:** [July 21, 2021, 1:22pm UTC](https://discourse.julialang.org/t/getting-nan-output-from-jump-variable-after-solving/65026 "2021-07-21T13:22:20Z")

</div>

Hi All, I am running a linear program with Gurobi. The variable is set as @variable(mod2,0\<=L\_time\_bC\[b in 1:18, c in 1:3\] ) \`\`\` I am using julia 1.62 with \[c52e3926\] Atom v0.12.32 \[336ed68f\] CSV v0.8.5 \[9961bab8\] …

---

## [@expression v.s. @constraint (when to use what)](https://discourse.julialang.org/t/expression-v-s-constraint-when-to-use-what/65008)

<div class="topic-metadata">

**Author:** [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Replies:** 5\
**Last updated:** [July 21, 2021, 3:11am UTC](https://discourse.julialang.org/t/expression-v-s-constraint-when-to-use-what/65008 "2021-07-21T03:11:57Z")

</div>

I’m pretty sure this question will be redundant, but I could not find an answer anywhere. My question is more like asking a style guide so that my code can avoid any unnecessary build/calculation time. Q1. My guess is b…

---

## [Non-linear expressions in optimization](https://discourse.julialang.org/t/non-linear-expressions-in-optimization/64969)

<div class="topic-metadata">

**Author:** [@Daniel\_Villamar](https://discourse.julialang.org/u/Daniel_Villamar)\
**Replies:** 5\
**Last updated:** [July 20, 2021, 4:33pm UTC](https://discourse.julialang.org/t/non-linear-expressions-in-optimization/64969 "2021-07-20T16:33:51Z")

</div>

Hi! I use the version JuMP v0.21.4 and Julia v1.4.2 and I optimizing with Ipopt I ve been working in a non-linear optimization model. Sorry for not presenting a MWE but my code is full of things. I have a problems wit…

---

## [Performance issues JuMP, GLPK](https://discourse.julialang.org/t/performance-issues-jump-glpk/64971)

<div class="topic-metadata">

**Author:** [@Annette\_F](https://discourse.julialang.org/u/Annette_F)\
**Replies:** 4\
**Last updated:** [July 20, 2021, 1:20pm UTC](https://discourse.julialang.org/t/performance-issues-jump-glpk/64971 "2021-07-20T13:20:12Z")

</div>

Goodmorning, I have created the following MIP which I assumed is small and would only take seconds to built and solve. I’ve been working with CPLEX/Gurobi quite a lot, just not in combination with Julia, so I expected …

---

## [Range constraint](https://discourse.julialang.org/t/range-constraint/64819)

<div class="topic-metadata">

**Author:** [@mjanun](https://discourse.julialang.org/u/mjanun)\
**Replies:** 10\
**Last updated:** [July 17, 2021, 9:35pm UTC](https://discourse.julialang.org/t/range-constraint/64819 "2021-07-17T21:35:16Z")

</div>

I have a constraint that can be either a range or an equality depending upon whether a user passes a range (i.e. two arguments) or a single value as a constraint. I convert the range constraint to an equality using the s…

---

## [Optimization with JuMP and KNITRO](https://discourse.julialang.org/t/optimization-with-jump-and-knitro/64644)

<div class="topic-metadata">

**Author:** [@Mario\_mushroom](https://discourse.julialang.org/u/Mario_mushroom)\
**Replies:** 2\
**Last updated:** [July 14, 2021, 8:55pm UTC](https://discourse.julialang.org/t/optimization-with-jump-and-knitro/64644 "2021-07-14T20:55:58Z")

</div>

Hey everyone, I was trying to do a non-linear optimization problem with KNITRO. The JuMP model seems fine: A JuMP Model Minimization problem with: Variables: 270 Objective function type: GenericQuadExpr{Float64,Variable…

---

## [How to evaluate a JuMP model given a candidate solution?](https://discourse.julialang.org/t/how-to-evaluate-a-jump-model-given-a-candidate-solution/64555)

<div class="topic-metadata">

**Author:** [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Replies:** 5\
**Last updated:** [July 14, 2021, 8:58am UTC](https://discourse.julialang.org/t/how-to-evaluate-a-jump-model-given-a-candidate-solution/64555 "2021-07-14T08:58:04Z")

</div>

Supposing I have built an optimization model in JuMP, how can I evaluate its objective with a candidate solution? This solution may be obtained manually or from other tools. That is, how to get objective(x) if I have a t…

---

## [How to add a constraint with neural network in a JuMP (PowerModels) model](https://discourse.julialang.org/t/how-to-add-a-constraint-with-neural-network-in-a-jump-powermodels-model/64593)

<div class="topic-metadata">

**Author:** [@oli1119](https://discourse.julialang.org/u/oli1119)\
**Replies:** 4\
**Last updated:** [July 14, 2021, 8:14am UTC](https://discourse.julialang.org/t/how-to-add-a-constraint-with-neural-network-in-a-jump-powermodels-model/64593 "2021-07-14T08:14:16Z")

</div>

Hello, I want to create a constraint: a variable var1 is equal to the output of a torch artificial neural network whose input is another variable var2. ------- This following function is my ann prediction (the ANN has …

---

## [Fix vs @constraint in JuMP](https://discourse.julialang.org/t/fix-vs-constraint-in-jump/64509)

<div class="topic-metadata">

**Author:** [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Replies:** 2\
**Last updated:** [July 12, 2021, 9:02pm UTC](https://discourse.julialang.org/t/fix-vs-constraint-in-jump/64509 "2021-07-12T21:02:35Z")

</div>

Dear All, I am trying to solve a mixed-integer optimization problem in JuMP and Gurobi. I have a variable x\_{i,j} over i,j \\in \\{1,2,\\ldots,n\\}, where n is a fairly large number. However, for this particular problem, ov…

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

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