Stopping

A framework to implement iterative algorithms

https://github.com/solverstoppingjulia/stopping.jl

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.8%) to scientific vocabulary

Keywords

optimization-algorithms optimization-framework

Keywords from Contributors

nlpmodels nonlinear-programming ipopt hsl sparse-matrix krylov pdes jso mathematical-optimization mathematical-programming
Last synced: 6 months ago · JSON representation ·

Repository

A framework to implement iterative algorithms

Basic Info
  • Host: GitHub
  • Owner: SolverStoppingJulia
  • License: other
  • Language: Julia
  • Default Branch: master
  • Homepage:
  • Size: 4.88 MB
Statistics
  • Stars: 12
  • Watchers: 2
  • Forks: 3
  • Open Issues: 14
  • Releases: 26
Topics
optimization-algorithms optimization-framework
Created almost 9 years ago · Last pushed 6 months ago
Metadata Files
Readme License Citation

README.md

Stopping

CI Coverage Status codecov Stable Dev DOI

How to Cite

If you use Stopping.jl in your work, please cite using the format given in CITATION.bib.

Purpose

Tools to ease the uniformization of stopping criteria in iterative solvers.

When a solver is called on an optimization model, four outcomes may happen:

  1. the approximate solution is obtained, the problem is considered solved
  2. the problem is declared unsolvable (unboundedness, infeasibility ...)
  3. the maximum available resources are not sufficient to compute the solution
  4. some algorithm dependent failure happens

This tool eases the first three items above. It defines a type

mutable struct GenericStopping <: AbstractStopping
    problem              :: Any                  # an arbitrary instance of a problem
    meta                 :: AbstractStoppingMeta # contains the used parameters and stopping status
    current_state        :: AbstractState        # Current information on the problem
    main_stp             :: Union{AbstractStopping, Nothing} # Stopping of the main problem, or nothing
    listofstates         :: Union{ListStates, Nothing} # History of states
    user_specific_struct :: Dict                  # User-specific structure

The StoppingMeta provides default tolerances, maximum resources, ... as well as (boolean) information on the result.

Your Stopping your way

The GenericStopping (with GenericState) provides a complete structure to handle stopping criteria. Then, depending on the problem structure, you can specialize a new Stopping by redefining a State and some functions specific to your problem.

We provide some specialization of the GenericStopping for optimization: * NLPStopping with NLPAtX as a specialized State for non-linear programming (based on NLPModels), or with OneDAtX as a specialized State for 1d optimization; * LAStopping with GenericState: for linear algebra problems.

Functions

The tool provides two main functions: * start!(stp :: AbstractStopping) initializes the time and the tolerance at the starting point and check wether the initial guess is optimal. * stop!(stp :: AbstractStopping) checks optimality of the current guess as well as failure of the system (unboundedness for instance) and maximum resources (number of evaluations of functions, elapsed time ...)

Stopping uses the informations furnished by the State to evaluate its functions. Communication between the two can be done through the following functions: * update_and_start!(stp :: AbstractStopping; kwargs...) updates the states with informations furnished as kwargs and then call start!. * update_and_stop!(stp :: AbstractStopping; kwargs...) updates the states with informations furnished as kwargs and then call stop!. * fill_in!(stp :: AbstractStopping, x :: Iterate) a function that fill in all the State with all the informations required to correctly evaluate the stopping functions. This can reveal useful, for instance, if the user do not trust the informations furnished by the algorithm in the State. * reinit!(stp :: AbstractStopping) reinitialize the entries of the Stopping to reuse for another call.

Consult the HowTo tutorial to learn more about the possibilities offered by Stopping.

You can also access other examples of algorithms in the test/examples folder, which for instance illustrate the strenght of Stopping with subproblems: * Consult the OptimSolver tutorial for more on how to use Stopping with nested algorithms. * Check the Benchmark tutorial to see how Stopping can combined with SolverBenchmark.jl. * Stopping can be adapted to closed solvers via a buffer function as in Buffer tutorial for an instance with Ipopt via NLPModelsIpopt. * Consult the WarmStart to use Stopping in a warm-start context using internal user-defined structure and the list of states.

How to install

Install and test the Stopping package with the Julia package manager: julia pkg> add Stopping pkg> test Stopping You can access the most up-to-date version of the Stopping package using: julia pkg> add https://github.com/SolverStoppingJulia/Stopping.jl pkg> test Stopping pkg> status Stopping

Example

