# Optimization (Mathematical)

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

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

**Page:** 39

---

## [Solve bilevel optimization the stupid way](https://discourse.julialang.org/t/solve-bilevel-optimization-the-stupid-way/103024)

<div class="topic-metadata">

**Author:** [@cricci](https://discourse.julialang.org/u/cricci)\
**Replies:** 6\
**Last updated:** [September 15, 2023, 9:27am UTC](https://discourse.julialang.org/t/solve-bilevel-optimization-the-stupid-way/103024 "2023-09-15T09:27:38Z")

</div>

I would like to solve a bilevel optimization problem in a dumb way. Consider the following (as an example) \\min\_{x,y}\\quad x^4 - \\sin(y)\\\\ \\text{s.t.}\\quad x \\geq 2, x^3+y^3 \\leq 1\\\\ y(x) \\in \\arg\\min\_{y} y^2 + x\\\\ 3…

---

## [ANN: JuMP v1.15 is released](https://discourse.julialang.org/t/ann-jump-v1-15-is-released/103875)

<div class="topic-metadata">

**Author:** [@odow](https://discourse.julialang.org/u/odow)\
**Replies:** 0\
**Last updated:** [September 15, 2023, 3:10am UTC](https://discourse.julialang.org/t/ann-jump-v1-15-is-released/103875 "2023-09-15T03:10:53Z")

</div>

Dear all, I am very pleased to announce the release of JuMP v1.15. This is a very large minor release because it introduces an entirely new API for nonlinear programs. To summarize, there is now a first-class nonlinea…

---

## [Get presolved model from Gurobi](https://discourse.julialang.org/t/get-presolved-model-from-gurobi/103827)

<div class="topic-metadata">

**Author:** [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)\
**Replies:** 5\
**Last updated:** [September 15, 2023, 1:11am UTC](https://discourse.julialang.org/t/get-presolved-model-from-gurobi/103827 "2023-09-15T01:11:14Z")

</div>

Hi, in Julia is it possible to get the model after Gurobi finishes “presolve”? That is the model after being simplified by Gurobi (less variables, constraints,…). The method Model.presolve() in the Gurobi Python interfa…

---

## [BilevelJump with mode=BilevelJuMP.BigMMode or mode=BilevelJuMP.FortunyAmatMcCarlMode](https://discourse.julialang.org/t/bileveljump-with-mode-bileveljump-bigmmode-or-mode-bileveljump-fortunyamatmccarlmode/103806)

<div class="topic-metadata">

**Author:** [@martina.gherardi](https://discourse.julialang.org/u/martina.gherardi)\
**Replies:** 2\
**Last updated:** [September 14, 2023, 2:26am UTC](https://discourse.julialang.org/t/bileveljump-with-mode-bileveljump-bigmmode-or-mode-bileveljump-fortunyamatmccarlmode/103806 "2023-09-14T02:26:10Z")

</div>

Hi, I would like to ask 2 questions about the reformulation of the complementary slackness with Fortuny-Amat and McCarl done by BilevelJump with the following setting mode=BilevelJuMP.BigMMode(; with\_slack = false, pri…

---

## [Curious about copying a model that has had constraints deleted](https://discourse.julialang.org/t/curious-about-copying-a-model-that-has-had-constraints-deleted/103814)

<div class="topic-metadata">

**Author:** [@hdavid16](https://discourse.julialang.org/u/hdavid16)\
**Replies:** 1\
**Last updated:** [September 13, 2023, 9:44pm UTC](https://discourse.julialang.org/t/curious-about-copying-a-model-that-has-had-constraints-deleted/103814 "2023-09-13T21:44:21Z")

</div>

Here is an interesting scenario. I’m playing around with how copy works in JuMP. #make dummy model m=Model(); @variable(m,x); c1=@constraint(m,x\<=10); c2=@constraint(m,x\<=100); delete(m,c1) delete(m,c2) #readd c…

---

## [Conditional Constraint Construction Based on Input Data Presence/Absence of Set Combinations in Julia JUMP](https://discourse.julialang.org/t/conditional-constraint-construction-based-on-input-data-presence-absence-of-set-combinations-in-julia-jump/103717)

<div class="topic-metadata">

**Author:** [@Dimi](https://discourse.julialang.org/u/Dimi)\
**Replies:** 6\
**Last updated:** [September 12, 2023, 9:03pm UTC](https://discourse.julialang.org/t/conditional-constraint-construction-based-on-input-data-presence-absence-of-set-combinations-in-julia-jump/103717 "2023-09-12T21:03:20Z")

</div>

Hello everyone. I am currently transitioning from GAMS optimisation to Julia optimisation (in VScode) and trying to figure out the “optimal/fastest” way of constructing conditional constraints based on the presence (or a…

---

## [OptimizationOptimJL: single function returning objective and gradients](https://discourse.julialang.org/t/optimizationoptimjl-single-function-returning-objective-and-gradients/103704)

<div class="topic-metadata">

**Author:** [@james3](https://discourse.julialang.org/u/james3)\
**Replies:** 2\
**Last updated:** [September 12, 2023, 5:33pm UTC](https://discourse.julialang.org/t/optimizationoptimjl-single-function-returning-objective-and-gradients/103704 "2023-09-12T17:33:12Z")

</div>

I am using OptimizationOptimJL, and wish to supply my own gradients. There are many common calculations that are shared when evaluating the objective function, and the gradients, so I wish to have a single function that …

---

## [Objective function value for all the points in the feasible region](https://discourse.julialang.org/t/objective-function-value-for-all-the-points-in-the-feasible-region/103772)

<div class="topic-metadata">

**Author:** [@Gagan\_Meena](https://discourse.julialang.org/u/Gagan_Meena)\
**Replies:** 9\
**Last updated:** [September 12, 2023, 9:37am UTC](https://discourse.julialang.org/t/objective-function-value-for-all-the-points-in-the-feasible-region/103772 "2023-09-12T09:37:57Z")

</div>

How can we find out the objective function value for all the points in the feasible region for a complex optimization problem using JuMP? Is there a built-in method for doing so? If yes, then please specify the same. I…

---

## [Using JuMP variables and expressions in conditional statements](https://discourse.julialang.org/t/using-jump-variables-and-expressions-in-conditional-statements/103414)

<div class="topic-metadata">

**Author:** [@AshwinSandeep1](https://discourse.julialang.org/u/AshwinSandeep1)\
**Replies:** 27\
**Last updated:** [September 12, 2023, 3:35am UTC](https://discourse.julialang.org/t/using-jump-variables-and-expressions-in-conditional-statements/103414 "2023-09-12T03:35:52Z")

</div>

Hi all I am trying to construct conditioinal statements using the @NLexpression macro but it seems expressions and even variables can’t be used in this context. Is there a way to do this? My aim is to do the following: …

---

## [How to read .gdx files in Julia?](https://discourse.julialang.org/t/how-to-read-gdx-files-in-julia/103575)

<div class="topic-metadata">

**Author:** [@Iheb](https://discourse.julialang.org/u/Iheb)\
**Replies:** 2\
**Last updated:** [September 10, 2023, 10:33pm UTC](https://discourse.julialang.org/t/how-to-read-gdx-files-in-julia/103575 "2023-09-10T22:33:36Z")

</div>

I have a Multistage SP written in GAMS and I want to exchange data between GAMS and Julia via gdx files (Maybe another method if there exists any). I tried using GAMS.jl but it what it does is just convert the model wri…

---

## [NonlinearSolve.jl and Optimization.jl conflict on install](https://discourse.julialang.org/t/nonlinearsolve-jl-and-optimization-jl-conflict-on-install/103707)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 1\
**Last updated:** [September 9, 2023, 7:57pm UTC](https://discourse.julialang.org/t/nonlinearsolve-jl-and-optimization-jl-conflict-on-install/103707 "2023-09-09T19:57:14Z")

</div>

Tried on an Mac M1 and on Windows, also on (initially) empty package. Whatever of these two I install first, on installation of the second one I get error like this: (OptimizationInd) pkg\> add NonlinearSolve Resolvin…

---

## [Creating Variables from a Vector of Tuples and Naming Them](https://discourse.julialang.org/t/creating-variables-from-a-vector-of-tuples-and-naming-them/103525)

<div class="topic-metadata">

**Author:** [@nemoincognito](https://discourse.julialang.org/u/nemoincognito)\
**Replies:** 8\
**Last updated:** [September 5, 2023, 3:22am UTC](https://discourse.julialang.org/t/creating-variables-from-a-vector-of-tuples-and-naming-them/103525 "2023-09-05T03:22:00Z")

</div>

I have converted some PuLP code to Julia and have three vectors of Tuples. supplylist: 149988-element Vector{Tuple{String15, String31}} flowslist: 499572-element Vector{Tuple{String15, String15, String31}} edgelist: …

---

## [Add nested optimization problem in JuMP](https://discourse.julialang.org/t/add-nested-optimization-problem-in-jump/103378)

<div class="topic-metadata">

**Author:** [@leima0521](https://discourse.julialang.org/u/leima0521)\
**Replies:** 4\
**Last updated:** [September 1, 2023, 2:09pm UTC](https://discourse.julialang.org/t/add-nested-optimization-problem-in-jump/103378 "2023-09-01T14:09:55Z")

</div>

I want to include an inner loop optimization (a fixed point iteration algorithm) inside my current optimization problem. I cannot figure out how to make it work… Any help/guidance/advice is truly appreciated! The curren…

---

## [Max and min Gurobi constraint in Julia](https://discourse.julialang.org/t/max-and-min-gurobi-constraint-in-julia/103370)

<div class="topic-metadata">

**Author:** [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)\
**Replies:** 2\
**Last updated:** [September 1, 2023, 10:13am UTC](https://discourse.julialang.org/t/max-and-min-gurobi-constraint-in-julia/103370 "2023-09-01T10:13:21Z")

</div>

Hi All, MAX constraint: The constraint !\[\</span\>r = \\max\\{x\_1,\\ldots,x\_k,c\\}\<span\> MIN constraint: Similar to a MAX constraint, the constraint !\[\</span\>r = \\min\\{x\_1,\\ldots,x\_k,c\\}\<span\>\] can we code max and min cons…

---

## [Optimization v3.16.0 errors in precompile](https://discourse.julialang.org/t/optimization-v3-16-0-errors-in-precompile/103229)

<div class="topic-metadata">

**Author:** [@jaksaa](https://discourse.julialang.org/u/jaksaa)\
**Replies:** 3\
**Last updated:** [August 31, 2023, 8:35pm UTC](https://discourse.julialang.org/t/optimization-v3-16-0-errors-in-precompile/103229 "2023-08-31T20:35:10Z")

</div>

Have Julia Version 1.9.2 Optimization v3.16.0 Two errors are present │ ┌ Error: Error during loading of extension OptimizationSparseFinitediffExt of Optimization, use \`Base.retry\_load\_extensions()\` to retry. and │…

---

## [Anybody using ESDL (Energy System Modeling Language)?](https://discourse.julialang.org/t/anybody-using-esdl-energy-system-modeling-language/103405)

<div class="topic-metadata">

**Author:** [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Replies:** 0\
**Last updated:** [August 31, 2023, 1:49pm UTC](https://discourse.julialang.org/t/anybody-using-esdl-energy-system-modeling-language/103405 "2023-08-31T13:49:27Z")

</div>

Is anybody using the ESDL format (ESDL Documentation - ESDL, Meer Informatie)? I noticed that it is not as widespread outside of the Netherlands, but it looks very useful: ESDL is a modelling language created to descr…

---

## [Are vectorized constraints no longer supported on JuMP?](https://discourse.julialang.org/t/are-vectorized-constraints-no-longer-supported-on-jump/103355)

<div class="topic-metadata">

**Author:** [@AS011996](https://discourse.julialang.org/u/AS011996)\
**Replies:** 1\
**Last updated:** [August 30, 2023, 8:03am UTC](https://discourse.julialang.org/t/are-vectorized-constraints-no-longer-supported-on-jump/103355 "2023-08-30T08:03:52Z")

</div>

The vectorized constraints on Constraints · JuMP no longer seems to work. The following code using JuMP model = Model(); @variable(model, x\[i=1:2\]) A = \[1 2; 3 4\] b = \[5, 6\] @constraint(model, con\_vector, A \* x == b)…

---

## [Combinatorial Benders cuts](https://discourse.julialang.org/t/combinatorial-benders-cuts/103012)

<div class="topic-metadata">

**Author:** [@papar](https://discourse.julialang.org/u/papar)\
**Replies:** 7\
**Last updated:** [August 30, 2023, 2:56am UTC](https://discourse.julialang.org/t/combinatorial-benders-cuts/103012 "2023-08-30T02:56:17Z")

</div>

I have a big-M constraint in a stochastic programming problem that I want to replace with combinatorial Benders cuts. I have tried implementing combinatorial Bender decomposition, but I get unbounded problem error when i…

---

## [Fix() variables not working with COSMO or Clarabel](https://discourse.julialang.org/t/fix-variables-not-working-with-cosmo-or-clarabel/103255)

<div class="topic-metadata">

**Author:** [@J\_T](https://discourse.julialang.org/u/J_T)\
**Replies:** 1\
**Last updated:** [August 27, 2023, 12:44pm UTC](https://discourse.julialang.org/t/fix-variables-not-working-with-cosmo-or-clarabel/103255 "2023-08-27T12:44:51Z")

</div>

I discoverd the issue trying a non-linear problem, but I can reproduce it with a simple linear example. using JuMP, Tulip, COSMO, Clarabel # const MT = Float64 const MT = Float32 # enough curvature to be interesting x …

---

## [The method JuMP classifies linear/affine/quadratic/nonlinear... types of constraints](https://discourse.julialang.org/t/the-method-jump-classifies-linear-affine-quadratic-nonlinear-types-of-constraints/103233)

<div class="topic-metadata">

**Author:** [@shawn\_T](https://discourse.julialang.org/u/shawn_T)\
**Replies:** 3\
**Last updated:** [August 26, 2023, 11:08pm UTC](https://discourse.julialang.org/t/the-method-jump-classifies-linear-affine-quadratic-nonlinear-types-of-constraints/103233 "2023-08-26T23:08:19Z")

</div>

I am learning to use Julia optimization package and found that JuMP can identify the above types of constraints from the input constraint expression, I do not quite understand how JuMP does it since I haven’t located the…

---

## [Problems with Generic numeric type in JuMP](https://discourse.julialang.org/t/problems-with-generic-numeric-type-in-jump/103221)

<div class="topic-metadata">

**Author:** [@J\_T](https://discourse.julialang.org/u/J_T)\
**Replies:** 2\
**Last updated:** [August 26, 2023, 9:45pm UTC](https://discourse.julialang.org/t/problems-with-generic-numeric-type-in-jump/103221 "2023-08-26T21:45:58Z")

</div>

For type T = Float64 the following works, but it fails for either T = Float32 and T = BigFloat: using JuMP, COSMO m = Model( COSMO.Optimizer{T} @variable( m, t \>= zero(T) ) @objective( m, Min, t ) optimize!( m ) It als…

---

## [Creating a sparse array with JuMP.QuadExpr elements](https://discourse.julialang.org/t/creating-a-sparse-array-with-jump-quadexpr-elements/103171)

<div class="topic-metadata">

**Author:** [@JPG](https://discourse.julialang.org/u/JPG)\
**Replies:** 2\
**Last updated:** [August 25, 2023, 3:58pm UTC](https://discourse.julialang.org/t/creating-a-sparse-array-with-jump-quadexpr-elements/103171 "2023-08-25T15:58:46Z")

</div>

Hello all, I’m very new to Julia and basically I want to define an empty sparse matrix of N x N and fill it up at certain points in the diagonal with just JuMP.QuadExpr elements. I know I can do: A = spzeros(N, N) but …

---

## [splitDict() function from PuLP](https://discourse.julialang.org/t/splitdict-function-from-pulp/103050)

<div class="topic-metadata">

**Author:** [@nemoincognito](https://discourse.julialang.org/u/nemoincognito)\
**Replies:** 1\
**Last updated:** [August 22, 2023, 2:09am UTC](https://discourse.julialang.org/t/splitdict-function-from-pulp/103050 "2023-08-22T02:09:34Z")

</div>

Hi I am migrating a lot of code over from PuLP to JuMP and just wanted to suggest that Julia put in a splitDict() function which is useful for Network Flow optimization work. I’ve added something that works below. funct…

---

## [How to analyse sensitivity in multi-optimal solution?](https://discourse.julialang.org/t/how-to-analyse-sensitivity-in-multi-optimal-solution/102938)

<div class="topic-metadata">

**Author:** [@jack\_lee](https://discourse.julialang.org/u/jack_lee)\
**Replies:** 6\
**Last updated:** [August 21, 2023, 10:28pm UTC](https://discourse.julialang.org/t/how-to-analyse-sensitivity-in-multi-optimal-solution/102938 "2023-08-21T22:28:39Z")

</div>

Here is the problem I meet: find the best plan; How much should the profit per unit of product III increase to make it worthwhile to arrange production? What is the range of variation of the profit of product I that …

---

## [JuMP: how to find which constraints a variable appears in](https://discourse.julialang.org/t/jump-how-to-find-which-constraints-a-variable-appears-in/103014)

<div class="topic-metadata">

**Author:** [@rjuly7](https://discourse.julialang.org/u/rjuly7)\
**Replies:** 2\
**Last updated:** [August 21, 2023, 2:37pm UTC](https://discourse.julialang.org/t/jump-how-to-find-which-constraints-a-variable-appears-in/103014 "2023-08-21T14:37:14Z")

</div>

I am using JuMP to formulate a large optimization problem. Is there any function which allows me to see all constraints in which a specific variable appears? Or if I have the reference to a specific constraint, is there …

---

## [Are there ways to preallocate memory via structs for JuMP autodiff?](https://discourse.julialang.org/t/are-there-ways-to-preallocate-memory-via-structs-for-jump-autodiff/102945)

<div class="topic-metadata">

**Author:** [@told](https://discourse.julialang.org/u/told)\
**Replies:** 2\
**Last updated:** [August 20, 2023, 8:58pm UTC](https://discourse.julialang.org/t/are-there-ways-to-preallocate-memory-via-structs-for-jump-autodiff/102945 "2023-08-20T20:58:20Z")

</div>

I’m very aware of the limitations of ForwardDiff.jl that code has to be written general enough to accept {T\<:Real}. The JuMP docs suggest to write target functions like function good\_f(x::T...) where {T\<:Real} y = …

---

## [Check for Total Unimodularity of a Matrix](https://discourse.julialang.org/t/check-for-total-unimodularity-of-a-matrix/102908)

<div class="topic-metadata">

**Author:** [@TBuConst](https://discourse.julialang.org/u/TBuConst)\
**Replies:** 2\
**Last updated:** [August 19, 2023, 5:55am UTC](https://discourse.julialang.org/t/check-for-total-unimodularity-of-a-matrix/102908 "2023-08-19T05:55:43Z")

</div>

Hi everyone, I’m wondering whether a specif function exists in Julia or in a package. Say, I have a matrix M and I want to find out, whether it is totally unimodular or not. Is there any ready-to-use function comparable…

---

## [Getting started example not running Optimization.jl](https://discourse.julialang.org/t/getting-started-example-not-running-optimization-jl/102944)

<div class="topic-metadata">

**Author:** [@p\_f](https://discourse.julialang.org/u/p_f)\
**Replies:** 3\
**Last updated:** [August 18, 2023, 5:34pm UTC](https://discourse.julialang.org/t/getting-started-example-not-running-optimization-jl/102944 "2023-08-18T17:34:12Z")

</div>

I’m assuming I’m missing something stupid, but I am just copy pasting code from the getting started section Getting Started with Optimization in Julia · Optimization.jl The very first block of code runs fine. The first …

---

## [About the generation of JuMP model files of MIQCP type from other platforms such as GAMS or AMLP](https://discourse.julialang.org/t/about-the-generation-of-jump-model-files-of-miqcp-type-from-other-platforms-such-as-gams-or-amlp/102914)

<div class="topic-metadata">

**Author:** [@JackaChou](https://discourse.julialang.org/u/JackaChou)\
**Replies:** 1\
**Last updated:** [August 18, 2023, 5:23am UTC](https://discourse.julialang.org/t/about-the-generation-of-jump-model-files-of-miqcp-type-from-other-platforms-such-as-gams-or-amlp/102914 "2023-08-18T05:23:04Z")

</div>

I want to solve a MIQCP type problem which is written in GAMS and the JuMP version is generated using the convert function. A painpoint is that the generated JuMP file is not recognized as a MIQCP problem but a general M…

---

## [Connecting a simple first-order solver to solve standard form linear program to JuMP](https://discourse.julialang.org/t/connecting-a-simple-first-order-solver-to-solve-standard-form-linear-program-to-jump/95694)

<div class="topic-metadata">

**Author:** [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Replies:** 37\
**Last updated:** [August 16, 2023, 8:14pm UTC](https://discourse.julialang.org/t/connecting-a-simple-first-order-solver-to-solve-standard-form-linear-program-to-jump/95694 "2023-08-16T20:14:48Z")

</div>

Dear All, To demonstrate the usage of first-order algorithms to solve linear programs in a graduate course that I am TAing (MIT 15.084: Nonlinear Optimization, link:https://gitlab.com/vanparys-courses/15.084-sp23) I hav…

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

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