maxwnewcomer / NWTOPT

NWTOPT is a hyperparameter optimization and tuning system for steady-state and transient models ran by MODFLOW-NWT
Creative Commons Zero v1.0 Universal
2 stars 0 forks source link

Multistep loss function #26

Open maxwnewcomer opened 2 years ago

maxwnewcomer commented 2 years ago

I remember @hwreeves-USGS, @rjhunt-usgs, and I had a conversation on a different loss function that would incorporate MB throughout each step, but I'm forgetting what the suggestion for change was. Would either of you be able to clarify what that idea was? It was something like an averaging of per-step MB I think...

hwreeves-USGS commented 2 years ago

@maxwnewcomer I thought I did this as a branch, but evidently I just worked locally: I will attach the file. I made a transient method in objective.py that used flopy to read the lst file and get the mass balance errors for all the timesteps. Then the loss function I tested was: sum(abs(incremental_percent_disrepancy)*length_stress_period)/sum(length_stress_period) objective_w_transient.txt

maxwnewcomer commented 2 years ago

@hwreeves-USGS do you think it would be beneficial to give a higher weight to the final mass balance or would that be unnecessary?

hwreeves-USGS commented 2 years ago

@maxwnewcomer I think unnecessary - at least for the test I was doing the final m.b. was really close to zero - I went to this approach because intermediate stress periods had large errors (both positive and negative). One suggestion that @rjhunt-usgs had was to just use the max m.b. error: maybe after the first couple of stress periods because sometimes there is some initial adjustement in the model that damps out.

maxwnewcomer commented 2 years ago

@boomchrisvanden First get updated master and create a new branch.

Then navigate to NWT_SUBMIT/NWTOPT_FILES/objective.py

In that file there is a method called getData(),

Create a new method getDataTransient() that takes in the same arguments to getData(). I will then provide you with a .list file that should be able to be read by that specific function.

@hwreeves-USGS has already written the function (file_with_function), you just need to implement it, check it for bugs, then test it on the provided list file.

To test, cd to the objective.py directory, then in the terminal type python3 The terminal will then start accepting live code. You can simply write import objective.getDataTransient as GDT then test by writing GDT(pathtolistfile ... whatever args) and hope that it returns the proper values.

This is only the first step in this issue's fix, but it should be a good start!