Skip to content

Instantly share code, notes, and snippets.

@pkofod
Created February 12, 2019 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkofod/6c95db7a9f87e7ec412afe5662982c80 to your computer and use it in GitHub Desktop.
Save pkofod/6c95db7a9f87e7ec412afe5662982c80 to your computer and use it in GitHub Desktop.
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.0.2 (2018-11-08)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using Optim
julia> function rosenbrock(x::Vector)
return (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
end
rosenbrock (generic function with 1 method)
julia> optimize(rosenbrock, fill(-1.0,2), fill(1.0, 2), rand(2), Fminbox(GradientDescent()))
Results of Optimization Algorithm
* Algorithm: Fminbox with Gradient Descent
* Starting Point: [0.48326410702842115,0.4690378993320623]
* Minimizer: [0.9999999839553474,0.9999999678607662]
* Minimum: 2.576802e-16
* Iterations: 21
* Convergence: true
* |x - x'| ≤ 0.0e+00: false
|x - x'| = 2.06e-08
* |f(x) - f(x')| ≤ 0.0e+00 |f(x)|: false
|f(x) - f(x')| = 1.48e+00 |f(x)|
* |g(x)| ≤ 1.0e-08: true
|g(x)| = 9.99e-09
* Stopped by an increasing objective: false
* Reached Maximum Number of Iterations: false
* Objective Calls: 577760
* Gradient Calls: 577760
julia> optimize(rosenbrock, fill(-1.0,2), fill(1.0, 2), rand(2), Fminbox(BFGS()))
Results of Optimization Algorithm
* Algorithm: Fminbox with BFGS
* Starting Point: [0.5506698212274612,0.8757619596191757]
* Minimizer: [0.9999999896473769,0.9999999792757609]
* Minimum: 1.072129e-16
* Iterations: 6
* Convergence: true
* |x - x'| ≤ 0.0e+00: false
|x - x'| = 3.10e-07
* |f(x) - f(x')| ≤ 0.0e+00 |f(x)|: false
|f(x) - f(x')| = 2.05e+02 |f(x)|
* |g(x)| ≤ 1.0e-08: true
|g(x)| = 3.80e-09
* Stopped by an increasing objective: false
* Reached Maximum Number of Iterations: false
* Objective Calls: 536
* Gradient Calls: 536
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment