diff --git a/src/Stopping.jl b/src/Stopping.jl index dcf913c6..831982b9 100644 --- a/src/Stopping.jl +++ b/src/Stopping.jl @@ -131,15 +131,17 @@ AbstractStopping Abstract type, if specialized stopping were to be implemented they would need to be subtypes of AbstractStopping """ -abstract type AbstractStopping{Pb <: Any, - M <: AbstractStoppingMeta, - SRC <: AbstractStopRemoteControl, - T <: AbstractState, - LoS <: AbstractListStates} end - -struct VoidStopping{Pb, M, SRC, T, LoS} <: AbstractStopping{Pb, M, SRC, T, LoS} end +abstract type AbstractStopping{Pb <: Any, + M <: AbstractStoppingMeta, + SRC <: AbstractStopRemoteControl, + T <: AbstractState, + MStp <: Any, #AbstractStopping + LoS <: AbstractListStates, + Uss <: Any} end + +struct VoidStopping{Pb, M, SRC, T, MStp, LoS, Uss} <: AbstractStopping{Pb, M, SRC, T, MStp, LoS, Uss} end function VoidStopping() - return VoidStopping{Any, StoppingMeta, StopRemoteControl, GenericState, VoidListStates}() + return VoidStopping{Any, StoppingMeta, StopRemoteControl, GenericState, Nothing, VoidListStates, Nothing}() end export AbstractStopping, VoidStopping diff --git a/src/Stopping/GenericStoppingmod.jl b/src/Stopping/GenericStoppingmod.jl index 29b9918f..6794aff8 100644 --- a/src/Stopping/GenericStoppingmod.jl +++ b/src/Stopping/GenericStoppingmod.jl @@ -45,7 +45,7 @@ Examples: GenericStopping(pb, x0, rtol = 1e-1) """ -mutable struct GenericStopping{Pb, M, SRC, T, LoS} <: AbstractStopping{Pb, M, SRC, T, LoS} +mutable struct GenericStopping{Pb, M, SRC, T, MStp, LoS, Uss} <: AbstractStopping{Pb, M, SRC, T, MStp, LoS, Uss} # Problem pb :: Pb @@ -58,13 +58,13 @@ mutable struct GenericStopping{Pb, M, SRC, T, LoS} <: AbstractStopping{Pb, M, SR current_state :: T # Stopping of the main problem, or nothing - main_stp :: AbstractStopping + main_stp :: MStp # History of states listofstates :: LoS # User-specific structure - stopping_user_struct :: Any #this type should be parametric + stopping_user_struct :: Uss end @@ -133,7 +133,7 @@ function fill_in!(stp :: AbstractStopping, x :: T) where T end """ -update\\_and\\_start!: update the values in the State and initialize the Stopping. +update\\_and\\_start!: update values in the State and initialize the Stopping. Returns the optimality status of the problem as a boolean. `update_and_start!(:: AbstractStopping; kwargs...)` @@ -171,7 +171,7 @@ end Purpose is to know if there is a need to even perform an optimization algorithm or if we are at an optimal solution from the beginning. - Set `no_start_opt_check` to *true* to avoid checking optimality and domain errors. + Set `no_start_opt_check` to *true* avoid checking optimality and domain errors. The function `start!` successively calls: `_domain_check(stp, x)`, `_optimality_check(stp, x)`, `_null_test(stp, x)` and @@ -183,7 +183,9 @@ end - Keywords argument are passed to the `_optimality_check!` call. - Compatible with the `StopRemoteControl`. """ -function start!(stp :: AbstractStopping; no_start_opt_check :: Bool = false, kwargs...) +function start!(stp :: AbstractStopping; + no_start_opt_check :: Bool = false, + kwargs...) state = stp.current_state src = stp.stop_remote @@ -603,8 +605,8 @@ end `_optimality_check(:: AbstractStopping; kwargs...)` """ -function _optimality_check(stp :: AbstractStopping{Pb, M, SRC, T, LoS}; - kwargs...) where {Pb, M, SRC, T, LoS} +function _optimality_check(stp :: AbstractStopping{Pb, M, SRC, T, MStp, LoS, Uss}; + kwargs...) where {Pb, M, SRC, T, MStp, LoS, Uss} setfield!(stp.current_state, :current_score, stp.meta.optimality_check(stp.pb, stp.current_state; kwargs...)) diff --git a/src/Stopping/LineSearchStoppingmod.jl b/src/Stopping/LineSearchStoppingmod.jl index 38fd427c..d7c1a08b 100644 --- a/src/Stopping/LineSearchStoppingmod.jl +++ b/src/Stopping/LineSearchStoppingmod.jl @@ -34,7 +34,7 @@ Input : See also GenericStopping, NLPStopping, LSAtT """ -mutable struct LS_Stopping{Pb, M, SRC, LoS} <: AbstractStopping{Pb, M, SRC, LSAtT, LoS} +mutable struct LS_Stopping{Pb, M, SRC, MStp, LoS, Uss} <: AbstractStopping{Pb, M, SRC, LSAtT, MStp, LoS, Uss} # problem pb :: Pb @@ -46,13 +46,13 @@ mutable struct LS_Stopping{Pb, M, SRC, LoS} <: AbstractStopping{Pb, M, SRC, LSA current_state :: LSAtT # Stopping of the main problem, or nothing - main_stp :: AbstractStopping + main_stp :: MStp # History of states listofstates :: LoS # User-specific structure - stopping_user_struct :: Any + stopping_user_struct :: Uss end diff --git a/src/Stopping/LinearAlgebraStopping.jl b/src/Stopping/LinearAlgebraStopping.jl index 75351a3a..26d4f2fd 100644 --- a/src/Stopping/LinearAlgebraStopping.jl +++ b/src/Stopping/LinearAlgebraStopping.jl @@ -42,7 +42,7 @@ There is additional constructors: See also GenericStopping, NLPStopping, LS\\_Stopping, linear\\_system\\_check, normal\\_equation\\_check """ - mutable struct LAStopping{Pb, M, SRC, T, LoS} <: AbstractStopping{Pb, M, SRC, T, LoS} + mutable struct LAStopping{Pb, M, SRC, T, MStp, LoS, Uss} <: AbstractStopping{Pb, M, SRC, T, MStp, LoS, Uss} # problem pb :: Pb @@ -52,11 +52,11 @@ See also GenericStopping, NLPStopping, LS\\_Stopping, linear\\_system\\_check, n # current state of the problem current_state :: T # Stopping of the main problem, or nothing - main_stp :: AbstractStopping + main_stp :: MStp # History of states listofstates :: LoS # User-specific structure - stopping_user_struct :: Any + stopping_user_struct :: Uss #zero is initial point zero_start :: Bool diff --git a/src/Stopping/NLPStoppingmod.jl b/src/Stopping/NLPStoppingmod.jl index f16639a9..418a4c34 100644 --- a/src/Stopping/NLPStoppingmod.jl +++ b/src/Stopping/NLPStoppingmod.jl @@ -29,7 +29,7 @@ Attributes: Note: Kwargs are forwarded to the classical constructor. """ -mutable struct NLPStopping{Pb, M, SRC, T, LoS} <: AbstractStopping{Pb, M, SRC, T, LoS} +mutable struct NLPStopping{Pb, M, SRC, T, MStp, LoS, Uss} <: AbstractStopping{Pb, M, SRC, T, MStp, LoS, Uss} # problem pb :: Pb @@ -42,13 +42,13 @@ mutable struct NLPStopping{Pb, M, SRC, T, LoS} <: AbstractStopping{Pb, M, SRC, current_state :: T # Stopping of the main problem, or nothing - main_stp :: AbstractStopping + main_stp :: MStp # History of states listofstates :: LoS # User-specific structure - stopping_user_struct :: Any + stopping_user_struct :: Uss end diff --git a/stopping/Manifest.toml b/stopping/Manifest.toml index cc73feb8..f4c73531 100644 --- a/stopping/Manifest.toml +++ b/stopping/Manifest.toml @@ -1,5 +1,11 @@ # This file is machine-generated - editing it directly is not advised +[[Adapt]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "42c42f2221906892ceb765dbcb1a51deeffd86d7" +uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +version = "2.3.0" + [[Artifacts]] deps = ["Pkg"] git-tree-sha1 = "c30985d8821e0cd73870b17b0ed0ce6dc44cb744" @@ -90,6 +96,17 @@ version = "1.0.2" deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +[[ExprTools]] +git-tree-sha1 = "10407a39b87f29d47ebaca8edbc75d7c302ff93e" +uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" +version = "0.1.3" + +[[EzXML]] +deps = ["Printf", "XML2_jll"] +git-tree-sha1 = "0fa3b52a04a4e210aeb1626def9c90df3ae65268" +uuid = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" +version = "1.1.0" + [[FastClosures]] git-tree-sha1 = "acebe244d53ee1b461970f8910c235b259e772ef" uuid = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a" @@ -115,6 +132,12 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +[[Intervals]] +deps = ["Dates", "Printf", "RecipesBase", "Serialization", "TimeZones"] +git-tree-sha1 = "323a38ed1952d30586d0fe03412cde9399d3618b" +uuid = "d8418881-c3e1-53bb-8760-2df7ec849ed5" +version = "1.5.0" + [[InvertedIndices]] deps = ["Test"] git-tree-sha1 = "15732c475062348b0165684ffe28e85ea8396afc" @@ -144,6 +167,12 @@ uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +[[Libiconv_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "8e924324b2e9275a51407a4e06deb3455b1e359f" +uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" +version = "1.16.0+7" + [[LinearAlgebra]] deps = ["Libdl"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -176,6 +205,12 @@ version = "0.4.4" [[Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" +[[Mocking]] +deps = ["ExprTools"] +git-tree-sha1 = "916b850daad0d46b8c71f65f719c49957e9513ed" +uuid = "78c3b35d-d492-501b-9361-3d52fe80e533" +version = "0.7.1" + [[MuladdMacro]] git-tree-sha1 = "c6190f9a7fc5d9d5915ab29f2134421b12d24a68" uuid = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221" @@ -192,6 +227,12 @@ git-tree-sha1 = "bfe47e760d60b82b66b61d2d44128b62e3a369fb" uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" version = "0.3.5" +[[OffsetArrays]] +deps = ["Adapt"] +git-tree-sha1 = "b0cc1c42b63e30b759f4e1cf045ad8a51069d6cc" +uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +version = "1.4.2" + [[OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "9db77584158d0ab52307f8c04f8e7c08ca76b5b3" @@ -213,6 +254,12 @@ version = "1.0.15" deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +[[Polynomials]] +deps = ["Intervals", "LinearAlgebra", "OffsetArrays", "RecipesBase"] +git-tree-sha1 = "1c6c5b0c3713738d6b987903c529d80622c37e07" +uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" +version = "1.2.0" + [[PooledArrays]] deps = ["DataAPI"] git-tree-sha1 = "b1333d4eced1826e15adbdf01a4ecaccca9d353c" @@ -237,6 +284,11 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" deps = ["Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +[[RecipesBase]] +git-tree-sha1 = "b3fb709f3c97bfc6e948be68beeecb55a0b340ae" +uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" +version = "1.1.1" + [[Reexport]] deps = ["Pkg"] git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0" @@ -304,6 +356,12 @@ version = "1.2.2" deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +[[TimeZones]] +deps = ["Dates", "EzXML", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"] +git-tree-sha1 = "4ba8a9579a243400db412b50300cd61d7447e583" +uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" +version = "1.5.3" + [[TimerOutputs]] deps = ["Printf"] git-tree-sha1 = "3318281dd4121ecf9713ce1383b9ace7d7476fdd" @@ -316,3 +374,15 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [[Unicode]] uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" + +[[XML2_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"] +git-tree-sha1 = "be0db24f70aae7e2b89f2f3092e93b8606d659a6" +uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" +version = "2.9.10+3" + +[[Zlib_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "320228915c8debb12cb434c59057290f0834dbf6" +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.11+18" diff --git a/stopping/Project.toml b/stopping/Project.toml index cbdfb4f1..ad5d37eb 100644 --- a/stopping/Project.toml +++ b/stopping/Project.toml @@ -3,6 +3,7 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125" NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6" +Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"