uvex_transients.phase_space.experiment#

The experiment: a sampler, a map, a stopping rule and a campaign, as one object that can be run and saved.

A phase-space scenario is made of four things. A Sampler answers “how many detections in n tries at a point”, a StoppingRule says how many tries a point gets, a PhaseSpaceMap holds the points and models the success fraction, and CampaignSettings says how long to run. Experiment holds the four, so a new scenario is a new sampler and nothing else:

experiment = Experiment.create(
    MySampler(...),
    bounds=[(41.0, 45.0), (0.0, 3.0)],
)
experiment.run()
experiment.save("points.ecsv")
table = experiment.grid_table(60)

Files. Experiment.save writes the points as an ECSV table whose header records everything needed to rebuild the experiment: the space, the settings of the model, the stopping rule, the campaign, and the sampler as its registered kind and settings (see get_sampler()), so that no Python import path is stored. Experiment.load reads that, and also the files of the earlier format, which recorded a RecoveryEvaluator (a class that no longer exists); it rebuilds those as the canonical sampler.

The campaign. run_campaign() is the loop that joins a map, a sampler and a stopping rule. The map says where to measure next, the sampler measures a point, and the rule says how many tries a point gets, so the loop measures an initial space-filling design, then repeats: ask the map for a batch of points, measure them and add the counts, until the budget is spent or the map is good enough. It is short on purpose, and everything it needs to be extended (a different sampler, a different rule, another acquisition) is in the three objects it is given.

Seeds. The randomness of the measurement of a point is the seed of the point, point_seed(): a child of the campaign’s root seed that is identified by the index of the point in the map, not by when it happened to be measured. A point is measured the same way whatever the order a batch is evaluated in, and so whether it is evaluated in a loop, on a thread pool or on a cluster (fork_map()), and resuming a campaign from its saved points continues the same sequence of seeds.

Functions

fork_map(sampler, rule[, processes])

Provide a map_fn that measures the points of a batch in forked worker processes.

point_seed(root, index)

Return the seed of the point with a given index in a campaign.

run_campaign(phase_map, sampler, rule, ...)

Measure points of a map until its budget is spent or it is converged.

Classes

CampaignSettings(n_initial, batch_size, ...)

How long a campaign runs and how it spends its points.

Experiment(sampler, phase_map, rule, campaign)

A sampler, the map of its success fraction, the stopping rule for its points, and a campaign.