---
layout: post
title:  "Programming Multi-Agent Systems Using the Actor Model"
categories: programming,scala,ideas
---

This semester, one of the classes I'm taking is Computer Science 383: Robotics and Multi-Agent Systems. As we've learned more about programming multi-agent systems, such as agent-based simulations, I've began to wonder if the actor model used in languages like [Erlang](http://www.theerlangelist.com/2013/01/actors-in-erlangelixir.html) or Scala's [Akka](http://akka.io) library could be used for implementing multi-agent systems.

Multi-agent systems are software systems in which multiple agents, programs which autonomously make decisions to carry out a set of goals, interact in some manner, either cooperatively or competitively. Multi-agent systems are often used to simulate some real world system --- for example,as an ecosystem consisting of predator and prey agents or a market consisting of buyer and seller agents --- but they also have been used in scenarios where multiple software systems with differning responsibilities must work together to achieve some task.

The actors model is a model for concurrency which consists of a set of actors, entities that communicate through asynchronous message passing. Actors typically encapsulate state, and exist completely decoupled from one another, interacting only by anonymously sending and recieving messages. The model, therefore, is inherently concurrent, eliminating a number of the issues common to concurrent systems. As I mentioned above, actor-based programming is the primary concurrency model used in Erlang, and the popular Akka framework for Scala and Java provides a domain-specific language for implementing actors.

The behaviour of many classes of agent in multi-agent systems is often modeled using [finite state machines](http://en.wikipedia.org/wiki/Finite-state_machine) (FSM), where the agent transitions between specific states which dictate its' future actions. FSM-based behaviour is common in the actor model as well. For example, Akka provides a [module](http://doc.akka.io/docs/akka/snapshot/scala/fsm.html) for specifying the behaviour of actors as FSM, as does [Erlang](http://www.erlang.org/documentation/doc-4.8.2/doc/design_principles/fsm.html).

It seems to me that many multi-agent systems could be implemented using the actor model. Interactions between agents would be represented as messages that could be passed between actors, and behaviour would be modeled as as state transitions in a finite state machine. Frameworks such as Akka or actor-oriented languages such as Erlang might make the implementation of some multi-agent systems much easier by providing an existing platform on which to build agents. This would allow programmers simply to write agents for specific purposes without having to re-implement common functionality such as inter-agent communication. Furthermore, the inherent concurrency of the actor model would ensure that large systems consisting of many agents to take full advantage of the multi-threading capability of modern computing hardware, or even to run on a cluster or across multiple machines. When I begin working on my independant study for CS383 in a few weeks, I'll definitely take a further look into the potential of actor-based programming as a platform for implementing multi-agent systems.
Add actor-based multi-agent systems post
Add actor-based multi-agent systems post
