scarlib

Scala Multi-Agent Deep Reinforcement Learning Framework

https://github.com/scarlib-group/scarlib

Science Score: 18.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.6%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Scala Multi-Agent Deep Reinforcement Learning Framework

Basic Info
  • Host: GitHub
  • Owner: ScaRLib-group
  • License: other
  • Language: Scala
  • Default Branch: main
  • Homepage:
  • Size: 383 KB
Statistics
  • Stars: 3
  • Watchers: 3
  • Forks: 1
  • Open Issues: 1
  • Releases: 0
Created over 3 years ago · Last pushed over 2 years ago
Metadata Files
Readme Changelog License Citation

README.md

ScaRLib -- Scala Multi-Agent Deep Reinforcement Learning Framework.

ScaRLib is a Scala library for defining collaborative learning systems with many agents, namely: CMARL systems. In particular, this library offers: - Centralized and decentralized learning modes - Typed DSL used for defining multi-agent learning tasks - Binding with state-of-the-art deep learning libraries (torch) - Integration with Alchemist (a large-scale multi-agent simulator) and ScaFi (an aggregate programming language) to define typical scenarios in collective adaptive system.

ScaRLib submodules

scarlib-modules

ScaRLib Core

The module scarlib-core implements all the abstractions that model the CMARL domain. The key element is the system, it might be of two different types: i) Centralized Training Decentralized Execution system (CTDESystem) ii) Decentralized Training Decentralized Execution system (DTDESystem). Basically, the system, is a collection of agents that interact within a shared environment and that are trained to optimize a global or local reward signal expressed by a reward function. Through this definition, we have mentioned the remaining concepts of the CMARL domain, therefore, to create an experiment, it is necessary to define six basic elements:

  • Action space: the set of actions each agent can perform, it could be easily defined extending the trait Action, for example: ```scala object ActionSpace { case object North extends Action case object South extends Action case object East extends Action case object West extends Action

    def toSeq() = Seq(North, South, East, West) } ```

  • State: represents all the information an agent knows about the Environment at a certain time, it must extend the trait State

  • Reward function: defines how good is an action given the state in which the agent is scala class SimpleRewardFunction() extends RewardFunction { def compute(currentState: State, action: Action, newState: State): Double = ??? }

  • Environment: provides feedback to the agent in the form of rewards or penalties for each action taken in a given state

  • Dataset: the storage for the experience accumulated over the time by the agents. The tool provides a simple buffered queue, if needed a user might implement his own dataset extending the trait ReplayBuffer

  • Agents: the number of agents involved in the experiment

Another pre-implemented component is the learning algorithm: the DQN. It approximates the Q-function used in the Q-Learning algorithm with a Neural Network to deal with the explosion of the state space. As with all the ML algorithms there are some hyper-parameters we can tune to optimize the learning, for that reason we provide a way to specify them in a single point: scala case class LearningConfiguration( epsilon: Decay[Double] = new ExponentialDecay(0.9, 0.1, 0.01), gamma: Double = 0.9, learningRate: Double = 0.0005, batchSize: Int = 32, updateEach: Int = 100, random: Random = new Random(1), dqnFactory: DQNAbstractFactory )

Alchemist - Scafi

The module alchemist-scafi provides the bindings with two state-of-the-art tools, namely: Scafi and Alchemist. The integration of these two tools is a game-changer because it introduces significant potential in ScaRLib: i) Scafi enables the usage of the Aggregate Programming paradigms to express collective behaviours for the agents ii) Alchemist enables the definition of large-scale sets of agents in complex distributed systems (e.g., swarm robotics).

