# Optimization (Mathematical)

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

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

**Page:** 55

---

## [Different lags for DDEProblem](https://discourse.julialang.org/t/different-lags-for-ddeproblem/89482)

<div class="topic-metadata">

**Author:** [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Replies:** 2\
**Last updated:** [November 3, 2022, 1:33pm UTC](https://discourse.julialang.org/t/different-lags-for-ddeproblem/89482 "2022-11-03T13:33:08Z")

</div>

Hi! I try to use delay differential equations from DifferentialEquations.jl. I look at docs and make system with different delays, it works but looks not fine: hist1 = h(p, t)\[1\] hist2 = h(p, t - 2)\[2\] hist3 = h(p, …

---

## [How to linearize a conditional constraint in JuMP?](https://discourse.julialang.org/t/how-to-linearize-a-conditional-constraint-in-jump/89685)

<div class="topic-metadata">

**Author:** [@Alex\_ricci](https://discourse.julialang.org/u/Alex_ricci)\
**Replies:** 1\
**Last updated:** [November 3, 2022, 3:03am UTC](https://discourse.julialang.org/t/how-to-linearize-a-conditional-constraint-in-jump/89685 "2022-11-03T03:03:11Z")

</div>

Any proper way for linearizing this conditional constraint? if x \\leq 0 then y=0 if x \> 0 then y=1

---

## [How to define an array of variables in JuMP that has different lengths in different dimensions](https://discourse.julialang.org/t/how-to-define-an-array-of-variables-in-jump-that-has-different-lengths-in-different-dimensions/89598)

<div class="topic-metadata">

**Author:** [@Alex\_ricci](https://discourse.julialang.org/u/Alex_ricci)\
**Replies:** 1\
**Last updated:** [November 1, 2022, 6:43am UTC](https://discourse.julialang.org/t/how-to-define-an-array-of-variables-in-jump-that-has-different-lengths-in-different-dimensions/89598 "2022-11-01T06:43:44Z")

</div>

I have a parameter called z\_{t, w} with the size of 2 \\times 2 which is a vector of vectors. For example, z\_{1,1} and z\_{2,1} are z\[1,1\] = \[10 10 30 40 50\] z\[2,1\] = \[20 30 40\] I want to define a variable y based on z…

---

## [Jump quadratic problem](https://discourse.julialang.org/t/jump-quadratic-problem/89475)

<div class="topic-metadata">

**Author:** [@Muhammad\_Nadeem](https://discourse.julialang.org/u/Muhammad_Nadeem)\
**Replies:** 2\
**Last updated:** [November 1, 2022, 3:34am UTC](https://discourse.julialang.org/t/jump-quadratic-problem/89475 "2022-11-01T03:34:25Z")

</div>

Hello all, I am solving a simple quadratric problem of the form x\* = argmin 0.5 x'Qx + x'q # x # s.t. l1 ≤ Ax ≤ u1 my code is as follows: model = Model(HiGHS.Optimi…

---

## [How to include a customized function which takes expressions as input values inside a constraint?](https://discourse.julialang.org/t/how-to-include-a-customized-function-which-takes-expressions-as-input-values-inside-a-constraint/89187)

<div class="topic-metadata">

**Author:** [@Alex\_ricci](https://discourse.julialang.org/u/Alex_ricci)\
**Replies:** 3\
**Last updated:** [November 1, 2022, 12:37am UTC](https://discourse.julialang.org/t/how-to-include-a-customized-function-which-takes-expressions-as-input-values-inside-a-constraint/89187 "2022-11-01T00:37:38Z")

</div>

consider this program H=4 J=3 m = Model(GLPK.Optimizer) @variable(m, x\[ 1:H , 1:J \], Bin) I am trying to model this constraint: Where 1.() is an indicator function. After a few hours of playing this is the best I c…

---

## [Getting output after solver timeout reached](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324)

<div class="topic-metadata">

**Author:** [@Viktor\_Pavlovic](https://discourse.julialang.org/u/Viktor_Pavlovic)\
**Replies:** 9\
**Last updated:** [October 31, 2022, 8:03pm UTC](https://discourse.julialang.org/t/getting-output-after-solver-timeout-reached/81324 "2022-10-31T20:03:07Z")

</div>

Hello all, I have recently started using Couenne to solve MINLPs and have now encountered problems where I don’t obtain a solution in a reasonable amount of time. I am wondering if I can get set a time limit and obtain …

---

## [JuMP optimization](https://discourse.julialang.org/t/jump-optimization/89528)

<div class="topic-metadata">

**Author:** [@Muhammad\_Nadeem](https://discourse.julialang.org/u/Muhammad_Nadeem)\
**Replies:** 2\
**Last updated:** [October 30, 2022, 7:25pm UTC](https://discourse.julialang.org/t/jump-optimization/89528 "2022-10-30T19:25:36Z")

</div>

Hello all, I am trying to solve an optimization problem in JUMP, however it is giving me some weird error (at least to me :slight\_smile: ), please see my code below using JuMP using HiGHS Q = \[1 0; 0 1.0\] A = zero…

---

## [Can't seem to get Optimization.jl to converge to solution in Monte Carlo simulation but the objective function seems to work okay otherwise](https://discourse.julialang.org/t/cant-seem-to-get-optimization-jl-to-converge-to-solution-in-monte-carlo-simulation-but-the-objective-function-seems-to-work-okay-otherwise/88764)

<div class="topic-metadata">

**Author:** [@sumant28](https://discourse.julialang.org/u/sumant28)\
**Replies:** 9\
**Last updated:** [October 29, 2022, 5:00pm UTC](https://discourse.julialang.org/t/cant-seem-to-get-optimization-jl-to-converge-to-solution-in-monte-carlo-simulation-but-the-objective-function-seems-to-work-okay-otherwise/88764 "2022-10-29T17:00:12Z")

</div>

A basic binary logic works fine using Optimization, OptimizationOptimJL, OptimizationBBO, OptimizationMOI, ForwardDiff, ModelingToolkit, Random function SimulateBinaryLogit(x, Beta) N = size(x, 1) J = size(Beta, 1)…

---

## [Problem summing multiple dims in NLobjective](https://discourse.julialang.org/t/problem-summing-multiple-dims-in-nlobjective/89442)

<div class="topic-metadata">

**Author:** [@this\_josh](https://discourse.julialang.org/u/this_josh)\
**Replies:** 3\
**Last updated:** [October 29, 2022, 8:30am UTC](https://discourse.julialang.org/t/problem-summing-multiple-dims-in-nlobjective/89442 "2022-10-29T08:30:34Z")

</div>

I’m having trouble using matrices in an NLobjective model = Model() @variable(model, 0 .\<= x\[1:100, 1:100\] .\<= 1) @NLexpression(model,x\_con\[ii=1:100, jj=1:100\], x\[ii,jj\] \* abs(x\[ii,jj\])) This works @NLobjective(model…

---

## [Implement time out when creating the model](https://discourse.julialang.org/t/implement-time-out-when-creating-the-model/89451)

<div class="topic-metadata">

**Author:** [@dourouc05](https://discourse.julialang.org/u/dourouc05)\
**Replies:** 3\
**Last updated:** [October 28, 2022, 11:36pm UTC](https://discourse.julialang.org/t/implement-time-out-when-creating-the-model/89451 "2022-10-28T23:36:49Z")

</div>

Hi, I’m comparing several ways of solving the same problem. One of these approaches create extremely large models, so large that @variable(model, variable\[e in edges(graph), d in edges(graph2), v in vertices(graph)\]) ta…

---

## [Using simplex method with Mosek with MosekTool package](https://discourse.julialang.org/t/using-simplex-method-with-mosek-with-mosektool-package/89416)

<div class="topic-metadata">

**Author:** [@Khashayar-Neshat](https://discourse.julialang.org/u/Khashayar-Neshat)\
**Replies:** 2\
**Last updated:** [October 28, 2022, 5:56pm UTC](https://discourse.julialang.org/t/using-simplex-method-with-mosek-with-mosektool-package/89416 "2022-10-28T17:56:31Z")

</div>

Hi, I want to solve a linear programming problem with the SumOfSquare package with Mosek. How can I tell the MosekTool package that Mosek use the simplex method instead of the interior point method?

---

## [Soft constraints in JuMP](https://discourse.julialang.org/t/soft-constraints-in-jump/89373)

<div class="topic-metadata">

**Author:** [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Replies:** 1\
**Last updated:** [October 27, 2022, 4:04pm UTC](https://discourse.julialang.org/t/soft-constraints-in-jump/89373 "2022-10-27T16:04:14Z")

</div>

I am completely new to the JuMP.jl package. I am trying to set soft constraints with different weights but only getting errors for any constraints I set. I would like something similar to this link I have tried using…

---

## [SDP Sum of Squares optimization](https://discourse.julialang.org/t/sdp-sum-of-squares-optimization/88487)

<div class="topic-metadata">

**Author:** [@parf](https://discourse.julialang.org/u/parf)\
**Replies:** 10\
**Last updated:** [October 27, 2022, 1:45pm UTC](https://discourse.julialang.org/t/sdp-sum-of-squares-optimization/88487 "2022-10-27T13:45:08Z")

</div>

I am trying to solve the following optimization problem: using DynamicPolynomials using SumOfSquares using SDPAFamily χ=1.0 @polyvar x1 x2 x3 x4 f = \[2\*x1\*x4 - 2\*x2\*x3 - x1, -2\*x1\*x3 - 2\*x2\*x4 - x2, 2\*x1\*x2,…

---

## [Polyhedron of JuMP model with Polyhedra or Lazyset](https://discourse.julialang.org/t/polyhedron-of-jump-model-with-polyhedra-or-lazyset/89218)

<div class="topic-metadata">

**Author:** [@papar](https://discourse.julialang.org/u/papar)\
**Replies:** 7\
**Last updated:** [October 26, 2022, 10:53pm UTC](https://discourse.julialang.org/t/polyhedron-of-jump-model-with-polyhedra-or-lazyset/89218 "2022-10-26T22:53:48Z")

</div>

Hello, I want to plot a 3D polyhedron of a JuMP model for education purposes. I have seen these packages Polyhedra and LazySets, but I am unsure how to convert a JuMP model. I believe it requires projection/elimination.…

---

## [Print JuMP model in IJulia in plain text (i.e. non-LaTeX)](https://discourse.julialang.org/t/print-jump-model-in-ijulia-in-plain-text-i-e-non-latex/89276)

<div class="topic-metadata">

**Author:** [@fleimgruber](https://discourse.julialang.org/u/fleimgruber)\
**Replies:** 4\
**Last updated:** [October 26, 2022, 9:07am UTC](https://discourse.julialang.org/t/print-jump-model-in-ijulia-in-plain-text-i-e-non-latex/89276 "2022-10-26T09:07:57Z")

</div>

I want to use JuMP with the IJulia server, but in a reduced editing environment, i.e. not inside a browser. For this reason I want a call to print(model) to print in plain text instead of LaTeX. I found (old) code exampl…

---

## [JuMP with Mosek against CVX/Yalmip/Mosek API](https://discourse.julialang.org/t/jump-with-mosek-against-cvx-yalmip-mosek-api/89231)

<div class="topic-metadata">

**Author:** [@nkuma](https://discourse.julialang.org/u/nkuma)\
**Replies:** 1\
**Last updated:** [October 25, 2022, 4:16am UTC](https://discourse.julialang.org/t/jump-with-mosek-against-cvx-yalmip-mosek-api/89231 "2022-10-25T04:16:34Z")

</div>

I’m pretty new in Julia and I am interested in using Mosek with JuMP. I have been using Mosek with CVX and Yalmip in Matlab, but ran into some issues with speed. Is there any comparison with these solvers in terms of p…

---

## [Problems with integer stack size](https://discourse.julialang.org/t/problems-with-integer-stack-size/89192)

<div class="topic-metadata">

**Author:** [@mb96](https://discourse.julialang.org/u/mb96)\
**Replies:** 6\
**Last updated:** [October 24, 2022, 7:26pm UTC](https://discourse.julialang.org/t/problems-with-integer-stack-size/89192 "2022-10-24T19:26:15Z")

</div>

Hi, I am solving a optimization problem with 13104 variables the maximization is looped over some set of initial conditions. At some point I get the following problem: Can some provide some information about what in…

---

## [Question about quadratic cost function in JuMP](https://discourse.julialang.org/t/question-about-quadratic-cost-function-in-jump/89143)

<div class="topic-metadata">

**Author:** [@Steve\_Zhang](https://discourse.julialang.org/u/Steve_Zhang)\
**Replies:** 2\
**Last updated:** [October 24, 2022, 1:56am UTC](https://discourse.julialang.org/t/question-about-quadratic-cost-function-in-jump/89143 "2022-10-24T01:56:52Z")

</div>

I am new to Julia and transferred from Matlab. Now I am using JuMP to write an optimization problem with a quadratic cost function like: and my code for optimization problem is: function get\_cost\_func(sys, R, M) …

---

## [PATHsolver not working](https://discourse.julialang.org/t/pathsolver-not-working/89156)

<div class="topic-metadata">

**Author:** [@Muhammad\_Nadeem](https://discourse.julialang.org/u/Muhammad_Nadeem)\
**Replies:** 3\
**Last updated:** [October 23, 2022, 11:25pm UTC](https://discourse.julialang.org/t/pathsolver-not-working/89156 "2022-10-23T23:25:00Z")

</div>

Hello all, I am trying to run a simple mixed complementary problem using PATHsolver, but it is giving me this error “UndefVarError: solveMCP not defined” My code is: using PATHSolver M = \[0 0 -1 -1 ; 0 0 1 -2 ; …

---

## [Unsupported Argument in Optimization.solve](https://discourse.julialang.org/t/unsupported-argument-in-optimization-solve/89146)

<div class="topic-metadata">

**Author:** [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Replies:** 1\
**Last updated:** [October 23, 2022, 5:29pm UTC](https://discourse.julialang.org/t/unsupported-argument-in-optimization-solve/89146 "2022-10-23T17:29:48Z")

</div>

I am running a demonstration of NeuralODE, fond at: https://diffeqflux.sciml.ai/stable/examples/neural\_ode/: result\_neuralode2 = Optimization.solve(optprob2, Optim.BFGS(initial\_stepnorm=0.01), callback = callb…

---

## [JuMP constraint with limited dimension of an index](https://discourse.julialang.org/t/jump-constraint-with-limited-dimension-of-an-index/89100)

<div class="topic-metadata">

**Author:** [@MeryKay](https://discourse.julialang.org/u/MeryKay)\
**Replies:** 1\
**Last updated:** [October 22, 2022, 9:57am UTC](https://discourse.julialang.org/t/jump-constraint-with-limited-dimension-of-an-index/89100 "2022-10-22T09:57:15Z")

</div>

Hi everyboday! In one constraint, I want to limit my index to a specific intervall within the intervall which is used in all other cases. More specific this means: index p is normally defined in p = 1:P whereby P=10 N…

---

## [Optimizing noisy objective](https://discourse.julialang.org/t/optimizing-noisy-objective/25260)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 60\
**Last updated:** [October 22, 2022, 8:19am UTC](https://discourse.julialang.org/t/optimizing-noisy-objective/25260 "2022-10-22T08:19:10Z")

</div>

I have a f: \\mathbb{R}^n \\to \\mathbb{R}^m function, m \> n, and I am trying to minimize some norm of f(x). The norm itself is flexible, I would like to get something working. The problem is that f is stochastic as it com…

---

## [MILP: formulation of sums with barriers](https://discourse.julialang.org/t/milp-formulation-of-sums-with-barriers/89067)

<div class="topic-metadata">

**Author:** [@MeryKay](https://discourse.julialang.org/u/MeryKay)\
**Replies:** 4\
**Last updated:** [October 21, 2022, 5:17pm UTC](https://discourse.julialang.org/t/milp-formulation-of-sums-with-barriers/89067 "2022-10-21T17:17:48Z")

</div>

I want to program a sum over an indexed variable, whereby the index has a barrier just for this constraint. sum(X\[t\] for t=1:T) is clear to me, but how can I integrate the barrier of t\<= R\_j as shown in the screenshot. …

---

## [Nonlinear semidefinite programming recommendation](https://discourse.julialang.org/t/nonlinear-semidefinite-programming-recommendation/75338)

<div class="topic-metadata">

**Author:** [@wujinq](https://discourse.julialang.org/u/wujinq)\
**Replies:** 17\
**Last updated:** [October 21, 2022, 2:38pm UTC](https://discourse.julialang.org/t/nonlinear-semidefinite-programming-recommendation/75338 "2022-10-21T14:38:10Z")

</div>

I want to do the following optimization: \\min E \\ \\ \\text{s.t.} \\ \\ x \\in \\mathbb{R}, \\ \\ \\text{$M$ is semidefinite}, where M\_{ij} is a polynominal of x and E. Is there a Julia package suitable for this problem?

---

## [Optimizing over the quantum entropy cone natively in JuMP](https://discourse.julialang.org/t/optimizing-over-the-quantum-entropy-cone-natively-in-jump/59833)

<div class="topic-metadata">

**Author:** [@ryancorywright](https://discourse.julialang.org/u/ryancorywright)\
**Replies:** 6\
**Last updated:** [October 21, 2022, 12:33pm UTC](https://discourse.julialang.org/t/optimizing-over-the-quantum-entropy-cone-natively-in-jump/59833 "2022-10-21T12:33:31Z")

</div>

Hi everyone, I was wondering if it was possible to optimize over the quantum entropy cone natively in JuMP. If you need a reminder, the cone is \\{(X\_1, X\_2, X\_3): X\_1 \\preceq X\_2^{\\frac{1}{2}} \\log(X\_2^{\\frac{-1}{2}}X…

---

## [Reducing framework overhead of solving a simple JuMP model in a hot loop](https://discourse.julialang.org/t/reducing-framework-overhead-of-solving-a-simple-jump-model-in-a-hot-loop/88977)

<div class="topic-metadata">

**Author:** [@erwinkn](https://discourse.julialang.org/u/erwinkn)\
**Replies:** 4\
**Last updated:** [October 20, 2022, 7:34pm UTC](https://discourse.julialang.org/t/reducing-framework-overhead-of-solving-a-simple-jump-model-in-a-hot-loop/88977 "2022-10-20T19:34:57Z")

</div>

I have a nonlinear JuMP model that is used in a hot loop: it is run 4000-8000 times, each run with a different set of parameters. The reason for this loop is that I want to perform global sensitivity analysis on the para…

---

## [Slicing a SparseAxisArray Variable in JuMP](https://discourse.julialang.org/t/slicing-a-sparseaxisarray-variable-in-jump/88332)

<div class="topic-metadata">

**Author:** [@Janogo](https://discourse.julialang.org/u/Janogo)\
**Replies:** 11\
**Last updated:** [October 19, 2022, 10:55pm UTC](https://discourse.julialang.org/t/slicing-a-sparseaxisarray-variable-in-jump/88332 "2022-10-19T22:55:06Z")

</div>

Hi everyone, I wish to slice a SparseAxisArray Container in JuMP. The documentation says this should work: julia\> x = Containers.@container(\[i = 1:3, j = \[:A, :B\]; i \> 1\], (i, j)) JuMP.Containers.SparseAxisArray{Tuple{…

---

## [Creating fixed model associated with a MIP model using Gurobi in JuMP](https://discourse.julialang.org/t/creating-fixed-model-associated-with-a-mip-model-using-gurobi-in-jump/88961)

<div class="topic-metadata">

**Author:** [@SarojKhanal](https://discourse.julialang.org/u/SarojKhanal)\
**Replies:** 1\
**Last updated:** [October 19, 2022, 8:39pm UTC](https://discourse.julialang.org/t/creating-fixed-model-associated-with-a-mip-model-using-gurobi-in-jump/88961 "2022-10-19T20:39:23Z")

</div>

Hi, I am using JuMP and Gurobi solver to implement a mixed-integer linear program model and trying to access duals. I see \[Model.fixed()\](https://www.gurobi.com/documentation/9.5/refman/py\_model\_fixed.html) as a way to f…

---

## [Maximize sum of the piecewise function](https://discourse.julialang.org/t/maximize-sum-of-the-piecewise-function/88882)

<div class="topic-metadata">

**Author:** [@t.sh](https://discourse.julialang.org/u/t.sh)\
**Replies:** 2\
**Last updated:** [October 18, 2022, 5:00am UTC](https://discourse.julialang.org/t/maximize-sum-of-the-piecewise-function/88882 "2022-10-18T05:00:03Z")

</div>

I am the new in JuMP package, and I am trying to solve the optimization with a piecewise function My maximum working example looks as follows: using JuMP, Ipopt function sum\_rate(β::T ...) where {T \<: Real} rate =…

---

## [HiGHS duals for MIPs](https://discourse.julialang.org/t/highs-duals-for-mips/88817)

<div class="topic-metadata">

**Author:** [@adow031](https://discourse.julialang.org/u/adow031)\
**Replies:** 2\
**Last updated:** [October 17, 2022, 5:15am UTC](https://discourse.julialang.org/t/highs-duals-for-mips/88817 "2022-10-17T05:15:25Z")

</div>

I’m testing out the HiGHS optimizer in JuMP, and have found that HiGHS returns duals (they all seem to be 0) for MIPs. All other optimizers that I’ve used return errors when attempting to find duals of MIPs: ERROR: Asse…

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

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