예제 #1
0
def demonstrate_generator_agent_use() -> AgentNetwork:
    # Start agent network server.
    agent_network = AgentNetwork()

    # Initialize agents by adding them to the agent network.
    default_sine_agent = agent_network.add_agent(name="Default Sine generator",
                                                 agentType=SineGeneratorAgent)

    # Custom parameters of the specified agentType can either be handed over as **kwargs
    # in the network instance's add_agent() method, or...
    custom_sine_agent = agent_network.add_agent(
        name="Custom Sine generator",
        agentType=SineGeneratorAgent,
        sfreq=75,
        sine_freq=np.pi,
    )
    # ... in a separate call of the agent instance's init_parameters() method.
    custom_sine_agent.init_parameters(amplitude=0.75, )

    monitor_agent = agent_network.add_agent(
        name="Showcase a default and a customized sine signal",
        agentType=MonitorAgent)

    # Interconnect agents by either way:
    # 1) by agent network.bind_agents(source, target).
    agent_network.bind_agents(default_sine_agent, monitor_agent)

    # 2) by the agent.bind_output().
    custom_sine_agent.bind_output(monitor_agent)

    # Set all agents' states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution
    return agent_network
예제 #2
0
def main():
    # start agent network server
    agentNetwork = AgentNetwork()
    # init agents
    gen_agent = agentNetwork.add_agent(agentType=DataStreamAgent)
    trainer_agent = agentNetwork.add_agent(agentType=Trainer)
    predictor_agent = agentNetwork.add_agent(agentType=Predictor)
    evaluator_agent = agentNetwork.add_agent(agentType=Evaluator)
    monitor_agent_1 = agentNetwork.add_agent(agentType=MonitorAgent)
    monitor_agent_2 = agentNetwork.add_agent(agentType=MonitorAgent)
    gen_agent.init_parameters(stream=SineGenerator(), pretrain_size=1000,
                              batch_size=1)
    trainer_agent.init_parameters(ml_model=HoeffdingTree())
    # connect agents : We can connect multiple agents to any particular agent
    # However the agent needs to implement handling multiple input types
    agentNetwork.bind_agents(gen_agent, trainer_agent)
    agentNetwork.bind_agents(gen_agent, predictor_agent)
    agentNetwork.bind_agents(trainer_agent, predictor_agent)
    agentNetwork.bind_agents(predictor_agent, evaluator_agent)
    agentNetwork.bind_agents(evaluator_agent, monitor_agent_1)
    agentNetwork.bind_agents(predictor_agent, monitor_agent_2)
    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #3
0
def test_simpleAgent(agentType, expected_monitor_results):
    #start agent network server
    agentNetwork = AgentNetwork(dashboard_modules=False)

    #init agents by adding into the agent network
    simple_agent = agentNetwork.add_agent(agentType=agentType)
    monitor_agent_1 = agentNetwork.add_agent(agentType=MonitorAgent)

    #shorten n wait loop time
    simple_agent.init_agent_loop(0.01)

    #connect agents
    agentNetwork.bind_agents(simple_agent, monitor_agent_1)

    # set all agents states to "Running"
    agentNetwork.set_running_state()
    time.sleep(test_timeout)

    # test to see if monitor agents have received the correct data
    assert str(
        monitor_agent_1.get_attr('memory')) == str(expected_monitor_results)

    # shutdown agent network
    agentNetwork.shutdown()
    time.sleep(3)
예제 #4
0
def demonstrate_generator_agent_use():
    # Start agent network server.
    agent_network = AgentNetwork()

    # Initialize agents by adding them to the agent network.
    gen_agent = agent_network.add_agent(agentType=NoisySineGeneratorAgent)
    # the buffer size controls the window size of the moving average filter
    fast_rolling_mean_agent = agent_network.add_agent(
        agentType=RollingMeanAgent, buffer_size=5)
    slow_rolling_mean_agent = agent_network.add_agent(
        agentType=RollingMeanAgent, buffer_size=10)

    monitor_agent = agent_network.add_agent(agentType=MonitorAgent)

    # bind agents
    agent_network.bind_agents(gen_agent, fast_rolling_mean_agent)
    agent_network.bind_agents(gen_agent, slow_rolling_mean_agent)
    agent_network.bind_agents(gen_agent, monitor_agent)
    agent_network.bind_agents(fast_rolling_mean_agent, monitor_agent)
    agent_network.bind_agents(slow_rolling_mean_agent, monitor_agent)

    # Set all agents' states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution
    return agent_network
