# Optimization (Mathematical)

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

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

**Page:** 43

---

## [Worker terminated in parallel computation with Gurobi](https://discourse.julialang.org/t/worker-terminated-in-parallel-computation-with-gurobi/100273)

<div class="topic-metadata">

**Author:** [@umbe](https://discourse.julialang.org/u/umbe)\
**Replies:** 5\
**Last updated:** [June 15, 2023, 6:12pm UTC](https://discourse.julialang.org/t/worker-terminated-in-parallel-computation-with-gurobi/100273 "2023-06-15T18:12:25Z")

</div>

Hello to everyone, I am trying to execute in parallel multiple optimizations with Gurobi inside a genetic algorithm written by myself. The code is very long and structured in many parts, here I report the conceptual st…

---

## [Eating the cake (nat res depletion model) with endogenous time horizon in InfiniteOpt](https://discourse.julialang.org/t/eating-the-cake-nat-res-depletion-model-with-endogenous-time-horizon-in-infiniteopt/100235)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 5\
**Last updated:** [June 14, 2023, 1:59pm UTC](https://discourse.julialang.org/t/eating-the-cake-nat-res-depletion-model-with-endogenous-time-horizon-in-infiniteopt/100235 "2023-06-14T13:59:50Z")

</div>

Hello, I am trying to numerically solve the dynamic problem of optimal natural resource depletion (aka “eating the cake”) with InfiniteOpt.jl. The script below works fine, but for the time horizon (i.e. the upper bound …

---

## [JuMP + Baron](https://discourse.julialang.org/t/jump-baron/100401)

<div class="topic-metadata">

**Author:** [@selvi-aras](https://discourse.julialang.org/u/selvi-aras)\
**Replies:** 2\
**Last updated:** [June 15, 2023, 3:01pm UTC](https://discourse.julialang.org/t/jump-baron/100401 "2023-06-15T15:01:55Z")

</div>

Dear JuMP community, When I use Baron to solve a small-scale problem, I get an error of following form: =========================================================================== This BARON run may utilize the follow…

---

## [How to add multiple condition for indices on constraints](https://discourse.julialang.org/t/how-to-add-multiple-condition-for-indices-on-constraints/100373)

<div class="topic-metadata">

**Author:** [@Pablo\_Flores](https://discourse.julialang.org/u/Pablo_Flores)\
**Replies:** 2\
**Last updated:** [June 15, 2023, 2:02pm UTC](https://discourse.julialang.org/t/how-to-add-multiple-condition-for-indices-on-constraints/100373 "2023-06-15T14:02:49Z")

</div>

Hello everyone, I’m having problems with my model when I try to add two conditions inside a constraint, where I try to define the constraint where an index cannot be equal to 2 values ​​from a set, and then create spec…

---

## [Why Optim.jl does not allow for backwards mode autodifferentiation?](https://discourse.julialang.org/t/why-optim-jl-does-not-allow-for-backwards-mode-autodifferentiation/100346)

<div class="topic-metadata">

**Author:** [@Devetak](https://discourse.julialang.org/u/Devetak)\
**Replies:** 6\
**Last updated:** [June 15, 2023, 12:27pm UTC](https://discourse.julialang.org/t/why-optim-jl-does-not-allow-for-backwards-mode-autodifferentiation/100346 "2023-06-15T12:27:39Z")

</div>

I apologise if this is a silly question. Why Optim.jl does not allow for backwards mode autodifferentiation? If I understand things correctly backwards mode is better for the case when the output dimension is smaller th…

---

## [Array issue with optimzing a function with quadgk](https://discourse.julialang.org/t/array-issue-with-optimzing-a-function-with-quadgk/41837)

<div class="topic-metadata">

**Author:** [@shoshievass](https://discourse.julialang.org/u/shoshievass)\
**Replies:** 12\
**Last updated:** [June 15, 2023, 3:07am UTC](https://discourse.julialang.org/t/array-issue-with-optimzing-a-function-with-quadgk/41837 "2023-06-15T03:07:44Z")

</div>

I’m trying to minimize a function that involves an integral, the integrand of which is one of the optimizing parameters. I can compute the function and get the gradient with Zygote, but I’m getting an odd conversion erro…

---

## [Optimizing an objective function with a vector containing constants, variables, and functions of variables using JuMP](https://discourse.julialang.org/t/optimizing-an-objective-function-with-a-vector-containing-constants-variables-and-functions-of-variables-using-jump/100366)

<div class="topic-metadata">

**Author:** [@Hyrum\_Hansen](https://discourse.julialang.org/u/Hyrum_Hansen)\
**Replies:** 3\
**Last updated:** [June 14, 2023, 9:42pm UTC](https://discourse.julialang.org/t/optimizing-an-objective-function-with-a-vector-containing-constants-variables-and-functions-of-variables-using-jump/100366 "2023-06-14T21:42:24Z")

</div>

I’m working on a set of optimization problems where I need to maximize something that looks a lot like a quadratic form but isn’t. The following example is one such problem: Maximize f^TAf where f = \[1, x, x^2\] and A i…

---

## [Parallel Optimization with Surrogates.jl](https://discourse.julialang.org/t/parallel-optimization-with-surrogates-jl/93586)

<div class="topic-metadata">

**Author:** [@Dreycen\_Foiles](https://discourse.julialang.org/u/Dreycen_Foiles)\
**Replies:** 6\
**Last updated:** [June 14, 2023, 8:08pm UTC](https://discourse.julialang.org/t/parallel-optimization-with-surrogates-jl/93586 "2023-06-14T20:08:36Z")

</div>

I’m thinking about using Surrogates.jl to optimize a process in my lab using the Gaussian processes for Bayesian optimization. It’s easier for me to run multiple experiments at once, so I was wondering if it was possible…

---

## [How to set an objective to minimize the variance in ratio of allocation](https://discourse.julialang.org/t/how-to-set-an-objective-to-minimize-the-variance-in-ratio-of-allocation/100263)

<div class="topic-metadata">

**Author:** [@Ashok\_Khatri](https://discourse.julialang.org/u/Ashok_Khatri)\
**Replies:** 4\
**Last updated:** [June 14, 2023, 1:24pm UTC](https://discourse.julialang.org/t/how-to-set-an-objective-to-minimize-the-variance-in-ratio-of-allocation/100263 "2023-06-14T13:24:37Z")

</div>

I am trying to write a model where I have to distribute fractions of rent from properties to loans. The objective is to distribute the rents as equally as possible given the loan balance. Say there are 5 properties and …

---

## [Genetic Algorithm packages](https://discourse.julialang.org/t/genetic-algorithm-packages/100159)

<div class="topic-metadata">

**Author:** [@jonathanfischer97](https://discourse.julialang.org/u/jonathanfischer97)\
**Replies:** 12\
**Last updated:** [June 13, 2023, 12:58pm UTC](https://discourse.julialang.org/t/genetic-algorithm-packages/100159 "2023-06-13T12:58:52Z")

</div>

For those who run genetic algorithms or similar optimizations methods in Julia, which package do you use? I’ve been using Evolutionary.jl and it works well, but am wondering there are any alternatives worth checking out…

---

## [We don't know how to parse constraints containing expressions of type :generator](https://discourse.julialang.org/t/we-dont-know-how-to-parse-constraints-containing-expressions-of-type-generator/100270)

<div class="topic-metadata">

**Author:** [@A.Marx](https://discourse.julialang.org/u/A.Marx)\
**Replies:** 3\
**Last updated:** [June 13, 2023, 8:53am UTC](https://discourse.julialang.org/t/we-dont-know-how-to-parse-constraints-containing-expressions-of-type-generator/100270 "2023-06-13T08:53:49Z")

</div>

I am trying to set up the following dispatch optimization problem. However, the capacity constraints gives me the error: \`@constraint(m, \[t in time\], (cfD\[:p\] \>= y\[p, t\] for p = plants))\`: Unsupported constraint express…

---

## [How to troubleshoot ForwardDiff](https://discourse.julialang.org/t/how-to-troubleshoot-forwarddiff/99728)

<div class="topic-metadata">

**Author:** [@johnb](https://discourse.julialang.org/u/johnb)\
**Replies:** 18\
**Last updated:** [June 12, 2023, 10:05pm UTC](https://discourse.julialang.org/t/how-to-troubleshoot-forwarddiff/99728 "2023-06-12T22:05:45Z")

</div>

I’ve been trying to write a loss function for a PDE that I’m solving in order to identify parameters and I would like to use the gradient of my loss function in parameter optimization. Unfortunately, ForwardDiff returns …

---

## [How to add names to a collection of constraints in JuMP using @constraints](https://discourse.julialang.org/t/how-to-add-names-to-a-collection-of-constraints-in-jump-using-constraints/100130)

<div class="topic-metadata">

**Author:** [@JackaChou](https://discourse.julialang.org/u/JackaChou)\
**Replies:** 4\
**Last updated:** [June 12, 2023, 6:37am UTC](https://discourse.julialang.org/t/how-to-add-names-to-a-collection-of-constraints-in-jump-using-constraints/100130 "2023-06-12T06:37:21Z")

</div>

I want to name different kinds of constraints for enhancing readability and debugging, what’s the right syntax to do it with @constraints, I know this is easy for @constraint(, base\_name = “Name”). Below is my code with…

---

## [How to find Shadow Price in JuMP](https://discourse.julialang.org/t/how-to-find-shadow-price-in-jump/99887)

<div class="topic-metadata">

**Author:** [@Gagan\_Meena](https://discourse.julialang.org/u/Gagan_Meena)\
**Replies:** 6\
**Last updated:** [June 9, 2023, 4:38am UTC](https://discourse.julialang.org/t/how-to-find-shadow-price-in-jump/99887 "2023-06-09T04:38:47Z")

</div>

How to find the shadow price for the equality constraint in the following code? using JuMP, Gurobi include("Data.jl") Market\_dt = PlanningData function Market\_Clearing(Market\_dt) # Sets and Indices n …

---

## [Cannot build CPLEX even with correct environment variable](https://discourse.julialang.org/t/cannot-build-cplex-even-with-correct-environment-variable/87234)

<div class="topic-metadata">

**Author:** [@Richard0416](https://discourse.julialang.org/u/Richard0416)\
**Replies:** 5\
**Last updated:** [June 8, 2023, 9:14pm UTC](https://discourse.julialang.org/t/cannot-build-cplex-even-with-correct-environment-variable/87234 "2023-06-08T21:14:33Z")

</div>

Hello! I am trying to add CPLEX to Julia. I download the latest version of CPLEX, 22.1 And also updated the CPLEX.jl package to the latest version, v0.9.4. When running Pkg.build(“CPLEX”), it seems that the path is wron…

---

## [Upperbound and Lowerbound of SDDP.jl](https://discourse.julialang.org/t/upperbound-and-lowerbound-of-sddp-jl/100060)

<div class="topic-metadata">

**Author:** [@Sorooshsa](https://discourse.julialang.org/u/Sorooshsa)\
**Replies:** 1\
**Last updated:** [June 8, 2023, 9:11pm UTC](https://discourse.julialang.org/t/upperbound-and-lowerbound-of-sddp-jl/100060 "2023-06-08T21:11:08Z")

</div>

Hi, I solved a Multi-stage stochastic problem in Julia using SDDP.jl Package. As we know in theory, SDDP.jl is based on diving a problem into the master problem and subproblems and progressively adding cuts (Like Neste…

---

## [Use CPLEX solver in JuMP](https://discourse.julialang.org/t/use-cplex-solver-in-jump/100048)

<div class="topic-metadata">

**Author:** [@R0033h](https://discourse.julialang.org/u/R0033h)\
**Replies:** 1\
**Last updated:** [June 8, 2023, 1:02pm UTC](https://discourse.julialang.org/t/use-cplex-solver-in-jump/100048 "2023-06-08T13:02:34Z")

</div>

I am a new learner to Julia and I would like to know how can create subproblem. I tried many ways but all of them not correct. the problem is ( we assumed: there are 400 students and 4 schools each school have 100 stud…

---

## [Can I use if statements in ParameterisedFunctions.jl? Is there a work around?](https://discourse.julialang.org/t/can-i-use-if-statements-in-parameterisedfunctions-jl-is-there-a-work-around/79347)

<div class="topic-metadata">

**Author:** [@BinaryBot](https://discourse.julialang.org/u/BinaryBot)\
**Replies:** 3\
**Last updated:** [June 7, 2023, 12:57pm UTC](https://discourse.julialang.org/t/can-i-use-if-statements-in-parameterisedfunctions-jl-is-there-a-work-around/79347 "2023-06-07T12:57:32Z")

</div>

I am trying to check weather my Differential Equation implemented using DifferentialEquation.jl matches the results obtained in Matlab. I learnt I could do this by implementing the same differential equation using MATLAB…

---

## [New to Jump and Julia](https://discourse.julialang.org/t/new-to-jump-and-julia/99823)

<div class="topic-metadata">

**Author:** [@A.Marx](https://discourse.julialang.org/u/A.Marx)\
**Replies:** 5\
**Last updated:** [June 7, 2023, 12:01am UTC](https://discourse.julialang.org/t/new-to-jump-and-julia/99823 "2023-06-07T00:01:30Z")

</div>

Hey all, I am trying to programm a simple optimization problem which minimizes the cost of a of an energy system with 4 suppliers subject to capacitiy constraints for 6 periods. The costs are for each period are: c…

---

## [Transitioning an LP to stochastic version with InfiniteOpt.jl (+ feeding in samples ?)](https://discourse.julialang.org/t/transitioning-an-lp-to-stochastic-version-with-infiniteopt-jl-feeding-in-samples/99896)

<div class="topic-metadata">

**Author:** [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Replies:** 7\
**Last updated:** [June 6, 2023, 8:59pm UTC](https://discourse.julialang.org/t/transitioning-an-lp-to-stochastic-version-with-infiniteopt-jl-feeding-in-samples/99896 "2023-06-06T20:59:18Z")

</div>

Hello! I was searching to transition some of my deterministic ILP models to a stochastic version. I started investigating InfiniteOpt.jl and made a simple stochastic flavor of the JuMP LP example. I just modeled a para…

---

## [Symmetry & SOS Optimization Compatibility Issues?](https://discourse.julialang.org/t/symmetry-sos-optimization-compatibility-issues/98057)

<div class="topic-metadata">

**Author:** [@ilovemath](https://discourse.julialang.org/u/ilovemath)\
**Replies:** 6\
**Last updated:** [June 5, 2023, 8:29pm UTC](https://discourse.julialang.org/t/symmetry-sos-optimization-compatibility-issues/98057 "2023-06-05T20:29:12Z")

</div>

Hello all, I am trying to implement rotational symmetry for an SOS problem. In particular, I followed the example problem here: Dihedral symmetry of the Robinson form · SumOfSquares. My goal is to use a cyclic group i…

---

## [First time using Jump](https://discourse.julialang.org/t/first-time-using-jump/99819)

<div class="topic-metadata">

**Author:** [@A.Marx](https://discourse.julialang.org/u/A.Marx)\
**Replies:** 3\
**Last updated:** [June 3, 2023, 8:25pm UTC](https://discourse.julialang.org/t/first-time-using-jump/99819 "2023-06-03T20:25:18Z")

</div>

Hello all, I am new to JuMP and Julia. I am getting this error: LoadError: UndefVarError: @optimize! not defined in expression starting at c:\\Users\\alex-\\Documents\\OR Lab\\Introduction to Julia JuMP.jl:49 After @opti…

---

## [About using powermodels to solve problems with SDP-OPF](https://discourse.julialang.org/t/about-using-powermodels-to-solve-problems-with-sdp-opf/99750)

<div class="topic-metadata">

**Author:** [@lzq-zbc](https://discourse.julialang.org/u/lzq-zbc)\
**Replies:** 1\
**Last updated:** [June 2, 2023, 3:36am UTC](https://discourse.julialang.org/t/about-using-powermodels-to-solve-problems-with-sdp-opf/99750 "2023-06-02T03:36:35Z")

</div>

I want to use the ECOS solver to solve some errors in the SDP model in OPF. using JuMP, PowerModels, Ipopt,ECOS file\_name = "E:/Vscode——data/data/case5.m" model = Model(ECOS.Optimizer) power\_model = PowerModels.instan…

---

## [Julia exits when running several models (JuMP) in a row](https://discourse.julialang.org/t/julia-exits-when-running-several-models-jump-in-a-row/99686)

<div class="topic-metadata">

**Author:** [@Yuri\_Masakazu\_Mizusa](https://discourse.julialang.org/u/Yuri_Masakazu_Mizusa)\
**Replies:** 6\
**Last updated:** [June 1, 2023, 11:08pm UTC](https://discourse.julialang.org/t/julia-exits-when-running-several-models-jump-in-a-row/99686 "2023-06-01T23:08:01Z")

</div>

Hi, I’m running several instances on the same model in order to compare performance, like described below. My problem is that I have 1000 instances and halfway Julia exit, probably due to memory, but I don’t really und…

---

## [High-dimensional optimization problem with inequality constraint](https://discourse.julialang.org/t/high-dimensional-optimization-problem-with-inequality-constraint/63957)

<div class="topic-metadata">

**Author:** [@mengxiaoliu](https://discourse.julialang.org/u/mengxiaoliu)\
**Replies:** 10\
**Last updated:** [June 1, 2023, 7:03am UTC](https://discourse.julialang.org/t/high-dimensional-optimization-problem-with-inequality-constraint/63957 "2023-06-01T07:03:33Z")

</div>

Hello, I am solving a high-dimensional optimization problem with an inequality constraint using blackboxoptim. The objective function is differentiable, but I cannot write down the Hessians by hand. The dimensionality i…

---

## [UndefVarError: \_pass\_variable\_names\_to\_solver not defined - Xpress solver in Julia](https://discourse.julialang.org/t/undefvarerror-pass-variable-names-to-solver-not-defined-xpress-solver-in-julia/99292)

<div class="topic-metadata">

**Author:** [@Ignacio](https://discourse.julialang.org/u/Ignacio)\
**Replies:** 4\
**Last updated:** [May 31, 2023, 7:41am UTC](https://discourse.julialang.org/t/undefvarerror-pass-variable-names-to-solver-not-defined-xpress-solver-in-julia/99292 "2023-05-31T07:41:12Z")

</div>

Good evening, I am building an optimization model, in which I want to pass the names of the variables and constranits to the solver, so an IIS can be built afterwards if the problem turns out to be infeasible. I am usin…

---

## [Recommended way to do callbacks in MIP root node](https://discourse.julialang.org/t/recommended-way-to-do-callbacks-in-mip-root-node/99617)

<div class="topic-metadata">

**Author:** [@felipecordera](https://discourse.julialang.org/u/felipecordera)\
**Replies:** 3\
**Last updated:** [May 31, 2023, 1:36am UTC](https://discourse.julialang.org/t/recommended-way-to-do-callbacks-in-mip-root-node/99617 "2023-05-31T01:36:26Z")

</div>

Hi everyone, I would like to know whether there are any recommendations in the workflow for the following situation: I have defined a MIP model along with a solver-independent lazy callback function, and I would like t…

---

## [BiLevel with Lower Quadratic Constraints](https://discourse.julialang.org/t/bilevel-with-lower-quadratic-constraints/99603)

<div class="topic-metadata">

**Author:** [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Replies:** 3\
**Last updated:** [May 30, 2023, 10:26pm UTC](https://discourse.julialang.org/t/bilevel-with-lower-quadratic-constraints/99603 "2023-05-30T22:26:54Z")

</div>

As “BilevelJuMP is not able to solve problems with quadratic constraints in the lower level.” Is there a recommended way to solve bilevel optimizations where the lower level has quadratic constraints and the upper level …

---

## [BoundaError with NLopt in JuMP with a user-defined function and its gradient](https://discourse.julialang.org/t/boundaerror-with-nlopt-in-jump-with-a-user-defined-function-and-its-gradient/99598)

<div class="topic-metadata">

**Author:** [@naouess](https://discourse.julialang.org/u/naouess)\
**Replies:** 1\
**Last updated:** [May 30, 2023, 7:28pm UTC](https://discourse.julialang.org/t/boundaerror-with-nlopt-in-jump-with-a-user-defined-function-and-its-gradient/99598 "2023-05-30T19:28:19Z")

</div>

Hello, I am solving an NLP in JuMP with several nonlinear user-defined functions as constraints. I provide the functions and their gradients in the following way: for j in 1:24 register(m, Symbol("myfunc\_$j"), length(…

---

## [What is the meaning of multiple objective functions?](https://discourse.julialang.org/t/what-is-the-meaning-of-multiple-objective-functions/51857)

<div class="topic-metadata">

**Author:** [@prit](https://discourse.julialang.org/u/prit)\
**Replies:** 4\
**Last updated:** [May 30, 2023, 2:24pm UTC](https://discourse.julialang.org/t/what-is-the-meaning-of-multiple-objective-functions/51857 "2023-05-30T14:24:15Z")

</div>

I have multiple objective functions in my code, created by a loop around the @objective macro. Here’s the code: using JuMP using MosekTools K = 3 N = 2 penalties = \[1.0, 3.9, 8.7\] function fac1(r::Number, i::Number, l::…

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

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