Exemplo n.º 1
0
    def graph(self):
        if os.path.isfile(fpath_db): os.remove(fpath_db)

        te = TrajectoryEnsemble(fpath_db)

        if te.is_db_empty:
            te.set_pragma_memoize_group_ids(True)
            te.add_trajectories([
                (Simulation().
                    add([
                        SARSQuarantineIntervention(
                            SEQIHRModel('sars', beta=0.80, alpha_n=0.75, alpha_q=0.40, delta_n=0.01, delta_h=0.03, mu=0.01, chi=0.01, phi=0.20, rho=0.75, solver=ODESolver()),
                            chi=0.99,
                            i=int(intervention_onset)
                        ),
                        Group(m=95000, attr={ 'sars': 's' }),
                        Group(m= 5000, attr={ 'sars': 'e' })
                    ])
                ) for intervention_onset in TN(30,120, 75,100, 5)
            ])
            te.set_group_names(group_names)
            
            sys.stdout = open('out.dat', 'w')
            s.run(400)
            sys.stdout.close()
        
            with open('out.dat') as file:
                self.data = file.readlines()
                self.data = str(self.data)
            apple  = self.data.replace('\\n', '<br>')
            # print(apple)

             te.plot_mass_locus_line     ((1200,300), os.path.join(os.path.dirname(__file__), 'out', 'plot-line.png'), col_scheme='tableau10', opacity_min=0.35)
             te.plot_mass_locus_line_aggr((1200,300), os.path.join(os.path.dirname(__file__), 'out', 'plot-ci.png'),   col_scheme='tableau10')

            fpath_diag = os.path.join(os.path.dirname(__file__), 'out', 'sim-04.diag')
            fpath_pdf  = os.path.join(os.path.dirname(__file__), 'out', 'sim-04.pdf')
            te.traj[2].sim.gen_diagram(fpath_diag, fpath_pdf)
Exemplo n.º 2
0
# ----------------------------------------------------------------------------------------------------------------------
if os.path.isfile(fpath_db): os.remove(fpath_db)

te = TrajectoryEnsemble(fpath_db)
# te = TrajectoryEnsemble(fpath_db, cluster_inf=ClusterInf(address='auto'))
# te = TrajectoryEnsemble(fpath_db, cluster_inf=ClusterInf(num_cpus=6, memory=500*1024*1024, object_store_memory=500*1024*1024, include_webui=True))

if te.is_db_empty:
    te.set_pragma_memoize_group_ids(True)
    te.add_trajectories([
        Trajectory(
            (Simulation().
                add([
                    SIRModel('flu', beta=0.10, gamma=0.05, solver=MCSolver()),
                    SIRModel('flu', beta=0.50, gamma=U(0.01, 0.15), i=[int(5 + TN(0,50, 5,10)), 50], solver=MCSolver()),
                    FluProcess(i=[50,0], p_max=None, a=3.0, scale=flu_proc_scale),
                    Group(m=950, attr={ 'flu': 's' }),
                    Group(m= 50, attr={ 'flu': 'i' })
                ])
            )
        ) for flu_proc_scale in U(1,5, 1)
    ])
    te.set_group_names(group_names)
    te.run(120)


# Visualize:
te.plot_mass_locus_line     ((1200,300), os.path.join(os.path.dirname(__file__), 'out', '_plot-line.png'), opacity_min=0.2)
te.plot_mass_locus_line_aggr((1200,300), os.path.join(os.path.dirname(__file__), 'out', '_plot-iqr.png'))