예제 #5
0
def main():
    #start agent network server
    agentNetwork = AgentNetwork()

    #init agents by adding into the agent network
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)
    iiR_agent = agentNetwork.add_agent(agentType=iiRAgent)
    agentNetwork.bind_agents(iiR_agent, monitor_agent)
    iiR_agent.bind_output(monitor_agent)

    # there will be len(genTypes) generator agents with the specified type in genTypes
    # the first geerator agent (i.e., genAgents[0]) with signal type genTypes[0] will be connected to the filter

    genTypes = [SineGeneratorAgent, RectGeneratorAgent, ShockGeneratorAgent]
    genAgents = []
    for i in range(len(genTypes)):
        genAgents.append(agentNetwork.add_agent(agentType=genTypes[i]))
        agentNetwork.bind_agents(genAgents[i], monitor_agent)
        genAgents[i].bind_output(monitor_agent)

    agentNetwork.bind_agents(genAgents[0], iiR_agent)
    genAgents[0].bind_output(iiR_agent)

    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #6
0
def main():
    #start agent network server
    log_file = False
    agentNetwork = AgentNetwork(log_filename=log_file, dashboard_update_interval=1)

    #init agents by adding into the agent network
    #x_sensor_agent = agentNetwork.add_agent(name="X_acceleration",agentType= AccelerationSensorAgent).init_parameters(axis='y')
    #y_sensor_agent = agentNetwork.add_agent(name="Y_acceleration",agentType= AccelerationSensorAgent).init_parameters(axis='y')
    #z_sensor_agent = agentNetwork.add_agent(name="Z_acceleration",agentType= AccelerationSensorAgent).init_parameters(axis='z')
    sensor_buffer_size = 1
    acceleration_agent = agentNetwork.add_agent(name="XYZ_acceleration",buffer_size=1, agentType=AccelerationSensorAgent).init_parameters(axis='xyz')
    nozzle_sensor_agent = agentNetwork.add_agent(name="Nozzle_temperature",buffer_size=1, agentType= TemperatureSensorAgent).init_parameters(position='tool0')
    platform_sensor_agent = agentNetwork.add_agent(name="Platform_temperature",buffer_size=1, agentType= TemperatureSensorAgent).init_parameters(position='bed')

    sensor_agents = [acceleration_agent,nozzle_sensor_agent,platform_sensor_agent]

    #do something for all agents
    for sensor_agent in sensor_agents:
        #bind sensor agent to monitor
        monitor_agent = agentNetwork.add_agent(agentType= MonitorAgent,buffer_size=100)
        sensor_agent.bind_output(monitor_agent)

        #set loop interval for each sensor agent
        sensor_agent.init_agent_loop(loop_wait=1)

    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #7
0
def main():
    # start agent network server
    agentNetwork = AgentNetwork()

    # init agents
    gen_agent = agentNetwork.add_agent(agentType=RandomGeneratorAgent)
    plotting_image_agent = agentNetwork.add_agent(agentType=PlottingAgent,
                                                  name="Plot_image")
    plotting_plotly_agent = agentNetwork.add_agent(agentType=PlottingAgent,
                                                   name="Plot_plotly")
    plotting_mpld3_agent = agentNetwork.add_agent(agentType=PlottingAgent,
                                                  name="Plot_mpld3")
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)

    # init parameters
    plotting_image_agent.init_parameters(plot_mode="image")
    plotting_plotly_agent.init_parameters(plot_mode="plotly")
    plotting_mpld3_agent.init_parameters(plot_mode="mpld3")

    # bind agents
    agentNetwork.bind_agents(gen_agent, plotting_image_agent)
    agentNetwork.bind_agents(gen_agent, plotting_plotly_agent)
    agentNetwork.bind_agents(gen_agent, plotting_mpld3_agent)
    agentNetwork.bind_agents(plotting_image_agent, monitor_agent)
    agentNetwork.bind_agents(plotting_plotly_agent, monitor_agent)
    agentNetwork.bind_agents(plotting_mpld3_agent, monitor_agent)

    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #8
