示例#1
0
    def __init__(self, path, treatments, name=None, seed=1, analysis_path=None, full=True):
        logtools.set_logging()

        if name is None:
            name = _make_name_from_program()

        self.path = _construct_path(path, name)
        if analysis_path:
            self.analysis_path = _construct_path(analysis_path, name)
        else:
            self.analysis_path = self.path

        self.next_treatment_seq = 0
        if full:
            self.lineage_class = FullLineage
        else:
            self.lineage_class = SnapshotLineage

        self.seed = seed
        self.rng = random.Random(seed)

        self.user_interrupt = False

        self.treatments = []
        for t in treatments:
            assert isinstance(t, Treatment)
            self.treatments.append(t)
            t._bind(self)

        self._construct()
示例#2
0
def calc_gens(verbose, treatment, replicate):
    set_logging(verbose)

    try:
        the_t, the_rep = NS.experiment.find_matching(treatment, replicate)
    except ExperimentError as e:
        raise click.BadParameter(e.message)

    # First, let's find the best fitness
    NS.experiment.visit_lineages(StatsGenerations(NS.experiment),
                                 only_treatment=the_t,
                                 only_replicate=the_rep)
示例#3
0
def run(overwrite, verbose, treatment, replicate):
    """Run the simulation.

    This will create a new simulation or complete an existing one (if
    unfinished).
    """
    set_logging(verbose)
    try:
        the_t, the_rep = NS.experiment.find_matching(treatment, replicate)
    except ExperimentError as e:
        raise click.BadParameter(e.message)

    NS.experiment.run(overwrite=overwrite,
                      only_treatment=the_t,
                      only_replicate=the_rep)
示例#4
0
def stats(every, treatment, replicate, verbose):
    """Gather statistics about the simulation"""
    set_logging(verbose)

    try:
        the_t, the_rep = NS.experiment.find_matching(treatment, replicate)
    except ExperimentError as e:
        raise click.BadParameter(e.message)

    visitor = StatsVisitor(NS.experiment,
                           [StatsRelevantControl, StatsFitness,
                            StatsMutualInformation, StatsBindings])
    NS.experiment.visit_generations(visitor,
                                    only_treatment=the_t,
                                    only_replicate=the_rep,
                                    every=every)
示例#5
0
def env_robustness(verbose, treatment, replicate, every, only):
    set_logging(verbose)

    try:
        the_t, the_rep = NS.experiment.find_matching(treatment, replicate)
    except ExperimentError as e:
        raise click.BadParameter(e.message)

    # First, let's find the best fitness
    visitor = StatsVisitor(NS.experiment,
                           [StatsEnvironmental])
    NS.experiment.visit_generations(visitor,
                                    only_treatment=the_t,
                                    only_replicate=the_rep,
                                    every=every,
                                    only=only)