https://github.com/bartvlaatum/greenlightgym
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.5%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: BartvLaatum
- License: gpl-3.0
- Language: Python
- Default Branch: master
- Size: 65.2 MB
Statistics
- Stars: 17
- Watchers: 1
- Forks: 3
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
GreenLight-Gym: A Reinforcement Learning Environment for Greenhouse Crop Production Systems 🍅
UPDATE 09-05-2025
We released a new version named GreenLight-Gym2. This new repository is accompanied with an accepted paper for The 8th IFAC Conference on Sensing, Control and Automation Technologies for Agriculture. Find the new preprint here.
Summary
This repository is a reimplementation of the high-tech greenhouse model GreenLight in high-performance Cython code, wrapped by the Gymnasium environment. The environment is desinged to train reinforcement learning models for greenhouse crop production systems.
✏ author: Bart van Laatum
📧 e-mail: bart.vanlaatum@wur.nl

The software has a modular architecture allowing users to study different aspects of the greenhouse control problem. For instance, one can customize:
- Controllers
- Controllable inputs
- Weather trajectories
- GreenLight model parameters
- Observations spaces
- Constraints & rewards
Installation
To be able to compile Cython code, and convert it into a C script, Windows user are required to Miscrosoft Visual Studio with Desktop C++ development. Also see this blog post over here.
We recommend Python 3.11+ installation using Anaconda.
- Create a virtual conda environment as follows:
shell
conda create -n greenlight_gym python==3.11
and activate the environment:
shell
conda activate greenlight_gym
- Next, clone this repository
shell
git clone git@github.com:BartvLaatum/GreenLightGym.git
and navigate into this folder
shell
cd GreenLightGym
- Subsequently, install this project as an development package as follows:
shell
pip install -e .
This allows you to make modifications to the greenlight_gym codebase without having to reinstall the complete package.
- Since this the GreenLight model is built using Cython, one must recompile the Cython code. This can be achieved by:
shell
python setup.py build_cython_only --inplace
Which lets you rebuilt the GreenLight model without reinstalling the complete package again. Everytime you make adjustments to the Cython code one must recompile the code using the command.
Usage
The script experiments/train_agent.py creates the RL-agent, and training and evaluation environments.
Simultaneously the agents is being trained, while logging statistics to Weights and Biases (wandb). Make sure to have a wandb account.
In the configs/ folder you can define hyperparamters for your RL agents. Currently, only PPO is supported. Also, environment arguments can be specified.
Run commands for training RL algorithms
There are several bash scripts that facilitate training RL agents in a similar fashion to our article. Please note that the default hyperparameters make your training time quite long. You could try to start with training a single agent for a lower amount of timesteps.
1) Running the convergence analysis experiment for both the multiplicate and the additive reward function:
shell
. scripts/convergence_test.sh
2) Running the simulation study on the RL agents their sensitivity to penalty coefficients:
shell
. scripts/penalty_coeffs.sh
3) Running the benchmark simulation study for two RL agents using a multiplicate and an additive reward function:
shell
. scripts/benchmark.sh
4) Run the rule-based controller on the benchmark simulation using the following run command from the command line:
shell
python -m greenlight_gym.experiments.benchmark_rule_based ----env_id <GLEnv> --n_years <numberofyeartoeval> --train_or_test <trainortestset> --config_name <nameoftheenvconfig-file> --save
Post processing data from Weights and Biases
If you have run the convergence.sh script then you can extract some training statistics via the wandb API by running:
python -m greenlight_gym.post_processing.extract_wandb_data.py --entity <wanbdusername> --project <wandbprojectname> --group <wanbdgroupname>
Notebooks for visualisations
You can visualise some of the results with the notebooks from the visualisations/ folder.
1) rollout_reward.ipynb shows some statisitics on the training curves of the convergence.sh study.
2) controller_analysis.ipynb gives you a detailed analysis of controller performance and behaviour. Make sure to load in the right controller evaluation data, requires to have run benchmark.sh and the benchmark the rule-based controller.
3) penalty_coeffs.ipynb visualises the senstivity analysis of the penalty coefficients.
Future updates
Add environments based on setpoints instead of climate actuators.
Implement model-based control methods like Model Predictive Control (MPC).
Add different (off-policy) RL-models like SAC, DDPG, etc.
Include recurrent policies.
Citation
If you find GreenLight-Gym and/or its accompanying article useful, please cite GreenLight-Gym2.
Owner
- Login: BartvLaatum
- Kind: user
- Repositories: 1
- Profile: https://github.com/BartvLaatum
GitHub Events
Total
- Issues event: 1
- Watch event: 13
- Issue comment event: 3
- Push event: 4
- Pull request review event: 1
- Pull request event: 2
- Fork event: 4
Last Year
- Issues event: 1
- Watch event: 13
- Issue comment event: 3
- Push event: 4
- Pull request review event: 1
- Pull request event: 2
- Fork event: 4
Dependencies
- Cython ==0.29.35
- Farama-Notifications ==0.0.4
- GitPython ==3.1.34
- Jinja2 ==3.1.2
- Markdown ==3.4.4
- MarkupSafe ==2.1.3
- Pillow ==9.5.0
- PyYAML ==6.0.1
- Werkzeug ==2.3.7
- absl-py ==1.4.0
- appdirs ==1.4.4
- cachetools ==5.3.1
- certifi ==2023.7.22
- charset-normalizer ==3.2.0
- click ==8.1.7
- cloudpickle ==2.2.1
- colorama ==0.4.6
- contourpy ==1.1.0
- cycler ==0.11.0
- docker-pycreds ==0.4.0
- filelock ==3.12.3
- fonttools ==4.40.0
- gitdb ==4.0.10
- google-auth ==2.22.0
- google-auth-oauthlib ==1.0.0
- gprof2dot ==2022.7.29
- grpcio ==1.57.0
- gymnasium ==0.29.0
- idna ==3.4
- kiwisolver ==1.4.4
- matplotlib ==3.7.1
- mpmath ==1.3.0
- networkx ==3.1
- numpy ==1.24.3
- oauthlib ==3.2.2
- packaging ==23.1
- pandas ==2.0.3
- pathtools ==0.1.2
- protobuf ==4.24.2
- psutil ==5.9.5
- pyasn1 ==0.5.0
- pyasn1-modules ==0.3.0
- pyparsing ==3.1.0
- python-dateutil ==2.8.2
- pytz ==2023.3
- requests ==2.31.0
- requests-oauthlib ==1.3.1
- rsa ==4.9
- scipy ==1.11.0
- seaborn ==0.12.2
- sentry-sdk ==1.30.0
- setproctitle ==1.3.2
- six ==1.16.0
- smmap ==5.0.0
- stable-baselines3 ==2.1.0
- sympy ==1.12
- tensorboard ==2.14.0
- tensorboard-data-server ==0.7.1
- torch ==2.0.1
- typing_extensions ==4.7.1
- tzdata ==2023.3
- urllib3 ==1.26.16
- wandb ==0.15.9