Skip to content

Commit

Permalink
add state doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tmigot committed Jan 26, 2021
1 parent c172e58 commit 9997f43
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
13 changes: 8 additions & 5 deletions src/State/GenericStatemod.jl
Expand Up @@ -32,12 +32,16 @@ Constructors:
`GenericState(:: T; d :: T = _init_field(T), res :: T = _init_field(T), current_time :: Float64 = NaN, current_score :: Union{T,eltype(T)} = _init_field(eltype(T))) where T <:AbstractVector`
Note: By default, unknown entries are set using *\\_init\\_field*.
Note:
- By default, unknown entries are set using `_init_field`.
- By default the type of `current_score` is `eltype(x)` and cannot be changed once the State is created.
To have a vectorized `current_score` of length n, try something like `GenericState(x, Array{eltype(x),1}(undef, n))`.
Examples:
GenericState(x)
GenericState(x, current\\_time = 1.0)
GenericState(x, current\\_score = 1.0)
GenericState(x)
GenericState(x, Array{eltype(x),1}(undef, length(x)))
GenericState(x, current\\_time = 1.0)
GenericState(x, current\\_score = 1.0)
See also: Stopping, NLPAtX
"""
Expand Down Expand Up @@ -103,7 +107,6 @@ function update!(stateatx :: T;
fnames = fieldnames(T)
for k keys(kwargs)
#check if k is in fieldnames and type compatibility
#two calls to getfield...
if (k fnames) && typeof(kwargs[k]) <: typeof(getfield(stateatx, k))
setfield!(stateatx, k, kwargs[k])
end
Expand Down
5 changes: 4 additions & 1 deletion src/State/LSAtTmod.jl
Expand Up @@ -21,7 +21,10 @@ Constructors:
`LSAtT(:: T; ht :: T = _init_field(T), gt :: T = _init_field(T), h₀ :: T = _init_field(T), g₀ :: T = _init_field(T), current_time :: Float64 = NaN, current_score :: T = _init_field(T)) where T <: Number`
Note: By default, unknown entries are set using *_init_field*.
Note:
- By default, unknown entries are set using `_init_field`.
- By default the type of `current_score` is `eltype(x)` and cannot be changed once the State is created.
To have a vectorized `current_score` of length n, try something like `GenericState(x, Array{eltype(x),1}(undef, n))`.
"""
mutable struct LSAtT{S, T <: Number} <: AbstractState{S, T}

Expand Down
16 changes: 9 additions & 7 deletions src/State/NLPAtXmod.jl
Expand Up @@ -36,13 +36,15 @@ Constructors:
`NLPAtX(:: T, :: T; fx :: eltype(T) = _init_field(eltype(T)), gx :: T = _init_field(T), Hx :: Matrix{eltype(T)} = _init_field(Matrix{eltype(T)}), mu :: T = _init_field(T), cx :: T = _init_field(T), Jx :: Matrix{eltype(T)} = _init_field(Matrix{eltype(T)}), d :: T = _init_field(T), res :: T = _init_field(T), current_time :: Float64 = NaN, current_score :: Union{T,eltype(T)} = _init_field(eltype(T)), evals :: Counters = Counters()) where T <: AbstractVector`
Note:
- By default, unknown entries are set using *\\_init\\_field* (except evals).
- All these information (except for *x* and *lambda*) are optionnal and need to be update when
required. The update is done through the update! function.
- *x* and *lambda* are mandatory entries. If no constraints `lambda = []`.
- The constructor check the size of the entries.
See also: GenericState, update!, update\\_and\\_start!, update\\_and\\_stop!, reinit!
- By default, unknown entries are set using `_init_field` (except evals).
- By default the type of `current_score` is `eltype(x)` and cannot be changed once the State is created.
To have a vectorized `current_score` of length n, try something like `GenericState(x, Array{eltype(x),1}(undef, n))`.
- All these information (except for `x` and `lambda`) are optionnal and need to be update when
required. The update is done through the `update!` function.
- `x` and `lambda` are mandatory entries. If no constraints `lambda = []`.
- The constructor check the size of the entries.
See also: `GenericState`, `update!`, `update_and_start!`, `update_and_stop!`, `reinit!`
"""
mutable struct NLPAtX{S, T <: AbstractVector,
MT <: AbstractMatrix} <: AbstractState{S, T}
Expand Down

0 comments on commit 9997f43

Please sign in to comment.