Skip to content

fizruk/free-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

free-agent

Build Status

This package provides a general framework for multi agent systems. Agent-environment interface is implemented using free monads.

About this project

NOTE: the project has been stale for quite a while since I didn't have much time to invest into it.

free-agent is a proof-of-concept for developing multi-agent systems in Haskell using so called "free monads". I would consider this to be a relatively low-level (logically speaking) platform for designing MAS, since it does not implement high-level logic stuff (like BDI-model).

I apologize for the terrible lack of documentation, this was one of my early projects :( I might come back at this project later at least to update it with some proper docs.

The key idea of the project is to completely isolate agent program from the environment and general I/O by introducing an explicit agent interface (as a datatype). Having agent's program as an (almost) first-class value, we can:

  • execute agent in completely different environments without changing any agent's code;
  • reliably reproduce agent's actions (since all side effects are controlled by the environment); this is crucial for
    • reproducible test scenarios and
    • reproducing logged MAS actions;
  • automatically add debug-printing or distributed logging (see below);
  • shuffle, re-order or parallelise actions (for efficiency or to model unstable environments);
  • substitute agent's sensors/actors with different ones

In this project I also experimented with making a part of agent's internal logic accessible to the environment. Basically, I allow a single context (monad transformer) to be sliced in between agent's sensors and actions and visible to an executing environment. This tweak allows for the implementation of Behaviosites (but again, I don't have a working example).

Another interesting idea I have looked at is generic log & replay for MAS. Some work on that is available at https://github.com/fizruk/replay-free. The idea is to get a generic mechanism to record possibly branching (parallel/distributed) execution in terms of agent's sensors and actions. And then to replay those sensors and actions (possibly in a different environment). This generic mechanism could significantly improve debugging distributed behaviour, such as any possible deadlocks, races and such. The usage of replay-free boils down to two functions: record and replay. There's even an example with concurrent program being logged and replayed.

Haskell has been a great language for this project:

  • Haskell's purity allows us to enforce agent's interface, disallowing any extra effects;
  • Haskell's do-notation allows us to write agent programs cleanly and imperatively (Haskell is the best imperative language!);
  • Haskell's purity combined with expressive type system allows to write powerful and reusable code (e.g. reusable MAS algorithms);
  • free monads and Template Haskell allow to easily create agent's low-level eDSL for sensors/actors.

Some obvious drawbacks of the project are:

  • lack of documentation;
  • lack of powerful examples/demos with more sophisticated agents and envrionments;
  • incomplete feature set (need more prebuilt environments, interfaces, logging mechanisms, etc.).

Installation

You can simply clone this repository and run cabal-install:

$ git clone https://github.com/fizruk/free-agent.git
$ cd free-agent
$ cabal install

Documentation

Haddock documentation is available at http://fizruk.github.io/free-agent/docs/

How to run tests

cabal configure --enable-tests && cabal build && cabal test

Contributing

Contributions and bug reports are welcome!

Please feel free to contact me via GitHub or on the #haskell IRC channel on irc.freenode.net.

Nickolay Kudasov

About

A general framework for multi-agent systems. An agent-environment interface is abstracted with a free monad.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published