# Optimization (Mathematical)

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

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

**Page:** 113

---

## [Help with function sum{}](https://discourse.julialang.org/t/help-with-function-sum/22128)

<div class="topic-metadata">

**Author:** [@danielcas](https://discourse.julialang.org/u/danielcas)\
**Replies:** 3\
**Last updated:** [March 21, 2019, 2:05am UTC](https://discourse.julialang.org/t/help-with-function-sum/22128 "2019-03-21T02:05:30Z")

</div>

H, on my file there’s a constraint written like this @NLconstraint(m,-sum{log(x\[i\])/gamma\[i\], i=1:n}\<=mm), when I run the program I get an error saying that this type of syntax is no longer supported. so…¿What is the new…

---

## [Vector affine function with SOC not supported in JuMP (.18 -\> .19 breaking change?)](https://discourse.julialang.org/t/vector-affine-function-with-soc-not-supported-in-jump-18-19-breaking-change/22076)

<div class="topic-metadata">

**Author:** [@guille](https://discourse.julialang.org/u/guille)\
**Replies:** 6\
**Last updated:** [March 20, 2019, 4:47pm UTC](https://discourse.julialang.org/t/vector-affine-function-with-soc-not-supported-in-jump-18-19-breaking-change/22076 "2019-03-20T16:47:34Z")

</div>

Hey all! Quick question (it is quite likely this question has a simple solution), but I’m working on doing a quick overhaul of some code for a paper. The original code was written on JuMP .17/.18, but with some of the b…

---

## [If condition in constraint set](https://discourse.julialang.org/t/if-condition-in-constraint-set/22057)

<div class="topic-metadata">

**Author:** [@ilias](https://discourse.julialang.org/u/ilias)\
**Replies:** 1\
**Last updated:** [March 19, 2019, 3:37pm UTC](https://discourse.julialang.org/t/if-condition-in-constraint-set/22057 "2019-03-19T15:37:33Z")

</div>

Is there a way to rewrite the following constraint set in one row? for i in set\_i for ii in set\_i if parameter\[ii\] \>= parameter\[i\] @constraint( model, x\[i\] - y\[ii\] \<= 0 ); end end end…

---

## [help converting JuMPArray to regular array](https://discourse.julialang.org/t/help-converting-jumparray-to-regular-array/21924)

<div class="topic-metadata">

**Author:** [@levip](https://discourse.julialang.org/u/levip)\
**Replies:** 2\
**Last updated:** [March 19, 2019, 2:56pm UTC](https://discourse.julialang.org/t/help-converting-jumparray-to-regular-array/21924 "2019-03-19T14:56:23Z")

</div>

I’m trying to inspect the dual values of one of my constraints, but I cannot figure out how to convert the returned variable to a regular Array (so that I can ultimately save it to a CSV). I get a 3-dimensional JuMPArray…

---

## [Recommended way of solving multiple similar problems with JuMP](https://discourse.julialang.org/t/recommended-way-of-solving-multiple-similar-problems-with-jump/22055)

<div class="topic-metadata">

**Author:** [@Sebastian\_Rollen](https://discourse.julialang.org/u/Sebastian_Rollen)\
**Replies:** 1\
**Last updated:** [March 19, 2019, 2:20pm UTC](https://discourse.julialang.org/t/recommended-way-of-solving-multiple-similar-problems-with-jump/22055 "2019-03-19T14:20:32Z")

</div>

Hi, I have an application where I have to solve a quadratic problem multiple times, with the only thing changing between problems being the RHS of a constraint. Currently I do this by setting up the problem with the RHS…

---

## [Optimize slow constraint generation](https://discourse.julialang.org/t/optimize-slow-constraint-generation/21996)

<div class="topic-metadata">

**Author:** [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Replies:** 1\
**Last updated:** [March 18, 2019, 12:55pm UTC](https://discourse.julialang.org/t/optimize-slow-constraint-generation/21996 "2019-03-18T12:55:25Z")

</div>

This is somewhat related to my other post (Deleting containerized constraints) but here, I want to see if there is a way to formulate my constraint differently. Following advice in this thread, I put all my variable and…

---

## [Key error in JuMP on domain tuples](https://discourse.julialang.org/t/key-error-in-jump-on-domain-tuples/21872)

<div class="topic-metadata">

**Author:** [@Di11on](https://discourse.julialang.org/u/Di11on)\
**Replies:** 6\
**Last updated:** [March 15, 2019, 2:18pm UTC](https://discourse.julialang.org/t/key-error-in-jump-on-domain-tuples/21872 "2019-03-15T14:18:02Z")

</div>

Hi folks, I’m having a strange problem with JuMP that I hope someone can identify… The first formulation below results in a key error but the second doesn’t but both should, in theory involve evaluations on the same se…

---

## [JuMP/CPLEX: adding objective function expression in loop is very resource-consuming](https://discourse.julialang.org/t/jump-cplex-adding-objective-function-expression-in-loop-is-very-resource-consuming/21859)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 3\
**Last updated:** [March 15, 2019, 11:40am UTC](https://discourse.julialang.org/t/jump-cplex-adding-objective-function-expression-in-loop-is-very-resource-consuming/21859 "2019-03-15T11:40:49Z")

</div>

Dear community, I use JuMP 0.18.5, CPLEX 0.4.3, Julia 1.1, and observe a strange behaviour when adding an objective function expression with a loop. Here is a stupid minimal example: using TimerOutputs using JuMP using…

---

## [Gurobi local cuts](https://discourse.julialang.org/t/gurobi-local-cuts/21814)

<div class="topic-metadata">

**Author:** [@Lefteris\_Manousakis](https://discourse.julialang.org/u/Lefteris_Manousakis)\
**Replies:** 4\
**Last updated:** [March 13, 2019, 1:42pm UTC](https://discourse.julialang.org/t/gurobi-local-cuts/21814 "2019-03-13T13:42:04Z")

</div>

HI everyone! I am tryin to add local cut with Gurobi (Julia v0.6). Although it works with CPLEX is seems that Gurobi wrapper does not support local cuts. \> LoadError: e\[91mMethodError: no method matching cbaddcutlocal!…

---

## [Variable not defined when working with 2 loops](https://discourse.julialang.org/t/variable-not-defined-when-working-with-2-loops/21772)

<div class="topic-metadata">

**Author:** [@WangQuanmeng](https://discourse.julialang.org/u/WangQuanmeng)\
**Replies:** 5\
**Last updated:** [March 13, 2019, 6:15am UTC](https://discourse.julialang.org/t/variable-not-defined-when-working-with-2-loops/21772 "2019-03-13T06:15:02Z")

</div>

Hi all, I am working on lagrangian relaxation of a particular problem, and I meet the following error. The original problem consists of 10 almost independent subproblems, where 10 subproblems are only linked by 1 simpl…

---

## [Optimization and arbitrary precision](https://discourse.julialang.org/t/optimization-and-arbitrary-precision/21801)

<div class="topic-metadata">

**Author:** [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Replies:** 2\
**Last updated:** [March 13, 2019, 12:52am UTC](https://discourse.julialang.org/t/optimization-and-arbitrary-precision/21801 "2019-03-13T00:52:40Z")

</div>

Hi all, I’ve been exploring some packages for solving nonlinear least squares problems. LsqFit.jl, LeastSquaresOptim.jl and Optim.jl are the ones I’ve come across so far and all of them give me great results. However, …

---

## [using "max" in nonlinear constraints](https://discourse.julialang.org/t/using-max-in-nonlinear-constraints/21606)

<div class="topic-metadata">

**Author:** [@zhangxz1123](https://discourse.julialang.org/u/zhangxz1123)\
**Replies:** 11\
**Last updated:** [March 8, 2019, 7:22pm UTC](https://discourse.julialang.org/t/using-max-in-nonlinear-constraints/21606 "2019-03-08T19:22:27Z")

</div>

Hi there, I’m trying to use the max function in one of my NLconstraint. Following @ odow’s advice, I use auto-differentiation to allow max into the constraint. The problem is that the length of the array that I want to …

---

## [LsqFit.jl error on ODE data fitting](https://discourse.julialang.org/t/lsqfit-jl-error-on-ode-data-fitting/21587)

<div class="topic-metadata">

**Author:** [@Andre\_Mello](https://discourse.julialang.org/u/Andre_Mello)\
**Replies:** 2\
**Last updated:** [March 8, 2019, 7:06pm UTC](https://discourse.julialang.org/t/lsqfit-jl-error-on-ode-data-fitting/21587 "2019-03-08T19:06:03Z")

</div>

Hi all, my first post here so bare with me please. I’m also new to the Julia language and enjoying it very much so far. Now to the point. I’ve been trying LsqFit and wanted to implement a simple curve fitting model us…

---

## [How to write a constraint in JuMP where the index has if-else structure](https://discourse.julialang.org/t/how-to-write-a-constraint-in-jump-where-the-index-has-if-else-structure/21635)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 4\
**Last updated:** [March 8, 2019, 3:42pm UTC](https://discourse.julialang.org/t/how-to-write-a-constraint-in-jump-where-the-index-has-if-else-structure/21635 "2019-03-08T15:42:20Z")

</div>

I have a little question in how to write a constraint in Jump language. The constraint is: sum\_{i} sum\_{r=0}^{9} x\[i,j,t-r\] \<= 1, for all t=1,…,12 and j=1,…,9 if t - r \< 0, change by t - r + 9. How can I use a if-else…

---

## [Adding local lazy constraints in Gurobi with JuMP v0.18](https://discourse.julialang.org/t/adding-local-lazy-constraints-in-gurobi-with-jump-v0-18/21517)

<div class="topic-metadata">

**Author:** [@Wei\_Wang](https://discourse.julialang.org/u/Wei_Wang)\
**Replies:** 2\
**Last updated:** [March 6, 2019, 3:48pm UTC](https://discourse.julialang.org/t/adding-local-lazy-constraints-in-gurobi-with-jump-v0-18/21517 "2019-03-06T15:48:00Z")

</div>

Hi all, I am using JuMP v0.18. I want to locally add lazy constraints but when I setting localcut to true I get the following error MethodError: no method matching cbaddlazylocal!(::Gurobi.GurobiCallbackData, ::Array{I…

---

## [JuMP 19.0: constraint\_by\_name fails for vectorized constraints](https://discourse.julialang.org/t/jump-19-0-constraint-by-name-fails-for-vectorized-constraints/21481)

<div class="topic-metadata">

**Author:** [@torgo](https://discourse.julialang.org/u/torgo)\
**Replies:** 6\
**Last updated:** [March 5, 2019, 6:15pm UTC](https://discourse.julialang.org/t/jump-19-0-constraint-by-name-fails-for-vectorized-constraints/21481 "2019-03-05T18:15:38Z")

</div>

using JuMP m = Model() @variable(m, x\[1:2\]) @constraint(m, mycons, x .== 0) cn = constraint\_by\_name(m, "mycons") # returns nothing Should cn be nothing? I expected it would return an array of constraint references.

---

## [Boundaries for @NLparameters](https://discourse.julialang.org/t/boundaries-for-nlparameters/21490)

<div class="topic-metadata">

**Author:** [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Replies:** 4\
**Last updated:** [March 5, 2019, 1:47pm UTC](https://discourse.julialang.org/t/boundaries-for-nlparameters/21490 "2019-03-05T13:47:43Z")

</div>

I am currently discovering the world of JuMP.jl and I have to say, I am amazed, thanks for this package! TL;DR: how do I add constraints or limits to parameters which are not defined by @variable but @NLparameter? Full…

---

## [Adding CPLEX callbacks with JuMP v0.19](https://discourse.julialang.org/t/adding-cplex-callbacks-with-jump-v0-19/21449)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 7\
**Last updated:** [March 4, 2019, 3:28pm UTC](https://discourse.julialang.org/t/adding-cplex-callbacks-with-jump-v0-19/21449 "2019-03-04T15:28:14Z")

</div>

Dear community, I use CPLEX 12.8 and made an update from JuMP v18.5 to v0.19. Due to major changes in the new version I have to adapt my code, and I do not succeed to add callbacks. The release notes say that callbacks …

---

## [JuMP uses all available memory, can't do anything else after](https://discourse.julialang.org/t/jump-uses-all-available-memory-cant-do-anything-else-after/21238)

<div class="topic-metadata">

**Author:** [@cosmia](https://discourse.julialang.org/u/cosmia)\
**Replies:** 1\
**Last updated:** [February 27, 2019, 7:50am UTC](https://discourse.julialang.org/t/jump-uses-all-available-memory-cant-do-anything-else-after/21238 "2019-02-27T07:50:04Z")

</div>

Hey guys, so I have an optimization problem in which JuMP with Ipopt uses 90% of my available RAM memory for automatic differentiation. In my layman’s understanding, after it calculates the hessian and all, it stores it…

---

## [Some trick in NLconstraint to avoid NaN or Inf for zero initial condition ?](https://discourse.julialang.org/t/some-trick-in-nlconstraint-to-avoid-nan-or-inf-for-zero-initial-condition/9831)

<div class="topic-metadata">

**Author:** [@cfrodriguez](https://discourse.julialang.org/u/cfrodriguez)\
**Replies:** 3\
**Last updated:** [February 26, 2019, 2:33pm UTC](https://discourse.julialang.org/t/some-trick-in-nlconstraint-to-avoid-nan-or-inf-for-zero-initial-condition/9831 "2019-02-26T14:33:57Z")

</div>

Hello all, I am new using JuMP. In my code, I added a thermodynamic model (UNIQUAC). When xNT1 = 0.001 it work well. But when the value is almost zero (1e-11) it doesn’t work and JuMP give me “Warning: Cutting back alph…

---

## [Getting the optimal solution](https://discourse.julialang.org/t/getting-the-optimal-solution/21167)

<div class="topic-metadata">

**Author:** [@Rajat\_Sanyal](https://discourse.julialang.org/u/Rajat_Sanyal)\
**Replies:** 2\
**Last updated:** [February 25, 2019, 2:22pm UTC](https://discourse.julialang.org/t/getting-the-optimal-solution/21167 "2019-02-25T14:22:13Z")

</div>

Let us consider the following optimization problem: using JuMP, Ipopt function Opti\_model(A,b) m = Model(with\_optimizer(Ipopt.Optimizer)) @variable(m,x\[1:5\],lower\_bound=0,upper\_bound=1) @objective(m,Max,sum(…

---

## [Name styles of variables, parameters, sets, etc...](https://discourse.julialang.org/t/name-styles-of-variables-parameters-sets-etc/21089)

<div class="topic-metadata">

**Author:** [@haokuny](https://discourse.julialang.org/u/haokuny)\
**Replies:** 1\
**Last updated:** [February 24, 2019, 12:30am UTC](https://discourse.julialang.org/t/name-styles-of-variables-parameters-sets-etc/21089 "2019-02-24T00:30:55Z")

</div>

When building a JuMP model, one thing I feel very important is to distinguish between variables and parameters in each equation. It’s important because, for example, the term “var. \* par.” is linear but the term “var. \* …

---

## [Help with my MINLP](https://discourse.julialang.org/t/help-with-my-minlp/19927)

<div class="topic-metadata">

**Author:** [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Replies:** 8\
**Last updated:** [February 23, 2019, 6:59pm UTC](https://discourse.julialang.org/t/help-with-my-minlp/19927 "2019-02-23T18:59:52Z")

</div>

Hello, sorry for this long post and problem… but if any help is trully appreciated. I need help with my MINLP, since the results i’m getting is not what i was expecting… This is an electrical engineering problem, where …

---

## [Make changes of the new model effecting the old one](https://discourse.julialang.org/t/make-changes-of-the-new-model-effecting-the-old-one/21092)

<div class="topic-metadata">

**Author:** [@haokuny](https://discourse.julialang.org/u/haokuny)\
**Replies:** 2\
**Last updated:** [February 23, 2019, 6:17am UTC](https://discourse.julialang.org/t/make-changes-of-the-new-model-effecting-the-old-one/21092 "2019-02-23T06:17:09Z")

</div>

Let’s say I have built a model called mymodel and I want to make some extension, meaning to add some new variables and constraints, but I want to do it to my new model. So I mymodelnew = mymodel. Then the problem is, wh…

---

## [About the optimization problem choice in JuMP v0.19](https://discourse.julialang.org/t/about-the-optimization-problem-choice-in-jump-v0-19/21018)

<div class="topic-metadata">

**Author:** [@ErwanPiR](https://discourse.julialang.org/u/ErwanPiR)\
**Replies:** 8\
**Last updated:** [February 21, 2019, 2:20pm UTC](https://discourse.julialang.org/t/about-the-optimization-problem-choice-in-jump-v0-19/21018 "2019-02-21T14:20:29Z")

</div>

I hope this isn’t a dumb question… With the precedent version of JuMP, to define the kind of optimization problem (LP, MIP,…), the syntax was Model(solver=GLPKSolverMIP(args…)) or Model(solver=GLPKSolverLP()) I …

---

## [Error with Ipopt ](https://discourse.julialang.org/t/error-with-ipopt/20989)

<div class="topic-metadata">

**Author:** [@Y\_Li](https://discourse.julialang.org/u/Y_Li)\
**Replies:** 2\
**Last updated:** [February 20, 2019, 1:32am UTC](https://discourse.julialang.org/t/error-with-ipopt/20989 "2019-02-20T01:32:35Z")

</div>

Hi, I am using JuMP and IPOPT to solve an non-linear optimization, below is my code using JuMP using Ipopt model =Model(solver=IpoptSolver()) @variable(model, x ) @variable(model, y ) @variable(model, z ) #define our ob…

---

## [JuMP: Catch error if solver stops early due to network error or running out of memory ?](https://discourse.julialang.org/t/jump-catch-error-if-solver-stops-early-due-to-network-error-or-running-out-of-memory/20962)

<div class="topic-metadata">

**Author:** [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Replies:** 1\
**Last updated:** [February 19, 2019, 1:32am UTC](https://discourse.julialang.org/t/jump-catch-error-if-solver-stops-early-due-to-network-error-or-running-out-of-memory/20962 "2019-02-19T01:32:55Z")

</div>

I am solving a large MILP by calling Gurobi through JuMP v0.18. Gurobi issues an error, which I believe is due to it running out of RAM. Is it possible for JuMP to catch the error and collect the best known solution?

---

## [JuMP v0.19 has been released](https://discourse.julialang.org/t/jump-v0-19-has-been-released/20878)

<div class="topic-metadata">

**Author:** [@blegat](https://discourse.julialang.org/u/blegat)\
**Replies:** 6\
**Last updated:** [February 18, 2019, 8:22pm UTC](https://discourse.julialang.org/t/jump-v0-19-has-been-released/20878 "2019-02-18T20:22:59Z")

</div>

We are thrilled to announce the release of JuMP v0.19. Work on this release started nearly two years ago at the first JuMP-dev meetup. As introduced in an earlier post and at the second JuMP-dev meetup, JuMP has undergo…

---

## [How use SCIP in Windows](https://discourse.julialang.org/t/how-use-scip-in-windows/20929)

<div class="topic-metadata">

**Author:** [@muriloasouza](https://discourse.julialang.org/u/muriloasouza)\
**Replies:** 3\
**Last updated:** [February 18, 2019, 2:38pm UTC](https://discourse.julialang.org/t/how-use-scip-in-windows/20929 "2019-02-18T14:38:36Z")

</div>

Hello, Can anyone help in how to install SCIP to use it in Windows through Julia 0.6/JuMP? I’ve seen some instructions here: But only for OS X and Linux, so i have no idea what i need to do to use it in Windows. I’…

---

## [writing in excel](https://discourse.julialang.org/t/writing-in-excel/9577)

<div class="topic-metadata">

**Author:** [@razieh95](https://discourse.julialang.org/u/razieh95)\
**Replies:** 3\
**Last updated:** [February 16, 2019, 4:56pm UTC](https://discourse.julialang.org/t/writing-in-excel/9577 "2019-02-16T16:56:53Z")

</div>

hi. How write value variables in different excel sheets?

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

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