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 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
, packagexc
- The DSL implementation includes the components described in the paper, namely:
xc.NValues#NValue
: data structure modelling a neighbouring valuexc.XCLang
andxc.XCLangImpl
: interface with the XC constructs and corresponding implementation classXCLib
: provides reusable functions (building blocks) uponXCLang
; examples includecollect
,broadcast
,distanceTo
(see examples in the paper)XCProgram
: class to be specialised and implemented (main
method) in order to define an XC program
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)
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:
./gradlew hello
: this would start the graphical simulator with one specific instance of the case study.- 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).
./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.
- As the simulation batch goes on, it exports data under the
data/
directory. - 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/
- (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
See the LICENSE file.