0
def main():
    # start agent network server
    agentNetwork = AgentNetwork()

    # init agents by adding into the agent network
    gen_agent = agentNetwork.add_agent(agentType=TimeSineGeneratorAgent)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)

    # provide custom parameters to the monitor agent
    xname, yname = "Time", "Y"
    monitor_agent.init_parameters(
        custom_plot_function=custom_create_monitor_graph,
        xname=xname,
        yname=yname,
        noise_level=0.1,
    )

    # bind agents
    agentNetwork.bind_agents(gen_agent, monitor_agent)

    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #9
0
def demonstrate_metrological_stream():

    # start agent network server
    agent_network = AgentNetwork(backend=Backend.MESA)

    # Initialize signal generating class outside of agent framework.
    signal = MetrologicalSineGenerator()

    # Initialize metrologically enabled agent taking name from signal source metadata.
    source_name = signal.metadata.metadata["device_id"]
    source_agent = agent_network.add_agent(
        name=source_name, agentType=MetrologicalSineGeneratorAgent)
    source_agent.init_parameters(signal)

    # Initialize metrologically enabled plotting agent.
    monitor_agent = agent_network.add_agent(
        "Metrological plot including measurement uncertainties",
        agentType=MetrologicalMonitorAgent,
        buffer_size=50,
    )

    # Bind agents.
    source_agent.bind_output(monitor_agent)

    # Set all agents states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution.
    return agent_network
예제 #10
0
def test_remove_agent():
    #start agent network server
    agentNetwork = AgentNetwork(dashboard_modules=False)

    #init agents by adding into the agent network
    dummy_agent1 = agentNetwork.add_agent(agentType= AgentMET4FOF)
    dummy_agent2 = agentNetwork.add_agent(agentType= AgentMET4FOF)
    dummy_agent3 = agentNetwork.add_agent(agentType= AgentMET4FOF)
    dummy_agent4 = agentNetwork.add_agent(agentType= AgentMET4FOF)

    agentNetwork.bind_agents(dummy_agent1, dummy_agent2)
    agentNetwork.bind_agents(dummy_agent1, dummy_agent3)
    agentNetwork.bind_agents(dummy_agent1, dummy_agent4)

    agentNetwork.bind_agents(dummy_agent4, dummy_agent2)
    agentNetwork.bind_agents(dummy_agent3, dummy_agent4)
    agentNetwork.bind_agents(dummy_agent2, dummy_agent4)

    agentNetwork.remove_agent(dummy_agent1)
    agentNetwork.remove_agent(dummy_agent2)
    agentNetwork.remove_agent(dummy_agent3)
    agentNetwork.remove_agent(dummy_agent4)
    time.sleep(2)
    assert len(agentNetwork.agents()) == 0
    agentNetwork.shutdown()
