dpgen2.exploration.scheduler package#

Submodules#

dpgen2.exploration.scheduler.convergence_check_stage_scheduler module#

class dpgen2.exploration.scheduler.convergence_check_stage_scheduler.ConvergenceCheckStageScheduler(stage: ExplorationStage, selector: ConfSelector, max_numb_iter: int | None = None, fatal_at_max: bool = True)[source]#

Bases: StageScheduler

Methods

complete()

Tell if the stage is complete

converged()

Tell if the stage is converged

force_complete()

For complete the stage

get_reports()

Return all exploration reports

next_iteration()

Return the index of the next iteration

plan_next_iteration([report, trajs])

Make the plan for the next iteration of the stage.

reached_max_iteration

complete()[source]#

Tell if the stage is complete

Returns:
converged bool

if the stage is complete

converged()[source]#

Tell if the stage is converged

Returns:
converged bool

the convergence

force_complete()[source]#

For complete the stage

get_reports()[source]#

Return all exploration reports

Returns:
reports List[ExplorationReport]

the reports

next_iteration()[source]#

Return the index of the next iteration

Returns:
index int

the index of the next iteration

plan_next_iteration(report: ExplorationReport | None = None, trajs: List[Path] | List[HDF5Dataset] | None = None) Tuple[bool, BaseExplorationTaskGroup | None, ConfSelector | None][source]#

Make the plan for the next iteration of the stage.

It checks the report of the current and all historical iterations of the stage, and tells if the iterations are converged. If not converged, it will plan the next ieration for the stage.

Parameters:
reportExplorationReport

The exploration report of this iteration.

trajsUnion[List[Path], List[HDF5Dataset]]

A list of configurations generated during the exploration. May be used to generate new configurations for the next iteration.

Returns:
stg_complete: bool

If the stage completed. Two cases may happen: 1. converged. 2. when not fatal_at_max, not converged but reached max number of iterations.

task: ExplorationTaskGroup

A ExplorationTaskGroup defining the exploration of the next iteration. Should be None if the stage is converged.

conf_selector: ConfSelector

The configuration selector for the next iteration. Should be None if the stage is converged.

reached_max_iteration()[source]#

dpgen2.exploration.scheduler.scheduler module#

class dpgen2.exploration.scheduler.scheduler.ExplorationScheduler[source]#

Bases: object

The exploration scheduler.

Methods

add_stage_scheduler(stage_scheduler)

Add stage scheduler.

complete()

Tell if all stages are converged.

force_stage_complete()

Force complete the current stage

get_convergence_ratio()

Get the accurate, candidate and failed ratios of the iterations

get_iteration()

Get the index of the current iteration.

get_stage()

Get the index of current stage.

get_stage_of_iterations()

Get the stage index and the index in the stage of iterations.

plan_next_iteration([report, trajs])

Make the plan for the next DPGEN iteration.

print_convergence

print_last_iteration

add_stage_scheduler(stage_scheduler: StageScheduler)[source]#

Add stage scheduler.

All added schedulers can be treated as a list (order matters). Only one stage is converged, the iteration goes to the next iteration.

Parameters:
stage_schedulerStageScheduler

The added stage scheduler

complete()[source]#

Tell if all stages are converged.

force_stage_complete()[source]#

Force complete the current stage

get_convergence_ratio()[source]#

Get the accurate, candidate and failed ratios of the iterations

Returns:
accu np.ndarray

The accurate ratio. length of array the same as # iterations.

cand np.ndarray

The candidate ratio. length of array the same as # iterations.

fail np.ndarray

The failed ration. length of array the same as # iterations.

get_iteration()[source]#

Get the index of the current iteration.

Iteration index increase when self.plan_next_iteration returns valid expl_task_grp and conf_selector for the next iteration.

get_stage()[source]#

Get the index of current stage.

Stage index increases when the previous stage converges. Usually called after self.plan_next_iteration.

get_stage_of_iterations()[source]#

Get the stage index and the index in the stage of iterations.

plan_next_iteration(report: ExplorationReport | None = None, trajs: List[Path] | List[HDF5Dataset] | None = None) Tuple[bool, ExplorationTaskGroup | None, ConfSelector | None][source]#

Make the plan for the next DPGEN iteration.

Parameters:
reportExplorationReport

The exploration report of this iteration.

trajsUnion[List[Path], List[HDF5Dataset]]

A list of configurations generated during the exploration. May be used to generate new configurations for the next iteration.

Returns:
complete: bool

If all the DPGEN stages complete.

task: ExplorationTaskGroup

A ExplorationTaskGroup defining the exploration of the next iteration. Should be None if converged.

conf_selector: ConfSelector

The configuration selector for the next iteration. Should be None if converged.

print_convergence()[source]#
print_last_iteration(print_header=False)[source]#

dpgen2.exploration.scheduler.stage_scheduler module#

class dpgen2.exploration.scheduler.stage_scheduler.StageScheduler[source]#

Bases: ABC

The scheduler for an exploration stage.

Methods

complete()

Tell if the stage is complete

converged()

Tell if the stage is converged

force_complete()

For complete the stage

get_reports()

Return all exploration reports

next_iteration()

Return the index of the next iteration

plan_next_iteration(report, trajs)

Make the plan for the next iteration of the stage.

abstract complete() bool[source]#

Tell if the stage is complete

Returns:
converged bool

if the stage is complete

abstract converged() bool[source]#

Tell if the stage is converged

Returns:
converged bool

the convergence

abstract force_complete()[source]#

For complete the stage

abstract get_reports() List[ExplorationReport][source]#

Return all exploration reports

Returns:
reports List[ExplorationReport]

the reports

abstract next_iteration() int[source]#

Return the index of the next iteration

Returns:
index int

the index of the next iteration

abstract plan_next_iteration(report: ExplorationReport, trajs: List[Path] | List[HDF5Dataset]) Tuple[bool, ExplorationTaskGroup, ConfSelector][source]#

Make the plan for the next iteration of the stage.

It checks the report of the current and all historical iterations of the stage, and tells if the iterations are converged. If not converged, it will plan the next ieration for the stage.

Parameters:
reportExplorationReport

The exploration report of this iteration.

trajsUnion[List[Path], List[HDF5Dataset]]

A list of configurations generated during the exploration. May be used to generate new configurations for the next iteration.

Returns:
stg_complete: bool

If the stage completed. Two cases may happen: 1. converged. 2. when not fatal_at_max, not converged but reached max number of iterations.

task: ExplorationTaskGroup

A ExplorationTaskGroup defining the exploration of the next iteration. Should be None if the stage is converged.

conf_selector: ConfSelector

The configuration selector for the next iteration. Should be None if the stage is converged.