Controls#
The Controls
class details control parameters for the RAT run. Note that many of these are
specific to certain procedures: the relevant procedure is listed in square brackets before the
field description.
- pydantic model RATapi.Controls#
The full set of controls parameters for all five procedures that are required for the compiled RAT code.
- Fields:
adaptPCR (bool)
boundHandling (RATapi.utils.enums.BoundHandling)
calcSldDuringFit (bool)
crossoverProbability (float)
display (RATapi.utils.enums.Display)
fWeight (float)
funcTolerance (float)
jumpProbability (float)
maxFuncEvals (int)
maxIterations (int)
nChains (int)
nLive (int)
nMCMC (int)
nSamples (int)
nsTolerance (float)
numGenerations (int)
pUnitGamma (float)
parallel (RATapi.utils.enums.Parallel)
populationSize (int)
procedure (RATapi.utils.enums.Procedures)
propScale (float)
resampleMinAngle (float)
resampleNPoints (int)
strategy (RATapi.utils.enums.Strategies)
targetValue (float)
updateFreq (int)
updatePlotFreq (int)
xTolerance (float)
- field adaptPCR: bool = True#
[DREAM] Whether the crossover probability for differential evolution should be adapted during the run.
- field boundHandling: BoundHandling = BoundHandling.Reflect#
[DREAM] How steps past the space boundaries should be handled. Can be ‘off’, ‘reflect’, ‘bound’, or ‘fold’.
- field calcSldDuringFit: bool = False#
Whether SLD will be calculated during fit (for live plotting etc.)
- field crossoverProbability: float = 0.8#
[DE] The probability of exchange of parameters between individuals at any iteration.
- Constraints:
gt = 0.0
lt = 1.0
- field display: Display = Display.Iter#
How much RAT should print to the terminal. Can be ‘off’, ‘iter’, ‘notify’, or ‘final’.
- field fWeight: float = 0.5#
[DE] The step size for how different mutations are to their parents.
- Constraints:
gt = 0.0
- field funcTolerance: float = 1e-06#
[SIMPLEX] The termination tolerance for change in chi-squared.
- Constraints:
gt = 0.0
- field jumpProbability: float = 0.5#
[DREAM] The probability range for the size of jumps in sampling. Larger values mean more variable jumps.
- Constraints:
gt = 0.0
lt = 1.0
- field maxFuncEvals: int = 10000#
[SIMPLEX] The maximum number of function evaluations before the algorithm terminates.
- Constraints:
gt = 0
- field maxIterations: int = 1000#
[SIMPLEX] The maximum number of iterations before the algorithm terminates.
- Constraints:
gt = 0
- field nChains: int = 10#
[DREAM] The number of Markov chains to use in the algorithm.
- Constraints:
gt = 0
- field nLive: int = 150#
[NS] The number of points to sample.
- Constraints:
ge = 1
- field nMCMC: int = 0#
[NS] If non-zero, an MCMC process with
nMCMC
chains will be used instead of MultiNest.- Constraints:
ge = 0
- field nSamples: int = 20000#
[DREAM] The number of samples in the initial population for each chain.
- Constraints:
ge = 0
- field nsTolerance: float = 0.1#
[NS] The tolerance threshold for when the algorithm should terminate.
- Constraints:
ge = 0.0
- field numGenerations: int = 500#
[DE] The maximum number of iterations before the algorithm terminates.
- Constraints:
ge = 1
- field pUnitGamma: float = 0.2#
[DREAM] The probability that the scaling-down factor of jumps will be ignored and a larger jump will be taken.
- Constraints:
gt = 0.0
lt = 1.0
- field parallel: Parallel = Parallel.Single#
How the calculation should be parallelised. Can be ‘single’, ‘contrasts’ or ‘points’.
- field populationSize: int = 20#
[DE] The number of candidate solutions that exist at any time.
- Constraints:
ge = 1
- field procedure: Procedures = Procedures.Calculate#
Which procedure RAT should execute. Can be ‘calculate’, ‘simplex’, ‘de’, ‘ns’, or ‘dream’.
- field propScale: float = 0.1#
[NS] A scaling factor for the ellipsoid generated by MultiNest.
- Constraints:
gt = 0.0
lt = 1.0
- field resampleMinAngle: float = 0.9#
The upper threshold on the angle between three sampled points for resampling, in units of radians over pi.
- Constraints:
gt = 0
le = 1
- field resampleNPoints: int = 50#
The number of initial points to use for resampling.
- Constraints:
gt = 0
- field strategy: Strategies = Strategies.RandomWithPerVectorDither#
[DE] The algorithm used to generate new candidates.
- field targetValue: float = 1.0#
[DE] The value of chi-squared at which the algorithm will terminate.
- Constraints:
ge = 1.0
- field updateFreq: int = 1#
[SIMPLEX, DE] Number of iterations between printing progress updates to the terminal.
- field updatePlotFreq: int = 20#
[SIMPLEX, DE] Number of iterations between updates to live plots.
- field xTolerance: float = 1e-06#
[SIMPLEX] The termination tolerance for step size.
- Constraints:
gt = 0.0
- delete_IPC()#
Delete the inter-process communication file.
- initialise_IPC()#
Setup the inter-process communication file.
- classmethod load(path)#
Load a controls object from file.
- Parameters:
path (str or Path) – The path to the controls object file.
- Return type:
- model_post_init(context, /)#
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self (BaseModel) – The BaseModel instance.
context (Any) – The context.
- Return type:
None
- save(path, filename='controls')#
Save a controls object to a JSON file.
- Parameters:
path (str or Path) – The directory in which the controls object will be written.
filename (str) – The name for the JSON file containing the controls object.
- sendStopEvent()#
Sends the stop event via the inter-process communication file.
Warning
- UserWarning
Raised if we try to delete an IPC file that was not initialised.
- serialize()#
Filter fields so only those applying to the chosen procedure are serialized.