# PiecewiseLink Node

## General Description

The **PiecewiseLink node** is an extension of Node that represents a non-linear [Link](/waterstrategy/modeling-basics/node-types/water-transport/link-node.md) with a piece wise cost function. This object is intended to model situations where there is a benefit of supplying certain flow rates but beyond a fixed limit there is a change in (or zero) cost. [API Reference](https://pywr.github.io/pywr-docs/master/api/generated/pywr.nodes.PiecewiseLink.html).

This Node is implemented using a compound node structure like so:

```
        | Separate Domain         |
Output -> Sublink 0 -> Sub Output -> Input
       -> Sublink 1 ---^
       ...             |
       -> Sublink n ---|
```

This means routes do not directly traverse this node due to the separate domain in the middle. Instead several new routes are made for each of the sublinks and connections to the Output/Input node. The reason for this breaking of the route is to avoid an geometric increase in the number of routes when multiple PiecewiseLinks are present in the same route.

## Primary Attributes

<table><thead><tr><th width="180.33333333333331">Name</th><th width="318">Description</th><th>Required</th></tr></thead><tbody><tr><td>allocation penalty</td><td>The cost per unit flow via the node</td><td>Optional</td></tr><tr><td>max_flow</td><td>The maximum flow constraint on the node</td><td>Optional</td></tr><tr><td>min_flow</td><td>The minimum flow constraint on the node</td><td>Optional</td></tr></tbody></table>

## Examples

coming soon...


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://water-strategy.gitbook.io/waterstrategy/modeling-basics/node-types/water-transport/piecewiselink-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
