# Optimization (Mathematical)

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

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

**Page:** 50

---

## [How to optimize trace of matrix inverse with JuMP or Convex?](https://discourse.julialang.org/t/how-to-optimize-trace-of-matrix-inverse-with-jump-or-convex/94167)

<div class="topic-metadata">

**Author:** [@biona001](https://discourse.julialang.org/u/biona001)\
**Replies:** 6\
**Last updated:** [February 10, 2023, 1:03am UTC](https://discourse.julialang.org/t/how-to-optimize-trace-of-matrix-inverse-with-jump-or-convex/94167 "2023-02-10T01:03:43Z")

</div>

Hi community, I want to minimize tr(S^{-1}) + tr((A - S)^{-1}) such that S \\succeq 0 and A - S \\succeq 0 (S is the optimization matrix, A is some fixed positive definite matrix) I tried using JuMP + Hypatia: using Hyp…

---

## [What is the difference between variable definition in JuMP like these two ways](https://discourse.julialang.org/t/what-is-the-difference-between-variable-definition-in-jump-like-these-two-ways/94337)

<div class="topic-metadata">

**Author:** [@Betristor](https://discourse.julialang.org/u/Betristor)\
**Replies:** 4\
**Last updated:** [February 9, 2023, 8:20pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-variable-definition-in-jump-like-these-two-ways/94337 "2023-02-09T20:20:20Z")

</div>

I got two difinition ways used in my JuMP model. And I encountered some trouble when I try to access their results using value function. A is a variable defined as @variable(M, A\[i = 1:3, t = 1:24\]) and B is like @variab…

---

## [Number of iterations increases with successive optimizations](https://discourse.julialang.org/t/number-of-iterations-increases-with-successive-optimizations/94352)

<div class="topic-metadata">

**Author:** [@aurelhern](https://discourse.julialang.org/u/aurelhern)\
**Replies:** 2\
**Last updated:** [February 9, 2023, 7:40pm UTC](https://discourse.julialang.org/t/number-of-iterations-increases-with-successive-optimizations/94352 "2023-02-09T19:40:59Z")

</div>

Dear all, I am running an optimization problem (multi-period DC-optimal power flow). And when using set\_normalized\_rhs function to modify the constant term on the right-hand-side of the concerned constraints and re-opti…

---

## [Error in InfiniteOpt.jl quick start example](https://discourse.julialang.org/t/error-in-infiniteopt-jl-quick-start-example/94275)

<div class="topic-metadata">

**Author:** [@Jian\_ZUO](https://discourse.julialang.org/u/Jian_ZUO)\
**Replies:** 5\
**Last updated:** [February 9, 2023, 7:23pm UTC](https://discourse.julialang.org/t/error-in-infiniteopt-jl-quick-start-example/94275 "2023-02-09T19:23:37Z")

</div>

Hi everyone, I have tried to run a tutorial example in InfiniteOpt.jl. using InfiniteOpt, Distributions, Ipopt # DEFINE THE PROBLEM CONSTANTS μ = 1; σ = 0.2 x0 = \[0, 0\]; v0 = \[0, 0\] p = \[1 4 6 1; 1 3 0 1\]; tw = \[0,…

---

## [Piecewise-constant fitting](https://discourse.julialang.org/t/piecewise-constant-fitting/94091)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 21\
**Last updated:** [February 9, 2023, 12:40am UTC](https://discourse.julialang.org/t/piecewise-constant-fitting/94091 "2023-02-09T00:40:42Z")

</div>

Is there an example or a Julia package for piecewise-constant fitting of 1D series? See a Matlab example of expected results here. Thanks.

---

## [How to define multiple random variables in SDDP](https://discourse.julialang.org/t/how-to-define-multiple-random-variables-in-sddp/94231)

<div class="topic-metadata">

**Author:** [@Sorooshsa](https://discourse.julialang.org/u/Sorooshsa)\
**Replies:** 5\
**Last updated:** [February 8, 2023, 6:52pm UTC](https://discourse.julialang.org/t/how-to-define-multiple-random-variables-in-sddp/94231 "2023-02-08T18:52:25Z")

</div>

Hi everyone, I have a small stochastic hydropower problem. As you may know, water inflows are considered random variables in most hydropower problems, just like my problem. There is a well-structured example here: htt…

---

## [MOI: Re-evaluate custom bridge & \`direct\_model(...)\` bridging](https://discourse.julialang.org/t/moi-re-evaluate-custom-bridge-direct-model-bridging/94219)

<div class="topic-metadata">

**Author:** [@sstroemer](https://discourse.julialang.org/u/sstroemer)\
**Replies:** 9\
**Last updated:** [February 8, 2023, 7:36am UTC](https://discourse.julialang.org/t/moi-re-evaluate-custom-bridge-direct-model-bridging/94219 "2023-02-08T07:36:20Z")

</div>

As far as I understand, when I add a custom bridge (struct MyCustomBridge{T} \<: MOI.Bridges.Constraint.AbstractBridge end) to my model using model = JuMP.Model(HiGHS.Optimizer) MOI.Bridges.add\_bridge(JuMP.backend(model…

---

## [JuMP: Multiplicative parameters for LP](https://discourse.julialang.org/t/jump-multiplicative-parameters-for-lp/94192)

<div class="topic-metadata">

**Author:** [@sstroemer](https://discourse.julialang.org/u/sstroemer)\
**Replies:** 3\
**Last updated:** [February 7, 2023, 7:52pm UTC](https://discourse.julialang.org/t/jump-multiplicative-parameters-for-lp/94192 "2023-02-07T19:52:45Z")

</div>

I’m trying to rework how “model parameters” work in my model. I know that using JuMP import HiGHS model = direct\_model(HiGHS.Optimizer()) p = @variable(model) fix(p, 1.0; force=true) x = @variable(model) @constraint(…

---

## [Gradient norm does not change in \`Optim\` using \`autodiff\`](https://discourse.julialang.org/t/gradient-norm-does-not-change-in-optim-using-autodiff/94215)

<div class="topic-metadata">

**Author:** [@csev](https://discourse.julialang.org/u/csev)\
**Replies:** 2\
**Last updated:** [February 7, 2023, 6:31pm UTC](https://discourse.julialang.org/t/gradient-norm-does-not-change-in-optim-using-autodiff/94215 "2023-02-07T18:31:59Z")

</div>

I’m trying to figure out how to interpret the occasional failure of an optimization routine to move form a candidate point. Below (at bottom) is output from Optim using NewtonTrustRegion, with autodiff = true. The neithe…

---

## [UndefVarError: with\_optimizer not defined with ProxSDP](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076)

<div class="topic-metadata">

**Author:** [@horvetz](https://discourse.julialang.org/u/horvetz)\
**Replies:** 4\
**Last updated:** [February 7, 2023, 6:17am UTC](https://discourse.julialang.org/t/undefvarerror-with-optimizer-not-defined-with-proxsdp/94076 "2023-02-07T06:17:32Z")

</div>

I just installed ProxSDP, but when I tried this test code, # Load packages using ProxSDP, JuMP, LinearAlgebra # Number of vertices n = 4 # Graph weights W = \[18.0 -5.0 -7.0 -6.0 -5.0 6.0 0.0 -1.0 -7.0…

---

## [Recommended optimizer in OptimizationBBO](https://discourse.julialang.org/t/recommended-optimizer-in-optimizationbbo/94188)

<div class="topic-metadata">

**Author:** [@magnumopus94](https://discourse.julialang.org/u/magnumopus94)\
**Replies:** 1\
**Last updated:** [February 7, 2023, 11:53am UTC](https://discourse.julialang.org/t/recommended-optimizer-in-optimizationbbo/94188 "2023-02-07T11:53:51Z")

</div>

Hello! I’ve been using the OptimizationBBO.jl recently. In the GitHub page, it is stated that The recommended optimizer is BBO\_adaptive\_de\_rand\_1\_bin\_radiuslimited() May I know why this is the case? On what basis i…

---

## [Constrain 2D array variable to contain a value \`x\` number of times](https://discourse.julialang.org/t/constrain-2d-array-variable-to-contain-a-value-x-number-of-times/94180)

<div class="topic-metadata">

**Author:** [@dash102](https://discourse.julialang.org/u/dash102)\
**Replies:** 3\
**Last updated:** [February 7, 2023, 4:20am UTC](https://discourse.julialang.org/t/constrain-2d-array-variable-to-contain-a-value-x-number-of-times/94180 "2023-02-07T04:20:31Z")

</div>

I am trying to solve for a 2D array x of dimension 4x2 that satisfy the following: x contains integers between 0 and 5 (inclusive) For each column col of x: 1 \<= col\[i\] - col\[i-2\] \<= 2 for i = 3, 4, 7, 8 col\[i\] % …

---

## [How to access variables and expressions faster in jump](https://discourse.julialang.org/t/how-to-access-variables-and-expressions-faster-in-jump/94123)

<div class="topic-metadata">

**Author:** [@Betristor](https://discourse.julialang.org/u/Betristor)\
**Replies:** 4\
**Last updated:** [February 6, 2023, 7:42pm UTC](https://discourse.julialang.org/t/how-to-access-variables-and-expressions-faster-in-jump/94123 "2023-02-06T19:42:58Z")

</div>

I established a very large model using julia with plenty of variables and expressions. Though not all of these will be meaningful for accessing, I still wrote all into results in dataframe and then saved to csv files. I’…

---

## [Query Gurobi attributes of JuMP model](https://discourse.julialang.org/t/query-gurobi-attributes-of-jump-model/94113)

<div class="topic-metadata">

**Author:** [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Replies:** 2\
**Last updated:** [February 6, 2023, 2:15am UTC](https://discourse.julialang.org/t/query-gurobi-attributes-of-jump-model/94113 "2023-02-06T02:15:33Z")

</div>

I am interested in obtaining particular solution attributes (e.g., DualVio) of my Gurobi model constructed by JuMP. Can I use the Gurobi.jl C interface to query a solved JuMP model to obtain solution quality attributes? …

---

## [How interpret constraint values for inequalities?](https://discourse.julialang.org/t/how-interpret-constraint-values-for-inequalities/93866)

<div class="topic-metadata">

**Author:** [@hugh\_man](https://discourse.julialang.org/u/hugh_man)\
**Replies:** 3\
**Last updated:** [February 5, 2023, 11:59pm UTC](https://discourse.julialang.org/t/how-interpret-constraint-values-for-inequalities/93866 "2023-02-05T23:59:06Z")

</div>

Hello, I’m trying to understand the values outputted when evaluating a constraint. In another thread I received this useful response on how to evaluate constraints. I’ll use a slightly modified example from there (pas…

---

## [Mosek Solver Option](https://discourse.julialang.org/t/mosek-solver-option/94106)

<div class="topic-metadata">

**Author:** [@A\_M](https://discourse.julialang.org/u/A_M)\
**Replies:** 3\
**Last updated:** [February 5, 2023, 11:57pm UTC](https://discourse.julialang.org/t/mosek-solver-option/94106 "2023-02-05T23:57:35Z")

</div>

Solving a linear problem using Mosek, I set MSK\_DPAR\_INTPNT\_TOL\_PFEAS, which is Primal feasibility tolerance used by the interior-point optimizer for linear problems, to 1.0 by set\_optimizer\_attribute(model, "MSK\_DPAR\_I…

---

## [Bayesian optimization](https://discourse.julialang.org/t/bayesian-optimization/94060)

<div class="topic-metadata">

**Author:** [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Replies:** 8\
**Last updated:** [February 5, 2023, 10:44pm UTC](https://discourse.julialang.org/t/bayesian-optimization/94060 "2023-02-05T22:44:45Z")

</div>

Hello, I try to understand Bayesian optimization, which I want to use for the estimation of the power coefficient of a wind turbine which is a function of (at least) the wind speed and declines over the years. Can it b…

---

## [Manipulate sparse arrays](https://discourse.julialang.org/t/manipulate-sparse-arrays/94082)

<div class="topic-metadata">

**Author:** [@Tri](https://discourse.julialang.org/u/Tri)\
**Replies:** 2\
**Last updated:** [February 5, 2023, 10:02pm UTC](https://discourse.julialang.org/t/manipulate-sparse-arrays/94082 "2023-02-05T22:02:44Z")

</div>

I am using sparse array as variables in the following: using Ipopt,JuMP model = Model(Ipopt.Optimizer) n = 4 @variable(model, X\[i=1:n, j=1:i-1\] \>=0) @variable(model, y\[1:n\]\>=0) @variable(model, z\[1:n\]) @NLconstraint…

---

## [Unable to add objectives in vector form using JuMP](https://discourse.julialang.org/t/unable-to-add-objectives-in-vector-form-using-jump/94041)

<div class="topic-metadata">

**Author:** [@Gokhan\_Kof](https://discourse.julialang.org/u/Gokhan_Kof)\
**Replies:** 5\
**Last updated:** [February 4, 2023, 8:51pm UTC](https://discourse.julialang.org/t/unable-to-add-objectives-in-vector-form-using-jump/94041 "2023-02-04T20:51:11Z")

</div>

Hi, I was trying to test multi-objective support of JuMP (MOO) pkg\> st Project MOO v0.0.1 Status \`~/Desktop/MOO.jl/Project.toml\` \[60bf3e95\] GLPK v1.1.0 \[4076af6c\] JuMP v1.7.0 \`https://github.com/jump-dev…

---

## [Equivalent Circuit Optimization](https://discourse.julialang.org/t/equivalent-circuit-optimization/93907)

<div class="topic-metadata">

**Author:** [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Replies:** 9\
**Last updated:** [February 3, 2023, 4:30pm UTC](https://discourse.julialang.org/t/equivalent-circuit-optimization/93907 "2023-02-03T16:30:45Z")

</div>

Hi, yesterday I worked on a script provided by Maxime to find an optimal solution for the parameters of an equivalent circuit. For this purpose there is the established python package impedance.py, but this package fai…

---

## [JuMP MethodError: Cannot \`convert\` an object of type AffExpr to an object of type VariableRef](https://discourse.julialang.org/t/jump-methoderror-cannot-convert-an-object-of-type-affexpr-to-an-object-of-type-variableref/93951)

<div class="topic-metadata">

**Author:** [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Replies:** 2\
**Last updated:** [February 3, 2023, 1:35am UTC](https://discourse.julialang.org/t/jump-methoderror-cannot-convert-an-object-of-type-affexpr-to-an-object-of-type-variableref/93951 "2023-02-03T01:35:18Z")

</div>

The first way of imposing the constraints works. The second way causes the error below. Is there a better way to impose theses constraints? using JuMP using LinearAlgebra v = 64 J = 10 model = Model() @variable(model, …

---

## [Defining a JuMP binary variable](https://discourse.julialang.org/t/defining-a-jump-binary-variable/93904)

<div class="topic-metadata">

**Author:** [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Replies:** 1\
**Last updated:** [February 2, 2023, 4:44am UTC](https://discourse.julialang.org/t/defining-a-jump-binary-variable/93904 "2023-02-02T04:44:44Z")

</div>

Is there a difference in performance within JuMP, MOI, and/or the third-party MILP solver between the two possible ways of defining a binary variable given below? @variable(m, b, Int, lower\_bound = 0, upper\_bound = 1) …

---

## [Help in Optim/optimize - structure of code and help](https://discourse.julialang.org/t/help-in-optim-optimize-structure-of-code-and-help/93656)

<div class="topic-metadata">

**Author:** [@Outeirom](https://discourse.julialang.org/u/Outeirom)\
**Replies:** 2\
**Last updated:** [February 1, 2023, 3:55am UTC](https://discourse.julialang.org/t/help-in-optim-optimize-structure-of-code-and-help/93656 "2023-02-01T03:55:49Z")

</div>

I have a code taht is more or less like this: fixed parameters \\alpha, \\beta... that never changes #then I have vector of parameters I want to calibrate (theta) and target (mom\_data) theta = \[ \*vector of parameters to …

---

## [How to get ordering of constraints when calling eval\_constraint?](https://discourse.julialang.org/t/how-to-get-ordering-of-constraints-when-calling-eval-constraint/93772)

<div class="topic-metadata">

**Author:** [@hugh\_man](https://discourse.julialang.org/u/hugh_man)\
**Replies:** 2\
**Last updated:** [January 31, 2023, 4:00pm UTC](https://discourse.julialang.org/t/how-to-get-ordering-of-constraints-when-calling-eval-constraint/93772 "2023-01-31T16:00:09Z")

</div>

Hello, I have a large JuMP model constructed programmatically as a function of some input data. My ultimate goal is to plug in arbitrary values into the variables and evaluate the values of the constraints. To accompi…

---

## [Vectorized Modulo Function for JuMP](https://discourse.julialang.org/t/vectorized-modulo-function-for-jump/93800)

<div class="topic-metadata">

**Author:** [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Replies:** 3\
**Last updated:** [January 31, 2023, 4:25am UTC](https://discourse.julialang.org/t/vectorized-modulo-function-for-jump/93800 "2023-01-31T04:25:01Z")

</div>

I’m trying to write a vectorized modulo function for JuMP to be invoked via: e = reformulate\_mod\_vec(model, A\*\[x;y\], v) A is a Jx(n+m) fixed matrix, x is a nx1 vector of JuMP variables, y is a mx1 vector of JuMP variab…

---

## [How to use the rule set from ChainRules.jl?](https://discourse.julialang.org/t/how-to-use-the-rule-set-from-chainrules-jl/93658)

<div class="topic-metadata">

**Author:** [@Jonas208](https://discourse.julialang.org/u/Jonas208)\
**Replies:** 1\
**Last updated:** [January 30, 2023, 10:10pm UTC](https://discourse.julialang.org/t/how-to-use-the-rule-set-from-chainrules-jl/93658 "2023-01-30T22:10:59Z")

</div>

What is the best way to use the ruleset from ChainRules.jl if you want to build an AD engine based on operator overloading. I can’t find much useful information in the ChainRules documentation, nor in the ChainRulesOver…

---

## [How to access the exit of MadNLP solver directly](https://discourse.julialang.org/t/how-to-access-the-exit-of-madnlp-solver-directly/93685)

<div class="topic-metadata">

**Author:** [@VPBML](https://discourse.julialang.org/u/VPBML)\
**Replies:** 5\
**Last updated:** [January 29, 2023, 8:39pm UTC](https://discourse.julialang.org/t/how-to-access-the-exit-of-madnlp-solver-directly/93685 "2023-01-29T20:39:52Z")

</div>

Hi all, I wonder if it is possible to access the exit of a solver directly from JuMP0, i.e. the exit we get when not setting the JuMP model in silent as shown in the screenshot below. I would really appreciate it if you…

---

## [Duality gap in Convex.jl](https://discourse.julialang.org/t/duality-gap-in-convex-jl/93741)

<div class="topic-metadata">

**Author:** [@ajd](https://discourse.julialang.org/u/ajd)\
**Replies:** 2\
**Last updated:** [January 29, 2023, 7:50pm UTC](https://discourse.julialang.org/t/duality-gap-in-convex-jl/93741 "2023-01-29T19:50:31Z")

</div>

Using the SCS solver with Convex.jl, the output of the solver includes in its printed output the duality gap: ------------------------------------------------------------------ SCS v3.2.1 - Splitting Conic Solve…

---

## [MOI Count Repetitions of Integers](https://discourse.julialang.org/t/moi-count-repetitions-of-integers/93545)

<div class="topic-metadata">

**Author:** [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Replies:** 6\
**Last updated:** [January 26, 2023, 7:43am UTC](https://discourse.julialang.org/t/moi-count-repetitions-of-integers/93545 "2023-01-26T07:43:05Z")

</div>

Given a vector of integers, is there a MOI constraint that will count the number of repetitions of each distinct integer in the vector?

---

## [Can I "warm start" Optim.jl's BFGS more cleanly?](https://discourse.julialang.org/t/can-i-warm-start-optim-jls-bfgs-more-cleanly/93648)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 1\
**Last updated:** [January 27, 2023, 7:28pm UTC](https://discourse.julialang.org/t/can-i-warm-start-optim-jls-bfgs-more-cleanly/93648 "2023-01-27T19:28:31Z")

</div>

Hey, I am solving a series of problems which are in some sense very small modifications from one another. At eash step, I modify my loss using the information from the inverse hessian obtained by BFGS, and then i resta…

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

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