physicool.optimization
A module for model calibration and optimization routines.
Module Contents
Classes
A class to run PhysiCell models through Python as a black box. |
|
Functions
|
Creates a project command based on the current OS. |
Removes the files from the output folder and creates it again (make data-cleanup). |
|
Removes the temp folder if it exists. |
|
Compiles the current project by calling make. |
|
|
Attributes
- physicool.optimization.LOG_FILE = 'debug.log'
- physicool.optimization._create_project_command(project_name)[source]
Creates a project command based on the current OS.
- Parameters:
project_name (str) – The base name of the PhysiCell executable file.
- Returns:
The full command to be called in order to run the executable in the shell, adapted to the current OS.
- Return type:
str
- physicool.optimization.clean_outputs()[source]
Removes the files from the output folder and creates it again (make data-cleanup).
- Return type:
None
- physicool.optimization.clean_tmp_files()[source]
Removes the temp folder if it exists.
- Return type:
None
- physicool.optimization.compile_project()[source]
Compiles the current project by calling make.
- Return type:
None
- class physicool.optimization.PhysiCellBlackBox[source]
A class to run PhysiCell models through Python as a black box. Models can be run as they are, and it’s possible to run replicates.
Alternatively, users can decide to include a ParamsUpdater object to change values in the XML file before the model is run and/or a OutputProcessor to extract data from the output files and return a given user-defined metric.
Output files can be kept or discarded. If kept, they will be stored inside a new “temp” folder.
- updater: Optional[physicool.updaters.ParamsUpdater]
- processor: Optional[physicool.processing.OutputProcessor]
- project_name: str = 'project'
- project_command: str
- version: str
- run(params=None, number_of_replicates=1, keep_files=True)[source]
Runs the black box pipeline.
- Parameters:
params (Optional[Dict[str, float]]) – The new parameter values, to be updated in the XML file by the ParamsUpdater class.
number_of_replicates (int) – The number of simulation replicates to be run.
keep_files (bool) – If the output files should be stored in a tmp folder.
- Returns:
The output metrics computed by the OutputProcessor class
- Return type:
Optional[np.ndarray]
- physicool.optimization.run_sweep(black_box, name, bounds, step)[source]
- Parameters:
black_box (PhysiCellBlackBox) –
name (str) –
bounds (Tuple[float, float]) –
step (float) –
- Return type:
numpy.ndarray
- class physicool.optimization.MultiLevelSweep[source]
- black_box: PhysiCellBlackBox
- target_data: numpy.ndarray
- n_levels: int
- points_dir: int
- percentage_dir: float
- parameters: List[str]
- error_estimator: physicool.processing.ErrorQuantification
- plotter: physicool.plotting.SweeperPlot
- results: numpy.ndarray
- current_level: int
- current_opt_point: Tuple[float, float]
- param_bounds: List[Tuple[Union[None, float], Union[None, float]]]
- set_param_bounds(param1_bounds=None, param2_bounds=None)[source]
Defines the parameter bounds to be considered when creating a parameter space.
- Parameters:
param1_bounds (Optional[Tuple[Union[None, float], Union[None, float]]]) –
param2_bounds (Optional[Tuple[Union[None, float], Union[None, float]]]) –
- Return type:
None
- get_parameter_range(factor, idx)[source]
Returns the parameter values to be tested based on the current level and bounds.
- Parameters:
factor (float) –
idx (int) –
- Return type:
numpy.ndarray
- get_optimal_idx()[source]
Returns the indexes for the smallest error in the current level.
- Return type:
Tuple[int, int]