# SAMIN Example in Optim.jl not working

**URL:** <https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187>\
**Category:** Optimization (Mathematical)\
**Created:** [April 5, 2018, 10:44pm UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187 "2018-04-05T22:44:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [April 5, 2018, 10:44pm UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187/1 "2018-04-05T22:44:49Z")

</div>

From [Simulated Annealing w/ bounds - Optim.jl](http://julianlsolvers.github.io/Optim.jl/latest/algo/samin/)

```julia
julia> using Optim, OptimTestProblems

julia> prob = OptimTestProblems.UnconstrainedProblems.examples["Rosenbrock"];

julia> res = Optim.optimize(prob.f, prob.initial_x,
               fill(-100.0, 2), fill(100.0, 2), SAMIN(), Optim.Options(iterations=20000))
ERROR: UndefVarError: SAMIN not defined

```

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [April 5, 2018, 11:42pm UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187/2 "2018-04-05T23:42:25Z")

</div>

This works on my machine. Can you update and see if this is still a problem?

---

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [April 5, 2018, 11:56pm UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187/3 "2018-04-05T23:56:29Z")

</div>

still a problem here even after a Pkg.update(). what version are you using? anything defined in your startup?

ipro@~/bitcookbook:0:525\> julia

```julia
  | | |_| | | | (_| | | Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\ __'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-apple-darwin14.5.0

julia> using Optim, OptimTestProblems

julia> prob = OptimTestProblems.UnconstrainedProblems.examples["Rosenbrock"];

julia> res = Optim.optimize(prob.f, prob.initial_x,
                      fill(-100.0, 2), fill(100.0, 2), SAMIN(), Optim.Options(iterations=20000))
ERROR: UndefVarError: SAMIN not defined

julia> Pkg.status.(["Optim", "OptimTestProblems"]);
 - Optim 0.14.1
 - OptimTestProblems 1.2.0

```

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [April 5, 2018, 11:58pm UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187/4 "2018-04-05T23:58:22Z")

</div>

I will double check, I am using a modified `0.12.0`.

Edit: this was actually modified master.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [April 6, 2018, 12:10am UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187/5 "2018-04-06T00:10:02Z")

</div>

Ok I can reproduce. If you checkout master, it works. Run `Pkg.checkout("Optim")`. You can also open an issue on Github.

Edit: I see now, the algorithm was implemented at a later stage after `v0.14.0` so you can either wait for the next tag or checkout master. You are looking at the latest docs but these reflect what’s happening on master not the last tag. For that, you need the stable docs [Optim.jl](http://julianlsolvers.github.io/Optim.jl/stable/).

---

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [April 6, 2018, 2:54am UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187/6 "2018-04-06T02:54:57Z")

</div>

thank you, m. this solved my problem. I understand that master will soon replace the standard branch anyway, so presumably this will fix itself soon. so its probably only annoying to ping the folks who are in charge.

regards,

/iaw

---

<div class="post-metadata">

**Author:** ![anriseth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anriseth/32/3106_2.png) [@anriseth](https://discourse.julialang.org/u/anriseth)\
**Post date:** [April 6, 2018, 8:35am UTC](https://discourse.julialang.org/t/samin-example-in-optim-jl-not-working/10187/7 "2018-04-06T08:35:53Z")

</div>

`SAMIN` is a very recent algorithm introduced in Optim, so if you have some feedback related to it (and anything else in Optim), you can [create an issue on Github](https://github.com/JuliaNLSolvers/Optim.jl/issues) (or ask here on discourse, or ask on gitter 😉 )

> [@iwelch](#):
>
> From [Simulated Annealing w/ bounds - Optim.jl](http://julianlsolvers.github.io/Optim.jl/latest/algo/samin/)

This is a bit subtle, but the documentation you are looking at is the “latest”, which corresponds to the latest `master` branch. The [stable](http://julianlsolvers.github.io/Optim.jl/stable/) documentation is valid for the most recent release.
