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

Node activity #425

Merged
merged 9 commits into from
Jul 17, 2023
Merged

Node activity #425

merged 9 commits into from
Jul 17, 2023

Conversation

SouthEndMusic
Copy link
Collaborator

Fixes #98.

Here are some design decisions I came across:

  • Basin and DiscreteControl nodes are always active
  • Should terminals be active/inactive? Now yes for completeness
  • Should the integral term keep integrating when a PID control node is inactive? Now yes
  • Should a pump/weir under the control of a PID controller that is inactive always be off?

@SouthEndMusic SouthEndMusic requested a review from visr July 13, 2023 14:32
@SouthEndMusic SouthEndMusic marked this pull request as draft July 13, 2023 14:32
@visr
Copy link
Member

visr commented Jul 13, 2023

  • Basin and DiscreteControl nodes are always active
    • That's fine
  • Should terminals be active/inactive? Now yes for completeness
    • Not sure what effect it would have? They don't do anything other than receiving flow. Would they throw and error on receiving flow?
  • Should the integral term keep integrating when a PID control node is inactive? Now yes
    • Not sure, it sounds more logical if it would be set to 0 on deactivation and stay 0. But probably not very important.
  • Should a pump/weir under the control of a PID controller that is inactive always be off?
    • Perhaps just retain their last value? What does it mean for a weir to be off?

@gijsber
Copy link
Contributor

gijsber commented Jul 14, 2023

Basin and DiscreteControl nodes are always active

yes
Should terminals be active/inactive? Now yes for completeness
always active
Should the integral term keep integrating when a PID control node is inactive? Now yes
If the node being controlled is turned inactive, the associated (PID) control node can be inactive as well.
Should a pump/weir under the control of a PID controller that is inactive always be off?
I would think that the pump/weir has been set inactive and hence the PID controller becomes inactive. Once it activates I agree with Martijn that retaining the last value is most likely the best way

@@ -22,11 +22,14 @@ end

function LinearResistance(db::DB, config::Config)::LinearResistance
static = load_structvector(db, config, LinearResistanceStaticV1)
return LinearResistance(static.node_id, static.resistance)
active = coalesce.(static.active, true)
Copy link
Member

Choose a reason for hiding this comment

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

Do I understand correctly that the 3 valid values for "active" are, true, false, and missing? Would it be easier to disallow missing and default to true?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that can be handled in the parse_static function of #424.

@@ -126,6 +126,7 @@ of Vectors or Arrow Primitives, and is added to avoid type instabilities.
"""
struct TabulatedRatingCurve{C} <: AbstractParameterNode
node_id::Vector{Int}
active::BitVector
Copy link
Member

Choose a reason for hiding this comment

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

Shall we simply use Vector{Bool} here? It uses more memory, but should be faster to read and write, since bits don't need to be shuffled around.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was talking with Bart about this, the reason I suggested BitVector is that he was using a function that returned a BitVector, so no conversion step was necessary that way.

But if you think Vector{Bool} is faster, we should probably switch.

Copy link
Member

Choose a reason for hiding this comment

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

Ok let's keep it the same. If it causes issues or shows up in profiling we can switch later.

Apparently the performance is not so clear cut: https://discourse.julialang.org/t/bitvector-vs-vector-bool-as-default-on-comparison-operations/49431

@SouthEndMusic SouthEndMusic marked this pull request as ready for review July 14, 2023 09:36
Copy link
Member

@visr visr left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Two things are still needed, some tests and not supporting missing active columns. But we can do that after #424 as you mention, or create a separate issue.

@SouthEndMusic
Copy link
Collaborator Author

Looks good to me!

Two things are still needed, some tests and not supporting missing active columns. But we can do that after #424 as you mention, or create a separate issue.

I'm not sure what precisely you mean by not supporting missing active columns, or is that now fixed?

@SouthEndMusic SouthEndMusic merged commit 9de83a8 into main Jul 17, 2023
18 checks passed
@SouthEndMusic SouthEndMusic deleted the Node_activity branch July 17, 2023 05:17
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.

Add "active" column to node type static tables
4 participants