# Optimization (Mathematical)

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

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

**Page:** 92

---

## [Testing code that is executed when solve reaches non-optimal status](https://discourse.julialang.org/t/testing-code-that-is-executed-when-solve-reaches-non-optimal-status/47293)

<div class="topic-metadata">

**Author:** [@vtjeng](https://discourse.julialang.org/u/vtjeng)\
**Replies:** 3\
**Last updated:** [September 27, 2020, 10:51pm UTC](https://discourse.julialang.org/t/testing-code-that-is-executed-when-solve-reaches-non-optimal-status/47293 "2020-09-27T22:51:50Z")

</div>

I’m looking for advice on the best way to test code that is executed only when the termination status for optimization returns a status of MathOptInterface.TIME\_LIMIT. The first approach I tried was to construct models …

---

## [Error installing Mosek (unable to build)](https://discourse.julialang.org/t/error-installing-mosek-unable-to-build/47337)

<div class="topic-metadata">

**Author:** [@axw](https://discourse.julialang.org/u/axw)\
**Replies:** 1\
**Last updated:** [September 27, 2020, 9:47pm UTC](https://discourse.julialang.org/t/error-installing-mosek-unable-to-build/47337 "2020-09-27T21:47:54Z")

</div>

Got the license file and put in C:\\Users\\user\_name\\mosek. Ran pkg add mosek, and looks fine. But when I pkg build mosek I get this error. Any ideas? I see on the mosek site it mentions defining some distro but I’m …

---

## [Strange behaviour with if-else-Statements](https://discourse.julialang.org/t/strange-behaviour-with-if-else-statements/47266)

<div class="topic-metadata">

**Author:** [@SonntagK](https://discourse.julialang.org/u/SonntagK)\
**Replies:** 4\
**Last updated:** [September 25, 2020, 3:47pm UTC](https://discourse.julialang.org/t/strange-behaviour-with-if-else-statements/47266 "2020-09-25T15:47:24Z")

</div>

Hello, I’m new to Julia and working with Julia/JuMP for optimization purposes. I want to use if-else-statements in the constraints I’m defining to write them more compact. When trying so I ran in some strange behaviour. …

---

## [Problems updating from JuMP 0.21.4 to 0.21.5](https://discourse.julialang.org/t/problems-updating-from-jump-0-21-4-to-0-21-5/47145)

<div class="topic-metadata">

**Author:** [@gbustosx](https://discourse.julialang.org/u/gbustosx)\
**Replies:** 4\
**Last updated:** [September 25, 2020, 3:39pm UTC](https://discourse.julialang.org/t/problems-updating-from-jump-0-21-4-to-0-21-5/47145 "2020-09-25T15:39:33Z")

</div>

Hi, all, I can’t seem to update from JuMP 0.21.4 to 0.21.5, should I go back to 0.21.3 firtst? Many thanks!

---

## [Solver for a robust model](https://discourse.julialang.org/t/solver-for-a-robust-model/47088)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 5\
**Last updated:** [September 25, 2020, 2:16pm UTC](https://discourse.julialang.org/t/solver-for-a-robust-model/47088 "2020-09-25T14:16:57Z")

</div>

I believe that the solver is suitable for robust models, but I cannot obtain the result of the compilation. (template for study taken from the website: https://jumper.readthedocs.io/en/latest/jumper.htm using JuMP, JuM…

---

## [Complementarity in MOI wrappers](https://discourse.julialang.org/t/complementarity-in-moi-wrappers/47225)

<div class="topic-metadata">

**Author:** [@mrt](https://discourse.julialang.org/u/mrt)\
**Replies:** 1\
**Last updated:** [September 24, 2020, 8:51pm UTC](https://discourse.julialang.org/t/complementarity-in-moi-wrappers/47225 "2020-09-24T20:51:09Z")

</div>

I’m writing a MathOptInterface wrapper for a solver, and have been trying to implement complementarity. How do I define the problem attribute for the optimizer? If I naively attempt e.g. : comp::Vector{ConstraintInfo{MO…

---

## [How to determine if a constraint is actually applied to the model?](https://discourse.julialang.org/t/how-to-determine-if-a-constraint-is-actually-applied-to-the-model/47176)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 5\
**Last updated:** [September 24, 2020, 10:08am UTC](https://discourse.julialang.org/t/how-to-determine-if-a-constraint-is-actually-applied-to-the-model/47176 "2020-09-24T10:08:38Z")

</div>

I have yet an another question. I have a working costraint: @variable(prmx, PRODAMOUNT\[op\_k in keys(\_ORDER\_PRODUCTs\_ALL), u\_k in keys(UNITS), t in TIME\], Int, lower\_bound = 0) for f\_f\_k in \_FORB…

---

## [Solution foun by heuristic GLPK](https://discourse.julialang.org/t/solution-foun-by-heuristic-glpk/38772)

<div class="topic-metadata">

**Author:** [@lausilvag](https://discourse.julialang.org/u/lausilvag)\
**Replies:** 9\
**Last updated:** [September 23, 2020, 8:04pm UTC](https://discourse.julialang.org/t/solution-foun-by-heuristic-glpk/38772 "2020-09-23T20:04:30Z")

</div>

Hi guys! I am using GLPK solver for a MIP. The output terminal shows me the next information: GLPK Simplex Optimizer, v4.64 16 rows, 120 columns, 800 non-zeros 1: obj = 4.548322148e+003 inf = 0.000e+000 (0) 9: o…

---

## [Availabilty of Hypatia.jl solver](https://discourse.julialang.org/t/availabilty-of-hypatia-jl-solver/47131)

<div class="topic-metadata">

**Author:** [@martincornejo](https://discourse.julialang.org/u/martincornejo)\
**Replies:** 2\
**Last updated:** [September 23, 2020, 12:14pm UTC](https://discourse.julialang.org/t/availabilty-of-hypatia-jl-solver/47131 "2020-09-23T12:14:01Z")

</div>

I was very excited to learned about the Hypatia.jl solver from the JuliaCon keynote of Juan Pablo Vielma and this JuMP-dev 2019 workshop from Chris Coey. However I haven’t found any repository or further information on i…

---

## [Problem with CPLEX lazy callback and JuMP](https://discourse.julialang.org/t/problem-with-cplex-lazy-callback-and-jump/47090)

<div class="topic-metadata">

**Author:** [@dragond4](https://discourse.julialang.org/u/dragond4)\
**Replies:** 2\
**Last updated:** [September 22, 2020, 8:59pm UTC](https://discourse.julialang.org/t/problem-with-cplex-lazy-callback-and-jump/47090 "2020-09-22T20:59:21Z")

</div>

Hi! When trying to use lazy callbacks in JuMP I get the following error if CPLEX is used as solver: ERROR: LoadError: TypeError: in typeassert, expected Tuple{CPLEX.Model,Function}, got a value of type Tuple{UInt64,In…

---

## [Jump Xpress - Problem with "MAXTIME" parameter](https://discourse.julialang.org/t/jump-xpress-problem-with-maxtime-parameter/45821)

<div class="topic-metadata">

**Author:** [@Tmart](https://discourse.julialang.org/u/Tmart)\
**Replies:** 10\
**Last updated:** [September 22, 2020, 3:22pm UTC](https://discourse.julialang.org/t/jump-xpress-problem-with-maxtime-parameter/45821 "2020-09-22T15:22:41Z")

</div>

Hello, When I set the parameter “MAXTIME” for a optimization problem in JUMP with the XPress solver, I have the error “DimensionMismatch(“array could not be broadcast to match destination”)”. However, in the output file…

---

## [Using Dualization](https://discourse.julialang.org/t/using-dualization/47036)

<div class="topic-metadata">

**Author:** [@RaquelSantos](https://discourse.julialang.org/u/RaquelSantos)\
**Replies:** 1\
**Last updated:** [September 21, 2020, 8:40pm UTC](https://discourse.julialang.org/t/using-dualization/47036 "2020-09-21T20:40:54Z")

</div>

I would like to pass this model to Dual but I still haven’t got it. Could someone help me? Thank you! using JuMP, Cbc, Dualization FabricaBrinquedos = Model(dual\_optimizer(Cbc.Optimizer))#When I try to compile using d…

---

## [Trying to run ARM based GLPK solver using JuMP on a RaspbaerryPi](https://discourse.julialang.org/t/trying-to-run-arm-based-glpk-solver-using-jump-on-a-raspbaerrypi/46716)

<div class="topic-metadata">

**Author:** [@BenjaminBastidas](https://discourse.julialang.org/u/BenjaminBastidas)\
**Replies:** 11\
**Last updated:** [September 21, 2020, 3:24pm UTC](https://discourse.julialang.org/t/trying-to-run-arm-based-glpk-solver-using-jump-on-a-raspbaerrypi/46716 "2020-09-21T15:24:35Z")

</div>

Hi everyone, first time posting, I have a problem I need help with, hope someone can help me. What I’m trying to do is to run an optimization problem using a RaspberryPi 4. To accomplish this I’m using JuMP and GLPK sol…

---

## [JuMP 0.21.5 released](https://discourse.julialang.org/t/jump-0-21-5-released/46976)

<div class="topic-metadata">

**Author:** [@odow](https://discourse.julialang.org/u/odow)\
**Replies:** 0\
**Last updated:** [September 21, 2020, 2:40am UTC](https://discourse.julialang.org/t/jump-0-21-5-released/46976 "2020-09-21T02:40:29Z")

</div>

Dear all, We are happy to announce the joint release of JuMP 0.21.5 and MathOptInterface 0.9.17! These releases are a mix of new features and some much needed performance optimizations. This should be a non-breaking rel…

---

## [How to make if in the objective function](https://discourse.julialang.org/t/how-to-make-if-in-the-objective-function/46859)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 14\
**Last updated:** [September 19, 2020, 10:53am UTC](https://discourse.julialang.org/t/how-to-make-if-in-the-objective-function/46859 "2020-09-19T10:53:22Z")

</div>

Here is the function @objective( prmx, Min, sum( sum( UNITS\[u\_k\]\["cap"\] - sum( PRODAMOUNT\[op\_k, u\_k, t\] \* \_PRODUCTs…

---

## [Why the results of my model remain the same even if the objective value changes?](https://discourse.julialang.org/t/why-the-results-of-my-model-remain-the-same-even-if-the-objective-value-changes/46817)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 5\
**Last updated:** [September 18, 2020, 7:56pm UTC](https://discourse.julialang.org/t/why-the-results-of-my-model-remain-the-same-even-if-the-objective-value-changes/46817 "2020-09-18T19:56:22Z")

</div>

I am struggling with modeling so much, for me what is logical is not so in the model. The next thing is how to force the system to change results by changing the objective value, so let me explain. I see we can only hav…

---

## [Why the @objective value is negative?](https://discourse.julialang.org/t/why-the-objective-value-is-negative/46781)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 2\
**Last updated:** [September 18, 2020, 1:18am UTC](https://discourse.julialang.org/t/why-the-objective-value-is-negative/46781 "2020-09-18T01:18:31Z")

</div>

I have this model (using cbc solver): @variable(premex, PRODAMOUNT\[op\_k in keys(\_ORDER\_PRODUCTs\_ALL), u\_k in keys(UNITS), t in TIME\], Int, lower\_bound = 0) @objective( premex, M…

---

## [SOCP modeling in Julia?](https://discourse.julialang.org/t/socp-modeling-in-julia/46808)

<div class="topic-metadata">

**Author:** [@Qinyang](https://discourse.julialang.org/u/Qinyang)\
**Replies:** 4\
**Last updated:** [September 18, 2020, 12:17am UTC](https://discourse.julialang.org/t/socp-modeling-in-julia/46808 "2020-09-18T00:17:36Z")

</div>

Hello friends, I am new to Julia and optimization. I have met a SOCP problem in my research. The model looks like the following the objective function is a quardratic one. PG(i), alpha(i) here are my variables. I main…

---

## [Bounded gradient descent on bounded interpolation searches \[NaN, NaN\]](https://discourse.julialang.org/t/bounded-gradient-descent-on-bounded-interpolation-searches-nan-nan/46346)

<div class="topic-metadata">

**Author:** [@grahamas](https://discourse.julialang.org/u/grahamas)\
**Replies:** 2\
**Last updated:** [September 17, 2020, 8:32pm UTC](https://discourse.julialang.org/t/bounded-gradient-descent-on-bounded-interpolation-searches-nan-nan/46346 "2020-09-17T20:32:34Z")

</div>

I’m confused how\[NaN, NaN\] could ever come up, and am at a loss as to how go about debugging. The same code works for several other example data. It seems like the issue is that there are so many zeros but I would think …

---

## [Optimization errors with simple JuMP function using GLPK Optimizer](https://discourse.julialang.org/t/optimization-errors-with-simple-jump-function-using-glpk-optimizer/46652)

<div class="topic-metadata">

**Author:** [@standon41](https://discourse.julialang.org/u/standon41)\
**Replies:** 9\
**Last updated:** [September 16, 2020, 8:53pm UTC](https://discourse.julialang.org/t/optimization-errors-with-simple-jump-function-using-glpk-optimizer/46652 "2020-09-16T20:53:07Z")

</div>

Hello, I am a novice to Julia programming. Going though a tutorial I see myself running into this error and I am not quite sure what it means. Can someone who is an expert in JuMP and GLPK advise? Error: MethodError: …

---

## [Using optimizer callbacks within JuMP to terminate MIP solve](https://discourse.julialang.org/t/using-optimizer-callbacks-within-jump-to-terminate-mip-solve/46679)

<div class="topic-metadata">

**Author:** [@adow031](https://discourse.julialang.org/u/adow031)\
**Replies:** 5\
**Last updated:** [September 16, 2020, 8:23pm UTC](https://discourse.julialang.org/t/using-optimizer-callbacks-within-jump-to-terminate-mip-solve/46679 "2020-09-16T20:23:57Z")

</div>

I’ve got a MIP problem in JuMP, for which I would like the branch-and-bound to terminate as soon as the incumbent reaches a particular value, or as soon as the lower bound reaches a (different) particular value. I’ve fo…

---

## [Reuse gurobi license](https://discourse.julialang.org/t/reuse-gurobi-license/46680)

<div class="topic-metadata">

**Author:** [@Ken\_Lin](https://discourse.julialang.org/u/Ken_Lin)\
**Replies:** 1\
**Last updated:** [September 16, 2020, 3:30am UTC](https://discourse.julialang.org/t/reuse-gurobi-license/46680 "2020-09-16T03:30:38Z")

</div>

I would like my code to reuse a single gurobi license instead of one per model. The following works for me: const GRB\_ENV = Gurobi.Env() m1 = Model(solver=GurobiSolver(GRB\_ENV)) m2 = Model(solver=GurobiSolver(GRB\_ENV))…

---

## [Condition in @objective](https://discourse.julialang.org/t/condition-in-objective/46526)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 5\
**Last updated:** [September 15, 2020, 10:54am UTC](https://discourse.julialang.org/t/condition-in-objective/46526 "2020-09-15T10:54:45Z")

</div>

I want to set an if statement in @objective macro. This is how it looks like now: @variable(premex, PRODAMOUNT\[op\_k in keys(\_ORDER\_PRODUCTs\_ALL), u\_k in keys(UNITS), t in TIME\], Int, lower\_bound = 0) @o…

---

## [Performance of optimization problem in a loop](https://discourse.julialang.org/t/performance-of-optimization-problem-in-a-loop/46374)

<div class="topic-metadata">

**Author:** [@Oliver\_Lylloff](https://discourse.julialang.org/u/Oliver_Lylloff)\
**Replies:** 14\
**Last updated:** [September 15, 2020, 7:30am UTC](https://discourse.julialang.org/t/performance-of-optimization-problem-in-a-loop/46374 "2020-09-15T07:30:37Z")

</div>

Hello. I’m trying to improve the performance of an optimization problem. I have a Hermitian matrix and want to minimize the diagonal terms while keeping the matrix positive semidefinite. Given a matrix S, \\text{minimi…

---

## [Making a collection of JuMP models using pmap](https://discourse.julialang.org/t/making-a-collection-of-jump-models-using-pmap/46530)

<div class="topic-metadata">

**Author:** [@adow031](https://discourse.julialang.org/u/adow031)\
**Replies:** 4\
**Last updated:** [September 13, 2020, 10:26pm UTC](https://discourse.julialang.org/t/making-a-collection-of-jump-models-using-pmap/46530 "2020-09-13T22:26:28Z")

</div>

I’m trying to create a number of JuMP models in parallel using pmap, and while the basic functionality of this is working fine, my implementation stores some variables and expressions in the ext field of the JuMP.Model. …

---

## [JuMP constraint MethodError: no method matching isless(::Int64, ::VariableRef)](https://discourse.julialang.org/t/jump-constraint-methoderror-no-method-matching-isless-int64-variableref/46498)

<div class="topic-metadata">

**Author:** [@valenmgama](https://discourse.julialang.org/u/valenmgama)\
**Replies:** 3\
**Last updated:** [September 12, 2020, 4:54pm UTC](https://discourse.julialang.org/t/jump-constraint-methoderror-no-method-matching-isless-int64-variableref/46498 "2020-09-12T16:54:47Z")

</div>

Hey, I need your help! What I am basically trying is to add a constraint to a JuMP matrix variable that no more than one element of a row can be a value larger than 0. In other words only 1 element in the row can be a …

---

## [How to get/set constraint names?](https://discourse.julialang.org/t/how-to-get-set-constraint-names/46411)

<div class="topic-metadata">

**Author:** [@vattyamv](https://discourse.julialang.org/u/vattyamv)\
**Replies:** 4\
**Last updated:** [September 11, 2020, 4:32pm UTC](https://discourse.julialang.org/t/how-to-get-set-constraint-names/46411 "2020-09-11T16:32:16Z")

</div>

Hi, I am trying to set and get constraint names but am running into some errors. I originally built the model without naming the constraints but now I want to name them. Take for example, for i in 1:timerange @const…

---

## [How to find the number of non-zeros weights needed to minimise the distance between a weighted sum and a population](https://discourse.julialang.org/t/how-to-find-the-number-of-non-zeros-weights-needed-to-minimise-the-distance-between-a-weighted-sum-and-a-population/46442)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 1\
**Last updated:** [September 11, 2020, 11:36am UTC](https://discourse.julialang.org/t/how-to-find-the-number-of-non-zeros-weights-needed-to-minimise-the-distance-between-a-weighted-sum-and-a-population/46442 "2020-09-11T11:36:35Z")

</div>

Hello, I need to use some individual elements (x\_n, in my application agricultural farms of which I know every details) as building blocks to reconstruct an observed aggregate V\_d \>=0 for the d dimensions (in my applica…

---

## [Package incompatibility](https://discourse.julialang.org/t/package-incompatibility/46420)

<div class="topic-metadata">

**Author:** [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Replies:** 8\
**Last updated:** [September 11, 2020, 2:13am UTC](https://discourse.julialang.org/t/package-incompatibility/46420 "2020-09-11T02:13:36Z")

</div>

I’m trying to find out what is holding back DataStructures package. Installed version is v0.17.20, latest version is 0.18.4. Attempting to explicitly add the latest version of DataStructures reveals a seemingly weird …

---

## [How to assign value to a matrix in an indicator constraint](https://discourse.julialang.org/t/how-to-assign-value-to-a-matrix-in-an-indicator-constraint/46314)

<div class="topic-metadata">

**Author:** [@sogrbilja](https://discourse.julialang.org/u/sogrbilja)\
**Replies:** 15\
**Last updated:** [September 10, 2020, 9:37am UTC](https://discourse.julialang.org/t/how-to-assign-value-to-a-matrix-in-an-indicator-constraint/46314 "2020-09-10T09:37:34Z")

</div>

Is it possible and how to assign values to POSITION\[R,C\] matrix in the indicator constraint @variable(premex, ROLNA\[R in keys(\_ROWS), C in keys(\_COLS), i\_k in keys(\_IMAGES\_ALL)\], Bin) @variable(premex, POSITION…

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

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