예제 #1
0
파일: model.py 프로젝트: dacharle/cps
def create_world(model, simulator, t_init):
    """
    Factory for world entities.

    """
    from cps.entity import Scheduler
    # create channel scheduler
    state_names = model.world_vars
    scheduler = Scheduler.worldSchedulerFromModel(t_init, model.world_channel_table)
    # create world
    return model.WorldType(state_names, scheduler, simulator)
예제 #2
0
파일: model.py 프로젝트: dacharle/cps
def create_agents(model, simulator, t_init):
    """
    Factory for agent entities.

    """
    agents = []
    from cps.logging import LoggerNode
    from cps.entity import Scheduler
    for i in range(model.n0):
        # create channel network/event schedule
        state_names = model.agent_vars
        scheduler = Scheduler.agentSchedulerFromModel(t_init, model.agent_channel_table, model.world_channel_table)
        # create agent
        if i in model.logged:
            # make logger here
            names, loggingfcn = model.logged[i]
            agents.append( model.LoggedAgentType(state_names, scheduler, simulator, LoggerNode(names, loggingfcn)) )
        else:
            agents.append( model.AgentType(state_names, scheduler, simulator) )
    return agents