# Gurobi with StochasticPrograms.jl

**URL:** <https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139>\
**Category:** Optimization (Mathematical)\
**Tags:** question, package\
**Created:** [April 12, 2021, 11:24pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139 "2021-04-12T23:24:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![arfuentes97](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arfuentes97](https://discourse.julialang.org/u/arfuentes97)\
**Post date:** [April 12, 2021, 11:24pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/1 "2021-04-12T23:24:58Z")

</div>

Hi there,

I’m trying to use Gurobi solver to optimize the farmer problem proposed in StochasticPrograms.jl and I get the following error message:

ERROR: MethodError: no method matching all\_decisions(::DeterministicEquivalent{2,1,Tuple{Array{Scenario{JuMP.Containers.DenseAxisArray{Float64,1,Tuple{Array{Symbol,1}},Tuple{JuMP.Containers.\_AxisLookup{Dict{Symbol,Int64}}}}},1}}})

When I try to solve it with GLPK it works fine.

Anyone knows what’s happpening or if it’s possible to use Gurobi with StochasticPrograms?

Thanks!

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [April 13, 2021, 12:13am UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/2 "2021-04-13T00:13:36Z")

</div>

Welcome!

Take a read of [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757). It’s easier to help if you provide a minimal working example.

Are you sure changing the solver to Gurobi is the problem? That error doesn’t look like it has anything to do with GLPK or Gurobi?

---

<div class="post-metadata">

**Author:** ![arfuentes97](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arfuentes97](https://discourse.julialang.org/u/arfuentes97)\
**Post date:** [April 13, 2021, 4:43pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/3 "2021-04-13T16:43:26Z")

</div>

Thanks for the fast response,

I’m using exactly the same code that’s provided in the [examples](https://martinbiel.github.io/StochasticPrograms.jl/stable/manual/examples/) of StochasticPrograms.jl

When I change the line

```
farmer = instantiate(farmer_model, [ξ₁,ξ₂,ξ₃], optimizer = GLPK.Optimizer) 

```

to  
farmer = instantiate(farmer\_model, [ξ₁,ξ₂,ξ₃], optimizer = Gurobi.Optimizer)

(and add using Gurobi on the top of the code)

then it shows the error message that I posted above.

That’s why I’m guessing that changing the solver is the problem, maybe I’m wrong

Thanks!

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [April 13, 2021, 8:16pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/4 "2021-04-13T20:16:44Z")

</div>

@martinbiel any ideas?

---

<div class="post-metadata">

**Author:** ![martinbiel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martinbiel/32/17661_2.png) [@martinbiel](https://discourse.julialang.org/u/martinbiel)\
**Post date:** [April 14, 2021, 12:19pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/5 "2021-04-14T12:19:21Z")

</div>

I recognize this from a while back: [https://github.com/martinbiel/StochasticPrograms.jl/commit/6285c23c2e2566d838ef56698d54c2ce364f77f3](https://github.com/martinbiel/StochasticPrograms.jl/commit/6285c23c2e2566d838ef56698d54c2ce364f77f3). I believe this is sorted on master. Until I push a new release, `add StochasticPrograms#master` should solve it temporarily 🙂

---

<div class="post-metadata">

**Author:** ![arfuentes97](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arfuentes97](https://discourse.julialang.org/u/arfuentes97)\
**Post date:** [April 14, 2021, 4:16pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/6 "2021-04-14T16:16:26Z")

</div>

Thanks @martinbiel,

I’m sorry but I’m new to Julia, how do I add StochasticPrograms#master to solve the problem?

---

<div class="post-metadata">

**Author:** ![arfuentes97](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arfuentes97](https://discourse.julialang.org/u/arfuentes97)\
**Post date:** [April 14, 2021, 4:30pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/7 "2021-04-14T16:30:50Z")

</div>

Nevermind, I figured out how to do it!

Thank you very much!

---

<div class="post-metadata">

**Author:** ![martinbiel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martinbiel/32/17661_2.png) [@martinbiel](https://discourse.julialang.org/u/martinbiel)\
**Post date:** [April 14, 2021, 4:31pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/8 "2021-04-14T16:31:11Z")

</div>

No problem. Good luck! 🙂

---

<div class="post-metadata">

**Author:** ![arfuentes97](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@arfuentes97](https://discourse.julialang.org/u/arfuentes97)\
**Post date:** [April 14, 2021, 4:31pm UTC](https://discourse.julialang.org/t/gurobi-with-stochasticprograms-jl/59139/9 "2021-04-14T16:31:35Z")

</div>

Thanks,

it worked by the way!
