Skip to content

sam::ResearchStrategy

Abstract class for different research strategies. More...

#include <ResearchStrategy.h>

Inherited by sam::DefaultResearchStrategy

Public Functions

Name
virtual ~ResearchStrategy() =0
ResearchStrategy()
virtual bool willStartHacking(std::optional< SubmissionPool > & subs)
Indicates whether the researcher will start going to the hacking procedure.
virtual bool willContinueHacking(Experiment * experiment, PolicyChain & pchain)
Indicates whether the researcher will continue the hacking procedure.
virtual bool willContinueHacking(std::optional< SubmissionPool > & sub, PolicyChain & pchain)
bool willBeSubmitting(const std::optional< SubmissionPool > & sub, PolicyChain & pchain)
virtual bool willContinueReplicating(SubmissionPool & subs)
Decides whether the researcher is going to continue the replication process or not.
void reset()
Resets the internal state of the research strategy.
std::optional< SubmissionPool > stashedSubmissions()
Returns a copy of the stashed_submissions.
virtual std::optional< SubmissionPool > selectOutcomeFromExperiment(Experiment * experiment, PolicyChainSet & pchain_set) =0
Returns an optional result of applying the PolicyChainSet on the given Experiment.
virtual std::optional< SubmissionPool > selectOutcomeFromPool(SubmissionPool & spool, PolicyChainSet & pchain_set) =0
Returns an optional result of applying the PolicyChainSet on the given list of submissions.
void saveOutcomes(Experiment & experiment, PolicyChain & pchain)
std::optional< SubmissionPool > selectOutcome(Experiment & experiment, PolicyChainSet & pchain_set)
Returns the result of applying the PolicyChainSet on the Experiment.
std::optional< SubmissionPool > selectBetweenSubmissions(SubmissionPool & spool, PolicyChainSet & pchain_set)
Returns the result of applying the PolicyChainSet on the submission pool.
std::unique_ptr< ResearchStrategy > build(json & research_strategy_config)
ResearchStrategy factory method.

Public Attributes

Name
sol::state lua
PolicyChainSet initial_selection_policies
PolicyChain submission_decision_policies
PolicyChainSet between_stashed_selection_policies
PolicyChainSet between_reps_policies
PolicyChain will_not_start_hacking_decision_policies
PolicyChain will_not_continue_replicating_decision_policy
PolicyChain stashing_policy

Protected Attributes

Name
std::optional< SubmissionPool > submission_candidates
SubmissionPool stashed_submissions

Detailed Description

class sam::ResearchStrategy;

Abstract class for different research strategies.

Note: This is being implemented as abstract class due to historical reasons. There is only one research strategy at the moment, but I'm considering the possibility of adding more and maybe redesigning this again.

Public Functions Documentation

function ~ResearchStrategy

virtual ~ResearchStrategy() =0

Pure destructors of ResearchStrategy. This is necessary for proper deconstruction of derived classes.

function ResearchStrategy

ResearchStrategy()

Besides constructing the base class, it also registers the Submission and DependentVariable in Lua for later use of the derived classes, e.g., DefaultResearchStrategy

function willStartHacking

inline virtual bool willStartHacking(
    std::optional< SubmissionPool > & subs
)

Indicates whether the researcher will start going to the hacking procedure.

Parameters:

  • subs The subs

Return: Returns true if researcher is going to start the hacking procedure

Reimplemented by: sam::DefaultResearchStrategy::willStartHacking

The default here is to not go for hacking if we already have one candidate; but this can be overridden in different research strategies

function willContinueHacking

inline virtual bool willContinueHacking(
    Experiment * experiment,
    PolicyChain & pchain
)

Indicates whether the researcher will continue the hacking procedure.

Parameters:

  • experiment A reference to the experiment

Reimplemented by: sam::DefaultResearchStrategy::willContinueHacking

This will be used by hackTheResearch and uses the decision policy to decide whether the next hacking strategy is going to be executed !

function willContinueHacking

inline virtual bool willContinueHacking(
    std::optional< SubmissionPool > & sub,
    PolicyChain & pchain
)

Reimplemented by: sam::DefaultResearchStrategy::willContinueHacking

function willBeSubmitting

bool willBeSubmitting(
    const std::optional< SubmissionPool > & sub,
    PolicyChain & pchain
)

Parameters:

  • subs A list of Submission(s)
  • pchain A policy chain

Return: returns true if submission should be submitted to the Journal.

Indicates whether the Researcher is going to submit the given set of submissions or not.

Usually submission_decision_policies will be used to evaluate the quality of the submission pool. This checks if at least one of the submissions satisfy all of the given policies.

function willContinueReplicating

inline virtual bool willContinueReplicating(
    SubmissionPool & subs
)