예제 #11
0
def main():
    # start agent network server
    agentNetwork = AgentNetwork(dashboard_modules=[
        examples.ZEMA_EMC.zema_datastream, examples.ZEMA_EMC.zema_agents
    ],
                                log_filename=False)
    # init agents by adding into the agent network
    datastream_agent = agentNetwork.add_agent(agentType=DataStreamAgent)
    train_test_split_agent = agentNetwork.add_agent(
        agentType=TrainTestSplitAgent)
    fft_bfc_agent = agentNetwork.add_agent(agentType=FFT_BFCAgent)
    pearson_fs_agent = agentNetwork.add_agent(
        agentType=Pearson_FeatureSelectionAgent)
    lda_agent = agentNetwork.add_agent(agentType=LDA_Agent)
    bayesianRidge_agent = agentNetwork.add_agent(agentType=Regression_Agent,
                                                 name="BayesianRidge_Agent")
    randomForest_agent = agentNetwork.add_agent(agentType=Regression_Agent,
                                                name="RandomForest_Agent")
    evaluator_agent = agentNetwork.add_agent(agentType=EvaluatorAgent)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)
    # init parameters
    # incremental training
    datastream_agent.init_parameters(stream=ZEMA_DataStream(),
                                     pretrain_size=1000,
                                     batch_size=250,
                                     loop_wait=10,
                                     randomize=True)
    # batch training
    # datastream_agent.init_parameters(stream=ZEMA_DataStream(),
    # pretrain_size=-1, randomize=True)
    # hold-out or prequential mode
    # train_test_split_agent.init_parameters(train_ratio=0.8) #hold-out
    train_test_split_agent.init_parameters(train_ratio=-1)  # prequential
    # init parameters for base models
    lda_agent.init_parameters()
    bayesianRidge_agent.init_parameters(regression_model="BayesianRidge")
    randomForest_agent.init_parameters(regression_model="RandomForest")
    # bind agents
    agentNetwork.bind_agents(datastream_agent, train_test_split_agent)
    agentNetwork.bind_agents(train_test_split_agent, fft_bfc_agent)
    agentNetwork.bind_agents(fft_bfc_agent, pearson_fs_agent)
    agentNetwork.bind_agents(pearson_fs_agent, lda_agent)
    agentNetwork.bind_agents(lda_agent, evaluator_agent)
    agentNetwork.bind_agents(pearson_fs_agent, bayesianRidge_agent)
    agentNetwork.bind_agents(bayesianRidge_agent, evaluator_agent)
    agentNetwork.bind_agents(pearson_fs_agent, randomForest_agent)
    agentNetwork.bind_agents(randomForest_agent, evaluator_agent)
    # bind to monitor agents
    agentNetwork.bind_agents(fft_bfc_agent, monitor_agent)
    agentNetwork.bind_agents(pearson_fs_agent, monitor_agent)
    agentNetwork.bind_agents(evaluator_agent, monitor_agent)
    # set running state
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #12
0
def main():
    agentNetwork = AgentNetwork(dashboard_extensions=Dashboard_ML_Experiment)

    ml_exp_name = "multiple"

    ML_Agent_pipelines_A = AgentPipeline(agentNetwork, [BNN_Model],
                                         hyperparameters=[[{
                                             "num_epochs": [500],
                                             "task": ["classification"],
                                             "architecture":
                                             [["d1", "d1"], ["d1", "d1", "d1"],
                                              ["d1", "d1", "d1", "d1"]]
                                         }]])
    ML_Agent_pipelines_B = AgentPipeline(
        agentNetwork, [StandardScaler], [BNN_Model],
        hyperparameters=[[],
                         [{
                             "num_epochs": [500],
                             "task": ["classification"],
                             "architecture": [["d1", "d1"], ["d1", "d1", "d1"],
                                              ["d1", "d1", "d1", "d1"]]
                         }]])

    #init
    datastream_agent = agentNetwork.add_agent(agentType=ML_DataStreamAgent)
    evaluation_agent = agentNetwork.add_agent(agentType=ML_EvaluatorAgent)

    datastream_agent.init_parameters(data_name="iris",
                                     x=datasets.load_iris().data,
                                     y=datasets.load_iris().target)
    evaluation_agent.init_parameters([f1_score, p_acc_unc, avg_unc],
                                     [{
                                         "average": 'micro'
                                     }, {}, {}],
                                     ML_exp=True)

    #setup ml experiment
    ml_experiment = ML_Experiment(
        datasets=[datastream_agent],
        pipelines=[ML_Agent_pipelines_A, ML_Agent_pipelines_B],
        evaluation=[evaluation_agent],
        name=ml_exp_name,
        train_mode="Kfold5")

    #optional: connect evaluation agent to monitor agent
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)
    evaluation_agent.bind_output(monitor_agent)

    #set to active running
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #13
0
def main():
    #initialise with dashboard ml experiments
    agentNetwork = AgentNetwork(dashboard_extensions=Dashboard_ML_Experiment)

    ml_exp_name = "multiple"

    kernel_iso = 1.0 * RBF([1.0])
    kernel_ani = 1.0 * RBF([1.0] * 4)

    ML_Agent_pipelines_A = AgentPipeline(agentNetwork,
                                         [GaussianProcessClassifier],
                                         hyperparameters=[[{
                                             "kernel": [kernel_iso]
                                         }]])
    ML_Agent_pipelines_B = AgentPipeline(agentNetwork, [StandardScaler],
                                         [GaussianProcessClassifier],
                                         hyperparameters=[[],
                                                          [{
                                                              "kernel":
                                                              [kernel_ani]
                                                          }]])

    #init
    datastream_agent = agentNetwork.add_agent(agentType=ML_DataStreamAgent)
    evaluation_agent = agentNetwork.add_agent(agentType=ML_EvaluatorAgent)

    datastream_agent.init_parameters(data_name="iris",
                                     x=datasets.load_iris().data,
                                     y=datasets.load_iris().target)
    evaluation_agent.init_parameters([f1_score], [{
        "average": 'micro'
    }],
                                     ML_exp=True)

    #setup ml experiment
    ml_experiment = ML_Experiment(
        datasets=[datastream_agent],
        pipelines=[ML_Agent_pipelines_A, ML_Agent_pipelines_B],
        evaluation=[evaluation_agent],
        name=ml_exp_name,
        train_mode="Kfold5")

    #optional: connect evaluation agent to monitor agent
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)
    evaluation_agent.bind_output(monitor_agent)

    #set to active running
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #14
0
def demonstrate_metrological_stream():
    """Demonstrate an agent network with two metrologically enabled agents

    The agents are defined as objects of the :class:`MetrologicalGeneratorAgent`
    class whose outputs are bound to a single monitor agent.

    The metrological agents generate signals from a sine wave and a multiwave generator
    source.

    Returns
    -------
    :class:`AgentNetwork`
        The initialized and running agent network object
    """
    # start agent network server
    agent_network = AgentNetwork(dashboard_modules=True)

    # Initialize metrologically enabled agent with a multiwave (sum of cosines)
    # generator as signal source taking name from signal source metadata.
    signal_multiwave = MetrologicalMultiWaveGenerator(quantity_names="Voltage",
                                                      quantity_units="V")
    source_name_multiwave = signal_multiwave.metadata.metadata["device_id"]
    source_agent_multiwave = agent_network.add_agent(
        name=source_name_multiwave, agentType=MetrologicalGeneratorAgent)
    source_agent_multiwave.init_parameters(signal=signal_multiwave)

    # Initialize second metrologically enabled agent with a sine generator as signal
    # source taking name from signal source metadata.
    signal_sine = MetrologicalSineGenerator()
    source_name_sine = signal_sine.metadata.metadata["device_id"]
    source_agent_sine = agent_network.add_agent(
        name=source_name_sine, agentType=MetrologicalGeneratorAgent)
    source_agent_sine.init_parameters(signal=signal_sine)

    # Initialize metrologically enabled plotting agent.
    monitor_agent = agent_network.add_agent(
        "MonitorAgent",
        agentType=MetrologicalMonitorAgent,
        buffer_size=50,
    )

    # Bind agents.
    source_agent_multiwave.bind_output(monitor_agent)
    source_agent_sine.bind_output(monitor_agent)

    # Set all agents states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution.
    return agent_network
