This repository contains the code for the examples of the Collektive DSL.
- Getting Started
In order to successfully download and execute the graphical experiments are needed:
- Internet connection;
- Git;
- Linux, macOS and Windows systems capable of running Java 17 (or higher);
- 4GB free space on disk (the system will automatically download its dependencies through Gradle);
- GPU with minimal OpenGL capabilities (OpenGL 2.0);
- 4GB RAM.
The project uses Gradle as a build tool,
and all the project dependencies are listed in the gradle\libs.versions.toml file.
- The experiments run in "batch mode" generate a lot of data, and the simulation may take a long time to finish (up to several hours) even with high-performance computers. We suggest running the experiments in "graphic mode" to have a better understanding of the simulation;
- On different monitor types with different resolutions, the graphical interface could appear a bit different;
- "batch mode" does not show any graphical interface;
- For GUI interpretation, please refer to the Simulation Graphical Interface section.
WARNING: re-running the whole experiment may take a very long time on a normal computer.
The simulation environment and graphical interface are provided by Alchemist Simulator. To understand how to interact with the GUI, please refer to the Alchemist documentation.
- Requires a Unix terminal (
(ba|z|fi)?sh) curlmust be installed- run:
# gradient example
curl https://raw.githubusercontent.com/collektive/collektive-examples/master/run-gradient.sh | bash - the repository is in your
Downloadsfolder for further inspection.
- Install a Gradle-compatible version of Java. Use the Gradle/Java compatibility matrix to learn which is the compatible version range. The Version of Gradle used in this experiment can be found in the gradle-wrapper.properties file located in the gradle/wrapper folder.
- Open a terminal
- Clone this repository on your pc with
git clone https://github.com/collektive/collektive-examples. - Move into the root folder with
cd collektive-examples - Depending on the platform, run the following command:
- Bash compatible (Linux, Mac OS X, Git Bash, Cygwin):
./gradlew run<ExperimentName>Graphic - Windows native (cmd.exe, Powershell):
gradlew.bat run<ExperimentName>Graphic
- Bash compatible (Linux, Mac OS X, Git Bash, Cygwin):
- Substitute
<ExperimentName>with the name of the experiment (in PascalCase) specified in the YAML simulation file. Or execute./gradlew tasksto view the list of available tasks.
NOTES:
- Due to Alchemist's limitations, the graphical interface will not appear if run on a docker container.
- The tasks in graphic mode will run the experiments with the default parameters.
To change the parameters of the experiments, you can modify the YAML files located in the src/main/yaml folder.
Each change in the parameters will result in a different setup and execution of the experiment.
For further information about the YAML structure, please refer to the Alchemist documentation.
WARNING: re-running the whole experiment may take a very long time on a normal computer.
To collect the data for the analysis and the charts, the experiments have to be run in "batch mode," which means that the experiments are run without the graphical interface, and with different combinations of parameters. Running the experiments in batch mode in a normal computer may take a very long time (e.g., days), depending on the available hardware. Moreover, be sure that the YAML file of the experiment you want to run in batch mode is properly configured with the desired parameters.
NOT YET SUPPORTED BY DEFAULT, WILL BE AVAILABLE SOON, but if you want to try it out, follow the steps below:
- Install Docker and docker-compose;
- Run
docker-compose upin the root folder of the repository: this will build the Docker images and run the containers needed to run the experiments. - From the
docker-compose.ymlfile, you can see that eight separate containers will be created, one for each experiment, and the data will be collected in thedatafolder. Note that thevolumesfield has to be updated to match your local environment.
- Install a Gradle-compatible version of Java.
Use the Gradle/Java compatibility matrix
to learn which is the compatible version range.
The Version of Gradle used in this experiment can be found in the
gradle-wrapper.propertiesfile located in thegradle/wrapperfolder. - Install the version of Python indicated in
.python-version(or usepyenv). - Launch either:
./gradlew runAllBatchon Linux, MacOS, or Windows if a bash-compatible shell is available;gradlew.bat runAllBatchon Windows cmd or Powershell;
- Once the experiment is finished, the results will be available in the
datafolder, if data extraction is properly configured in the YAML files.
NOT YET SUPPORTED BY DEFAULT, WILL BE AVAILABLE SOON, but if you want to try it out, follow the steps below:
WARNING: depending on the amount of data collected, this process may take a long time.
- Make sure you have Python 3.10 or higher installed.
- The data folder structure should be the following:
collektive-examples/ ├── data/ │ ├── <experiment-name>/ │ ├── <experiment-name2>/ │ └── .../
- Install the required Python packages by running:
pip install --upgrade pip pip install -r requirements.txt
- Run the script to process the data and generate the charts (this process may take some time):
python plotter_all.py
- The charts will be generated in the
chartsfolder. - If you want to regenerate the charts, you can run the script again.