Evolutionary Algorithms

Contains the implementations for the evolutionary algorithm methods

Implements the supported evolutionary algorithm methods.

class calisim.evolutionary.implementation.EvolutionaryMethod(calibration_func: Callable, specification: EvolutionaryMethodModel, engine: str = 'spotpy', implementation: CalibrationWorkflowBase | None = None)[source]

The evolutionary algorithm method class.

pydantic model calisim.evolutionary.implementation.EvolutionaryMethodModel[source]

The evolutionary algorithm method data model.

Parameters:

BaseModel (CalibrationModel) – The calibration base model class.

Config:
  • arbitrary_types_allowed: bool = True

  • protected_namespaces: tuple = ()

Fields:
field directions: list[str] | None = ['minimize']

The list of objective directions

field objective: str | None = 'rmse'

The objective function

field operators: dict[str, Any] | None = None

The dictionary of evolutionary operators

calisim.evolutionary.implementation.get_implementations() dict[str, type[CalibrationWorkflowBase]][source]

Get the calibration implementations for evolutionary algorithm.

Returns:

The dictionary

of calibration implementations for evolutionary algorithm.

Return type:

Dict[str, type[CalibrationWorkflowBase]]

EvoTorch

Contains the implementations for evolutionary algorithms using EvoTorch

Implements the supported evolutionary algorithms using the EvoTorch library.

class calisim.evolutionary.evotorch_wrapper.EvoTorchEvolutionary(calibration_func: Callable, specification: CalibrationModel, task: str)[source]

The EvoTorch evolutionary algorithm method class.

analyze() None[source]

Analyze the results of the simulation calibration procedure.

execute() None[source]

Execute the simulation calibration procedure.

specify() None[source]

Specify the parameters of the model calibration procedure.

SPOTPY

Contains the implementations for evolutionary algorithms using SPOTPY

Implements the supported evolutionary algorithms using the SPOTPY library.

class calisim.evolutionary.spotpy_wrapper.SPOTPYEvolutionary(calibration_func: Callable, specification: CalibrationModel, task: str)[source]

The SPOTPY evolutionary algorithm method class.

analyze() None[source]

Analyze the results of the simulation calibration procedure.

execute() None[source]

Execute the simulation calibration procedure.

specify() None[source]

Specify the parameters of the model calibration procedure.

class calisim.evolutionary.spotpy_wrapper.SPOTSetup(workflow: CalibrationWorkflowBase, objective_function: Callable, evolutionary_name: str)[source]

The SPOTPY calibration setup.

evaluation() ndarray | DataFrame[source]

Get the observed data.

Returns:

The observed data.

Return type:

np.ndarray | pd.DataFrame

objectivefunction(simulation: ndarray | DataFrame, evaluation: ndarray | DataFrame) float[source]

Call the objective function on simulated and observed data.

Parameters:
  • simulation (np.ndarray | pd.DataFrame) – The simulated data.

  • evaluation (np.ndarray | pd.DataFrame) – The observed data.

Returns:

The objective function results.

Return type:

float

parameters() ndarray[source]

Generate parameters from the prior specification.

Returns:

The generated parameters.

Return type:

np.ndarray

setup_from_workflow(workflow: CalibrationWorkflowBase) None[source]

Configure the calibration procedure from the workflow object.

Parameters:

workflow (CalibrationWorkflowBase) – The calibration workflow object.

simulation(X: ndarray) ndarray[source]

Run the simulation.

Parameters:

X (np.ndarray) – The simulation parameter vector.

Returns:

The simulation results.

Return type:

np.ndarray