# Path: pywr/core.py

# 
# Path: pywr/parameters/control_curves.py



import numpy as np
import pytest
from fixtures import three_storage_model
from pywr.core import Model, Input, Output, Link, Storage, AggregatedStorage
from pywr.parameters.control_curves import ControlCurveParameter
    from pywr.core import Scenario
    from pywr.parameters import ConstantScenarioParameter
    from pywr.core import Scenario
    from pywr.parameters import ConstantScenarioParameter
        agg_stg.get_max_volume()

    with pytest.raises(AttributeError):
        agg_stg.get_min_volume()


def test_aggregated_storage_control_curve(three_storage_model):
    """Test using a control curve based on an aggregate storage, rather than
    a single storage.
    """
    model = three_storage_model

    # create a new supply node
    inpt = Input(model, "Input 3", cost=-1000)
    inpt.connect(model.nodes["Output 0"])
    inpt.connect(model.nodes["Output 1"])
    inpt.connect(model.nodes["Output 2"])

    # limit the flow of the new node using a control curve on the aggregate storage
    curves = [0.5]  # 50%
    values = [0, 5]
    inpt.max_flow = ControlCurveParameter(
        model, model.nodes["Total Storage"], curves, values
    )

    # initial storage is > 50% so flow == 0
    model.step()
    np.testing.assert_allclose(inpt.flow, 0.0)

    # set initial storage to < 50%

# Path: pywr/core.py

# 
# Path: pywr/parameters/control_curves.py



# Path: tests/test_aggregated_nodes.py
import numpy as np
import pytest
from fixtures import three_storage_model
from pywr.core import Model, Input, Output, Link, Storage, AggregatedStorage
from pywr.parameters.control_curves import ControlCurveParameter
    from pywr.core import Scenario
    from pywr.parameters import ConstantScenarioParameter
    from pywr.core import Scenario
    from pywr.parameters import ConstantScenarioParameter

        agg_stg.get_max_volume()

    with pytest.raises(AttributeError):
        agg_stg.get_min_volume()


def test_aggregated_storage_control_curve(three_storage_model):
    """Test using a control curve based on an aggregate storage, rather than
    a single storage.
    """
    model = three_storage_model

    # create a new supply node
    inpt = Input(model, "Input 3", cost=-1000)
    inpt.connect(model.nodes["Output 0"])
    inpt.connect(model.nodes["Output 1"])
    inpt.connect(model.nodes["Output 2"])

    # limit the flow of the new node using a control curve on the aggregate storage
    curves = [0.5]  # 50%
    values = [0, 5]
    inpt.max_flow = ControlCurveParameter(
        model, model.nodes["Total Storage"], curves, values
    )

    # initial storage is > 50% so flow == 0
    model.step()
    np.testing.assert_allclose(inpt.flow, 0.0)

    # set initial storage to < 50%

    storages = [node for node in model.nodes if isinstance(node, Storage)]