예제 #15
0
def demonstrate_mesa_backend():

    # Start agent network and specify backend via the corresponding keyword parameter.
    _agent_network = AgentNetwork(backend=Backend.MESA)

    # Initialize agents by adding them to the agent network.
    sine_agent = _agent_network.add_agent(agentType=SineGeneratorAgent)
    monitor_agent = _agent_network.add_agent(agentType=MonitorAgent,
                                             buffer_size=200)
    sine_agent.bind_output(monitor_agent)

    # Set all agents states to "Running".
    _agent_network.set_running_state()

    return _agent_network
예제 #16
0
def main():
    # start agent network server
    agentNetwork = AgentNetwork()
    # init agents
    sub_agent = agentNetwork.add_agent(agentType=SubtractAgent)
    add_agent = agentNetwork.add_agent(agentType=AdditionAgent)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)
    # connect
    agentNetwork.bind_agents(sub_agent, monitor_agent)
    agentNetwork.bind_agents(add_agent, monitor_agent)
    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #17
0
def test_send_plot():
    # start agent network server
    agentNetwork = AgentNetwork(dashboard_modules=False)

    # init agents
    gen_agent = agentNetwork.add_agent(agentType=GeneratorAgent)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)

    agentNetwork.bind_agents(gen_agent, monitor_agent, channel="plot")

    gen_agent.dummy_send_graph(mode="plotly")
    time.sleep(3)

    assert monitor_agent.get_attr("plots")["GeneratorAgent_1"]

    agentNetwork.shutdown()
