caching
get_solver_cache_paths(symbolic_problem: SymbolicProblem, dt: float, total_time: float, cache_dir: Optional[Path] = None) -> Tuple[Path, Path]
¶
Generate cache file paths using symbolic AST hashing.
This function computes a hash based on the symbolic structure of the problem, which is more stable than hashing lowered JAX code. Two problems with the same mathematical structure will produce the same hash, regardless of variable names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbolic_problem
|
SymbolicProblem
|
The preprocessed SymbolicProblem |
required |
dt
|
float
|
Time step for propagation |
required |
total_time
|
float
|
Total simulation time |
required |
cache_dir
|
Optional[Path]
|
Directory to store cached solvers. If None, uses the default
cache directory (see :func: |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[Path, Path]
|
Tuple of (discretization_solver_path, propagation_solver_path) |
Source code in openscvx/utils/caching.py
load_or_compile_discretization_solver(discretization_solver: callable, cache_file: Path, params: Dict[str, Any], n_discretization_nodes: int, n_states: int, n_controls: int, save_compiled: bool = False, debug: bool = False) -> callable
¶
Load discretization solver from cache or compile and cache it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
discretization_solver
|
callable
|
The solver function to compile |
required |
cache_file
|
Path
|
Path to cache file |
required |
params
|
Dict[str, Any]
|
Parameters dictionary |
required |
n_discretization_nodes
|
int
|
Number of discretization nodes |
required |
n_states
|
int
|
Number of state variables |
required |
n_controls
|
int
|
Number of control variables |
required |
save_compiled
|
bool
|
Whether to save/load compiled solvers |
False
|
debug
|
bool
|
Whether in debug mode (skip compilation) |
False
|
Returns:
| Type | Description |
|---|---|
callable
|
Compiled discretization solver |
Source code in openscvx/utils/caching.py
load_or_compile_propagation_solver(propagation_solver: callable, cache_file: Path, params: Dict[str, Any], n_states_prop: int, n_controls: int, max_tau_len: int, save_compiled: bool = False) -> callable
¶
Load propagation solver from cache or compile and cache it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
propagation_solver
|
callable
|
The solver function to compile |
required |
cache_file
|
Path
|
Path to cache file |
required |
params
|
Dict[str, Any]
|
Parameters dictionary |
required |
n_states_prop
|
int
|
Number of propagation state variables |
required |
n_controls
|
int
|
Number of control variables |
required |
max_tau_len
|
int
|
Maximum tau length for propagation |
required |
save_compiled
|
bool
|
Whether to save/load compiled solvers |
False
|
Returns:
| Type | Description |
|---|---|
callable
|
Compiled propagation solver |
Source code in openscvx/utils/caching.py
prime_propagation_solver(propagation_solver: callable, params: Dict[str, Any], settings) -> None
¶
Prime the propagation solver with a test call to ensure it works.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
propagation_solver
|
callable
|
Compiled propagation solver |
required |
params
|
Dict[str, Any]
|
Parameters dictionary |
required |
settings
|
Settings configuration object |
required |