# Optimization (Mathematical)

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

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

**Page:** 34

---

## [Gurobi 11.0 support](https://discourse.julialang.org/t/gurobi-11-0-support/108667)

<div class="topic-metadata">

**Author:** [@Petra123](https://discourse.julialang.org/u/Petra123)\
**Replies:** 2\
**Last updated:** [January 12, 2024, 3:31am UTC](https://discourse.julialang.org/t/gurobi-11-0-support/108667 "2024-01-12T03:31:34Z")

</div>

Hi, I am new to Julia, and trying to set it up in my wsl environment. I want to use julia for stochastic programming, using the package StochasticPrograms.jl to be exact. I tried setting up Gurobi. I installed the laste…

---

## [Ensuring Forward and Backward Differentiability in Classical Inversion Process](https://discourse.julialang.org/t/ensuring-forward-and-backward-differentiability-in-classical-inversion-process/108609)

<div class="topic-metadata">

**Author:** [@vivekag7](https://discourse.julialang.org/u/vivekag7)\
**Replies:** 1\
**Last updated:** [January 10, 2024, 8:18am UTC](https://discourse.julialang.org/t/ensuring-forward-and-backward-differentiability-in-classical-inversion-process/108609 "2024-01-10T08:18:57Z")

</div>

Hi everyone, I am going to start off with some context and then proceed with describing my problem, so you get a better understanding of the scope. I am currently working on creating a classical inversion in the field …

---

## [Fix variables or add as a contraint?](https://discourse.julialang.org/t/fix-variables-or-add-as-a-contraint/108594)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 5\
**Last updated:** [January 9, 2024, 11:04pm UTC](https://discourse.julialang.org/t/fix-variables-or-add-as-a-contraint/108594 "2024-01-09T23:04:48Z")

</div>

Dear all, I have an Integer (binary) problem where I want to fix some variables to obtain an heuristic solution. I use to add the constraint: @constraint(model, x\[j\] == 1) if I want to fix x\_j in 1. I would like to …

---

## [Tuning parameters](https://discourse.julialang.org/t/tuning-parameters/108573)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 1\
**Last updated:** [January 9, 2024, 8:44pm UTC](https://discourse.julialang.org/t/tuning-parameters/108573 "2024-01-09T20:44:45Z")

</div>

I need to solve a hard MIP model using Gurobi. There is a tool to set the best parameters combination to solve this problem called “Parameter Tunning”. How can I find parameter tuning using Julia? Here, I present a simp…

---

## [Nonconvex.jl reproduces the initial vector as the optimized vector](https://discourse.julialang.org/t/nonconvex-jl-reproduces-the-initial-vector-as-the-optimized-vector/107094)

<div class="topic-metadata">

**Author:** [@AP\_profile](https://discourse.julialang.org/u/AP_profile)\
**Replies:** 33\
**Last updated:** [January 8, 2024, 7:14am UTC](https://discourse.julialang.org/t/nonconvex-jl-reproduces-the-initial-vector-as-the-optimized-vector/107094 "2024-01-08T07:14:34Z")

</div>

Hi all, I have been attempting to use Noncovex.jl for an optimization problem, defined as follows: using AbstractDifferentiation using ForwardDiff using Nonconvex Nonconvex.@load NLopt start\_vec = zeros(11) x = start\_…

---

## [Value.(x) with direct mode](https://discourse.julialang.org/t/value-x-with-direct-mode/108428)

<div class="topic-metadata">

**Author:** [@SingingKim](https://discourse.julialang.org/u/SingingKim)\
**Replies:** 2\
**Last updated:** [January 7, 2024, 4:50am UTC](https://discourse.julialang.org/t/value-x-with-direct-mode/108428 "2024-01-07T04:50:57Z")

</div>

I’m trying to reconstruct the optimization problem from the LP file that was generated from some commercial tool that has limited flexibility. I found a few relevant postings here and learned that I have to use the dire…

---

## [Gurobi: best bound 0.0e+00, gap 100.0000%](https://discourse.julialang.org/t/gurobi-best-bound-0-0e-00-gap-100-0000/108191)

<div class="topic-metadata">

**Author:** [@quais](https://discourse.julialang.org/u/quais)\
**Replies:** 7\
**Last updated:** [January 6, 2024, 9:13pm UTC](https://discourse.julialang.org/t/gurobi-best-bound-0-0e-00-gap-100-0000/108191 "2024-01-06T21:13:28Z")

</div>

Hi, I am currently working on a cost minimization model. However, I have the problem when solving with Gurobi (v10) that my best bounds is stuck at 0.0 all the time. As a result, my gap remains constant at 100%. Addition…

---

## [JuMP: Good first issue](https://discourse.julialang.org/t/jump-good-first-issue/108313)

<div class="topic-metadata">

**Author:** [@Paulnkk](https://discourse.julialang.org/u/Paulnkk)\
**Replies:** 3\
**Last updated:** [January 4, 2024, 12:05pm UTC](https://discourse.julialang.org/t/jump-good-first-issue/108313 "2024-01-04T12:05:05Z")

</div>

Hey, I am new in the jump community and wanted to learn more about it due to various applications for my phd research. I have some developer experience in cvxpy and happy to learn more! Here I wanted to ask if there are …

---

## [Convex.jl, possible to have a product as an operation?](https://discourse.julialang.org/t/convex-jl-possible-to-have-a-product-as-an-operation/108101)

<div class="topic-metadata">

**Author:** [@1m1](https://discourse.julialang.org/u/1m1)\
**Replies:** 8\
**Last updated:** [December 30, 2023, 5:21pm UTC](https://discourse.julialang.org/t/convex-jl-possible-to-have-a-product-as-an-operation/108101 "2023-12-30T17:21:17Z")

</div>

My constraints have a product. It is a convex set. I cannot find an operation to simply have the product of the components of a vector (or matrix/tensor in general). Is that not possible?

---

## [Conceptual Question on GPU Integration with Optimization.jl](https://discourse.julialang.org/t/conceptual-question-on-gpu-integration-with-optimization-jl/108165)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 2\
**Last updated:** [December 29, 2023, 11:55pm UTC](https://discourse.julialang.org/t/conceptual-question-on-gpu-integration-with-optimization-jl/108165 "2023-12-29T23:55:05Z")

</div>

This is more of a conceptual question about CUDA integration (CUDA.jl) with Optimization.jl Does the CUDA integration speed up both compilation AND solving time, or just solving time?

---

## [Multi-objective: have no optimal solutions after changing the priority of the objectives](https://discourse.julialang.org/t/multi-objective-have-no-optimal-solutions-after-changing-the-priority-of-the-objectives/108078)

<div class="topic-metadata">

**Author:** [@Shaolin](https://discourse.julialang.org/u/Shaolin)\
**Replies:** 3\
**Last updated:** [December 29, 2023, 2:38am UTC](https://discourse.julialang.org/t/multi-objective-have-no-optimal-solutions-after-changing-the-priority-of-the-objectives/108078 "2023-12-29T02:38:59Z")

</div>

Hi, I have a 4-objective optimization model using Gurobi, and there was the optimal solution when I set the poriority of one order (e.g. \[4,3,2,1\]). but when the priority changes ((e.g. \[2,3,4,1\])), the optimal solutio…

---

## [JuMP: MathOptInterface.ScalarNonlinearFunction](https://discourse.julialang.org/t/jump-mathoptinterface-scalarnonlinearfunction/108139)

<div class="topic-metadata">

**Author:** [@a\_jae](https://discourse.julialang.org/u/a_jae)\
**Replies:** 5\
**Last updated:** [December 28, 2023, 10:47pm UTC](https://discourse.julialang.org/t/jump-mathoptinterface-scalarnonlinearfunction/108139 "2023-12-28T22:47:36Z")

</div>

is there a way to run a function only under certain conditions? For example, I have the following model: using JuMP, Gurobi; model = Model(Gurobi.Optimizer); @variable(model, x\[1:t\] \>= 0, Int); @variable(model, y\[1:h…

---

## [Round off decision variable](https://discourse.julialang.org/t/round-off-decision-variable/107988)

<div class="topic-metadata">

**Author:** [@quais](https://discourse.julialang.org/u/quais)\
**Replies:** 2\
**Last updated:** [December 26, 2023, 8:50pm UTC](https://discourse.julialang.org/t/round-off-decision-variable/107988 "2023-12-26T20:50:57Z")

</div>

Hey, is there a way to round off decision variables? I initialized the following variable, which is given in hours: n = 4 model = Model() @variable(model, start\_n\[1:n\] \>= 0, Int) In one of my cost functions, however, I…

---

## [Unable to create vector out of AffExpr in some cases](https://discourse.julialang.org/t/unable-to-create-vector-out-of-affexpr-in-some-cases/107968)

<div class="topic-metadata">

**Author:** [@A\_C](https://discourse.julialang.org/u/A_C)\
**Replies:** 3\
**Last updated:** [December 26, 2023, 9:09pm UTC](https://discourse.julialang.org/t/unable-to-create-vector-out-of-affexpr-in-some-cases/107968 "2023-12-26T21:09:51Z")

</div>

MWE: using JuMP model = Model() x1 = @variable(model, base\_name = "x1") x2 = x1 + 1 x3::AffExpr = x1 # Works: x1 is of type VariableRef v1 = \[sin(x1), x1\] # Works: x2 is of type AffExpr v2 = \[sin(x1), x2\] # Does not …

---

## [Potential Bug in Optimization.jl](https://discourse.julialang.org/t/potential-bug-in-optimization-jl/108066)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 1\
**Last updated:** [December 26, 2023, 7:17pm UTC](https://discourse.julialang.org/t/potential-bug-in-optimization-jl/108066 "2023-12-26T19:17:21Z")

</div>

Here is my code which utilizes Optimization.jl and ModelingToolkit.jl: using BenchmarkTools, Optimization, OptimizationNLopt, ModelingToolkit function func\_1(x0,p) sse = sum(x0) + p\[1\] return sse end funct…

---

## [Optimization.jl Iterations](https://discourse.julialang.org/t/optimization-jl-iterations/107845)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 3\
**Last updated:** [December 21, 2023, 6:16pm UTC](https://discourse.julialang.org/t/optimization-jl-iterations/107845 "2023-12-21T18:16:12Z")

</div>

Hello, how do I extract the number of iterations from Optimization.jl (specifically the NLopt package)? Here is a sample code using Optimization, OptimizationNLopt, ModelingToolkit function calc\_sse(x0,p) return s…

---

## [Convert nl file to mps file using JuMP](https://discourse.julialang.org/t/convert-nl-file-to-mps-file-using-jump/107885)

<div class="topic-metadata">

**Author:** [@rlacjfjin](https://discourse.julialang.org/u/rlacjfjin)\
**Replies:** 8\
**Last updated:** [December 21, 2023, 3:00am UTC](https://discourse.julialang.org/t/convert-nl-file-to-mps-file-using-jump/107885 "2023-12-21T03:00:25Z")

</div>

As in question: Why I can't read nl file with other solver · Issue #3637 · jump-dev/JuMP.jl · GitHub When I using the code: model = read\_from\_file("my\_model.nl"; use\_nlp\_block = false) A JuMP Model Maximization problem…

---

## [JuMP @constraint macro modifies existing expression](https://discourse.julialang.org/t/jump-constraint-macro-modifies-existing-expression/107864)

<div class="topic-metadata">

**Author:** [@Ethan-Russell](https://discourse.julialang.org/u/Ethan-Russell)\
**Replies:** 1\
**Last updated:** [December 20, 2023, 9:03pm UTC](https://discourse.julialang.org/t/jump-constraint-macro-modifies-existing-expression/107864 "2023-12-20T21:03:10Z")

</div>

I have encountered cases where JuMP will modify an expression if it is used in a constraint. This seems like undesirable behavior, as the expression could be used later thinking it is the same as the original. Here is …

---

## [ForwardDiff.jl \\ Optiml.jl Newton Trust Region failing for unclear reason](https://discourse.julialang.org/t/forwarddiff-jl-optiml-jl-newton-trust-region-failing-for-unclear-reason/107799)

<div class="topic-metadata">

**Author:** [@Gabriel\_Kreindler](https://discourse.julialang.org/u/Gabriel_Kreindler)\
**Replies:** 12\
**Last updated:** [December 20, 2023, 6:32pm UTC](https://discourse.julialang.org/t/forwarddiff-jl-optiml-jl-newton-trust-region-failing-for-unclear-reason/107799 "2023-12-20T18:32:14Z")

</div>

I am trying to use Optim.jl’s NewtonTrustRegion with forward AD for computing the gradient and hessian. This fails for a reason that I don’t quite understand. I run optimize(fn\_closure, theta0, NewtonTrustRegion(), aut…

---

## ["Abstractdiffy" not defined for Nonconvex.jl](https://discourse.julialang.org/t/abstractdiffy-not-defined-for-nonconvex-jl/107789)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 5\
**Last updated:** [December 19, 2023, 2:32am UTC](https://discourse.julialang.org/t/abstractdiffy-not-defined-for-nonconvex-jl/107789 "2023-12-19T02:32:01Z")

</div>

Hello, here is a simplified version of my code, which uses Nonconvex.jl (, ReverseDiff.jl, AbstractDifferentiation.jl, and CUDA.jl: using DelimitedFiles, NPZ, SharedArrays, BenchmarkTools, Statistics, DataFrames using …

---

## [JuMP constraint MethodError](https://discourse.julialang.org/t/jump-constraint-methoderror/107752)

<div class="topic-metadata">

**Author:** [@AP\_profile](https://discourse.julialang.org/u/AP_profile)\
**Replies:** 1\
**Last updated:** [December 18, 2023, 2:39am UTC](https://discourse.julialang.org/t/jump-constraint-methoderror/107752 "2023-12-18T02:39:54Z")

</div>

I’ve been trying to use a constraint that uses Distribution.cdf() in optimization using JuMP. An example of this usage would be similar to the below code. model = JuMP.Model(NLopt.Optimizer); set\_optimizer\_attribute(mod…

---

## [Speeding up JuMP model creation with sets that depend on other indexes](https://discourse.julialang.org/t/speeding-up-jump-model-creation-with-sets-that-depend-on-other-indexes/107333)

<div class="topic-metadata">

**Author:** [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Replies:** 8\
**Last updated:** [December 15, 2023, 3:18pm UTC](https://discourse.julialang.org/t/speeding-up-jump-model-creation-with-sets-that-depend-on-other-indexes/107333 "2023-12-15T15:18:48Z")

</div>

I am looking for tips on building a model with variables, expressions, and constraints over sets that depends on indexes from other sets. For instance: @expression(model, \[i = 1:5, j = blah\[i\]\], ...) where blah is a di…

---

## [MethodError: no method matching add\_to\_expression!(::JuMP.AffExpr, ::JuMP.QuadExpr)](https://discourse.julialang.org/t/methoderror-no-method-matching-add-to-expression-jump-affexpr-jump-quadexpr/107379)

<div class="topic-metadata">

**Author:** [@Betristor](https://discourse.julialang.org/u/Betristor)\
**Replies:** 2\
**Last updated:** [December 15, 2023, 12:18pm UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-add-to-expression-jump-affexpr-jump-quadexpr/107379 "2023-12-15T12:18:21Z")

</div>

I got a model like using JuMP, Ipopt m = Model(Ipopt.Optimizer) @variable(m, x\[i=1:2\]\>=0) @expression(m, e1\[i=1:2\], i\*m\[:x\]\[i\]) ## Affine @expression(m, e2\[i=1:2\], m\[:x\]\[i\]^i) ## At most quadric add\_to\_expression!.(m\[:e…

---

## [Obtaining Step Norm in KNITRO.jl](https://discourse.julialang.org/t/obtaining-step-norm-in-knitro-jl/107577)

<div class="topic-metadata">

**Author:** [@fimiller](https://discourse.julialang.org/u/fimiller)\
**Replies:** 3\
**Last updated:** [December 14, 2023, 4:53pm UTC](https://discourse.julialang.org/t/obtaining-step-norm-in-knitro-jl/107577 "2023-12-14T16:53:06Z")

</div>

Hello, From a previous post (Computing common components in KNITRO callbacks), I am working on a creating an algorithm that uses the KNITRO.jl solver. I am in the process of trying to report data as I run experiments o…

---

## [Complementarity.jl with Path](https://discourse.julialang.org/t/complementarity-jl-with-path/103081)

<div class="topic-metadata">

**Author:** [@sjhon](https://discourse.julialang.org/u/sjhon)\
**Replies:** 9\
**Last updated:** [December 13, 2023, 7:48pm UTC](https://discourse.julialang.org/t/complementarity-jl-with-path/103081 "2023-12-13T19:48:34Z")

</div>

Im trying to solve a problema of d’aertrycke, ehrenmann, ralph & smeers (2017), the problem is the 3.3.1 that you can found here Risk trading in capacity equilibrium models Im trying to do this problem as a Mixed Comple…

---

## [How do I obtain the variables in a JuMP constraint?](https://discourse.julialang.org/t/how-do-i-obtain-the-variables-in-a-jump-constraint/107563)

<div class="topic-metadata">

**Author:** [@BdeKoning](https://discourse.julialang.org/u/BdeKoning)\
**Replies:** 1\
**Last updated:** [December 13, 2023, 7:40pm UTC](https://discourse.julialang.org/t/how-do-i-obtain-the-variables-in-a-jump-constraint/107563 "2023-12-13T19:40:29Z")

</div>

Say I define a constraint with JuMP: using JuMP model = Model(); @variable(model, x\[1:3\]); constraint = @constraint(model, c1, sum(x) \<= 1) How can I now, only using the variable constraint, obtain an iterable of varia…

---

## [JuliaSimModelOptimiser get calibration results](https://discourse.julialang.org/t/juliasimmodeloptimiser-get-calibration-results/107503)

<div class="topic-metadata">

**Author:** [@rpex](https://discourse.julialang.org/u/rpex)\
**Replies:** 1\
**Last updated:** [December 12, 2023, 3:33pm UTC](https://discourse.julialang.org/t/juliasimmodeloptimiser-get-calibration-results/107503 "2023-12-12T15:33:10Z")

</div>

Can JuliaSimModelOptimiser.jl topics be asked here? I define a search space and create an JuliaSimModelOptimizer.InverseProblem. Then I calibrate my search space to data and get a JuliaSimModelOptimizer.CalibrateResult. …

---

## [Setting up free final time in JuMP optimization](https://discourse.julialang.org/t/setting-up-free-final-time-in-jump-optimization/107302)

<div class="topic-metadata">

**Author:** [@pluie](https://discourse.julialang.org/u/pluie)\
**Replies:** 8\
**Last updated:** [December 12, 2023, 2:11pm UTC](https://discourse.julialang.org/t/setting-up-free-final-time-in-jump-optimization/107302 "2023-12-12T14:11:07Z")

</div>

I am trying to set up a nonlinear optimization problem using JuMP. I have been referencing some examples included in its documentation. The problem I am trying to set up is similar to the Rocket Control example: Rocket C…

---

## [Use ReverseDiff.jl in JuMP](https://discourse.julialang.org/t/use-reversediff-jl-in-jump/107469)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 7\
**Last updated:** [December 12, 2023, 10:10am UTC](https://discourse.julialang.org/t/use-reversediff-jl-in-jump/107469 "2023-12-12T10:10:54Z")

</div>

Is it possible to use ReverseDiff.jl in JuMP.jl instead of ForwardDiff.jl. I am not seeing the desired speedup in JuMP when I’m using ForwardDiff.jl

---

## [Problem with ForwardDiff not letting me update variable "d"](https://discourse.julialang.org/t/problem-with-forwarddiff-not-letting-me-update-variable-d/107417)

<div class="topic-metadata">

**Author:** [@bdas123](https://discourse.julialang.org/u/bdas123)\
**Replies:** 7\
**Last updated:** [December 11, 2023, 2:27pm UTC](https://discourse.julialang.org/t/problem-with-forwarddiff-not-letting-me-update-variable-d/107417 "2023-12-11T14:27:10Z")

</div>

Here is a watered down version of code I am using a = zeros(2393) a = findall(x -\> x == 0, a) b = zeros(293) e = rand(2979) l = zeros(137,293) g = ones(137,293) h = rand(137,170) function dummy(e::T...) where {T}…

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

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