예제 #18
0
def test_send_plot():
    # start agent network server
    agentNetwork = AgentNetwork(dashboard_modules=False)

    # init agents
    gen_agent = agentNetwork.add_agent(agentType=GeneratorAgent)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)

    agentNetwork.bind_agents(gen_agent, monitor_agent)

    gen_agent.dummy_send_graph()
    time.sleep(3)

    assert monitor_agent.get_attr('plots')['GeneratorAgent_1']

    agentNetwork.shutdown()
def main():
    # start agent network server
    agentNetwork = AgentNetwork()
    # init agents
    gen_agent = agentNetwork.add_agent(agentType=MultiGeneratorAgent)
    multi_math_agent = agentNetwork.add_agent(agentType=MultiOutputMathAgent)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)
    # connect agents : We can connect multiple agents to any particular agent
    # However the agent needs to implement handling multiple inputs
    agentNetwork.bind_agents(gen_agent, multi_math_agent)
    agentNetwork.bind_agents(gen_agent, monitor_agent)
    agentNetwork.bind_agents(multi_math_agent, monitor_agent)
    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #20
0
def demonstrate_generator_agent_use():
    # Start agent network server.
    agent_network = AgentNetwork()

    # Initialize agents by adding them to the agent network.
    # The buffer size is set during initialisation
    gen_agent = agent_network.add_agent(
        agentType=BufferSineGeneratorAgent, buffer_size=5
    )
    monitor_agent = agent_network.add_agent(agentType=MonitorAgent)

    # bind agents
    agent_network.bind_agents(gen_agent, monitor_agent)

    # Set all agents' states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution
    return agent_network
예제 #21
0
def main():
    #connect to agent network server
    log_file = False
    agentNetwork = AgentNetwork(dashboard_modules=False,
                                log_filename=log_file,
                                ip_addr=host_ip)

    #init agents by adding into the agent network
    gen_agent = agentNetwork.add_agent(agentType=OpenSenecaAgent,
                                       ip_addr=local_ip,
                                       buffer_size=1)
    gen_agent.init_parameters(port_name='/dev/ttyUSB0')
    gen_agent.init_agent_loop(loop_wait=1)

    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
def main():
    #start agent network server
    agentNetwork = AgentNetwork()

    #init agents by adding into the agent network
    gen_agent = agentNetwork.add_agent(agentType=SineGeneratorAgent)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)

    #connect agents by either way:
    # 1) by agent network.bind_agents(source,target)
    agentNetwork.bind_agents(gen_agent, monitor_agent)

    # 2) by the agent.bind_output()
    gen_agent.bind_output(monitor_agent)

    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #23
