Esempio n. 1
0
def pt_evaluation_for_test(bn: OpenBooleanNetwork, test_params: Iterable):
    '''
    Run a simulation for each set of test parameters. 
    '''
    
    data = []

    for tp in test_params:
        
        ### Generate ad hoc configuration for simulation purposes only ################################
        simconfig = GLOBALS.generate_sim_config()

        ### Generate simulation world file for simulation purposes only ################################
        if not simconfig.webots_world_path.exists():

            logger.info('Generated webots world file from template...')
            
            stub_utils.generate_webots_worldfile(
                GLOBALS.webots_world_path, 
                simconfig.webots_world_path,
                simconfig.arena_params
            )
        
        # May be launched parallel (... ?)
        data.append(
            evaluate_pt_bncontroller(simconfig, bn, tp)
        )

    return tuple(list(e) for e in zip(*data))
Esempio n. 2
0
from bncontroller.boolnet.structures import OpenBooleanNetwork
from bncontroller.rtest import find_bn_type

if __name__ == "__main__":

    load_global_config()

    if isinstance(GLOBALS.bn_model_path,
                  list) or GLOBALS.bn_model_path.is_dir():
        raise Exception('Model path should be a file.')

    GLOBALS.app['mode'] = 'handcheck'

    bn = find_bn_type(read_json(GLOBALS.bn_model_path))

    config = GLOBALS.generate_sim_config()

    ### Generate simulation world file for training ################################

    stub_utils.generate_webots_worldfile(GLOBALS.webots_world_path,
                                         config.webots_world_path,
                                         config.arena_params)

    stub_utils.generate_webots_props_file(GLOBALS.webots_world_path,
                                          config.webots_world_path)
    try:
        proc_closure = stub_utils.run_simulation(config, bn)
    except Exception:
        pass

    stub_utils.clean_dir(