Python multi agent system

aiomas – A library for multi-agent systems and RPC based on asyncio

aiomas is a new, asyncio based library that helps you with creating distributed multi-agent systems. It allows different clocks (real-time, coupled to simulations, …) and different codecs (MsgPack, JSON ) to be used. You can also just use the lower level abstractions for RPC or message based request-reply channels.

I started the development in December 2014 and OFFIS , the institute I’m working at, now kindly allowed me to release it as OSS (licensed under the MIT license).

What? But why?

Multi-agent systems are a thing in many scientific institutes, including OFFIS . In particular, my colleagues and I want to create a multi-agent system for managing dynamic virtual power plants in our current project Dynamic VPP (German link).

A very common tool (at least in science) for writing multi-agent systems is JADE . However, most people I know don’t really like working with JADE (yes, that’s an euphemism).

I also didn’t find a modern, well documented and easy-to-use Python library for the job. So I asked my self: “How hard would it be to create one on my own?”

Being one of the maintainers of the discrete-event simulation ( DES ) library SimPy, I already have some experience with event-based and asynchronous programming. Multi-agent systems are relatively similar to DES , so I thought I should give it a try.

I also wanted to get to know asyncio. I’ve never worked with it before but its concepts looked very similar to the ones we’ve been using in SimPy for years, so building a library for multi-agent systems on top of asyncio was a perfect project to learn something new.

How do I use it?

The basic idea behind aiomas is that agents should be plain Python classes. Methods that perform asynchronous operations (like sending messages to other agents) should be coroutines. Agents should be able to call methods that other agents expose. It should also be easy to distribute agents over multiple CPU cores or machines. But you, as the user, shouldn’t bothered with setting up sockets or implementing transports, protocols and other low-level stuff.

aiomas is still in a relatively early stage of development. What’s already there seems to work quite nicely, though.

Here is a simple example how it currently looks like:

>>> import asyncio >>> import aiomas >>> >>> class TestAgent(aiomas.Agent): . def __init__(self, container, name): . super().__init__(container, name) . print('Ohai, I am %s' % name) . . @asyncio.coroutine . def run(self, addr): . """The agent's "main" function.""" . remote_agent = yield from self.container.connect(addr) . ret = yield from remote_agent.service(42) . print('%s got %s from %s' % (self.name, ret, addr)) . . @aiomas.expose . def service(self, value): . """Exposed function that can be called by remote agents.""" . return value >>> >>> # A Container is the home for a number of agents. >>> c = aiomas.Container(('localhost', 5555)) >>> agents = [c.spawn(TestAgent) for i in range(2)] Ohai, I am agent://localhost:5555/0 Ohai, I am agent://localhost:5555/1 >>> >>> # Run agent 0 and let it call a method from agent 1 >>> loop = asyncio.get_event_loop() >>> loop.run_until_complete(agents[0].run('agent://localhost:5555/1')) agent://localhost:5555/0 got 42 from agent://localhost:5555/1 >>> >>> c.shutdown() 

What’s the list of features?

aiomas just puts three layers of abstraction around raw TCP / unix domain sockets provided by asyncio:

Request-reply channel: The channel layer is the basis for the rpc layer. It sends JSON or MsgPack encoded byte strings over TCP or unix domain sockets. It also maps replies (of success or failure) to their corresponding request. RPC :

Читайте также:  Unknown class type java

The rpc layer implements remote procedure calls which let you call methods on remote objects nearly as if they were normal objects:

Instead of ret = obj.meth(arg) you write ret = yield from obj.meth(arg) .

Agents and agent containers:

The top-layer provides a simple base class for your own agents. All agents live in a container.

Containers take care of creating agents and performing the communication between them.

The container provides a clock for the agents. This clock can either be synchronized with the real (wall-clock) time or be set by an external process (e.g., other simulators).

Although you usually want to use the agent layer, it is perfectly okay to only use the rpc or channel layer.

What’s comming next?

Some ideas for future releases:

  • SSL / TLS support for TCP sockets
  • Optional automatic re-connect after connection loss
  • Helper for binding a socket to a random free port
  • Implement a queue based transport that agents within a single container can use instead of a TCP connection.

Installation

aiomas requires Python >= 3.4, msgpack-python and arrow (it may also run on Python 3.3 with the asyncio package, but this is untested).

Install aiomas via pip by running:

The development happens on bitbucket. There’s no mailing list or IRC channel yet, so just create an issue for your feedback, send me an email, or leave me a tweet.

© 2007, Stefan Scherfke. All Rights Reserved. Impressum.

Powered by Pelican, made with love and Python.

Источник

Python Agent DEvelopment framework¶

PADE is a framework for development, execution and management of multi-agent systems environments of distributed computation.

Читайте также:  Abstract factory pattern php

PADE is 100% written in Python language and uses the Twisted libraries for implementing the communication between the network nodes.

PADE is open-source under MIT licence terms and is developed by Smart Grids Group (GREI) in Department of Electrical Engineering by Federal University of Ceará, Brazil.

Any one who want to contribute with PADE project is welcome to do so. You can download, execute, test and send us feedback about PADE functionalities.

PADE is simple!¶

# agent_example_1.py # A simple hello agent in PADE! from pade.misc.utility import display_message, start_loop from pade.core.agent import Agent from pade.acl.aid import AID from sys import argv class AgenteHelloWorld(Agent): def __init__(self, aid): super(AgenteHelloWorld, self).__init__(aid=aid) display_message(self.aid.localname, 'Hello World!') if __name__ == '__main__': agents_per_process = 3 c = 0 agents = list() for i in range(agents_per_process): port = int(argv[1]) + c agent_name = 'agent_hello_<>@localhost:<>'.format(port, port) agente_hello = AgenteHelloWorld(AID(name=agent_name)) agents.append(agente_hello) c += 1000 start_loop(agents) 

