Deltares / rtc-tools

The Deltares toolbox for control and optimization of environmental systems.
GNU Lesser General Public License v3.0
0 stars 2 forks source link

Allow infinities instead of NaN to signify "goal has no target at this time step" #1081

Open SGeeversAtVortech opened 5 years ago

SGeeversAtVortech commented 5 years ago

In GitLab by @vreeken on Nov 22, 2018, 20:37

Would it be a good idea to allow the use of +/- infinity to signify that no target_min/max should be set at certain time? Currently we only allow the use of NaN for this, but NaN is very annoying in that any comparisons/arithmetic fails (whereas it typically behaves nicely with infinity). Something simple as assert target_min.values <= target_max.values will fail if there are NaNs present.

As far as implementation is concerned, it seems that there are only some validation checks preventing the use of infinities as this[0]. The generated constraint+objective is exactly equal for both NaN and +/- inf. There might be other changes needed, but first I just want to check if anyone else thinks this might be worth supporting.

Somewhat related to #1079

[0] Two checks I could find was that target should be in the function range (which infinity obviously is not), and the monotonicity check.

SGeeversAtVortech commented 5 years ago

In GitLab by @jvande42b on Nov 23, 2018, 09:15

Coming from refactoring the LookupTable stuff, the first thing that comes to mind is that we need to do np.isfininte() instead of ~np.isnan() in __call__ and reverse_call().