Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CropGym update for new PCSE version #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

hbja
Copy link
Collaborator

@hbja hbja commented May 10, 2024

Some changes from the development branches.
Removed some experimental features (random weather, random initial conditions, ACNO-MDPs, NUE, etc.).

Conversions between WOFOST and LINTUL still needs to be scrutinized, as the current WOFOST uses "WSO" as the storage organ, which breaks the current implementation of conversion. A quick hack has been made in the development branches, but breaks compatibility. A TODO is to make this conversion more robust.

* dev branch

* minor fix

* typo

* updated tests

* minor changes

* refactor: VariableRecoveryRate to its own wrapper

* refactor: reduced coupling for MeasureOrNot

* added and refactor: Added fertilization limit and tests. Reinstate _observation for now, need to decouple from eval.py.

* added and refactor: Added fertilization limit and tests. Reinstate _observation for now, need to decouple from eval.py.

* added: test constraints, fertilization limit

* minor fix

* update: test CI, new SB3 2.1.0 breaking unit test

* update: minor fixes

* added: financial reward function based on DT deployment; WIP

* fix: deployment cost faulty

* added: Lithuanian soil params, and checker for config files

* forgot to add config files in previous commit :)

* CropGym now supports simulations through multiple years. Requires tests and more polishing.

* backwards compatibility

* minor fix

* ANE reward working. Added tests.

* added: VecNormalize wrapper for overriding "measure" normalization

* Now agent can pay lower cost for a noisy measurement. Added some tests.

* Added and refactor: Nitrogen budget, specify amount with args

* Added dependency to RLlib :) still some TODO's for callbacks and obs and reward normalization

* Minor CI dependency fix

* Minor CI dependency fix?

* Hmm minor CI dependency fix?

* Currently in dependency hell

* Out of hell :) checkpoint. Added location arg and prep for RLlib callbacks.

* added: function to generate agromanagement dict, towards replacing "replace_years"

* Callbacks with rllib are operational!

* added memory algorithms: PosMLP, IndRNN, DiffNC, S4D. Restructured train()

* reduce coupling in train()

* corrected normalization in sb3 vecenvs, slightly modified train()

* Checkpoint, norm still needs some work. Refactored measure index init in sb3.

* fun under the RAIN

* histograms

* add wofost results lt

* Added: evaluate agent script, changed measure graph eval, possibility for no weather observations, new agent for ACNO-MDPs are WIP.

* Implemented in-house normalization with fixed mean and std. Added 'observation masks'; still need to test with weather. Added A2C agent. Tuned RPPO and A2C agents.

* Test CI installation failed?

* WIP; normalization improvements

* normalization OK

* fix CI

* added: different costs of measuring

* fix one of the failing tests

* added start_type choice to allow sowing or emergence

* small refactoring and added some fixed normalization values

* fix small lint error

* weather obs, mask, and normalization works with custom feature extractor

* added option to randomize initial conditions for every reset() call and also added tests

* fixed the plotting funny line behaviour

* fixed crop parameters

* changed NL crop variety/parameters

* changed reward normalization, added cost multiplier and modified some graphs

* checkpoint, added non-selective measuring

* non-selective measuring working

* forgot to update tests lol

* refactor plotter functions

* Added box plots for measurement freq, changed DEP reward.

* refactor winterwheat.py, include eval in previous commit

* fixed DEP reward function bug and tidied up the new plots a bit

* overcompensated the fix lol

* FOUND AND FIXED BUG...

* put random in info dict and log pickle file for figure to comet_ml

* use np_random for random generator

* recode all match case into if else

* fix import

* add model asset log and rename for comet models

* add tag and rename for comet

* add tag and rename for comet

* fix logging asset in comet

* various improvements: fix simulation end, log measure probabilities, fixed random variable, added scatter plot

* :)

* :)))

* ylim edit

* plot edit and comet_ml logging

* adjusted prob plots for measure_all

* prob ylim

* normalization update

* name update

* fix prob indexing

* no measure fix

* For WOFOST. Test fails; need to look into CERES.

* Getting around rate calculation by modifying Engine()

* Fixed bug in run()

* Temporary way of sending signal. TODO: modify _apply_action() under Engine

* Add "END" reward function. TODO: make unit test and test behavior

* Add "ENY" reward function. TODO: make unit test and test behavior

* Added tests; fixed var conversion bug

* Added NUE reward and calculation of NUE

* Refactored how the reward object is called

* Added NUE test and refactored several processes (conversion TWSO, step() and rewards)

* Refactor: agromanagement replace year more robust now

* For test pass

* Added 2 rewards from literature, NUP and HAR

* Added DNU reward; dense NUE reward based on N growth in storage organs. Accordingly, added daily deposition estimation function. Added tests.

* Added FIN reward, rewards based on profit. Appended profit in step info to enable profit evaluations.

* NUE now logged by every reward function in step info

* Added random initial conditions for different soil layers.

* NUE properly logged for every reward function

* QoL updates

* Updated eval for trained agents

* Implemented functions to convert LARS-WG generated weather into CSV readable by PCSE

* Enable training with random weather and testing with NASA power weather

* Multiprocessing with SB3 supported; a few hacks to the magic methods in PCSE required. Also fixed tests.

* Fixed directory pointer in one of the unit tests

* Changed some rewards and tests

* Fixed critical bug in zero N storage for reward functions relying on relative reward.

* Import error :)

* Removed experimental features for checkout to master

* tidying up

* temporarily comment out CERES and model assertions. TODO: Look into CERES.

* Reinstated lintul conversions. TODO: make conversions more robust

* Reinstated lintul conversions. TODO: make conversions more robust

* Test

* Once more

---------

Co-authored-by: Michiel Kallenberg <>
self._location = location
self._timestep = timestep

# Store the crop/soil/site parameters
self._crop_params = crop_parameters
self._site_params = site_parameters
self._site_params_ = site_parameters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah we can remove that. Remnants from the random initialization :)

@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this is a hard copy? Or just use the one from pcse and then modify within cropgym?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also an option. I don't mind either!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use the once from PCSE?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if PCSE provides these yaml files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants