Skip to content

feat: Add Demand node. - #915

Merged
jetuk merged 1 commit into
mainfrom
demand-node
Nov 7, 2026
Merged

jetuk merged 1 commit into
mainfrom
demand-node

Conversation

@jetuk

@jetuk jetuk commented Oct 21, 2026

Copy link
Copy Markdown
Member

Adds a new Demand node that requires a max_flow attribute and therefore can produce a Deficit attribute in all cases.

Removes the Deficit attribute from Output node.

@Batch21 Batch21 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

couple of queries

Comment thread pywr-schema/src/nodes/core.rs Outdated
Comment on lines +43 to +47
/// A node that represents an input to the model, such as a river inflow or a reservoir inflow.
///
/// Flow is constrained by the `max_flow` and `min_flow` metrics. If `max_flow` is not specified,
/// the flow is unconstrained. If `min_flow` is not specified it defaults to 0.
/// the flow is unconstrained. If `min_flow` is not specified it defaults to 0. See
/// [`crate::nodes::DemandNode`] for an output with a required `max_flow` and a `Deficit` attribute.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment should be on the OutputNode not InputNode?

/// The deficit of the inflow compared to the `max_flow` metric.
Deficit,
/// The value of the `max_flow` metric. Requires `max_flow` to be defined.
MaxFlow,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if this attribute is referenced by another compoenent but max flow is not set then the model will pass the validation but error duing build. This is probably something the validation should capture.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@jetuk
jetuk requested a review from Batch21 October 23, 2026 14:45

@Batch21 Batch21 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks ready to go. I assume the merging main into this should fix the CI.

Adds a new Demand node that requires a max_flow attribute and
therefore can produce a Deficit attribute in all cases.

Removes the Deficit attribute from Output node.

# Conflicts:
#	Cargo.lock
@jetuk
jetuk merged commit f91c66c into main Nov 7, 2026
28 checks passed
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