Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
reykboerner committed Feb 21, 2024
2 parents acf9918 + a5057e6 commit aad5169
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Developers: Reyk Börner, Ryan Deeley and Raphael Römer

Thanks to Jeroen Wouters, Calvin Nesbitt, Tobias Grafke, George Datseris and Oliver Mehling

This work is part of the [CriticalEarth](https://criticalearth.eu) project.
This work is part of the [CriticalEarth](https://criticalearth.eu) project.
14 changes: 7 additions & 7 deletions src/largedeviations/min_action_method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To set an initial path different from a straight line, see the multiple dispatch
The minimization can be performed in blocks to save intermediate results.
## Keyword arguments
* `functional = "FW"`: type of action functional to minimize.
* `functional = "FW"`: type of action functional to minimize.
Defaults to [`fw_action`](@ref), alternative: [`om_action`](@ref).
* `maxiter = 100`: maximum number of iterations before the algorithm stops.
* `blocks = 1`: number of iterative optimization blocks
Expand All @@ -39,7 +39,7 @@ function min_action_method(sys::StochSystem, x_i::State, x_f::State, N::Int, T::
showprogress = false,
verbose = true,
kwargs...)

init = reduce(hcat, range(x_i, x_f, length=N))
min_action_method(sys::StochSystem, init, T;
functional=functional, maxiter=maxiter, blocks=blocks, method=method,
Expand Down Expand Up @@ -68,23 +68,23 @@ function min_action_method(sys::StochSystem, init::Matrix, T::Real;
showprogress = false,
verbose = true,
kwargs...)

println("=== Initializing MAM action minimizer ===")

A = inv(sys.Σ)
f(x) = action(sys, fix_ends(x, init[:,1], init[:,end]),
range(0.0, T, length=size(init, 2)), functional; cov_inv=A)

result = Vector{Optim.OptimizationResults}(undef, blocks)
result[1] = Optim.optimize(f, init, method,
Optim.Options(iterations=Int(ceil(maxiter/blocks)), kwargs...))
verbose ? println(result[1]) : nothing

if blocks > 1
iterator = showprogress ? tqdm(2:blocks) : 2:blocks
for m in iterator
result[m] = Optim.optimize(f, result[m-1].minimizer, method,
Optim.Options(Int(ceil(maxiter/blocks)), kwargs...))
Optim.Options(iterations=Int(ceil(maxiter/blocks)), kwargs...))
verbose ? println(result[m]) : nothing
end
save_info ? (return result) : return [Optim.minimizer(result[i]) for i=1:blocks]
Expand All @@ -102,4 +102,4 @@ function fix_ends(x::Matrix, x_i::State, x_f::State)
m = x
m[:,1] = x_i; m[:,end] = x_f
m
end;
end;

0 comments on commit aad5169

Please sign in to comment.