# Optimization (Mathematical)

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

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

**Page:** 108

---

## [JuMP/GLPK with equal upper and lower bounds](https://discourse.julialang.org/t/jump-glpk-with-equal-upper-and-lower-bounds/28469)

<div class="topic-metadata">

**Author:** [@pierre-haessig](https://discourse.julialang.org/u/pierre-haessig)\
**Replies:** 5\
**Last updated:** [September 9, 2019, 2:57pm UTC](https://discourse.julialang.org/t/jump-glpk-with-equal-upper-and-lower-bounds/28469 "2019-09-09T14:57:42Z")

</div>

Hello, I’m solving a linear optimization problem with JuMP (0.19.2) using GLPK.jl (0.10.0) as the solver. I’m struggling with the situation where the lower and upper bounds of a variable are equal (and because it’s in a…

---

## [Basic usage of NLsolve for scalar problems](https://discourse.julialang.org/t/basic-usage-of-nlsolve-for-scalar-problems/28489)

<div class="topic-metadata">

**Author:** [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Replies:** 3\
**Last updated:** [September 7, 2019, 11:15am UTC](https://discourse.julialang.org/t/basic-usage-of-nlsolve-for-scalar-problems/28489 "2019-09-07T11:15:43Z")

</div>

I have troubles to use NLsolve package for solving the following simple scalar example: 0 = cos(x) for x initialized to, say, 1.5 (the anticipated solution is thus pi/2, that is, something like 1.57). The code is juli…

---

## [How to view which of your binary values are 1](https://discourse.julialang.org/t/how-to-view-which-of-your-binary-values-are-1/28446)

<div class="topic-metadata">

**Author:** [@marinarrd](https://discourse.julialang.org/u/marinarrd)\
**Replies:** 7\
**Last updated:** [September 6, 2019, 9:14pm UTC](https://discourse.julialang.org/t/how-to-view-which-of-your-binary-values-are-1/28446 "2019-09-06T21:14:07Z")

</div>

I am very new to Julia. I wish to obtain the indices of my output that are non-zero

---

## [Handling INFEASIBLE\_OR\_UNBOUNDED](https://discourse.julialang.org/t/handling-infeasible-or-unbounded/28354)

<div class="topic-metadata">

**Author:** [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Replies:** 2\
**Last updated:** [September 5, 2019, 6:57pm UTC](https://discourse.julialang.org/t/handling-infeasible-or-unbounded/28354 "2019-09-05T18:57:53Z")

</div>

Using JuMP, I am getting the return code INFEASIBLE\_OR\_UNBOUNDED, but in my case, knowing whether the problem is feasible is important. I.e. I should be handling an unbounded problem differently from an infeasible one. I…

---

## [Function with Gurobi model and optional solver parameters](https://discourse.julialang.org/t/function-with-gurobi-model-and-optional-solver-parameters/28327)

<div class="topic-metadata">

**Author:** [@ibabeo](https://discourse.julialang.org/u/ibabeo)\
**Replies:** 3\
**Last updated:** [September 5, 2019, 1:05pm UTC](https://discourse.julialang.org/t/function-with-gurobi-model-and-optional-solver-parameters/28327 "2019-09-05T13:05:44Z")

</div>

I’m trying to make a function with arguments that I can pass to the model if any, otherwise stay default. function mymip(; verbose = true, timelimit=false, mipfocus=false, rins=false) model = Model(with\_optimizer(G…

---

## [Calling Fortran routine within Jump objective function](https://discourse.julialang.org/t/calling-fortran-routine-within-jump-objective-function/28347)

<div class="topic-metadata">

**Author:** [@kuwi](https://discourse.julialang.org/u/kuwi)\
**Replies:** 2\
**Last updated:** [September 5, 2019, 1:00pm UTC](https://discourse.julialang.org/t/calling-fortran-routine-within-jump-objective-function/28347 "2019-09-05T13:00:03Z")

</div>

Hello, I have a question regarding the call of Fortran routines within a Jump objective function. With the help of several forum posts, I managed to write Julia and Fortran code so I can call the Fortran routine from Ju…

---

## [Iterate over a SparseAxisArray container to retrieve variable values and index (jump 0.18+)](https://discourse.julialang.org/t/iterate-over-a-sparseaxisarray-container-to-retrieve-variable-values-and-index-jump-0-18/19498)

<div class="topic-metadata">

**Author:** [@willu47](https://discourse.julialang.org/u/willu47)\
**Replies:** 2\
**Last updated:** [September 4, 2019, 1:44pm UTC](https://discourse.julialang.org/t/iterate-over-a-sparseaxisarray-container-to-retrieve-variable-values-and-index-jump-0-18/19498 "2019-09-04T13:44:26Z")

</div>

I wish to iterate over the variables contained in a JuMP.SparseAxisArray so that I can write out variable values using JuMP.value(var), where var is an entry in the array. I would also like to obtain the value of the in…

---

## [How to solve non-linear system with input array?](https://discourse.julialang.org/t/how-to-solve-non-linear-system-with-input-array/28336)

<div class="topic-metadata">

**Author:** [@alvrg](https://discourse.julialang.org/u/alvrg)\
**Replies:** 4\
**Last updated:** [September 3, 2019, 10:15pm UTC](https://discourse.julialang.org/t/how-to-solve-non-linear-system-with-input-array/28336 "2019-09-03T22:15:58Z")

</div>

Hi, I want to find the roots of a system of non-linear equations like this one: function f!(F::Vector{Float64}, Δ::Vector{Float64}, L::Int64, N::Int64, g::Float64, …

---

## [How to build CDDLib.jl on Windows ✅](https://discourse.julialang.org/t/how-to-build-cddlib-jl-on-windows/28114)

<div class="topic-metadata">

**Author:** [@uwechsler](https://discourse.julialang.org/u/uwechsler)\
**Replies:** 1\
**Last updated:** [September 1, 2019, 2:48pm UTC](https://discourse.julialang.org/t/how-to-build-cddlib-jl-on-windows/28114 "2019-09-01T14:48:16Z")

</div>

For my current project, I’d like to run CDDLib.jl on a Windows system. Currently, I get the following error message when trying to build the library. (v1.1) pkg\> build CDDLib Building SpecialFunctions → \`C:\\Users\\wue…

---

## [Power Balance reference in PowerModels.jl](https://discourse.julialang.org/t/power-balance-reference-in-powermodels-jl/27865)

<div class="topic-metadata">

**Author:** [@andrewrosemberg](https://discourse.julialang.org/u/andrewrosemberg)\
**Replies:** 5\
**Last updated:** [August 30, 2019, 4:19am UTC](https://discourse.julialang.org/t/power-balance-reference-in-powermodels-jl/27865 "2019-08-30T04:19:20Z")

</div>

I’m running an OPF problem with SDPWRMForm and SOCWRConicForm formulations (AbstractWForms) and I’m trying to retrieve the duals from the power balance constraints (lam\_kcl\_r in the output). However, it seams that the re…

---

## [Problem in Power Flow using Julia](https://discourse.julialang.org/t/problem-in-power-flow-using-julia/1491)

<div class="topic-metadata">

**Author:** [@ashefa](https://discourse.julialang.org/u/ashefa)\
**Replies:** 18\
**Last updated:** [August 29, 2019, 4:18pm UTC](https://discourse.julialang.org/t/problem-in-power-flow-using-julia/1491 "2019-08-29T16:18:02Z")

</div>

I started writing “Power Flow” in two software, GAMS and Julialang, simultaneously. In addition to i did “Power Flow” in GAMS, i receive to results of “State Estimation” problem, but in Julia (using JuMP) yet i couldn’t …

---

## [JuMP v0.19.2 ⇒ v0.18.6](https://discourse.julialang.org/t/jump-v0-19-2-v0-18-6/27917)

<div class="topic-metadata">

**Author:** [@raktim](https://discourse.julialang.org/u/raktim)\
**Replies:** 3\
**Last updated:** [August 26, 2019, 1:57pm UTC](https://discourse.julialang.org/t/jump-v0-19-2-v0-18-6/27917 "2019-08-26T13:57:09Z")

</div>

Just installed Julia 1.2 along with JuMP and other packages. Did an update and noticed that JuMP was downgraded from version v0.19.2 ⇒ v0.18.6. Not sure why this is happening. Any clues?

---

## [JuMPeR installation problem with juliaPro-0.5.1.1](https://discourse.julialang.org/t/jumper-installation-problem-with-juliapro-0-5-1-1/2930)

<div class="topic-metadata">

**Author:** [@Ayse\_Nur\_Arslan](https://discourse.julialang.org/u/Ayse_Nur_Arslan)\
**Replies:** 3\
**Last updated:** [August 26, 2019, 1:31pm UTC](https://discourse.julialang.org/t/jumper-installation-problem-with-juliapro-0-5-1-1/2930 "2019-08-26T13:31:33Z")

</div>

Hello, I get the following error message when attempting to add the JuMPeR package using juliaPro-0.5.1.1 with the command Pkg.add(“JuMPeR”): ERROR: unsatisfiable package requirements detected: no feasible version cou…

---

## [Transposing player orders in a linear constraint](https://discourse.julialang.org/t/transposing-player-orders-in-a-linear-constraint/27945)

<div class="topic-metadata">

**Author:** [@Saggaa](https://discourse.julialang.org/u/Saggaa)\
**Replies:** 3\
**Last updated:** [August 26, 2019, 7:30am UTC](https://discourse.julialang.org/t/transposing-player-orders-in-a-linear-constraint/27945 "2019-08-26T07:30:28Z")

</div>

Hello everyone! I am currently learning Julia in college and i would need your expert help to better define a linear constraint in the frame of an assignment. Our professor is passionate about MLB and our assignment is…

---

## [Module idea for helping calculate large sparse Jacobians](https://discourse.julialang.org/t/module-idea-for-helping-calculate-large-sparse-jacobians/27941)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 5\
**Last updated:** [August 25, 2019, 7:43pm UTC](https://discourse.julialang.org/t/module-idea-for-helping-calculate-large-sparse-jacobians/27941 "2019-08-25T19:43:57Z")

</div>

I’ve put together a minimal, tiny draft of a project idea I had. It’s about helping to work with large structured models, the kind of thing you might use g2o for (and I imagine similar things might exist for FEM). Basica…

---

## [JuMP array or dictionary lookups](https://discourse.julialang.org/t/jump-array-or-dictionary-lookups/27937)

<div class="topic-metadata">

**Author:** [@bhalonen](https://discourse.julialang.org/u/bhalonen)\
**Replies:** 1\
**Last updated:** [August 24, 2019, 3:39pm UTC](https://discourse.julialang.org/t/jump-array-or-dictionary-lookups/27937 "2019-08-24T15:39:30Z")

</div>

Is it possible to look up values in an array or a dict using integer variables? Something like @variable(model, x, Int) # restrict x to appropriate values @constraint(model, my\_array\[x\] \<= 5) Or should a binary array …

---

## [Pseudo-inverse and the backslash operator](https://discourse.julialang.org/t/pseudo-inverse-and-the-backslash-operator/27882)

<div class="topic-metadata">

**Author:** [@gmouts](https://discourse.julialang.org/u/gmouts)\
**Replies:** 3\
**Last updated:** [August 23, 2019, 10:31am UTC](https://discourse.julialang.org/t/pseudo-inverse-and-the-backslash-operator/27882 "2019-08-23T10:31:44Z")

</div>

So, I have a sparse matrix A and a vector b and I want to compute pinv(A)\*b. After reading this post I tried the following: using LinearAlgebra julia\> A = \[1 1 1; 2 2 2; 1 0 1\] 3×3 Array{Int64,2}: 1 …

---

## [Simple bundle adjustment: array in nonlinear expression?](https://discourse.julialang.org/t/simple-bundle-adjustment-array-in-nonlinear-expression/27851)

<div class="topic-metadata">

**Author:** [@bars](https://discourse.julialang.org/u/bars)\
**Replies:** 4\
**Last updated:** [August 23, 2019, 9:27am UTC](https://discourse.julialang.org/t/simple-bundle-adjustment-array-in-nonlinear-expression/27851 "2019-08-23T09:27:49Z")

</div>

Hi there! I’m here since I find Julia, and JuMP in particular, very impressive and I suspect it should be a very good fit for SLAM (Simultaneous Localization and Mapping), where C++ is still the popular choice. In part…

---

## [StructJuMP](https://discourse.julialang.org/t/structjump/27797)

<div class="topic-metadata">

**Author:** [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)\
**Replies:** 2\
**Last updated:** [August 21, 2019, 3:17pm UTC](https://discourse.julialang.org/t/structjump/27797 "2019-08-21T15:17:45Z")

</div>

Any advice on how to get the extensive form from a StructuredModel?

---

## [How to get the current LP bound in an user callback (cplex)?](https://discourse.julialang.org/t/how-to-get-the-current-lp-bound-in-an-user-callback-cplex/27076)

<div class="topic-metadata">

**Author:** [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Replies:** 4\
**Last updated:** [August 20, 2019, 12:14pm UTC](https://discourse.julialang.org/t/how-to-get-the-current-lp-bound-in-an-user-callback-cplex/27076 "2019-08-20T12:14:07Z")

</div>

Dear community, I have a MIP in which I add cuts in a user callback (using JuMP 0.18.5, CPLEX 0.5, MathProgBase 0.7.7). I would like to retrieve the LP bound in the current node of the B&B tree, e.g., by doing something…

---

## [Newbie mathopt question: JuMP declare or restrain a variable to a few integers, not in a row](https://discourse.julialang.org/t/newbie-mathopt-question-jump-declare-or-restrain-a-variable-to-a-few-integers-not-in-a-row/27726)

<div class="topic-metadata">

**Author:** [@bhalonen](https://discourse.julialang.org/u/bhalonen)\
**Replies:** 2\
**Last updated:** [August 19, 2019, 7:17pm UTC](https://discourse.julialang.org/t/newbie-mathopt-question-jump-declare-or-restrain-a-variable-to-a-few-integers-not-in-a-row/27726 "2019-08-19T19:17:39Z")

</div>

I am looking to be able to declare a vector of integer variables and restrain them to 1, 2, 3 … some finite number of non sequential integers. Should I create some roundabout lookup table to interpret sequential integers…

---

## [Optim.jl with autodiff and complex numbers](https://discourse.julialang.org/t/optim-jl-with-autodiff-and-complex-numbers/27684)

<div class="topic-metadata">

**Author:** [@Dandan](https://discourse.julialang.org/u/Dandan)\
**Replies:** 8\
**Last updated:** [August 18, 2019, 8:03pm UTC](https://discourse.julialang.org/t/optim-jl-with-autodiff-and-complex-numbers/27684 "2019-08-18T20:03:03Z")

</div>

Hello! I would like to use Optim.jl with the target function defined on a complex Stiefel manifold (unitary matrices) of some large size. Stiefel manifold is already implemented in Optim.jl. The problem is I can’t use …

---

## [Pkg update downgrade JuMP](https://discourse.julialang.org/t/pkg-update-downgrade-jump/27621)

<div class="topic-metadata">

**Author:** [@remi-garcia](https://discourse.julialang.org/u/remi-garcia)\
**Replies:** 3\
**Last updated:** [August 17, 2019, 3:11pm UTC](https://discourse.julialang.org/t/pkg-update-downgrade-jump/27621 "2019-08-17T15:11:53Z")

</div>

Hi, When I add JuMP and GLPK I get this: (v1.1) pkg\> st Status \`~/.julia/environments/v1.1/Project.toml\` (empty environment) (v1.1) pkg\> add JuMP GLPK Resolving package versions... Updating \`~/.julia/environm…

---

## [Defining the objective using function](https://discourse.julialang.org/t/defining-the-objective-using-function/27633)

<div class="topic-metadata">

**Author:** [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)\
**Replies:** 5\
**Last updated:** [August 17, 2019, 2:09pm UTC](https://discourse.julialang.org/t/defining-the-objective-using-function/27633 "2019-08-17T14:09:55Z")

</div>

Dear users, I need to minimize this nonlinear function: f(x1,x2) = 1 + x2^2 - x - sin(x1) with box constraints. How can I do this by using a function, named E-restrito, providing as argument f? My code is: function E…

---

## [How to reconfigure Couenne for Cplex in windows](https://discourse.julialang.org/t/how-to-reconfigure-couenne-for-cplex-in-windows/27581)

<div class="topic-metadata">

**Author:** [@Raminel](https://discourse.julialang.org/u/Raminel)\
**Replies:** 2\
**Last updated:** [August 17, 2019, 2:02pm UTC](https://discourse.julialang.org/t/how-to-reconfigure-couenne-for-cplex-in-windows/27581 "2019-08-17T14:02:54Z")

</div>

Hi all, Can someone tell me how I can “reconfigure and recompile” Couenne to use Cplex for lp solver? I added this to couenne.opt “lp\_solver cplex” and read in teh manual that I need to run the configuration file after…

---

## [Type FPFunctionalCache has no field caches error](https://discourse.julialang.org/t/type-fpfunctionalcache-has-no-field-caches-error/27598)

<div class="topic-metadata">

**Author:** [@Farnazmdi](https://discourse.julialang.org/u/Farnazmdi)\
**Replies:** 5\
**Last updated:** [August 16, 2019, 6:42pm UTC](https://discourse.julialang.org/t/type-fpfunctionalcache-has-no-field-caches-error/27598 "2019-08-16T18:42:27Z")

</div>

Hi, I am using BlackBoxOptim and I get this error when I run it. Starting optimization with optimizer DiffEvoOpt{FitPopulation{Float64},RadiusLimitedSelector,BlackBoxOptim.AdaptiveDiffEvoRandBin{3},RandomBound{Continuo…

---

## [Convex.jl: Trouble with partially specified function inside another problem?](https://discourse.julialang.org/t/convex-jl-trouble-with-partially-specified-function-inside-another-problem/26508)

<div class="topic-metadata">

**Author:** [@Jacob\_Stevens-Haas](https://discourse.julialang.org/u/Jacob_Stevens-Haas)\
**Replies:** 5\
**Last updated:** [August 13, 2019, 4:13pm UTC](https://discourse.julialang.org/t/convex-jl-trouble-with-partially-specified-function-inside-another-problem/26508 "2019-08-13T16:13:45Z")

</div>

I’m trying to use a partially defined function as in DCP documentation. I have a minimization problem including convex function that isn’t a disciplined convex function. It’s fenchel conjugate is, however, so I was hop…

---

## [How to add Integer contraint to variables using the @variables macro?](https://discourse.julialang.org/t/how-to-add-integer-contraint-to-variables-using-the-variables-macro/27500)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 1\
**Last updated:** [August 13, 2019, 3:02pm UTC](https://discourse.julialang.org/t/how-to-add-integer-contraint-to-variables-using-the-variables-macro/27500 "2019-08-13T15:02:49Z")

</div>

To bound a variable to be integer I can use integer=true, e.g. @variable(m, 0 \<= p, integer=true, start=1), but how to do that when I use the @variables macro? I did try as such, but it is not recognised (also base\_name …

---

## [ForwardDiff fast construction of vectors/matrices without cats](https://discourse.julialang.org/t/forwarddiff-fast-construction-of-vectors-matrices-without-cats/27468)

<div class="topic-metadata">

**Author:** [@ys3636](https://discourse.julialang.org/u/ys3636)\
**Replies:** 6\
**Last updated:** [August 12, 2019, 9:25pm UTC](https://discourse.julialang.org/t/forwarddiff-fast-construction-of-vectors-matrices-without-cats/27468 "2019-08-12T21:25:21Z")

</div>

Hi, I’m trying to use Optim to do maximum-likelihood estimation of some parameters in a custom likelihood model. In particular, I would like to incorporate autodiff to increase the accuracy of my estimates. However, set…

---

## [Container of PSD variables in JuMP](https://discourse.julialang.org/t/container-of-psd-variables-in-jump/27448)

<div class="topic-metadata">

**Author:** [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Replies:** 3\
**Last updated:** [August 12, 2019, 4:02pm UTC](https://discourse.julialang.org/t/container-of-psd-variables-in-jump/27448 "2019-08-12T16:02:21Z")

</div>

What is the best way to create a container of PSD “variables” such that X\[i\] = i-th PSD variable?

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

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