optframework.kernel_opt.opt_core_ray module

Calculate the difference between the PSD of the simulation results and the experimental data. Minimize the difference by optimization algorithm to obtain the kernel of PBE.

class optframework.kernel_opt.opt_core_ray.OptCoreRay(*args, **kwargs)[source]

Bases: OptCore, Trainable

An extension of the OptCore class that integrates with Ray Tune for optimization.

This class inherits from both OptCore and tune.Trainable, making it a Ray Tune actor for managing optimization iterations. It allows for the running of the PBE calculation with Ray Tune’s iterative optimization framework, and implements the necessary methods to handle Ray Tune’s checkpointing, configuration resetting, and optimization step control.

Attributes

reuse_numint

A counter tracking the number of times the Actor has been reused.

actor_waitbool

A flag indicating whether the actor should wait between iterations if the execution time is too short.

setup(config, core_params, pop_params, data_path, exp_data_paths, x_uni_exp, data_exp, known_params, exp_case)[source]

Set up the environment for the optimization task.

This method initializes the core attributes and PBE solver for optimization. It also stores the experimental data and known parameters for use during the optimization process.

Parameters

configdict

The configuration dictionary used by Ray Tune to pass in optimization parameters.

core_paramsdict

The core parameters used for setting up the OptCore.

pop_paramsdict

The parameters for the PBE.

data_pathstr

The path to the experimental data.

x_uni_exparray-like

The unique particle diameters in experimental data.

data_exparray-like

The experimental PSD data.

known_paramsdict

A dictionary of known parameters that will be used to override any conflicting optimization parameters.

step()[source]

Perform one step of optimization.

This method is called by Ray Tune to execute a single iteration of the optimization. It calculates the loss (delta) between the experimental and simulated data based on the current configuration parameters.

Returns

dict

A dictionary containing the loss (delta) and the reuse count for the current Actor.

save_checkpoint(checkpoint_dir)[source]

Save the checkpoint. This method is required by Ray Tune but is not used in this implementation.

load_checkpoint(checkpoint_path)[source]

Load a checkpoint. This method is required by Ray Tune but is not used in this implementation.

reset_config(new_config)[source]

Reset the Actor for reuse in subsequent iterations.

This method is called when Ray Tune needs to reset the Actor between iterations. The reuse counter is incremented each time this method is called.

Returns

bool

Always returns True, indicating successful configuration reset.