flexops.costing.add_operating_cost

flexops.costing.add_operating_cost(*, block: Block, time_index: DatetimeIndex, dt_hours: float, tariff: DataFrame, electrical_power=None, fuel_power=None, dr_config: DRConfig | None = None, prorate: bool = True, consumption_estimate: dict[str, float] | None = None) → OperatingCostHandles

Build the facility’s whole in-objective operating cost — electric and fuel.

The umbrella over add_electricity_cost() and add_fuel_cost(): it builds each present utility’s convex-relaxed cost on the same opex block (EECO namespaces its components by utility, so the two never collide) and returns one OperatingCostHandles whose fields are the per-utility sums — the single total_operating_cost the scheduler minimizes. Still a RELAXED proxy, not the reported bill (use evaluate_cost()/evaluate_fuel_cost() post-solve).

The facility-level consumption defaults to the standard series registered on block — block.power_electrical (the canonical POWER_ELECTRICAL name) and block.fuel_usage — so a caller need not re-declare them each use; pass electrical_power/fuel_power to override (e.g. a toy model or a pre-aggregated series). A utility whose series is neither passed nor present on the block is simply omitted; at least one must resolve. The fuel leg bills through EECO’s "gas" utility (add_fuel_cost()’s only supported fuel_type today).

Parameters:
  • block – The Pyomo opex block to build both utilities’ cost on.

  • time_index – Naive pd.DatetimeIndex aligning to the power series.

  • dt_hours – Timestep length in hours; passed to EECO once for kW→kWh.

  • tariff – An EECO rate_data DataFrame (its electric and/or gas rows).

  • electrical_power – Time-indexed series of bare kW magnitudes (no units); defaults to block.power_electrical if present, or whatever pyo object is provided, else the electric leg is skipped.

  • fuel_power – Time-indexed fuel-usage series of bare m³/hr magnitudes (no units); defaults to block.fuel_usage if present, else the fuel leg is skipped.

  • dr_config – Optional DR container (v0: no constraints built).

  • consumption_estimate – Estimated total consumption over the horizon, keyed by EECO utility ("electric"/"gas"; kWh / m³). EECO needs it to price any tier other than a flat top tier.

Returns:

energy_cost, demand_charge and total_operating_cost are the sums across the built utilities, and eeco_block maps each built utility name ("electric"/"gas") to its raw EECO itemized structure.

Return type:

A combined OperatingCostHandles

Raises:
  • FlexConfigError – If neither an electric nor a fuel consumption series is passed or found on block.

  • FlexDataError – If time_index is timezone-aware.