using NLPModels, Stopping #import the packages nlp = ADNLPModel(x -> sum(x), ones(2)) #initialize an NLPModel with automatic differentiation We now initialize the NLPStopping. nlp_at_x = NLPAtX(ones(5)) #First create a State. We use unconstrained_check as an optimality function stop_nlp = NLPStopping(nlp, nlp_at_x, optimality_check = unconstrained_check) The following algorithm shows the most basic features of Stopping. It does many checks for you. In this innocent-looking algorithm, the call to update_and_start! and update_and_stop! will verifies unboundedness of x, the time spent in the algorithm, the number of iterations (= number of call to stop!), and the domain of x (in case some of its components become NaN for instance). ```julia function rand_solver(stp :: AbstractStopping, x0 :: AbstractVector)

x = x0
#First, call start! to check optimality and set an initial configuration
OK = update_and_start!(stp, x = x)

while !OK
    #Run some computations and update the iterate
    d = rand(length(x))
    x += d

    #Update the State and call the Stopping with stop!
    OK = update_and_stop!(stp, x = x, d = d)
end

return stp

end Finally, we can call the algorithm with our Stopping: stopnlp = randsolver(stopnlp, ) and consult it to know what happened status(stopnlp, list = true) printstyled("Final solution is $(stopnlp.currentstate.x)", color = :green) ``` We reached optimality, and thanks to the Stopping structure this simple looking algorithm verified at each step of the algorithm: - time limit has been respected; - evaluations of the problem are not excessive; - the problem is not unbounded (w.r.t. x and f(x)); - there is no NaN in x, f(x), g(x), H(x); - the maximum number of iteration (call to stop!) is limited.

Long-Term Goals

Stopping is aimed as a tool for improving the reusability and robustness in the implementation of iterative algorithms. We warmly welcome any feedback or comment leading to potential improvements.

Future work will address more sophisticated problems such as mixed-integer optimization problems, optimization with uncertainty. The list of suggested optimality functions will be enriched with state of the art conditions.

Citation (CITATION.bib)

@Misc{migot-dussault-stopping-2021,
  author       = {Migot, T. and
                  Dussault, J.-P.},
  title        = {{Stopping.jl} -- A framework to implement iterative algorithms},
  month        = {June},
  year         = {2022},
  doi          = {10.5281/zenodo.6705082},
  howpublished = {\url{https://doi.org/10.5281/zenodo.6705082}}
}

GitHub Events

Total
  • Create event: 3
  • Commit comment event: 3
  • Issues event: 2
  • Delete event: 2
  • Issue comment event: 1
  • Push event: 11
  • Pull request event: 2
Last Year
  • Create event: 3
  • Commit comment event: 3
  • Issues event: 2
  • Delete event: 2
  • Issue comment event: 1
  • Push event: 11
  • Pull request event: 2

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 395
  • Total Committers: 6
  • Avg Commits per committer: 65.833
  • Development Distribution Score (DDS): 0.215
Top Committers
Name Email Commits
tmigot t****t@g****m 310
Goysa2 s****e@u****a 56
tmigot t****t@u****m 11
JPD v****i@g****m 9
github-actions[bot] 4****]@u****m 8
CompatHelper Julia c****y@j****g 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 24
  • Total pull requests: 79
  • Average time to close issues: 17 days
  • Average time to close pull requests: 1 day
  • Total issue authors: 2
  • Total pull request authors: 2
  • Average comments per issue: 0.21
  • Average comments per pull request: 0.04
  • Merged pull requests: 73
  • Bot issues: 0
  • Bot pull requests: 25
Past Year
  • Issues: 1
  • Pull requests: 4
  • Average time to close issues: about 15 hours
  • Average time to close pull requests: 10 minutes
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • tmigot (23)
  • amontoison (1)
Pull Request Authors
  • tmigot (55)
  • github-actions[bot] (26)
Top Labels
Issue Labels
bug (4) docs (3) enhancement (3)
Pull Request Labels
formatting (22) automated pr (22) no changelog (22) bug (1)

Packages

  • Total packages: 1
  • Total downloads:
    • julia 1 total
  • Total dependent packages: 4
  • Total dependent repositories: 1
  • Total versions: 27
juliahub.com: Stopping

A framework to implement iterative algorithms

  • Versions: 27
  • Dependent Packages: 4
  • Dependent Repositories: 1
  • Downloads: 1 Total
Rankings
Dependent repos count: 7.7%
Dependent packages count: 13.5%
Average: 19.9%
Forks count: 27.2%
Stargazers count: 31.0%
Last synced: 6 months ago

Dependencies

.github/workflows/CompatHelper.yml actions
  • julia-actions/setup-julia latest composite
.github/workflows/Documentation.yml actions
  • actions/checkout v2 composite
  • julia-actions/setup-julia latest composite
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
.github/workflows/ci.yml actions
  • actions/cache v1 composite
  • actions/checkout v2 composite
  • codecov/codecov-action v1 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-processcoverage v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite
.github/workflows/format_pr.yml actions
  • actions/checkout v2 composite
  • peter-evans/create-pull-request v3 composite