CropGym update for new PCSE version#9
Open
hbja wants to merge 1 commit into
Open
Conversation
* 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 <>
michielkallenberg
approved these changes
May 10, 2024
| # Store the crop/soil/site parameters | ||
| self._crop_params = crop_parameters | ||
| self._site_params = site_parameters | ||
| self._site_params_ = site_parameters |
Collaborator
Author
There was a problem hiding this comment.
Ah we can remove that. Remnants from the random initialization :)
| @@ -0,0 +1,46 @@ | |||
| # -*- coding: utf-8 -*- | |||
Contributor
There was a problem hiding this comment.
Do we want this is a hard copy? Or just use the one from pcse and then modify within cropgym?
Collaborator
Author
There was a problem hiding this comment.
That's also an option. I don't mind either!
Contributor
There was a problem hiding this comment.
Can't we use the once from PCSE?
Collaborator
Author
There was a problem hiding this comment.
I'm not sure if PCSE provides these yaml files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.