Skip to content

odys.optimization.formulations.fixed_load

The fixed-load formulation. Fixed loads have no variables or constraints; their power injection is minus the summed demand. See Fixed loads on the Power balance formulation page.

Model formulation of fixed loads.

FixedLoadFormulation

Bases: Formulation

Fixed loads: inelastic demand that must be met, with no decision variables or constraints.

Source code in src/odys/optimization/formulations/fixed_load.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class FixedLoadFormulation(Formulation):
    """Fixed loads: inelastic demand that must be met, with no decision variables or constraints."""

    dimension = FIXED_LOAD
    entity_type = FixedLoad

    def __init__(self, fixed_loads: Sequence[FixedLoad], context: ModelContext) -> None:
        """Initialize with the fixed loads of the system.

        Args:
            fixed_loads: The fixed loads, at least one.
            context: The shared indexing of the problem.
        """
        super().__init__(fixed_loads, context)
        self.demand = context.profiles(LoadProfile, fixed_loads, self.coordinates, lambda profile: profile.values)

    @classmethod
    def build(cls, inputs: FormulationInputs) -> Self | None:
        """Return the formulation of the fixed loads, or None if there are none."""
        fixed_loads = inputs.of_type(FixedLoad)
        return cls(fixed_loads, inputs.context) if fixed_loads else None

    def power_injection(self) -> xr.DataArray:
        """Return minus the total fixed-load demand, per scenario and time."""
        injection: xr.DataArray = -self.demand.sum(FIXED_LOAD)
        return injection

    def dispatch(self, solution: xr.Dataset) -> None:
        """Return None: fixed loads have no decision variables, so no dispatch results."""

__init__(fixed_loads, context)

Initialize with the fixed loads of the system.

Parameters:

Name Type Description Default
fixed_loads Sequence[FixedLoad]

The fixed loads, at least one.

required
context ModelContext

The shared indexing of the problem.

required
Source code in src/odys/optimization/formulations/fixed_load.py
22
23
24
25
26
27
28
29
30
def __init__(self, fixed_loads: Sequence[FixedLoad], context: ModelContext) -> None:
    """Initialize with the fixed loads of the system.

    Args:
        fixed_loads: The fixed loads, at least one.
        context: The shared indexing of the problem.
    """
    super().__init__(fixed_loads, context)
    self.demand = context.profiles(LoadProfile, fixed_loads, self.coordinates, lambda profile: profile.values)

build(inputs) classmethod

Return the formulation of the fixed loads, or None if there are none.

Source code in src/odys/optimization/formulations/fixed_load.py
32
33
34
35
36
@classmethod
def build(cls, inputs: FormulationInputs) -> Self | None:
    """Return the formulation of the fixed loads, or None if there are none."""
    fixed_loads = inputs.of_type(FixedLoad)
    return cls(fixed_loads, inputs.context) if fixed_loads else None

dispatch(solution)

Return None: fixed loads have no decision variables, so no dispatch results.

Source code in src/odys/optimization/formulations/fixed_load.py
43
44
def dispatch(self, solution: xr.Dataset) -> None:
    """Return None: fixed loads have no decision variables, so no dispatch results."""

power_injection()

Return minus the total fixed-load demand, per scenario and time.

Source code in src/odys/optimization/formulations/fixed_load.py
38
39
40
41
def power_injection(self) -> xr.DataArray:
    """Return minus the total fixed-load demand, per scenario and time."""
    injection: xr.DataArray = -self.demand.sum(FIXED_LOAD)
    return injection