Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/api/states.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
NLAT2
NLAT3
PartialSquare
ExtendedSquare
```

## Internals
Expand Down
2 changes: 1 addition & 1 deletion src/ReservoirComputing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ include("esn/esn_predict.jl")
include("reca/reca.jl")
include("reca/reca_input_encodings.jl")

export NLADefault, NLAT1, NLAT2, NLAT3, PartialSquare
export NLADefault, NLAT1, NLAT2, NLAT3, PartialSquare, ExtendedSquare
export StandardStates, ExtendedStates, PaddedStates, PaddedExtendedStates
export StandardRidge
export scaled_rand, weighted_init, informed_init, minimal_init, chebyshev_mapping,
Expand Down
68 changes: 68 additions & 0 deletions src/states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,71 @@ function (ps::PartialSquare)(x_old::AbstractVector)

return x_new
end

@doc raw"""

ExtendedSquare()

Extension of the Lu initialization proposed in [^herteux2020].
The state vector is extended with the squared elements of the initial
state

# Equations

```math
\begin{equation}
\vec{x} = \{x_1, x_2, \dots, x_N, x_1^2, x_2^2, \dots, x_N^2\}
\end{equation}
```

# Examples

```jldoctest
julia> x_old = [1, 2, 3, 4, 5, 6, 7, 8, 9]
9-element Vector{Int64}:
1
2
3
4
5
6
7
8
9

julia> es = ExtendedSquare()
ExtendedSquare()

julia> x_new = es(x_old)
18-element Vector{Int64}:
1
2
3
4
5
6
7
8
9
1
4
9
16
25
36
49
64
81

```

[^herteux2020]: Herteux, Joschka, and Christoph Räth.
"Breaking symmetries of the reservoir equations in echo state networks."
Chaos: An Interdisciplinary Journal of Nonlinear Science 30.12 (2020).
"""
struct ExtendedSquare <: NonLinearAlgorithm end

function (::ExtendedSquare)(x_old::AbstractVector)
x_new = copy(x_old)
return vcat(x_new, x_new .^ 2)
end
3 changes: 2 additions & 1 deletion test/test_states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ nlas = [(NLADefault(), test_array),
(NLAT1(), [1, 2, 9, 4, 25, 6, 49, 8, 81]),
(NLAT2(), [1, 2, 2, 4, 12, 6, 30, 8, 9]),
(NLAT3(), [1, 2, 8, 4, 24, 6, 48, 8, 9]),
(PartialSquare(0.6), [1, 4, 9, 16, 25, 6, 7, 8, 9])]
(PartialSquare(0.6), [1, 4, 9, 16, 25, 6, 7, 8, 9]),
(ExtendedSquare(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 4, 9, 16, 25, 36, 49, 64, 81])]

pes = [(StandardStates(), test_array),
(PaddedStates(; padding=padding),
Expand Down
Loading