# Optimization (Mathematical)

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

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

**Page:** 93

---

## [JuMP Stopped Working Today](https://discourse.julialang.org/t/jump-stopped-working-today/46348)

<div class="topic-metadata">

**Author:** [@vattyamv](https://discourse.julialang.org/u/vattyamv)\
**Replies:** 4\
**Last updated:** [September 9, 2020, 11:07pm UTC](https://discourse.julialang.org/t/jump-stopped-working-today/46348 "2020-09-09T23:07:52Z")

</div>

Hi, I’ve been using JuMP for a project and it stopped working today after I installed Gurobi. I get ERROR: LoadError: MethodError: no method matching Model(::Type{Gurobi.Optimizer}) when I set the solver to Gurobi, but i…

---

## [Cannot Access variable values through Gurobi callback](https://discourse.julialang.org/t/cannot-access-variable-values-through-gurobi-callback/46138)

<div class="topic-metadata">

**Author:** [@hassanis](https://discourse.julialang.org/u/hassanis)\
**Replies:** 2\
**Last updated:** [September 8, 2020, 12:38pm UTC](https://discourse.julialang.org/t/cannot-access-variable-values-through-gurobi-callback/46138 "2020-09-08T12:38:26Z")

</div>

Hello, I’m trying to access my variable values through a callback on Gurobi (Gurobi Optimizer version 9.0.2; Pkg v0.8.1) (& JuMP v0.21.3). I’m able to run a few functions (eg. cbget\_mipsol\_obj), but ‘mipsol\_sol’ is not …

---

## [Problems trying to run JuMP and GLPK](https://discourse.julialang.org/t/problems-trying-to-run-jump-and-glpk/46175)

<div class="topic-metadata">

**Author:** [@HerAdri](https://discourse.julialang.org/u/HerAdri)\
**Replies:** 4\
**Last updated:** [September 8, 2020, 8:08am UTC](https://discourse.julialang.org/t/problems-trying-to-run-jump-and-glpk/46175 "2020-09-08T08:08:53Z")

</div>

When I try to run JuMP packets, GLPK with the command using JuMP, GLPK I get the following alert: m = Model(GLPK.Optimizer) ERROR: MethodError: no method matching Model(::Type{GLPK.Optimizer}) Closest candidates are: …

---

## [Adding SOS1 constraint problem](https://discourse.julialang.org/t/adding-sos1-constraint-problem/46209)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 10\
**Last updated:** [September 8, 2020, 5:57am UTC](https://discourse.julialang.org/t/adding-sos1-constraint-problem/46209 "2020-09-08T05:57:57Z")

</div>

I am trying to add a simple SOS1 constraint, but getting the following error MethodError: no method matching build\_constraint(::JuMP.var"#\_error#68"{Symbol}, ::Array{VariableRef,2}, ::SOS1) for @constrain…

---

## [Feeding solver parameters as a dictionary](https://discourse.julialang.org/t/feeding-solver-parameters-as-a-dictionary/46227)

<div class="topic-metadata">

**Author:** [@varun7rs](https://discourse.julialang.org/u/varun7rs)\
**Replies:** 2\
**Last updated:** [September 8, 2020, 12:06am UTC](https://discourse.julialang.org/t/feeding-solver-parameters-as-a-dictionary/46227 "2020-09-08T00:06:13Z")

</div>

I’d like to set solver parameters not manually but by just passing a dictionary and unpacking the keys and arguments using the splat operator. When I tried doing this: fRAN = Model(solver = GurobiSolver(parameters...)) …

---

## [Dual number is unidentified by OpenModelica while using user-defined function with autodiff in JuMP!](https://discourse.julialang.org/t/dual-number-is-unidentified-by-openmodelica-while-using-user-defined-function-with-autodiff-in-jump/45740)

<div class="topic-metadata">

**Author:** [@pandeysudan27](https://discourse.julialang.org/u/pandeysudan27)\
**Replies:** 6\
**Last updated:** [September 7, 2020, 10:20pm UTC](https://discourse.julialang.org/t/dual-number-is-unidentified-by-openmodelica-while-using-user-defined-function-with-autodiff-in-jump/45740 "2020-09-07T22:20:45Z")

</div>

Hi, I am trying to solve a simple set point tracking MPC using JuMP. The model I am trying is \\frac{dx}{dt} =a+bsin(x). There is no issues in JuMP while discretizing it in Julia. However, when the model is used from …

---

## [AssertionError rowub \< posinf JuMP model](https://discourse.julialang.org/t/assertionerror-rowub-posinf-jump-model/45976)

<div class="topic-metadata">

**Author:** [@dharik13](https://discourse.julialang.org/u/dharik13)\
**Replies:** 3\
**Last updated:** [September 6, 2020, 9:59pm UTC](https://discourse.julialang.org/t/assertionerror-rowub-posinf-jump-model/45976 "2020-09-06T21:59:47Z")

</div>

Hello, I am new to using Julia/JuMP (coming from python) and I am encountering the following error when trying to solve an LP model using Gurobi I dont quite follow what the statement “AssertionError: rowub\[i\] \< posi…

---

## [RotatedSecondOrderCone() usage](https://discourse.julialang.org/t/rotatedsecondordercone-usage/46019)

<div class="topic-metadata">

**Author:** [@asavasci](https://discourse.julialang.org/u/asavasci)\
**Replies:** 8\
**Last updated:** [September 5, 2020, 8:23pm UTC](https://discourse.julialang.org/t/rotatedsecondordercone-usage/46019 "2020-09-05T20:23:45Z")

</div>

Hi, how should I use RotatedSecondOrderCone() object when converting soc constraint x^2 + y^2 \<= wz where w\>=0, z\>= 0 ? I tried to resemble the constraint to given syntax in the manual . However, I am not sure if I am d…

---

## [How register a function in JuMP and use a subarray as args](https://discourse.julialang.org/t/how-register-a-function-in-jump-and-use-a-subarray-as-args/46043)

<div class="topic-metadata">

**Author:** [@Behemoth-s](https://discourse.julialang.org/u/Behemoth-s)\
**Replies:** 2\
**Last updated:** [September 5, 2020, 5:26pm UTC](https://discourse.julialang.org/t/how-register-a-function-in-jump-and-use-a-subarray-as-args/46043 "2020-09-05T17:26:47Z")

</div>

I would register constraint somehow like c1 as a user-defined function using Ipopt using JuMP using MathOptInterface const MOI = MathOptInterface d1 = 4 d2 = 5 d3 = 6 para\_a = rand(d3) m = Model(optimizer\_with\_attrib…

---

## [How to treat variable as binary in some points of model?](https://discourse.julialang.org/t/how-to-treat-variable-as-binary-in-some-points-of-model/46100)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 3\
**Last updated:** [September 5, 2020, 2:50pm UTC](https://discourse.julialang.org/t/how-to-treat-variable-as-binary-in-some-points-of-model/46100 "2020-09-05T14:50:16Z")

</div>

I have a decision variable PRODAMOUNT and it is of Int type. I need it as binary in some points of the model, like here in the objective function second PRODAMOUNT should be used as 1 when there is a positive value in it…

---

## [Tennis Lineup Optimizer](https://discourse.julialang.org/t/tennis-lineup-optimizer/46036)

<div class="topic-metadata">

**Author:** [@Cameron\_Taylor](https://discourse.julialang.org/u/Cameron_Taylor)\
**Replies:** 2\
**Last updated:** [September 4, 2020, 4:03pm UTC](https://discourse.julialang.org/t/tennis-lineup-optimizer/46036 "2020-09-04T16:03:31Z")

</div>

Hi all, I’m putting together a little tennis lineup optimizer program to play some daily fantasy contests during the US Open here. I’m trying to write a constraint that picks a set of players on the condition that a pl…

---

## [Find dependent variables as GenericAffExpr](https://discourse.julialang.org/t/find-dependent-variables-as-genericaffexpr/46009)

<div class="topic-metadata">

**Author:** [@umbe](https://discourse.julialang.org/u/umbe)\
**Replies:** 4\
**Last updated:** [September 4, 2020, 7:56am UTC](https://discourse.julialang.org/t/find-dependent-variables-as-genericaffexpr/46009 "2020-09-04T07:56:27Z")

</div>

Hi everybody! I’m trying to find a way to obtain the dependent variables of a nonlinear system as GenericAffExpr, expressed as a function only of the independent variables of an optimization problem. To be more precise…

---

## [Using JuMPeR](https://discourse.julialang.org/t/using-jumper/46000)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 1\
**Last updated:** [September 3, 2020, 8:58pm UTC](https://discourse.julialang.org/t/using-jumper/46000 "2020-09-03T20:58:19Z")

</div>

I look for articles that talk about robust optimization using JuMPeR. Can someone refer me? Thank you!

---

## [Providing More Initial Parameter Values than there are Parameters in the Function Being Optimized](https://discourse.julialang.org/t/providing-more-initial-parameter-values-than-there-are-parameters-in-the-function-being-optimized/45585)

<div class="topic-metadata">

**Author:** [@donkeysaddle](https://discourse.julialang.org/u/donkeysaddle)\
**Replies:** 9\
**Last updated:** [September 3, 2020, 5:51pm UTC](https://discourse.julialang.org/t/providing-more-initial-parameter-values-than-there-are-parameters-in-the-function-being-optimized/45585 "2020-09-03T17:51:45Z")

</div>

Why does the “extra” parameter value affect the optimization? Apologies if this is in the Optim documentation - I didn’t see it. For example: using Optim f(x) = (1.0 - x\[1\])^2 + 100.0 \* (x\[2\] - x\[1\]^2)^2 x0 = \[0.0, 0.…

---

## [Need help with building constraints](https://discourse.julialang.org/t/need-help-with-building-constraints/45911)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 9\
**Last updated:** [September 2, 2020, 8:20pm UTC](https://discourse.julialang.org/t/need-help-with-building-constraints/45911 "2020-09-02T20:20:34Z")

</div>

I am trying to fit images to A4 piece of paper, I am getting infeasible solution but I don’t understand why. params = Dict() params\["ROWS"\] = 1:297 params\["COLS"\] = 1:210 params\["TOTAL"\] = 210 \* 297 params\["I…

---

## [Empty list in sum create an error](https://discourse.julialang.org/t/empty-list-in-sum-create-an-error/45962)

<div class="topic-metadata">

**Author:** [@cotepascal76](https://discourse.julialang.org/u/cotepascal76)\
**Replies:** 6\
**Last updated:** [September 2, 2020, 7:14pm UTC](https://discourse.julialang.org/t/empty-list-in-sum-create-an-error/45962 "2020-09-02T19:14:31Z")

</div>

I would to define a constraint in jump using this compact notation like: sum( sum( Flow\[p,j\] for j in A\[p\] if j == "TT" ) for p in pars) ) the problem is that for a given p, there may be no “TT” in A\[p\] list and in …

---

## [Linear Complementarity Problem. Non-obsolete package?](https://discourse.julialang.org/t/linear-complementarity-problem-non-obsolete-package/39665)

<div class="topic-metadata">

**Author:** [@juliauser](https://discourse.julialang.org/u/juliauser)\
**Replies:** 14\
**Last updated:** [September 1, 2020, 12:33pm UTC](https://discourse.julialang.org/t/linear-complementarity-problem-non-obsolete-package/39665 "2020-09-01T12:33:19Z")

</div>

I was wondering which is a fast and easy to use package for a LCP problem. The examples using Complementarity I found give me errors (things like curly brackets were used) and PATHSolver requires a license (I cannot get …

---

## [Why isn't \`i\` defined inside this while?](https://discourse.julialang.org/t/why-isnt-i-defined-inside-this-while/45882)

<div class="topic-metadata">

**Author:** [@Somayeh\_Esmaeili](https://discourse.julialang.org/u/Somayeh_Esmaeili)\
**Replies:** 4\
**Last updated:** [September 1, 2020, 10:08am UTC](https://discourse.julialang.org/t/why-isnt-i-defined-inside-this-while/45882 "2020-09-01T10:08:14Z")

</div>

would you please help me why i cant be known inside this while as following in julia v1+? W=(\[1.0825998948767477 9.448347129060197 972.5335271289529; 165.861582812015 4.563134610834678 1.0293311999771995\], 0) i=1; k=siz…

---

## [Error building CPLEX](https://discourse.julialang.org/t/error-building-cplex/45798)

<div class="topic-metadata">

**Author:** [@Glaucio](https://discourse.julialang.org/u/Glaucio)\
**Replies:** 1\
**Last updated:** [August 30, 2020, 8:29pm UTC](https://discourse.julialang.org/t/error-building-cplex/45798 "2020-08-30T20:29:52Z")

</div>

me ajudem

---

## [Working with dictionaries in @variables and @constraints](https://discourse.julialang.org/t/working-with-dictionaries-in-variables-and-constraints/45726)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 2\
**Last updated:** [August 29, 2020, 2:48pm UTC](https://discourse.julialang.org/t/working-with-dictionaries-in-variables-and-constraints/45726 "2020-08-29T14:48:43Z")

</div>

I wonder if it is possible to work with Dict in @variables and @constraints like this: \_ORDER\_PRODUCTS and UNITS are Dict @constraint(premex, PRODAMOUNTint\_upper\[op in \_ORDER\_PRODUCTS, u in UNITS, t in TIME\], …

---

## [Expressions for partial derivatives using AD tools](https://discourse.julialang.org/t/expressions-for-partial-derivatives-using-ad-tools/45741)

<div class="topic-metadata">

**Author:** [@JLHTM](https://discourse.julialang.org/u/JLHTM)\
**Replies:** 2\
**Last updated:** [August 29, 2020, 1:53pm UTC](https://discourse.julialang.org/t/expressions-for-partial-derivatives-using-ad-tools/45741 "2020-08-29T13:53:51Z")

</div>

I have two bivariate functions (more generally, n n-variable functions) f\_1(x\_1,x\_2) and f\_2(x\_1,x\_2). I need to solve the following system of equations: \\frac{\\partial f\_1}{\\partial x\_1} = 0 and \\frac{\\partial f\_2}{\\par…

---

## [ERROR: MethodError: no method matching Model](https://discourse.julialang.org/t/error-methoderror-no-method-matching-model/45699)

<div class="topic-metadata">

**Author:** [@cotepascal76](https://discourse.julialang.org/u/cotepascal76)\
**Replies:** 2\
**Last updated:** [August 29, 2020, 10:34am UTC](https://discourse.julialang.org/t/error-methoderror-no-method-matching-model/45699 "2020-08-29T10:34:26Z")

</div>

Hello, I’m new in Julia and JuMP and I just tried to install and test JuMP but I got this error (with all solvers that I tested): julia\> Model(Gurobi.Optimizer) ERROR: MethodError: no method matching Model(::Type{Gurob…

---

## [Call a PowerModels' function in Matlab](https://discourse.julialang.org/t/call-a-powermodels-function-in-matlab/45647)

<div class="topic-metadata">

**Author:** [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Replies:** 2\
**Last updated:** [August 28, 2020, 4:37pm UTC](https://discourse.julialang.org/t/call-a-powermodels-function-in-matlab/45647 "2020-08-28T16:37:11Z")

</div>

Hi All, I want to call the bound tightening code in the PowerModels (i.e. following function) in Matlab. run\_obbt\_opf(case, upper\_bound, solver, model\_constructor= QCWRTriPowerModel) I tried to call “bound\_tightening\_…

---

## [Need someone to explain to me this](https://discourse.julialang.org/t/need-someone-to-explain-to-me-this/45645)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 4\
**Last updated:** [August 28, 2020, 1:24pm UTC](https://discourse.julialang.org/t/need-someone-to-explain-to-me-this/45645 "2020-08-28T13:24:13Z")

</div>

I am very new to Julia and will learn, but I would ask you if you can help an explain this line by line to me: @constraints(model, begin # Constraint 1 - Only one value appears in each cell cell\[i in…

---

## [Querying JuMP solutions - results out of order](https://discourse.julialang.org/t/querying-jump-solutions-results-out-of-order/45301)

<div class="topic-metadata">

**Author:** [@fnbillimoria](https://discourse.julialang.org/u/fnbillimoria)\
**Replies:** 2\
**Last updated:** [August 27, 2020, 7:06am UTC](https://discourse.julialang.org/t/querying-jump-solutions-results-out-of-order/45301 "2020-08-27T07:06:06Z")

</div>

Hello, I have created a JuMP model, and wish to source and sort the results. The JuMP model is created via a call to a function with results stored as below. I wish to obtain results for a variable array called pg. Ho…

---

## [How to register a function with parameter in JuMP](https://discourse.julialang.org/t/how-to-register-a-function-with-parameter-in-jump/45457)

<div class="topic-metadata">

**Author:** [@Behemoth-s](https://discourse.julialang.org/u/Behemoth-s)\
**Replies:** 2\
**Last updated:** [August 25, 2020, 2:10am UTC](https://discourse.julialang.org/t/how-to-register-a-function-with-parameter-in-jump/45457 "2020-08-25T02:10:25Z")

</div>

Here I have some variables and parameters model = Model(Ipopt.Optimizer) @variable(model, x\[1:2\]) p = \[4, 6\] I want to register a function with parameter in JuMP to do something like this bellow. function f(x, p) …

---

## [Proper declaration of constraint](https://discourse.julialang.org/t/proper-declaration-of-constraint/45424)

<div class="topic-metadata">

**Author:** [@mamo](https://discourse.julialang.org/u/mamo)\
**Replies:** 5\
**Last updated:** [August 24, 2020, 1:51pm UTC](https://discourse.julialang.org/t/proper-declaration-of-constraint/45424 "2020-08-24T13:51:39Z")

</div>

Constraint below says for each k, k=1, k=22, k=43 (since k is \< length(TIME)=63) PLEVEL\[1\]\<=… PLEVEL\[22\]\<=… PLEVEL\[43\]\<=… PLEVEL1 is binary. s1\[k in 1:interval:length(TIME) if k\<length(TIME)\], PLEVEL\[k\]-limit\<=M\*PLE…

---

## [ERROR: LoadError: MethodError: no method matching isless(::String, ::Int64)](https://discourse.julialang.org/t/error-loaderror-methoderror-no-method-matching-isless-string-int64/45408)

<div class="topic-metadata">

**Author:** [@mamo](https://discourse.julialang.org/u/mamo)\
**Replies:** 3\
**Last updated:** [August 23, 2020, 10:24pm UTC](https://discourse.julialang.org/t/error-loaderror-methoderror-no-method-matching-isless-string-int64/45408 "2020-08-23T22:24:26Z")

</div>

Send me please your opinion related to the error I received. Thanks! ERROR: LoadError: MethodError: no method matching isless(::String, ::Int64) Closest candidates are: isless(::Missing, ::Any) at missing.jl:87 isl…

---

## [Unclear error](https://discourse.julialang.org/t/unclear-error/45356)

<div class="topic-metadata">

**Author:** [@mamo](https://discourse.julialang.org/u/mamo)\
**Replies:** 2\
**Last updated:** [August 22, 2020, 7:55pm UTC](https://discourse.julialang.org/t/unclear-error/45356 "2020-08-22T19:55:42Z")

</div>

Below, is example 6.2 from the book (Julia Programming for OR) ‘’’ import Pkg Pkg.add(“DataFrames”) Pkg.add(“CSV”) Pkg.add(“JuMP”) Pkg.add(“MathOptInterface”) Pkg.add(“GLPK”) Pkg.add(“Clp”) Pkg.activate(@DIR) Pk…

---

## [Is there a Julia equivalent of scipy.optimize.minimize(method='TNC')?](https://discourse.julialang.org/t/is-there-a-julia-equivalent-of-scipy-optimize-minimize-method-tnc/45154)

<div class="topic-metadata">

**Author:** [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Replies:** 23\
**Last updated:** [August 21, 2020, 12:12am UTC](https://discourse.julialang.org/t/is-there-a-julia-equivalent-of-scipy-optimize-minimize-method-tnc/45154 "2020-08-21T00:12:52Z")

</div>

which is a truncated Newton (TNC) algorithm, see here for details: minimize(method=’TNC’) — SciPy v1.9.1 Manual. I have a box constrained optimization problem which requires more evaluations with Optim.jl + BFGS (or any…

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

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