Skip to content

Class SolverWrapper

The class SolverWrapper is a wrapper for each solver, it offers a common interface for reading the config file, setting up the solver and solving the problem.

API Documentation

__init__(config_file)

Initializes the SolverWrapper instance by loading configuration data from a JSON file.

Parameters:

Name Type Description Default
config_file str

The path to the configuration file in JSON format.

required

This method performs the following actions:

  • Loads the configuration data from the specified JSON file.
  • Calls internal methods to read and process various configuration sections:
  • ODE configuration
  • ODE solver configuration
  • Dataset configuration
  • Dictionary configuration
  • Solver configuration

setup(observable_func, x_sample_func=torch.rand, param_sample_func=torch.rand)

Initializes the solver setup by configuring the ODE, dataset, and dictionary.

Parameters:

Name Type Description Default
observable_func torch.Tensor -> torch.Tensor

A function that defines the observables for the system.

required
x_sample_func callable

A function to sample initial conditions. Defaults to torch.rand.

rand
param_sample_func callable

A function to sample parameters. Defaults to torch.rand.

rand

This method performs the following initializations:

  • Initializes the ordinary differential equation (ODE).
  • Sets up the ODE solver.
  • Initializes the dataset using the provided sampling functions.
  • Configures the dictionary with the given observable function.
  • Prepares the solver for execution.

solve()

Placeholder method for solving a problem or executing a specific task.

This method is intended to be overridden by subclasses to provide a concrete implementation of the solving logic. By default, it raises a NotImplementedError to indicate that the method has not been implemented.

Returns:

Type Description
NotImplementedError

Indicates that the method needs to be implemented in a subclass.