0
def main():
    #start agent network server
    log_file = False
    agentNetwork = AgentNetwork(log_filename=log_file, dashboard_update_interval=1)

    #init agents by adding into the agent network
    sensor_agent = agentNetwork.add_agent(agentType = OpenSenecaAgent, buffer_size=1)
    monitor_agent = agentNetwork.add_agent(agentType = MonitorAgent, buffer_size=100)

    sensor_agent.init_parameters(port_name='/dev/ttyUSB0')
    sensor_agent.init_agent_loop(loop_wait=1)

    #connect the sensor agent to the monitor agent
    agentNetwork.bind_agents(sensor_agent, monitor_agent)

    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #24
0
def demonstrate_generator_agent_use():
    # Start agent network server.
    agent_network = AgentNetwork()

    # Initialize agents by adding them to the agent network.
    gen_agent = agent_network.add_agent(agentType=MultiGeneratorAgent)
    monitor_agent = agent_network.add_agent(agentType=MonitorAgent)

    # Interconnect agents by either way:
    # 1) by agent network.bind_agents(source, target).
    agent_network.bind_agents(gen_agent, monitor_agent)

    # 2) by the agent.bind_output().
    gen_agent.bind_output(monitor_agent)

    # Set all agents' states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution
    return agent_network
def test_zema_emc_lda_agents():
    np.random.seed(100)
    #start agent network server
    agentNetwork = AgentNetwork(dashboard_modules=False)

    #init agents by adding into the agent network
    datastream_agent = agentNetwork.add_agent(agentType=DataStreamAgent)
    train_test_split_agent = agentNetwork.add_agent(
        agentType=TrainTestSplitAgent)
    fft_bfc_agent = agentNetwork.add_agent(agentType=FFT_BFCAgent)
    pearson_fs_agent = agentNetwork.add_agent(
        agentType=Pearson_FeatureSelectionAgent)
    lda_agent = agentNetwork.add_agent(agentType=LDA_Agent)
    evaluator_agent = agentNetwork.add_agent(agentType=EvaluatorAgent)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent)

    #init parameters
    datastream_agent.init_parameters(ZEMA_DataStream())
    train_test_split_agent.init_parameters(train_ratio=0.8)

    #bind agents
    agentNetwork.bind_agents(datastream_agent, train_test_split_agent)
    agentNetwork.bind_agents(train_test_split_agent, fft_bfc_agent)
    agentNetwork.bind_agents(fft_bfc_agent, pearson_fs_agent)
    agentNetwork.bind_agents(pearson_fs_agent, lda_agent)
    agentNetwork.bind_agents(lda_agent, evaluator_agent)

    #bind to monitor agents
    agentNetwork.bind_agents(fft_bfc_agent, monitor_agent)
    agentNetwork.bind_agents(pearson_fs_agent, monitor_agent)
    agentNetwork.bind_agents(lda_agent, monitor_agent)
    agentNetwork.bind_agents(evaluator_agent, monitor_agent)

    #trigger datastream to send all at once
    datastream_agent.send_all_sample()

    time.sleep(timeout_wait)

    assert lda_agent.get_attr('lda_test_score') == 0.8204924543288324

    agentNetwork.shutdown()
예제 #26
0
def demonstrate_generator_agent_use():
    # Start agent network server.
    agent_network = AgentNetwork()

    # Initialize agents by adding them to the agent network.
    gen_agent = agent_network.add_agent(agentType=SineGeneratorAgent)
    gen_agent.init_parameters(nested_output=True, scaler=1.0)
    gen_agent_2 = agent_network.add_agent(agentType=SineGeneratorAgent)
    gen_agent_2.init_parameters(nested_output=False, scaler=2.0)

    monitor_agent = agent_network.add_agent(agentType=MonitorAgent)

    # Connect the agents
    agent_network.bind_agents(gen_agent, monitor_agent)
    agent_network.bind_agents(gen_agent_2, monitor_agent)

    # Set all agents' states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution
    return agent_network
