Skip to content

This repository contains the XC/Scala DSL and XC/Scala-Alchemist-based case study of the paper "Functional programming for distributed systems with XC" accepted at ECOOP'22.

License

Notifications You must be signed in to change notification settings

scafi/artifact-2021-ecoop-smartc

 
 

Repository files navigation

XC: Scala DSL implementation and case study

This repository contains the DSL and case study of the paper "Functional programming for distributed systems with XC" accepted at ECOOP'22.

Related repositories:

XC/Scala: an XC implementation as an internal Scala domain-specific language (DSL)

XC is a language for building adaptive and self-organizing collective behaviours in homogeneous distributed systems. The XC/Scala DSL implementation builds on the ScaFi aggregate programming language.

  • The source code of the implementation can be found under src/main/scala, package xc
  • The DSL implementation includes the components described in the paper, namely:
    • xc.NValues#NValue: data structure modelling a neighbouring value
    • xc.XCLang and xc.XCLangImpl: interface with the XC constructs and corresponding implementation class
    • XCLib: provides reusable functions (building blocks) upon XCLang; examples include collect, broadcast, distanceTo (see examples in the paper)
    • XCProgram: class to be specialised and implemented (main method) in order to define an XC program

Case study: SmartC

The case study SmartC consists of a network of devices in a smart city executing a self-organizing behaviour for warning detection. The simulation leverages the Alchemist simulator

  • XC/Scala program run by all the devices in the simulation: src/main/scala/xc/casestudy/CaseStudy.scala
  • YAML descriptor of the simulation (for the Alchemist simulator): src/main/yaml/casestudy.yml
  • Gradle files (build.gradle.kts, gradlew, gradlew.bat): they provide support for running a batch of simulation runs; plotting configuration and scripts (plots/plot.yml, plotter.py) and they provide support for building plots from data generated by simulations
  • Simulation results: /results/data-casestudy-f16c/*.txt (cf. Figure 11---see next for reproduction)

Reproduction

The reader can reproduce Figure 10 and Figure 11 from the paper.

Requirements:

  • For running the experiments and getting data, the only requirement is the ability to run the Gradle wrapper. Gradle runs on all major operating systems and requires only a Java JDK version 8 or higher to execute.
  • For plotting data, Python 3 is required, together with a few dependencies.
sudo apt install -y python3-pip
python3 -m pip install numpy matplotlib ruamel.yaml

Please follow these steps to reproduce Figure 10:

  1. ./gradlew hello: this would start the graphical simulator with one specific instance of the case study.
  2. Press p to start the simulation. The simulation would then proceed according to the configured phases, showing colours and effects to denote different values of the nodes or the environment.

Please follow these steps to reproduce Figure 11 (a note: current Figure 11 from the paper is not the correct one; the correct one is to be generated from the simulation data provided in the artifact under /results/data-casestudy-f16c/*.txt--i.e., please base the evaluation of reproducibility on the data files included in the artifact submission).

  1. ./gradlew casestudy: this would start 30 simulations runs for the case study.
    • Depending on the available memory, it may run some simulations in parallel.
    • On the expected time to finish: using 1 thread, it takes about 1h45m on the following computer configuration: Dell Xps with Intel Core i7-8550U CPU @ 1.80GHz x 8, 16Gb RAM, SSD disk.
  2. As the simulation batch goes on, it exports data under the data/ directory.
  3. Once the process finishes, with a message like "BUILD SUCCESSFUL in ", it is possible to compare the results. Use the following to check that the same results have been reproduced: colordiff -s --left-column -y -w -I "\#.*" --suppress-common-lines data/ results/data-casestudy-f16c/
  4. (Optional) You can also plot the data using the following: python3 ./plotter.py plots/plot.yml results/data-casestudy-f16c/ casestudy.* casestudy results/data-casestudy-f16c/imgs

License

See the LICENSE file.

Contacts

Roberto Casadei

About

This repository contains the XC/Scala DSL and XC/Scala-Alchemist-based case study of the paper "Functional programming for distributed systems with XC" accepted at ECOOP'22.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 56.0%
  • Python 23.1%
  • Java 10.3%
  • Kotlin 9.6%
  • Other 1.0%