class Trial

A trial contains a number of TrialStages. The Acceptance is computed as the stages are enacted, and then sent to Criteria to decide if the trial is accepted or rejected.

Subclassed by feasst::TrialAVB2Half, feasst::TrialAVB4, feasst::TrialAdd, feasst::TrialAddAVB, feasst::TrialAddAVBDivalent, feasst::TrialAddMultiple, feasst::TrialBeta, feasst::TrialFactory, feasst::TrialGibbsParticleTransferOneWay, feasst::TrialGibbsVolumeTransferOneWay, feasst::TrialGrowLinear, feasst::TrialModel, feasst::TrialMorph, feasst::TrialMorphExpanded, feasst::TrialMove, feasst::TrialRemove, feasst::TrialRemoveAVB, feasst::TrialRemoveAVBDivalent, feasst::TrialRemoveMultiple, feasst::TrialRotateCluster, feasst::TrialSwapSites, feasst::TrialTranslateCluster, feasst::TrialVolume

Public Functions

double weight() const

Return the unnormalized relative probability of selection of this trial with respect to all trials.

double weight_per_number_fraction() const

Return the weight per number of particles of given type.

void add_stage(std::shared_ptr<TrialSelect> select, std::shared_ptr<Perturb> perturb, argtype *stage_args)

Add a stage which includes selection and perturbation with arguments.

void add_stage(std::shared_ptr<TrialSelect> select, std::shared_ptr<Perturb> perturb)

Same as above, but without arguments for stage.

void add_stage(std::shared_ptr<TrialStage> stage)

Same as above, but by copying an existing stage.

void set(const int index, std::shared_ptr<TrialStage> stage)

Set a stage, as can be done just before each attempt.

int num_stages() const

Number of stages.

const TrialStage &stage(const int index) const

Return a stage.

int64_t num_success() const

Number of successful attempts.

int64_t num_attempts() const

Number of attempts.

int64_t num_auto_reject() const

Number of automatic rejections.

void increment_num_attempts()

Increment the number of attempts for acceptance.

double acceptance() const

Return the ratio of the number of successful attempts and total attempts. Return -1 if no attempts were performed.

virtual void reset_stats()

Reset trial statistics.

virtual std::string status_header() const

Return the header description for the status of the trial (e.g., acceptance, etc).

virtual std::string status() const

Return the status of the trial (e.g., acceptance, etc).

virtual void tune()

Tune parameters.

virtual void precompute(Criteria *criteria, System *system)

Precompute quantities before simulation for optimization.

void set(std::shared_ptr<TrialCompute> compute)

Set the computation of the trial and acceptance.

const TrialCompute &compute() const

Return TrialCompute.

void revert(System *system, Criteria *criteria)

Revert all stages in reverse order.

virtual bool attempt(Criteria *criteria, System *system, Random *random)

Attempt a trial. Return true if accepted.

const std::string &description() const

Return the description, as used in Log.

void set_description(const std::string &description)

Set the description.


Trial(argtype args = argtype())


  • weight: unnormalized relative probability of selection of this trial with respect to all trials (default: 1).

  • weight_per_number_fraction: if > 0, the weight is continuously updated to (weight_per_number_fraction * number of TrialSelect::particle_type in first TrialStage / total number of particles). If <= 0, the given weight above is fixed to that value (default: -1). For a binary simulation, weight_per_number_fraction with a separate trial for particle_type 0 and 1 ensures equal probability of selecting either particle type regardless of the number of particles, while still allowing for different tunable parameters for each particle_type.