Skip to content

Commit 6e05383

Browse files
authored
Merge pull request #14 from djpasseyjr/icmap
activ_f
2 parents 9edbd0f + d767461 commit 6e05383

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

rescomp/ResComp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,10 @@ def initial_condition(self, u0):
231231
This typically conincided with the fixed point above but unlike the nonlinear solver, this method
232232
always converged.
233233
"activ_f"
234-
This sets the reservoir initial condition to r0 = activ_f(W_in @ u0). Incidentally, should send
234+
This sets the reservoir initial condition to r0 = activ_f(sigma * W_in @ u0). Incidentally, should send
235235
the reservoir initial condition close to the attracting fixed points of the system
236+
"activ_f_unscaled"
237+
This sets the reservoir initial condition to r0 = activ_f(sigma * W_in @ u0). Included for legacy reasons.
236238
"pseudoinverse"
237239
Only for use after training. This uses the pseudoinverse of W_out to compute the initial node
238240
state from an inital condition from the learned system
@@ -255,6 +257,8 @@ def initial_condition(self, u0):
255257
if err > 1e-12:
256258
warn(f"Reservoir fixed point failed to converge. ||r_n - r_(n+1)|| = {err}")
257259
elif self.map_initial == "activ_f":
260+
r0 = self.activ_f(self.W_in @ (self.sigma * u0))
261+
elif self.map_initial == "activ_f_unscaled":
258262
r0 = self.activ_f(self.W_in @ u0)
259263
elif self.map_initial == "pseudoinverse":
260264
if not self.is_trained:

rescomp/optimizer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
from .optimizer_controller import ResCompOptimizer
99
from .optimizer_functions import *
10-
from .optimizer_systems import get_res_defaults, load_from_file, loadprior, get_system
10+
from .optimizer_systems import get_res_defaults, load_from_file, loadprior, get_system, ChaosODESystem, SoftRobotSystem
1111
from .templates import random_slice, System

rescomp/optimizer/optimizer_systems.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,15 @@ def _clean_prior(prior):
117117
# Predefined systems
118118
#####################
119119

120-
def get_system(system_name):
120+
def get_system(system_name, **kwargs):
121121
"""
122122
Gets the system with the given name.
123123
If system_name is one of 'lorenz', 'thomas', 'rossler', or 'softrobot', uses the predefined system object.
124124
Otherwise, attempts to load a file.
125125
126+
For 'lorenz', 'thomas', 'rossler', and 'softrobot', the train_time, test_time, and dt parameters can be
127+
specified as keyword arguments.
128+
126129
Returns a rescomp.optimizer.System object
127130
"""
128131

@@ -131,12 +134,23 @@ def get_system(system_name):
131134
# -test time
132135
# -dt
133136
if system_name == 'lorenz':
134-
return ChaosODESystem('lorenz', 6.6, 8, 0.01)
137+
params = {'train_time':6.6, 'test_time':8., 'dt':0.01}
138+
params = {**params, **kwargs}
139+
return ChaosODESystem('lorenz', **params)
140+
135141
elif system_name == 'rossler':
136-
return ChaosODESystem('rossler', 165, 120, 0.01)
142+
params = {'train_time':165, 'test_time':120, 'dt':0.01}
143+
params = {**params, **kwargs}
144+
return ChaosODESystem('rossler', **params)
145+
137146
elif system_name == 'thomas':
138-
return ChaosODESystem('thomas', 660, 360, 0.1)
147+
params = {'train_time':660, 'test_time':360, 'dt':0.1}
148+
params = {**params, **kwargs}
149+
return ChaosODESystem('thomas', **params)
150+
139151
elif system_name == 'softrobot':
152+
params = {'train_time':165, 'test_time':80, 'dt':0.01}
153+
params = {**params, **kwargs}
140154
return SoftRobotSystem(165, 80, 0.01)
141155
else:
142156
try:

0 commit comments

Comments
 (0)