The definition of an experiment does not change significantly, only two elements are added:

  • Alchemist simulation definition: basically it is a YAML file containing the description of the alchemist environment, for example: yaml incarnation: scafi network-model: type: ConnectWithinDistance parameters: [0.5] deployments: type: Grid parameters: [-5,-5,5,5,0.25,0.25] programs: - program: - time-distribution: 1 type: Event actions: - type: RunScafiProgram parameters: [program] - program: send
  • Aggregate program: the Scafi program that express the aggregate logic. For example, if we want express the state as the distances from the neighbours: scala val state = foldhoodPlus(Seq.empty)(_ ++ _)(Set(nbrVector)) ### DSL Core The module dsl-core allows for agile and flexible creation of CMARL training systems.
    Using a system like Scala, creating a typed DSL allows for capturing errors during compilation, rather than waiting for the actual system runs to intercept simple configuration errors. The exposed DSL is a simple facade to the abstractions shown in the scarlib-core module. An example of DSL usage is the following: scala val system = learningSystem { rewardFunction { new MyRewardFunction() } actions { MyAction.all} // action supported by the agent dataset { ReplayBuffer[State, Action](10000) } // shared memory agents { 50 } // select the number of agent environment { // select a specific environment "it.unibo.scarlib.experiments.myEnvironment" } }

How to use it:

The tool is published on Maven. To integrate it into your own repository, you need to add (using Gradle): kotlin implementation("io.github.davidedomini:scarlib-core:$version") implementation("io.github.davidedomini:dsl-core:$version")

Quick start-up

To speed up the process of developing new experiments, we have provided a template repository from which you can start, ensuring: - Necessary libraries are pre-imported - Docker is configured to run everything in a virtual environment

Contributors

Owner

  • Name: ScaRLib-group
  • Login: ScaRLib-group
  • Kind: organization

Citation (CITATION)

To cite ScaRLib in publications, please use:

Domini, D., Cavallari, F., Aguzzi, G., Viroli, M. (2023). ScaRLib: A Framework for Cooperative Many Agent Deep Reinforcement Learning in Scala.
In: Jongmans, SS., Lopes, A. (eds) Coordination Models and Languages. COORDINATION 2023. Lecture Notes in Computer Science, vol 13908. Springer, Cham.
https://doi.org/10.1007/978-3-031-35361-1_3

A BibTeX entry for LaTeX users is

@InProceedings{10.1007/978-3-031-35361-1_3,
    author={Domini, Davide
        and Cavallari, Filippo
        and Aguzzi, Gianluca
        and Viroli, Mirko},
    editor={Jongmans, Sung-Shik
        and Lopes, Ant{\'o}nia},
    title={ScaRLib: A Framework for Cooperative Many Agent Deep Reinforcement Learning in Scala},
    booktitle={Coordination Models and Languages},
    year={2023},
    publisher={Springer Nature Switzerland},
    address={Cham},
    pages={52-70},
    abstract={Multi Agent Reinforcement Learning (MARL) is an emerging field in machine learning where multiple agents learn, simultaneously and in a shared environment, how to optimise a global or local reward signal. MARL has gained significant interest in recent years due to its successful applications in various domains, such as robotics, IoT, and traffic control. Cooperative Many Agent Reinforcement Learning (CMARL) is a relevant subclass of MARL, where thousands of agents work together to achieve a common coordination goal.},
    isbn={978-3-031-35361-1}
}

GitHub Events

Total
  • Watch event: 2
  • Push event: 1
  • Pull request event: 2
Last Year
  • Watch event: 2
  • Push event: 1
  • Pull request event: 2

Issues and Pull Requests

Last synced: about 2 years ago

All Time
  • Total issues: 1
  • Total pull requests: 29
  • Average time to close issues: N/A
  • Average time to close pull requests: 2 days
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.07
  • Merged pull requests: 26
  • Bot issues: 1
  • Bot pull requests: 23
Past Year
  • Issues: 0
  • Pull requests: 4
  • Average time to close issues: N/A
  • Average time to close pull requests: 2 minutes
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.5
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • renovate[bot] (1)
Pull Request Authors
  • renovate[bot] (23)
  • davidedomini (7)
Top Labels
Issue Labels
Pull Request Labels
dependencies (23) released (2)

Dependencies

.github/workflows/pipeline.yml actions
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
build.gradle.kts maven
  • org.junit.jupiter:junit-jupiter-api 5.9.2 testImplementation
  • org.junit.jupiter:junit-jupiter-engine * testRuntimeOnly
dsl-core/build.gradle.kts maven
  • org.scala-lang:scala3-library_3 3.2.2 implementation
  • junit:junit 4.13.2 testImplementation
  • org.scalatest:scalatest_3 3.2.15 testImplementation
  • org.scalatestplus:junit-4-13_3 3.2.15.0 testImplementation
scarlib-core/build.gradle.kts maven
  • dev.scalapy:scalapy-core_2.13 0.5.3 implementation
  • org.scala-lang:scala3-library_3 3.2.2 implementation
  • junit:junit 4.13.2 testImplementation
  • org.scalatest:scalatest_3 3.2.15 testImplementation
  • org.scalatestplus:junit-4-13_3 3.2.15.0 testImplementation
alchemist-scafi/build.gradle.kts maven
package.json npm
  • semantic-release-preconfigured-conventional-commits 1.1.16 development