# Optimization (Mathematical)

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

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

**Page:** 61

---

## [Cannot register function because it does not support differentiation although it does](https://discourse.julialang.org/t/cannot-register-function-because-it-does-not-support-differentiation-although-it-does/83167)

<div class="topic-metadata">

**Author:** [@DanDoe](https://discourse.julialang.org/u/DanDoe)\
**Replies:** 4\
**Last updated:** [June 22, 2022, 9:14pm UTC](https://discourse.julialang.org/t/cannot-register-function-because-it-does-not-support-differentiation-although-it-does/83167 "2022-06-22T21:14:41Z")

</div>

I want to perform some nonlinear optimization using Ipopt through JuMP. I have some user-defined function p\_nomr\_ln\_Sum (see below) that I want to use throughout the optimization. I keep getting the error ERROR: LoadErr…

---

## [How to find single solution for this system of linear inequalities?](https://discourse.julialang.org/t/how-to-find-single-solution-for-this-system-of-linear-inequalities/83149)

<div class="topic-metadata">

**Author:** [@Bobberson3108](https://discourse.julialang.org/u/Bobberson3108)\
**Replies:** 2\
**Last updated:** [June 22, 2022, 1:59am UTC](https://discourse.julialang.org/t/how-to-find-single-solution-for-this-system-of-linear-inequalities/83149 "2022-06-22T01:59:26Z")

</div>

I’m trying to solve a set of modular inequalities using JuMP by replacing the modulus with variables m and n. I’ve tried multiple different solvers but they’re all much too slow. I just want to find any singular solution…

---

## [NLopt :FORCED\_STOP when objective function has wrong signature (missing gradient arg)](https://discourse.julialang.org/t/nlopt-forced-stop-when-objective-function-has-wrong-signature-missing-gradient-arg/82742)

<div class="topic-metadata">

**Author:** [@pierre-haessig](https://discourse.julialang.org/u/pierre-haessig)\
**Replies:** 2\
**Last updated:** [June 21, 2022, 9:00pm UTC](https://discourse.julialang.org/t/nlopt-forced-stop-when-objective-function-has-wrong-signature-missing-gradient-arg/82742 "2022-06-21T21:00:01Z")

</div>

Hello, I just faced a small usability issue using NLopt.jl. I believe the issue is common enough (e.g. forum post from Oct 2020 https://discourse.julialang.org/t/nlopt-forced-stop) that it may suggest a better error cat…

---

## [Why Optim.seconds(res) does not exist?](https://discourse.julialang.org/t/why-optim-seconds-res-does-not-exist/83123)

<div class="topic-metadata">

**Author:** [@axel365](https://discourse.julialang.org/u/axel365)\
**Replies:** 1\
**Last updated:** [June 21, 2022, 1:29pm UTC](https://discourse.julialang.org/t/why-optim-seconds-res-does-not-exist/83123 "2022-06-21T13:29:06Z")

</div>

Almost all is in the title… With Optim.jl, wouldn’t it be useful to have a function that can access the number of seconds run for an optimization problem? If this exists already, i did not find it.

---

## [Infeasibilities with economic dispatch model](https://discourse.julialang.org/t/infeasibilities-with-economic-dispatch-model/82571)

<div class="topic-metadata">

**Author:** [@mbah](https://discourse.julialang.org/u/mbah)\
**Replies:** 4\
**Last updated:** [June 21, 2022, 7:25am UTC](https://discourse.julialang.org/t/infeasibilities-with-economic-dispatch-model/82571 "2022-06-21T07:25:19Z")

</div>

Hello, I am currently working on a network economic dispatch model. The basic transport model below works with only conventional generators. However, whenever I add renewable injection constraints with hourly capacity f…

---

## [Flow conservation constraint](https://discourse.julialang.org/t/flow-conservation-constraint/83075)

<div class="topic-metadata">

**Author:** [@Takashy](https://discourse.julialang.org/u/Takashy)\
**Replies:** 3\
**Last updated:** [June 20, 2022, 5:38pm UTC](https://discourse.julialang.org/t/flow-conservation-constraint/83075 "2022-06-20T17:38:10Z")

</div>

Hi there! I’m trying to write a flow conservation constrains. Yet it says key not found # this is the constraint I'd like to write (and α(i,j) is a binary variable and A1 is a subset of nodes) ∑ᵢ α\[i,j\] = ∑ₖ α\[j,k\] …

---

## [Parallelization of Sum in JuMP](https://discourse.julialang.org/t/parallelization-of-sum-in-jump/82979)

<div class="topic-metadata">

**Author:** [@LukasBarner](https://discourse.julialang.org/u/LukasBarner)\
**Replies:** 2\
**Last updated:** [June 20, 2022, 1:02pm UTC](https://discourse.julialang.org/t/parallelization-of-sum-in-jump/82979 "2022-06-20T13:02:54Z")

</div>

Hi everyone, I am writing a JuMP model, which has a quadratic term in the objective function. It looks something like the following: @expression(model, term, sum( ( a\[i\] - b\[i\] \* sum( x\[(i,j2)\] for j2 in dict\_j\[i\] ) )\*…

---

## [Using Optim.jl but failing to find minimum](https://discourse.julialang.org/t/using-optim-jl-but-failing-to-find-minimum/82751)

<div class="topic-metadata">

**Author:** [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Replies:** 6\
**Last updated:** [June 19, 2022, 1:44pm UTC](https://discourse.julialang.org/t/using-optim-jl-but-failing-to-find-minimum/82751 "2022-06-19T13:44:05Z")

</div>

I’m trying to minimize parameters to fit an HMM. It works part of the way, but it seems to get stuck for some points, often not too distant from the initial guess. If I examine the one-dimensional path of the objective …

---

## [COSMO.jl: SecondOrderCone](https://discourse.julialang.org/t/cosmo-jl-secondordercone/82497)

<div class="topic-metadata">

**Author:** [@DanDoe](https://discourse.julialang.org/u/DanDoe)\
**Replies:** 4\
**Last updated:** [June 19, 2022, 10:15am UTC](https://discourse.julialang.org/t/cosmo-jl-secondordercone/82497 "2022-06-19T10:15:03Z")

</div>

I would like to use the COSMO optimizing package for a second order cone program. I have a constraint of the form \\Vert A \\boldsymbol x + \\boldsymbol b \\Vert\_2 \\leq 1 which seems to be a perfect fit for the COSMO.Cons…

---

## [How to define a lower triangular decision matrix](https://discourse.julialang.org/t/how-to-define-a-lower-triangular-decision-matrix/82677)

<div class="topic-metadata">

**Author:** [@Tri](https://discourse.julialang.org/u/Tri)\
**Replies:** 7\
**Last updated:** [June 19, 2022, 3:35am UTC](https://discourse.julialang.org/t/how-to-define-a-lower-triangular-decision-matrix/82677 "2022-06-19T03:35:34Z")

</div>

Is there an efficient way to define a lower triangular matrix (other than defining n by n matrix and adding a constraint that sets every upper triangular element to be zero). I tried the following but it resulted in an …

---

## [How to define constraints on a collection of vectors separately?](https://discourse.julialang.org/t/how-to-define-constraints-on-a-collection-of-vectors-separately/82926)

<div class="topic-metadata">

**Author:** [@Kevin\_12](https://discourse.julialang.org/u/Kevin_12)\
**Replies:** 2\
**Last updated:** [June 18, 2022, 9:28am UTC](https://discourse.julialang.org/t/how-to-define-constraints-on-a-collection-of-vectors-separately/82926 "2022-06-18T09:28:15Z")

</div>

The original problem is so larg. But, Suppose we have this small set of vectors A = \[ \[ \[13, 48,99\] , \[71, 58, 99\]\], \[\[91, 59, 22\], \[94, 86, 22\], \[71, 58, 22\], \[19,55,22\]\], \[\[41, 79, 12\], \[23, 16, 12\],…

---

## [Automatic differentiation and Trapz](https://discourse.julialang.org/t/automatic-differentiation-and-trapz/82135)

<div class="topic-metadata">

**Author:** [@chupin](https://discourse.julialang.org/u/chupin)\
**Replies:** 10\
**Last updated:** [June 18, 2022, 5:53am UTC](https://discourse.julialang.org/t/automatic-differentiation-and-trapz/82135 "2022-06-18T05:53:18Z")

</div>

It seems that Nonconvex is not able to deal with the trapz function, but maybe, I’ve done something wrong. The code (that is a nonsense toy code) : using Nonconvex Nonconvex.@load Ipopt using Trapz function obj(hV,N,M)…

---

## [Xpress Julia API has bug with fixing variables](https://discourse.julialang.org/t/xpress-julia-api-has-bug-with-fixing-variables/82895)

<div class="topic-metadata">

**Author:** [@Popeye](https://discourse.julialang.org/u/Popeye)\
**Replies:** 5\
**Last updated:** [June 18, 2022, 5:38am UTC](https://discourse.julialang.org/t/xpress-julia-api-has-bug-with-fixing-variables/82895 "2022-06-18T05:38:40Z")

</div>

Fixing variables does not seems to be working with the Xpress solver. I used the example below (which was posted by someone on this forum) to create this MWE. I fix one of the variables as zero but it seems like JuMP is…

---

## [JuMP -- MethodError: no method matching \_parse\_section](https://discourse.julialang.org/t/jump-methoderror-no-method-matching-parse-section/82884)

<div class="topic-metadata">

**Author:** [@freiburgermsu](https://discourse.julialang.org/u/freiburgermsu)\
**Replies:** 1\
**Last updated:** [June 16, 2022, 8:44pm UTC](https://discourse.julialang.org/t/jump-methoderror-no-method-matching-parse-section/82884 "2022-06-16T20:44:25Z")

</div>

Hello, I receive the following error message ERROR: MethodError: no method matching \_parse\_section(::Val{:header}, ::MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ObjectiveContainer{Float6…

---

## [Fixing MIP problem integer variables to get Duals](https://discourse.julialang.org/t/fixing-mip-problem-integer-variables-to-get-duals/82885)

<div class="topic-metadata">

**Author:** [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Replies:** 1\
**Last updated:** [June 16, 2022, 6:41pm UTC](https://discourse.julialang.org/t/fixing-mip-problem-integer-variables-to-get-duals/82885 "2022-06-16T18:41:50Z")

</div>

Hi folks, We are solving large models iteratively. It’s a mip problem and to calculate duals, we fix the binary and integer variables and use unset\_binary() and then unset\_integer() to remove the constraints, then solve…

---

## [JuMP register polynomial with its gradient](https://discourse.julialang.org/t/jump-register-polynomial-with-its-gradient/82876)

<div class="topic-metadata">

**Author:** [@Luca](https://discourse.julialang.org/u/Luca)\
**Replies:** 1\
**Last updated:** [June 16, 2022, 6:39pm UTC](https://discourse.julialang.org/t/jump-register-polynomial-with-its-gradient/82876 "2022-06-16T18:39:55Z")

</div>

Dear all, I am using jump and I want to register a polynomial function with its gradient, with register(model2, :poly, num\_var, poly, gradient) I build the polynomial with AbstractAlgebra.jl and the gradient with the …

---

## [Unable to set parameter for GAMS package](https://discourse.julialang.org/t/unable-to-set-parameter-for-gams-package/82780)

<div class="topic-metadata">

**Author:** [@horvetz](https://discourse.julialang.org/u/horvetz)\
**Replies:** 5\
**Last updated:** [June 15, 2022, 6:59am UTC](https://discourse.julialang.org/t/unable-to-set-parameter-for-gams-package/82780 "2022-06-15T06:59:02Z")

</div>

I am having a problem regarding choosing parameters for the solvers KNITRO or CONOPT through the GAMS package. Here is my model. And here are the solvers options for KNITRO and CONOPT. using GAMS, JuMP model = Model(GAM…

---

## [SDDP: type Array has no field out](https://discourse.julialang.org/t/sddp-type-array-has-no-field-out/82731)

<div class="topic-metadata">

**Author:** [@chenr86](https://discourse.julialang.org/u/chenr86)\
**Replies:** 1\
**Last updated:** [June 14, 2022, 9:22am UTC](https://discourse.julialang.org/t/sddp-type-array-has-no-field-out/82731 "2022-06-14T09:22:58Z")

</div>

Hello, I’m using SDDP to solve my problem. Now I want to print the result of stage variable level, which is an array with 4 components. For loop structure is used to show the result: model = SDDP.LinearPolicyGraph( …

---

## [Finding all binding constraints using JuMP](https://discourse.julialang.org/t/finding-all-binding-constraints-using-jump/82579)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 3\
**Last updated:** [June 13, 2022, 1:25pm UTC](https://discourse.julialang.org/t/finding-all-binding-constraints-using-jump/82579 "2022-06-13T13:25:35Z")

</div>

Is this the correct way to find all the binding constraints in JuMP? I figure it is only binding of it has a nonzero shadow-price. However shadow\_price only works for \<, \> and == constraints so I am not sure i am going…

---

## [JuMP non-rectangular variable container: more efficient representation?](https://discourse.julialang.org/t/jump-non-rectangular-variable-container-more-efficient-representation/82669)

<div class="topic-metadata">

**Author:** [@Shuhua](https://discourse.julialang.org/u/Shuhua)\
**Replies:** 1\
**Last updated:** [June 13, 2022, 11:13am UTC](https://discourse.julialang.org/t/jump-non-rectangular-variable-container-more-efficient-representation/82669 "2022-06-13T11:13:18Z")

</div>

Let’s consider a minimal case. I have three kinds of variables: x of length 50, y of length 80, z of length 100. The length actually represents the number of time steps. I know that after time 50, x is always zero, and y…

---

## [Modelling of SOCP constraint and solving through CPLEX](https://discourse.julialang.org/t/modelling-of-socp-constraint-and-solving-through-cplex/82580)

<div class="topic-metadata">

**Author:** [@musman](https://discourse.julialang.org/u/musman)\
**Replies:** 1\
**Last updated:** [June 12, 2022, 7:01am UTC](https://discourse.julialang.org/t/modelling-of-socp-constraint-and-solving-through-cplex/82580 "2022-06-12T07:01:40Z")

</div>

Hello all, I am trying to implement and solve the following SOCP constraint through CPLEX solver (cij)^2 + (sij)^2 \<= cii\*cjj through Rotated Second Order cone as follows: nSc = 10 nTP = 24 nBus = 34 nLines = 33 @vari…

---

## [How to write a constraint Julia-jump](https://discourse.julialang.org/t/how-to-write-a-constraint-julia-jump/82513)

<div class="topic-metadata">

**Author:** [@lausilvag](https://discourse.julialang.org/u/lausilvag)\
**Replies:** 2\
**Last updated:** [June 10, 2022, 3:12pm UTC](https://discourse.julialang.org/t/how-to-write-a-constraint-julia-jump/82513 "2022-06-10T15:12:07Z")

</div>

Hi guys, i am new in julia and i need to write this constraint @FOR(pilotos(i): @for(vuelos(j): @for(vuelos(k) j#ne#k #and# dia(j)#eq#dia(k) #and# inicio(j)#le#inicio(k) #and# fin(j)#gt#inicio(k) : x(i,j)+x(i,k)\<=1))); …

---

## [\[solved\] A case where dijkstra\_shortest\_paths fails (due to the negative weight)](https://discourse.julialang.org/t/solved-a-case-where-dijkstra-shortest-paths-fails-due-to-the-negative-weight/82564)

<div class="topic-metadata">

**Author:** [@HanBBer](https://discourse.julialang.org/u/HanBBer)\
**Replies:** 4\
**Last updated:** [June 10, 2022, 2:25pm UTC](https://discourse.julialang.org/t/solved-a-case-where-dijkstra-shortest-paths-fails-due-to-the-negative-weight/82564 "2022-06-10T14:25:32Z")

</div>

I’m unsure if the Dijkstra algorithm should quit for any proper case. But it got stuck during my work, and attached belong is a code for reproducing. using Graphs node1 = \[1 1 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 8 8 8 8 9 …

---

## [I have an INLP and a linear relaxation; I want to steal someone else's branch-and-bound algorithm](https://discourse.julialang.org/t/i-have-an-inlp-and-a-linear-relaxation-i-want-to-steal-someone-elses-branch-and-bound-algorithm/82472)

<div class="topic-metadata">

**Author:** [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Replies:** 5\
**Last updated:** [June 10, 2022, 7:04am UTC](https://discourse.julialang.org/t/i-have-an-inlp-and-a-linear-relaxation-i-want-to-steal-someone-elses-branch-and-bound-algorithm/82472 "2022-06-10T07:04:56Z")

</div>

Suppose I have a binary optimization problem of the form maximize f(x) (1) subject to Ax ≤ b x binary Here f(x) is a disgusting, nonlinear, nonconcave black bo…

---

## [How do I extract a trace of the optimization steps in JuMP](https://discourse.julialang.org/t/how-do-i-extract-a-trace-of-the-optimization-steps-in-jump/82328)

<div class="topic-metadata">

**Author:** [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Replies:** 8\
**Last updated:** [June 10, 2022, 12:43am UTC](https://discourse.julialang.org/t/how-do-i-extract-a-trace-of-the-optimization-steps-in-jump/82328 "2022-06-10T00:43:50Z")

</div>

During optimization via some interior point method or similar the solver will compute the value of the objective and probably a bunch of other things. And one should see it going down Is there a standard way to captur…

---

## [Converting and applying MATLAB lsqnonlin function in Julia with multiple function arguments](https://discourse.julialang.org/t/converting-and-applying-matlab-lsqnonlin-function-in-julia-with-multiple-function-arguments/82440)

<div class="topic-metadata">

**Author:** [@JannisHoch](https://discourse.julialang.org/u/JannisHoch)\
**Replies:** 1\
**Last updated:** [June 8, 2022, 6:05pm UTC](https://discourse.julialang.org/t/converting-and-applying-matlab-lsqnonlin-function-in-julia-with-multiple-function-arguments/82440 "2022-06-08T18:05:57Z")

</div>

I am trying to convert some MATLAB code into Julia. For the largest part this went pretty smooth, but I am now stuck with converting the MATLAB \[lsqnonlin\]\[1\] function. After scanning available options, I think that the…

---

## [Cholesky factorization in JuMP](https://discourse.julialang.org/t/cholesky-factorization-in-jump/82227)

<div class="topic-metadata">

**Author:** [@horvetz](https://discourse.julialang.org/u/horvetz)\
**Replies:** 2\
**Last updated:** [June 8, 2022, 3:31pm UTC](https://discourse.julialang.org/t/cholesky-factorization-in-jump/82227 "2022-06-08T15:31:30Z")

</div>

I want to solve a SDP optimization problem using a nonlinear solver. Specifically I want to use Cholesky factorization to enforce positive definiteness of some decision variable A. That is I want to find a lower triangu…

---

## [Question about JuMP?](https://discourse.julialang.org/t/question-about-jump/82432)

<div class="topic-metadata">

**Author:** [@Raymond](https://discourse.julialang.org/u/Raymond)\
**Replies:** 5\
**Last updated:** [June 8, 2022, 2:46pm UTC](https://discourse.julialang.org/t/question-about-jump/82432 "2022-06-08T14:46:29Z")

</div>

What’s wrong with this problem? julia\> using JuMP julia\> using Ipopt julia\> model = Model(Ipopt.Optimizer) A JuMP Model Feasibility problem with: Variables: 0 Model mode: AUTOMATIC CachingOptimizer state: EMPTY\_OPTIMI…

---

## [One objective instead of stage objective with SDDP.jl](https://discourse.julialang.org/t/one-objective-instead-of-stage-objective-with-sddp-jl/82396)

<div class="topic-metadata">

**Author:** [@chenr86](https://discourse.julialang.org/u/chenr86)\
**Replies:** 8\
**Last updated:** [June 8, 2022, 3:56am UTC](https://discourse.julialang.org/t/one-objective-instead-of-stage-objective-with-sddp-jl/82396 "2022-06-08T03:56:07Z")

</div>

Hello, I’m new to optimization problem. I find SDDP.jl closed to what I want to do. There are state variable, control variables, random variables. But with SDDP.jl, we need to define the stage objective for each node, I…

---

## ["bad line xxx of yyy.nl file" error with AmplNLWriter (but solves with Ipopt.jl)](https://discourse.julialang.org/t/bad-line-xxx-of-yyy-nl-file-error-with-amplnlwriter-but-solves-with-ipopt-jl/82372)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 3\
**Last updated:** [June 7, 2022, 9:25pm UTC](https://discourse.julialang.org/t/bad-line-xxx-of-yyy-nl-file-error-with-amplnlwriter-but-solves-with-ipopt-jl/82372 "2022-06-07T21:25:29Z")

</div>

The following code solves correctly using the Ipopt.jl Ipopt interface, but returns an error “bad line xxx of yyy.nl file” when I try to use the AmplNLWriter.jl interface (both using Ipopt and Ipopt\_jll). Other “basic” …

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

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