コード例 #1
0
    def run_experiment(path: Path, custom_settings: dict):
        # 1. Initialize the experiment
        exp = Experiment()
        exp.load_config(config_file=path / 'config.json',
                        custom_settings=custom_settings)

        if exp.config['model']['n_areas'] == "TBD":
            exp.config['model']['n_areas'] = 2

        # 2. Simulate contact areas
        sim = Simulation(experiment=exp)
        sim.run_simulation()

        # 3. Define MCMC
        mc = MCMC(data=sim, experiment=exp)

        # 4. Warm-up sampler and sample from posterior
        mc.warm_up()
        mc.sample()

        # 5. Evaluate ground truth
        mc.eval_ground_truth()

        # 6. Log sampling statistics and save samples to file
        mc.save_samples(run=0)
コード例 #2
0
ファイル: run_sim_exp2.py プロジェクト: noorefrat/sbayes
        exp = Experiment()
        exp.load_config(
            config_file='experiments/simulation/sim_exp2/config.json',
            custom_settings={'model': {
                'INHERITANCE': IN
            }})
        exp.log_experiment()

        # 2. Simulate contact areas
        sim = Simulation(experiment=exp)
        sim.run_simulation()
        sim.log_simulation()

        # 3. Define MCMC
        mc = MCMC(data=sim, experiment=exp)
        mc.log_setup()

        # Rerun experiment to check for consistency
        for run in range(exp.config['mcmc']['N_RUNS']):

            # 4. Sample from posterior
            mc.warm_up()
            mc.sample()

            # 5. Evaluate ground truth
            mc.eval_ground_truth()

            # 6. Log sampling statistics and save samples to file
            mc.log_statistics()
            mc.save_samples(run=run)