コード例 #1
0
def test_optimization():
    if os.name != 'nt':
        return
    ema_logging.log_to_stderr(ema_logging.INFO)

    model = FluModel(r'../models', "fluCase")
    ensemble = ModelEnsemble()

    ensemble.model_structure = model
    ensemble.parallel = True

    pop_size = 8
    nr_of_generations = 10
    eps = np.array([1e-3, 1e6])

    stats, pop = ensemble.perform_outcome_optimization(
        obj_function=obj_function_multi,
        algorithm=epsNSGA2,
        reporting_interval=100,
        weights=(MAXIMIZE, MAXIMIZE),
        pop_size=pop_size,
        nr_of_generations=nr_of_generations,
        crossover_rate=0.8,
        mutation_rate=0.05,
        eps=eps)
コード例 #2
0
def test_optimization():
    if os.name != 'nt':
        return
    ema_logging.log_to_stderr(ema_logging.INFO)
    
    model = FluModel(r'../models', "fluCase")
    ensemble = ModelEnsemble()
    
    ensemble.model_structure = model
    ensemble.parallel=True
    
    pop_size = 8
    nr_of_generations = 10
    eps = np.array([1e-3, 1e6])

    stats, pop  = ensemble.perform_outcome_optimization(obj_function = obj_function_multi,
                                                    algorithm=epsNSGA2,
                                                    reporting_interval=100, 
                                                    weights=(MAXIMIZE, MAXIMIZE),
                                                    pop_size=pop_size,          
                                                    nr_of_generations=nr_of_generations,
                                                    crossover_rate=0.8,
                                                    mutation_rate=0.05,
                                                    eps=eps)
コード例 #3
0
'''
Created on Mar 15, 2012

.. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>
'''

from analysis import clusterer
from util import ema_logging

from core import ModelEnsemble
from test.scarcity_example import ScarcityModel

if __name__ == "__main__":
    ema_logging.log_to_stderr(ema_logging.INFO)
    model = ScarcityModel(r'..\..\src\test', "fluCase")

    ensemble = ModelEnsemble()
    ensemble.set_model_structure(model)
    ensemble.parallel = True

    results = ensemble.perform_experiments(200)

    clusterer.cluster(data=results,
                      outcome='relative market price',
                      distance='gonenc',
                      cMethod='maxclust',
                      cValue=5,
                      plotDendrogram=False)
コード例 #4
0
                             "susceptible to immune population delay time region 1"),
        ParameterUncertainty((0.5,2), 
                             "susceptible to immune population delay time region 2"),
        ParameterUncertainty((0.01, 5), 
                             "root contact rate region 1"),
        ParameterUncertainty((0.01, 5), 
                             "root contact ratio region 2"),
        ParameterUncertainty((0, 0.15), 
                             "infection ratio region 1"),
        ParameterUncertainty((0, 0.15), 
                             "infection rate region 2"),
        ParameterUncertainty((10, 100), 
                             "normal contact rate region 1"),
        ParameterUncertainty((10, 200), 
                             "normal contact rate region 2")]
                         
        
if __name__ == "__main__":
    ema_logging.log_to_stderr(ema_logging.INFO)
        
    model = FluModel(r'./models/flu', "fluCase")
    ensemble = ModelEnsemble()
    ensemble.model_structure = model
    
    ensemble.parallel = True #turn on parallel processing

    nr_experiments = 1000
    results = ensemble.perform_experiments(nr_experiments)
    
    fh =  r'./data/{} flu cases no policy.tar.gz'.format(nr_experiments)
    save_results(results, fh)
コード例 #5
0
        except KeyError:
            ema_logging.warning("key 'file' not found in policy")
        super(FluModel, self).model_init(policy, kwargs)
        
if __name__ == "__main__":
    ema_logging.log_to_stderr(ema_logging.INFO)
        
    model = FluModel(r'./models/flu', "flucase")
    ensemble = ModelEnsemble()
    ensemble.model_structure = model
    
    #add policies
    policies = [{'name': 'no policy',
                 'file': r'\FLUvensimV1basecase.vpm'},
                {'name': 'static policy',
                 'file': r'\FLUvensimV1static.vpm'},
                {'name': 'adaptive policy',
                 'file': r'\FLUvensimV1dynamic.vpm'}
                ]
    ensemble.policies = policies
    
    #turn on parallel processing
    ensemble.parallel = True 
    
    # run 1000 experiments
    nr_runs = 1000
    results = ensemble.perform_experiments(nr_runs)
    
    # save the results
#     save_results(results, r'./data/{} flu cases.tar.gz'.format(nr_runs))
コード例 #6
0
                     ParameterUncertainty((0.1,0.3),
                                          "kk")]
    
    #specification of the outcomes
    outcomes = [Outcome("B4:B1076", time=True),  #we can refer to a range in the normal way
                Outcome("P_t", time=True)] # we can also use named range
    
    #name of the sheet
    sheet = "Sheet1"
    
    #relative path to the Excel file
    workbook = r'\excel example.xlsx'
    

if __name__ == "__main__":    
    ema_logging.log_to_stderr(level=ema_logging.INFO)
    
    model = ExcelModel(r"./models/excelModel", "predatorPrey")
    
    ensemble = ModelEnsemble()
    ensemble.model_structure = model

    ensemble.parallel = True #turn on parallel computing
    pool = MultiprocessingPool(ensemble.model_structure, 
                               nr_processes=2)
    ensemble.pool = pool
    
    #run 100 experiments
    nr_experiments = 100
    results = ensemble.perform_experiments(nr_experiments)