The problems.base module

Base classes for Grond’s problem definition and the model history container.

Common behaviour of all source models offered by Grond is implemented here. Source model specific details are implemented in the respective submodules.

class grond.problems.base.ProblemConfig(**kwargs)[source]

Base class for config section defining the objective function setup.

Factory for Problem objects.




int, default: 2


int, default: 1

get_problem(event, target_groups, targets)[source]

Instantiate the problem with a given event and targets.

Returns:Problem object
class grond.problems.base.Problem(**kwargs)[source]

Base class for objective function setup.

Defines the problem to be solved by the optimiser.




dict of objects, default: {}


list of grond.meta.Parameter objects, default: []


int, default: 2

base_source, optional


list of grond.targets.base.MisfitTarget objects, default: []


list of grond.targets.base.TargetGroup objects, default: []


str, optional


int, default: 1

combine_misfits(misfits, extra_weights=None, extra_residuals=None, extra_correlated_weights={}, get_contributions=False)[source]

Combine misfit contributions (residuals) to global or bootstrap misfits

  • misfits – 3D array misfits[imodel, iresidual, 0] are the misfit contributions (residuals) misfits[imodel, iresidual, 1] are the normalisation contributions. It is also possible to give the misfit and normalisation contributions for a single model as misfits[iresidual, 0] and misfits[iresidual, 1]`` in which case, the first dimension (imodel) of the result will be stipped off.
  • extra_weights – if given, 2D array of extra weights to be applied to the contributions, indexed as extra_weights[ibootstrap, iresidual].
  • extra_residuals – if given, 2D array of perturbations to be added to the residuals, indexed as extra_residuals[ibootstrap, iresidual].
  • extra_correlated_weights – if a dictionary of imisfit: correlated weight matrix is passed a correlated weight matrix is applied to the misfit and normalisation values. imisfit is the starting index in the misfits vector the correlated weight matrix applies to.
  • get_contributions – get the weighted and perturbed contributions (don’t do the sum).

if no extra_weights or extra_residuals are given, a 1D array indexed as misfits[imodel] containing the global misfit for each model is returned, otherwise a 2D array misfits[imodel, ibootstrap] with the misfit for every model and weighting/residual set is returned.

Parameters:ns – 2D array with normalization factors ns[imodel, itarget]
Returns:2D array weights[imodel, itarget]
class grond.problems.base.ModelHistory(problem, nchains=None, path=None, mode='r')[source]

Write, read and follow sequences of models produced in an optimisation run.

  • problemgrond.Problem instance
  • path (str, optional) – path to rundir, defaults to None
  • mode (str, optional) – open mode, ‘r’: read, ‘w’: write

Add a listener to the history

The listening class can implement the following methods: * extend

classmethod follow(path, nchains=None, wait=20.0)[source]

Start following a rundir (constructor).

  • path (str, optional) – the path to follow, a grond rundir
  • wait (number in seconds, optional) – wait time until the folder become alive

A ModelHistory instance


Update history from path

exception grond.problems.base.ProblemInfoNotAvailable[source]
exception grond.problems.base.ProblemDataNotAvailable[source]
exception grond.problems.base.InvalidAttributeName[source]
exception grond.problems.base.NoSuchAttribute[source]