Decides whether the researcher is going to continue the replication process or not.

Parameters:

  • subs A list of submissions

Return: Returns true if the replication procedure should continue

Reimplemented by: sam::DefaultResearchStrategy::willContinueReplicating

function reset

inline void reset()

Resets the internal state of the research strategy.

function stashedSubmissions

inline std::optional< SubmissionPool > stashedSubmissions()

Returns a copy of the stashed_submissions.

Return: Returns an optional containing a copy of stashed_submissions

Todo: this can be improved

function selectOutcomeFromExperiment

virtual std::optional< SubmissionPool > selectOutcomeFromExperiment(
    Experiment * experiment,
    PolicyChainSet & pchain_set
) =0

Returns an optional result of applying the PolicyChainSet on the given Experiment.

Parameters:

  • experiment The experiment
  • pchain_set The policy chain set

Return: Returns a list of submissions, if any.

Reimplemented by: sam::DefaultResearchStrategy::selectOutcomeFromExperiment

function selectOutcomeFromPool

virtual std::optional< SubmissionPool > selectOutcomeFromPool(
    SubmissionPool & spool,
    PolicyChainSet & pchain_set
) =0

Returns an optional result of applying the PolicyChainSet on the given list of submissions.

Parameters:

  • spool The submission pool
  • pchain_set The policy chain set

Return: Returns a list of submissions, if any.

Reimplemented by: sam::DefaultResearchStrategy::selectOutcomeFromPool

function saveOutcomes

void saveOutcomes(
    Experiment & experiment,
    PolicyChain & pchain
)

Parameters:

  • experiment a reference to the experiment
  • pchain a policy chain, usually #stashing_policy
  • experiment a reference to the experiment
  • pchain a policy chain, usually stored in stashing_policy in the config file

Creates and save all possible submissions from an experiment, if they pass the given policy predicate

Create and save all possible submissions from an experiment, if the satisfy all of the given policies in the pchain.

function selectOutcome

std::optional< SubmissionPool > selectOutcome(
    Experiment & experiment,
    PolicyChainSet & pchain_set
)

Returns the result of applying the PolicyChainSet on the Experiment.

Parameters:

  • experiment The experiment
  • pchain_set The policy chain set.
  • experiment a reference to an experiment
  • pchain_set a reference to a policy chain set

Return:

  • Returns a list of submissions, if any.
  • A list of submissions, if any.

Select an unique outcome from an experiment, if at some point, a PolicyChain finds a group of outcomes instead of a unique outcome, the selection will be saved and the will await for processing in a different stages.

We check all available PolicyChains in the given chain set, and will stop as soon as any chain returns something!

function selectBetweenSubmissions

std::optional< SubmissionPool > selectBetweenSubmissions(
    SubmissionPool & spool,
    PolicyChainSet & pchain_set
)

Returns the result of applying the PolicyChainSet on the submission pool.

Parameters:

  • spool The spool
  • pchain_set The policy chain set
  • spool a collection of submissions collected in previous stages, e.g., selectOutcome
  • pchain_set a set of policy chains

Return:

  • Returns a list of submissions, if any.
  • A list of submissions, if any.

Note: If submission_candidate is empty to this point, and we cannot find anything here, we'll continue with nothing, and the current experiment will most likely be discarded.

Select a unique submission from the given pool of submissions. If none of the submissions satisfies all the policies, we just return, and submission_candidate will not be rewritten.

If any of the pchains return something, we ignore the rest, and leave!

function build

static std::unique_ptr< ResearchStrategy > build(
    json & research_strategy_config
)

ResearchStrategy factory method.

Parameters:

  • research_strategy_config A JSON object containing information about each research strategy.

Return: Returns a unique pointer to the newly build ResearchStrategy.

Public Attributes Documentation

variable lua

sol::state lua;

variable initial_selection_policies

PolicyChainSet initial_selection_policies;

Todo: These guys should move to their own class, I don't have to keep everything here!

variable submission_decision_policies

PolicyChain submission_decision_policies;

variable between_stashed_selection_policies

PolicyChainSet between_stashed_selection_policies;

variable between_reps_policies

PolicyChainSet between_reps_policies;

variable will_not_start_hacking_decision_policies

PolicyChain will_not_start_hacking_decision_policies;

variable will_not_continue_replicating_decision_policy

PolicyChain will_not_continue_replicating_decision_policy;

variable stashing_policy

PolicyChain stashing_policy;

Protected Attributes Documentation

variable submission_candidates

std::optional< SubmissionPool > submission_candidates;

variable stashed_submissions

SubmissionPool stashed_submissions;

List of selected submissions collected by the researcher using the stashing_policy


Updated on 29 June 2021 at 16:13:46 CEST


Last update: 2021-09-18