chronostar.icpool package#

Submodules#

chronostar.icpool.greedycycleicp module#

class chronostar.icpool.greedycycleicp.GreedyCycleICP(component_class, start_init_comps=None)#

Bases: BaseICPool

Manager and populator of a pool of initial conditions

The GreedyCollect algorithm immediately accepts a proposed component if the BIC improves, and then applies the next split on that accepted component.

max_components#

The max components in an initial condition provided by SimpleICPool, configurable

Type:

int, default 100

index_from_front#

Whether the target component index is a positive number (hence counting from front) or a negative number (hence counting from the back). Because the component list is modified in place, indexing from front results in any added component being split on the next iteration. Where as indexing from back skips the added component. For quicker, less accurate runs, set index_from_front=True. For slower, more accurate runs, set index_from_front=False.

Type:

bool, default True

Notes

GreedyCycle cycles over each component of the current best mixture, forming a new InitialCondition by splitting the target component and adding it to the queue [so far this is identical to SimpleICPool].

The difference with SimpleICPool, is that GreedyCycle immediately accepts any proposed component that improves the fit. GreedyCycle achieves this in the following way.

GreedyCycle only adds one InitialCondition at a time. After each iteration of the primary loop in Driver.run the registry of fitted mixtures will only ever have one mixture. Hence, each mixture will be the best of its “generation”. GreedyCycle updates best_mixture accordingly, and performs a split on the next component.

GreedyCycle is said to have converged if it has completed one whole cycle and found no beneficial splits.

This ICP does not lend itself to high level parallelism. Each generation produces only one InitialCondition, and thus generations cannot be split amongst processes.

property best_mixture: BaseMixture#

Get the mixture with the best score

Returns:

The best fitting mixture

Return type:

BaseMixture

get_next()#

Get the next initial condition set from queue

Returns:

(unique_id, initial condition set)

Return type:

tuple[int, list[BaseComponent]]

has_next()#

Return True if (after populating if needed) queue is non-empty

Returns:

True if queue is non-empty

Return type:

bool

increment_target_comp_ix()#

Increment the index of the target component

Depending on whether we’re indexing from front or back determines if the index should be a positive value or negative.

Return type:

None

next_gen(prev_comp_sets)#

Generate the next generation of initial conditions by splitting each existing component into two

Parameters:

prev_comp_sets (list[BaseComponent] (optional)) – A list of components from a previous fit. If none provided, a single (uninitialised) component will be returned.

Returns:

A list of initial conditions, where each initial condition is a list of components

Return type:

list[list[BaseComponent]]

Raises:

UserWarning – This introducer can only handle one set of components

put_in_queue(components, parent_label, extra)#

Put a new InitialCondition in the queue

Parameters:
  • components (tuple[BaseComponent, ...]) – A tuple of components

  • parent_label (str) – The label of the InitialCondition that initialised the parent mixture

  • extra (str) – An extra piece of information to append at the end of this InitialCondition’s label

Return type:

None

register_result(label, mixture, score)#

Register the result of a completed fit

Parameters:
  • label (str) – A uniquely identifying label with summary information: unique_id-parent_id-generation-ncomps

  • mixture (BaseMixture) – A mixture object whose fit has been finalised

  • score (float) – A score of the fit, where higher means better, e.g. -BIC

Return type:

None

try_populate_queue()#

Attempt to populate the queue of initial conditions

If this is the “first pass”, then the ICPool object will ask its introducer to produce a generation given no starting point.

Otherwise, it provides its introducer with the previous generation’s best mixture and adds the next generation to the queue.

Return type:

None

chronostar.icpool.simpleicpool module#

class chronostar.icpool.simpleicpool.SimpleICPool(component_class, start_init_comps=None)#

Bases: BaseICPool

Manager and populator of a pool of initial conditions

max_components#

The max components in an initial condition provided by SimpleICPool, configurable

Type:

int, default 100

property best_mixture: BaseMixture#

Get the mixture with the best score

Returns:

The best fitting mixture

Return type:

BaseMixture

get_next()#

Get the next initial condition set from queue

Returns:

(unique_id, initial condition set)

Return type:

tuple[int, list[BaseComponent]]

has_next()#

Return True if (after populating if needed) queue is non-empty

Returns:

True if queue is non-empty

Return type:

bool

next_gen(prev_comp_sets)#

Generate the next generation of initial conditions by splitting each existing component into two

Parameters:

prev_comp_sets (list[BaseComponent] (optional)) – A list of components from a previous fit. If none provided, a single (uninitialised) component will be returned.

Returns:

A list of initial conditions, where each initial condition is a list of components

Return type:

list[list[BaseComponent]]

Raises:

UserWarning – This introducer can only handle one set of components

put_in_queue(components, parent_label, extra)#

Put a new InitialCondition in the queue

Parameters:
  • components (tuple[BaseComponent, ...]) – A tuple of components

  • parent_label (str) – The label of the InitialCondition that initialised the parent mixture

  • extra (str) – An extra piece of information to append at the end of this InitialCondition’s label

Return type:

None

register_result(label, mixture, score)#

Register the result of a completed fit

Parameters:
  • label (str) – A uniquely identifying label with summary information: unique_id-parent_id-generation-ncomps

  • mixture (BaseMixture) – A mixture object whose fit has been finalised

  • score (float) – A score of the fit, where higher means better, e.g. -BIC

Return type:

None

try_populate_queue()#

Attempt to populate the queue of initial conditions

If this is the “first pass”, then the ICPool object will ask its introducer to produce a generation given no starting point.

Otherwise, it provides its introducer with the previous generation’s best mixture and adds the next generation to the queue.

Return type:

None

Module contents#