-
-
Notifications
You must be signed in to change notification settings - Fork 96
New output #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New output #113
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,31 +1,39 @@ | ||||||
abstract type AbstractOptimizationSolution end #experimental; comments welcome | ||||||
mutable struct OptimizationSolution{O, Tx, Tf, Tls, Tsb} <: AbstractOptimizationSolution | ||||||
method::O | ||||||
initial_x::Tx | ||||||
minimizer::Tx | ||||||
abstract type AbstractOptimizationSolution{T, N} <: AbstractNoTimeSolution{T, N} end | ||||||
|
||||||
struct OptimizationSolution{T, N, uType, P, A, Tf} <: AbstractOptimizationSolution{T, N} | ||||||
u::uType # minimizer | ||||||
prob::P # optimization problem | ||||||
alg::A # algorithm | ||||||
minimum::Tf | ||||||
iterations::Int | ||||||
iteration_converged::Bool | ||||||
ls_success::Tls | ||||||
time_run::Float64 | ||||||
stopped_by::Tsb | ||||||
initial_x::Array{Float64,1} | ||||||
retcode::Symbol | ||||||
original::String # original output of the optimizer | ||||||
end | ||||||
|
||||||
function Base.show(io::IO, r::AbstractOptimizationSolution) | ||||||
take = Iterators.take | ||||||
failure_string = "failure" | ||||||
if isa(r.ls_success, Bool) && !r.ls_success | ||||||
failure_string *= " (line search failed)" | ||||||
end | ||||||
function build_solution(prob::AbstractNonlinearProblem, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because this is not a PR to SciMLBase, you're just shadowing and this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot to upload the changed GalacticOptim.jl file where the build_solution is from SciMLBase. I edited it in two different places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
alg, u, minimum; | ||||||
initial_x = prob.u0, | ||||||
retcode = :Default, | ||||||
original = nothing, | ||||||
kwargs...) | ||||||
|
||||||
T = eltype(eltype(u)) | ||||||
N = ndims(u) | ||||||
|
||||||
OptimizationSolution{T, N, typeof(u), typeof(prob), typeof(alg), | ||||||
typeof(minimum)} | ||||||
(u, prob, alg, minimum, initial_x, | ||||||
retcode, original) | ||||||
end | ||||||
|
||||||
function Base.show(io::IO, A::AbstractNoTimeSolution) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
@printf io " * Status: %s\n\n" r.iteration_converged ? "success" : failure_string | ||||||
@printf io "\n * Status: %s\n\n" A.retcode === :Success ? "success" : "failure" | ||||||
@printf io " * Candidate solution\n" | ||||||
fmt = " Final objective value: %e "*repeat(", %e ",length(r.minimum)-1)*"\n" | ||||||
@eval @printf($io, $fmt, $r.minimum...) | ||||||
#@printf io " Final objective value: %e\n" r.minimum | ||||||
@printf io " Final objective value: %e\n" A.minimum | ||||||
@printf io "\n" | ||||||
@printf io " * Found with\n" | ||||||
@printf io " Algorithm: %s\n" r.method | ||||||
@printf io " Algorithm: %s\n" A.alg | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return | ||||||
end | ||||||
|
||||||
|
@@ -159,15 +167,7 @@ function __solve(prob::OptimizationProblem, opt, data = DEFAULT_DATA; | |||||
|
||||||
_time = time() | ||||||
|
||||||
OptimizationSolution(opt, | ||||||
prob.u0,# initial_x, | ||||||
θ, #pick_best_x(f_incr_pick, state), | ||||||
save_best ? first(min_err) : first(x), # pick_best_f(f_incr_pick, state, d), | ||||||
maxiters, #iteration, | ||||||
maxiters >= maxiters, #iteration == options.iterations, | ||||||
true, | ||||||
_time-t0, | ||||||
NamedTuple()) | ||||||
# here should be build_solution to create the output message | ||||||
end | ||||||
|
||||||
|
||||||
|
@@ -447,7 +447,7 @@ function __init__() | |||||
end | ||||||
|
||||||
_loss = function(θ) | ||||||
x = ntuple(i->first(prob.prob[i].f(θ, prob.prob[i].p, cur...)),length(prob.prob)) | ||||||
x = ntuple(i->first(prob.prob[i].f(θ, prob.prob[i].p, cur...)),length(prob.prob)) | ||||||
return x | ||||||
end | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the imports here