In this example file (wich is in PADE github repository in the example folder) is possible to visualize three well defined sessions.

The first session has the necessary PADE classes imports

In the second session is a class who uses the super PADE class Agent, where the main agent attributions are defined.

In the third session the procedures to launch agents in PADE run time are defined.

If you want to know more about PADE framework, you can follow the steps described hear: Hello World .

It’s easy to install¶

For install PADE just execute the following command in a unix-based terminal window:

$ pip install pade $ pade start-runtime --port 20000 agent_example_1.py

You can see more about installing PADE hear: Installation Process .

Functionalities¶

The PADE framework was developed with automation systems in mind. So, PADE has the following functionalities in its library fo multi-agent systems development:

Object Orientation Abstraction for build agents and its behaviours using object orientation concepts. Run time execution It’s a module to initialize the agents execution enviroment written 100% in Python language. FIPA-ACL messages It’s a module to build and handle messages in FIPA-ACL standard. Filtering Messages Filter functionalities to multiagent messages. FIPA protocols It’s a module for implement FIPA standard protocols, like ContractNet, Request and Subscribe. Cyclic and Timed Behaviours Module for cyclic and timed behaviours. Data Base Module for Data Base interaction. Serialized objects exchange It’s possible to send serialized objects in the FIPA-ACL messages content.

In addition to these features, PADE is easy to install and configure, multiplatform, and can be installed and used on embedded hardware that runs Linux operating system such as Raspberry Pi and BeagleBone Black as well as Windows operating system

User Guide¶

  • Installation Process
    • Installing PADE using PIP
    • Installing PADE using Github
    • PADE in a Python Virtual Environment
    • Running Timed agents in PADE
    • Mensagens FIPA-ACL no PADE
    • Enviando uma mensagem com PADE
    • Mensagem no padrão FIPA-ACL
    • Mensagem no padrão XML
    • Receinving FIPA-ACL messages with PADE framework
    • How to use the method call_later()
    • Enviando objetos serializados com pickle
    • Recebendo objetos serializados com pickle
    • How to filter messages usinf filters module.
    • FIPA-Request
    • FIPA-Contract-Net
    • FIPA-Subscribe
    • Características do PADE 1.0
    • Pacote core
    • Pacote misc

    Источник

    Saved searches

    Use saved searches to filter your results more quickly

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

    multi-agent-systems

    Here are 107 public repositories matching this topic.

    camel-ai / camel

    🐫 CAMEL: Communicative Agents for “Mind” Exploration of Large Scale Language Model Society

    atb033 / multi_agent_path_planning

    Python implementation of a bunch of multi-robot path-planning algorithms.

    instadeepai / Mava

    🦁 A library of multi-agent reinforcement learning systems and components

    DerrickXuNu / OpenCOOD

    [ICRA 2022] An opensource framework for cooperative detection. Official implementation for OPV2V.

    minqi / learning-to-communicate-pytorch

    Learning to Communicate with Deep Multi-Agent Reinforcement Learning in PyTorch

    liuruoze / mini-AlphaStar

    (JAIR’2022) A mini-scale reproduction code of the AlphaStar program. Note: the original AlphaStar is the AI proposed by DeepMind to play StarCraft II.

    semitable / robotic-warehouse

    Multi-Robot Warehouse (RWARE): A multi-agent reinforcement learning environment

    fetchai / agents-aea

    A framework for autonomous economic agent (AEA) development

    proroklab / VectorizedMultiAgentSimulator

    VMAS is a vectorized framework designed for efficient Multi-Agent Reinforcement Learning benchmarking. It is comprised of a vectorized 2D physics engine written in PyTorch and a set of challenging multi-robot scenarios. Additional scenarios can be implemented through a simple and modular interface.

    ArnaudFickinger / gym-multigrid

    Lightweight multi-agent gridworld Gym environment

    sw5park / LUISE

    LUI: Autonomous Collective Decision Making via Large Language Models

    NREL / PowerGridworld

    PowerGridworld provides users with a lightweight, modular, and customizable framework for creating power-systems-focused, multi-agent Gym environments that readily integrate with existing training frameworks for reinforcement learning (RL). https://arxiv.org/abs/2111.05969

    livey / scalable_maddpg

    scalable multi agents reinforcement learning

    erohkohl / mlsolver

    Modelling of multi-agent-system as Kripke structure and implementation of its knowledge-base with modal logic formulas.

    valory-xyz / open-aea

    A framework for open autonomous economic agent (AEA) development — no package vendor is prioritised over other package vendors

    valory-xyz / open-autonomy

    A framework for the creation of autonomous agent services.

    GT-RIPL / MultiAgentPerception

    Official source code to CVPR’20 paper, «When2com: Multi-Agent Perception via Communication Graph Grouping»

    CarsonScott / OpenAgent

    An agent library for systems of nested automata.

    sundw2014 / STLPlanning

    Path planning from STL (Signal Temporal Logic) specifications

    sunfanyunn / IMMA

    Official code for «Interaction Modeling with Multiplex Attention» (Neurips 2022)

    Improve this page

    Add a description, image, and links to the multi-agent-systems topic page so that developers can more easily learn about it.

    Add this topic to your repo

    To associate your repository with the multi-agent-systems topic, visit your repo’s landing page and select «manage topics.»

    Источник

Оцените статью