예제 #27
0
def demonstrate_generator_agent_use():
    # Start agent network server.
    agent_network = AgentNetwork()

    # Initialize agents by adding them to the agent network.
    gen_agent_1 = agent_network.add_agent(agentType=SineGeneratorAgent)
    gen_agent_2 = agent_network.add_agent(agentType=SineGeneratorAgent)
    monitor_agent = agent_network.add_agent(agentType=MonitorAgent)

    # bind generator agents outputs to monitor
    agent_network.bind_agents(gen_agent_1, monitor_agent)
    agent_network.bind_agents(gen_agent_2, monitor_agent)

    # setup health coalition group
    agent_network.add_coalition("REDUNDANT_SENSORS",
                                [gen_agent_1, gen_agent_2, monitor_agent])

    # Set all agents' states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution
    return agent_network
예제 #28
0
def main():
    #start agent network server
    agentNetwork = AgentNetwork(dashboard_modules=[],
                                dashboard_update_interval=0.75,
                                log_filename='log_name.csv',
                                backend="mesa")

    #init agents by adding into the agent network
    gen_agent = agentNetwork.add_agent(agentType=SineGeneratorAgent,
                                       buffer_size=1,
                                       log_mode=False)
    monitor_agent = agentNetwork.add_agent(agentType=MonitorAgent,
                                           buffer_size=50,
                                           log_mode=False)
    monitor_agent_2 = agentNetwork.add_agent(agentType=MonitorAgent,
                                             buffer_size=10,
                                             log_mode=False)

    gen_agent.init_agent_loop(loop_wait=1)

    #This monitor agent will only store 'quantities' of the data keys into its memory
    monitor_agent.init_parameters(plot_filter=['quantities'])

    #connect agents by either way:
    # 1) by agent network.bind_agents(source,target)
    agentNetwork.bind_agents(gen_agent, monitor_agent)

    # 2) by the agent.bind_output()
    gen_agent.bind_output(monitor_agent)
    gen_agent.bind_output(monitor_agent_2)

    # set all agents states to "Running"
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #29
0
파일: coupled_ML.py 프로젝트: Met4FoF/Code
def main():
    global agentNetwork
    # start agent network
    agentNetwork = AgentNetwork()
    # add agents
    data_stream_agent_1 = agentNetwork.add_agent(agentType=DataStreamAgent)
    ml_agent_hoeffdingTree = agentNetwork.add_agent(agentType=ML_Model)
    ml_agent_neuralNets = agentNetwork.add_agent(agentType=ML_Model)
    monitor_agent_1 = agentNetwork.add_agent(agentType=MonitorAgent)
    # init parameters
    data_stream_agent_1.init_parameters(stream=WaveformGenerator(),
                                        pretrain_size=1000,
                                        batch_size=100)
    ml_agent_hoeffdingTree.init_parameters(ml_model=HoeffdingTreeClassifier())
    ml_agent_neuralNets.init_parameters(ml_model=NaiveBayes())
    # connect agents
    agentNetwork.bind_agents(data_stream_agent_1, ml_agent_hoeffdingTree)
    agentNetwork.bind_agents(data_stream_agent_1, ml_agent_neuralNets)
    agentNetwork.bind_agents(ml_agent_hoeffdingTree, monitor_agent_1)
    agentNetwork.bind_agents(ml_agent_neuralNets, monitor_agent_1)
    agentNetwork.set_running_state()

    # allow for shutting down the network after execution
    return agentNetwork
예제 #30
0
def demonstrate_generator_agent_use():
    # Start agent network server.
    agent_network = AgentNetwork()

    # Initialize agents by adding them to the agent network.
    gen_agent: AgentMET4FOF = agent_network.add_agent(
        agentType=GaussianShockGeneratorAgent
    )
    # Here we apply the default settings we chose above.
    gen_agent.init_parameters()
    monitor_agent = agent_network.add_agent(agentType=MonitorAgent)

    # Interconnect agents by either way:
    # 1) by agent network.bind_agents(source, target).
    agent_network.bind_agents(gen_agent, monitor_agent)

    # 2) by the agent.bind_output().
    gen_agent.bind_output(monitor_agent)

    # Set all agents' states to "Running".
    agent_network.set_running_state()

    # Allow for shutting down the network after execution
    return agent_network