new_modeling_toolkit.core package

Subpackages

Submodules

new_modeling_toolkit.core.component module

class Component

Bases: FromCSVMixIn

Fields:
field attr_path: str | pathlib.Path | None = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/e3-resolve/checkouts/latest/docs/source')

the path to the attributes file

field class_name: str | None = None
field include: Annotated[bool, Metadata(category=FieldCategory.BUILD)] = True

Include component in system.

Constraints:
  • category = FieldCategory.BUILD

  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = False

construct_investment_rules(model: ModelTemplate, construct_costs: bool)

Constructs the investment-related optimization formulation (decision variables, expressions, constraints, etc.) for the Component.

Parameters:
  • model – the Model containing the necessary temporal settings information needed to construct the rules

  • construct_costs – whether cost-related investment terms should be constructed

construct_modeling_block(model: ModelTemplate, construct_investment_rules: bool = True, construct_operational_rules: bool = True, construct_costs: bool = True) β†’ pyo.Block

Constructs a Pyomo Block containing all decision variables, expressions, parameters, constraints, and sets required for representing this Component as a member of an energy system.

This method assumes that the model argument is an instance of an E3 ModelTemplate which contains some universal time-indexing sets that are used in the construction of decision variables, constraints, etc.

Parameters:
  • model – the Model to which the created Block should be attached

  • construct_investment_rules – whether rules related to investment decisions should be constructed

  • construct_operational_rules – whether rules related to operational decisions should be constructed

  • construct_costs – whether cost terms should be constructed

Returns:

the constructed Pyomo Block

Return type:

self.formulation_block

construct_operational_rules(model: ModelTemplate, construct_costs: bool)

Constructs the operations-related optimization formulation (decision variables, expressions, constraints, etc.) for the Component.

Parameters:
  • model – the Model containing the necessary temporal settings information needed to construct the rules

  • construct_costs – whether cost-related operational terms should be constructed

classmethod convert_units(row)

Convert units from user-defined unit to defined_unit.

copy(exclude: list[str] | None = None, include_linkages: bool = False, update: dict[str, Any] | None = None, new_class: Type | None = None)

Copy a component instance (and optionally convert it to a new component class type).

classmethod dfs_to_csv(*, instances: pd.DataFrame, wb: Book, dir_str: DirStructure, compare_files: bool = True, dry_run: bool = False, save_path_override: pathlib.Path | None = None) β†’ None

Save DataFrame into (separate) component CSV files.

export_component_result_summary(output_dir: Path, results_settings: dict) β†’ DataFrame

Loop through all pyomo objects on the formulation block and return all results objects with a labeled doc argument. Loop through all the input attributes on the class object and return all inputs with a title argument in the Field definition.

Concatenate all inputs and results by frequency of index and save to csv. Currently only implemented for non-indexed, annual, hourly, and chrono periods.

Parameters:
  • output_dir – path to save summary results as csv

  • results_settings – dictionary indicating which sets of results to report

Returns: pd.DataFrame of annual results

export_formulation_block_raw_results(output_dir: Path)

Save raw pyomo components to csv.

Parameters:

output_dir – raw results directory

extract_attribute_from_components(component_dict: None | Dict[str, Component], attribute: str)

Takes a dictionary with Components as the values and returns the dictionary with the same keys, but with the desired attribute extracted from the Components.

Parameters:
  • component_dict – dictionary of Components

  • attribute – attribute to extract from each Component

Returns:

dictionary containing the extracted attributes

Return type:

component_attributes

classmethod from_dir(data_path: PathLike, scenarios: list | None = None) β†’ dict[str, Component]

Read instances from directory of instances with attribute.csv files.

Parameters:

data_path –

Returns:

classmethod from_json(filepath: PathLike) β†’ Component

Reads JSON file back to Component object.

classmethod get_metadata(field_name: str)

Get field’s Metadata() from annotation (or return an default Metadata() instance.

classmethod map_units(row)

Return original units for named attribute.

classmethod model_fields_by_category() β†’ dict

Create a nested dictionary of model fields by category for UI (if specified in Metadata annotation).

model_post_init(__context: Any) β†’ None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • __context – The context.

classmethod parse_user_unit(row)

Convert user-defined unit to pint Unit instance.

resample_ts_attributes(modeled_years: tuple[int, int], weather_years: tuple[int, int], resample_weather_year_attributes=True, resample_non_weather_year_attributes=True)

Resample timeseries attributes to the default frequencies to make querying via slice_by_timepoint and slice_by_year more consistent later.

  1. Downsample data by comparing against a β€œcorrect index” with the correct default_freq

  2. If data start year > modeled start year, fill timeseries backward

  3. Create a temporary timestamp for the first hour of the year after the modeled end year to make sure we have all the hours, minutes (e.g., 23:59:59) filled in in step (4)

  4. Resample to fill in any data (particularly at end of timeseries) and drop temporary timestamp from (3)

revalidate()

Abstract method to run additional validations after Linkage.announce_linkage_to_instances.

sum_attribute_from_components(component_dict: None | Dict[str, Component], attribute: str, timeseries: bool = False, skip_none: bool = False)

Extracts an attribute from all Components in component_dict and sums them. If the attributes are Timeseries objects, use timeseries=True. The skip_none argument will skip any Components for which the desired attribute has no value.

Parameters:
  • component_dict – dictionary containing the Components (e.g. System.resources)

  • attribute – the desired attribute to sum

  • timeseries – whether or not the attribute is a timeseries

  • skip_none – whether or not to skip Components for which the attribute is None

Returns:

the aggregated value across all Components

Return type:

aggregate

sum_timeseries_attributes(attributes: List[str], name: str, skip_none: bool = False) β†’ None | NumericTimeseries

Sums multiple attributes of the instance which are Timeseries objects.

Parameters:
  • attributes – list of attributes to sum

  • name – name for the resulting Timeseries

  • skip_none – whether or not to skip attributes if they are None

Returns:

a Timeseries that is the sum of the input attributes

Return type:

result

classmethod to_excel(*, anchor_range: Range, excel_api: ExcelApiCalls, modeled_years_range: list[int] = range(2020, 2051), modeled_years_visible: list | None = None, include: list[str] | None = None, exclude: list[str] | None = None, num_rows: int = 20, add_doc_hyperlinks: bool = True, linkages_to_write: list['LinkageFieldsToWrite'] | None = None, table_name: str)

Create a new user inputs tab in an Excel UI, using E3 Model Template.xlsm.

property formulation_block: Block | None

The Pyomo Block for the Component

property linkage_attributes: list[str]
property non_linkage_attributes: list[str]
property results_reporting_category
property results_reporting_folder
property three_way_linkage_attributes: list[str]
property timeseries_attrs
class ExpressionContainer

Bases: VarContainer

Fields:
  • max (None | float | new_modeling_toolkit.core.temporal.timeseries.NumericTimeseries)

  • min (None | float | new_modeling_toolkit.core.temporal.timeseries.NumericTimeseries)

  • name (str | tuple)

  • value (None | float | new_modeling_toolkit.core.temporal.timeseries.NumericTimeseries)

class LastUpdatedOrderedDict

Bases: OrderedDict

Store items in the order the keys were last added

class VarContainer

Bases: FromCSVMixIn

Fields:
field max: None | float | ts.NumericTimeseries = None
Constraints:
  • union_mode = left_to_right

field min: None | float | ts.NumericTimeseries = None
Constraints:
  • union_mode = left_to_right

field value: None | float | ts.NumericTimeseries = None
Constraints:
  • union_mode = left_to_right

classmethod default_factory(name: str | tuple[str])

new_modeling_toolkit.core.custom_constraint module

class CustomConstraintLHS

Bases: Component

Note: stylistically, the team chose not to put any Pyomo blocks on linkages, so the workaround for custom constraints was to create a LHS component for the multipliers. In my opinion, this is confusing because making sure that CustomConstraintRHS, CustomConstraintLHS, and CustomConstraintLinkage are all correctly connected is challenging from a user experience standpoint.

Fields:
field additional_index: str | None = None

Additional variable index before the timestamp. Ex: for policy constraints

field custom_constraints: dict[tuple | str, CustomConstraintLinkage] = {}
Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • linkage_order = 2

  • default_exclude = True

field modeled_year_multiplier: NumericTimeseries [Optional]

The left hand side annual multiplier of the instance pyomo component as a float. Will be added to the hourly target if applicable.

field pyomo_component_name: str [Required]

The pyomo component name of the linked component to constrain.

field weather_year_hourly_multiplier: NumericTimeseries | None [Optional]

The left hand side instance hourly multiplier of the instance pyomo component as a float. Will be multiplied with the annual multiplier if applicable.

get_lhs_multiplier(index: Tuple[Timestamp], hourly: bool) β†’ float
Parameters:
  • index –

  • hourly – bool, True if the RHS is hourly, include both annual and hourly multipliers

Returns: annual LHS component multiplier * hourly LHS component multiplier (if applicable)

SAVE_PATH: ClassVar[str] = 'custom_constraints/lhs'
class CustomConstraintRHS

Bases: Component

Fields:
field annual_target: NumericTimeseries [Optional]

The right hand side annual target of the custom constraints as a float. Will be added to the hourly target if applicable.

field constraint_operator: ConstraintOperator [Required]

RHS {greater than, less than, equal to} sum(LHS)

field custom_constraints: dict[tuple | str, CustomConstraintLinkage] = {}

Component variables to sum together as the lhs of the custom constraint

Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • linkage_order = 1

  • default_exclude = True

field penalty: float = 50000000
field weather_year_hourly_target: NumericTimeseries [Optional]

The right hand side hourly target of the custom constraints as a float. Will be added to the annual target if applicable.

get_rhs_target(index: Tuple[Timestamp]) β†’ float

Return the custom constraint RHS target. All RHS have an annual target. If the constraint is indexed hourly as well, add the annual target to the hourly target. :param index: [modeled_year] for annual only or [modeled_year, dispatch_window, timestamp] for hourly

Returns: annual target at model year timestamp + hourly target at weather year hour timestamp (if applicable)

SAVE_PATH: ClassVar[str] = 'custom_constraints/rhs'
property is_annual: bool

Loop through all CustomConstraint linkage linked to the RHS target. If all of the constraint components are indexed annually, return True indicating the constraint will only be constructed annually Returns: bool

property is_hourly: bool

Loop through all CustomConstraint linkage linked to the RHS target. If any of the constraint components are indexed hourly, return True, indicating that the constraint must be constructed hourly. Returns: bool

new_modeling_toolkit.core.custom_model module

class CustomModel

Bases: BaseModel

Standard pydantic BaseModel configuration.

Fields:
field name: str | tuple [Required]
classmethod get_field_type(*, field_info: FieldInfo) β†’ tuple

Return a tuple of a field’s type(s).

classmethod get_subclasses()

Get all subclasses recursively.

class FieldCategory(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

BUILD = 'Build Parameters'
OPERATIONS = 'Operational Parameters'
PYOMO_VARS = 'Decision Variables'
RELIABILITY = 'Reliability Parameters'
class Metadata(category: 'None | FieldCategory' = None, units: 'pint.Unit | str' = '', excel_short_title: 'str' = '', tools: 'None | set[ModelType]' = None, warning_bounds: 'tuple[float | int | None, float | int | None]' = (None, None), show_year_headers: 'bool' = True, linkage_order: "typing.Literal['from', 'to', 1, 2, 3, None]" = None, default_exclude: 'bool' = False)

Bases: object

category: None | FieldCategory = None
default_exclude: bool = False
excel_short_title: str = ''
linkage_order: Literal['from', 'to', 1, 2, 3, None] = None
show_year_headers: bool = True
tools: None | set[ModelType] = None
units: Unit | str = ''
warning_bounds: tuple[float | int | None, float | int | None] = (None, None)
class ModelType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

PATHWAYS = 'Pathways'
RECAP = 'Recap'
RESOLVE = 'Resolve'
TEMPLATE = 'Template'
df_encoder(df, date_format='iso')

Convert pandas dataframe to JSON.

Need to do json.loads because df.to_json() returns a string in JSON format.

get_units(attr_name: str)

new_modeling_toolkit.core.excel module

new_modeling_toolkit.core.from_csv_mix_in module

class FromCSVMixIn

Bases: CustomModel

Base class to implement a standard from_csv class method to read from interim data folder.

Fields:
  • name ()

classmethod field_is_timeseries(*, field_info) β†’ bool
classmethod from_csv(filename: Path, scenarios: List | None = None, data: Dict | None = None, name: str | None = None) β†’ FromCSVMixIn

Create Component instance from CSV input file.

The CSV input file must have the following mandatory three-column format, with two optional columns (column order does not matter; however, column header names do matter):

timestamp

attribute

value

unit (optional)

scenario (optional)

[None or timestamp (hour beginning)]

[attribute name]

[value]

[unit name]

[scenario name]

Units

Unit conversion is handled by the pint Python package. Expected attribute units are hard-coded in the Python implementation. If the pint package can find an appropiate conversion between the user-specified input of the attribute and the expected unit, it will convert data automatically to the expected unit.

For example, if the expected unit is MMBtu (named as million_Btu or MBtu in pint), a user can easily enter data in Btu, and the code will automatically divide the input value by 1e6.

Scenarios

Scenarios are handled via an optional scenario column. Scenario handling is done via some clever pandas DataFrame sorting. In detail:

  1. The scenario column is converted to a pd.Categorical, which is an ordered list.

  2. The scenario columns is sorted based on the Categorical ordering, where values with no scenario tag (None/NaN) are lowest-priority.

  3. The method df.groupby.last() is used to take the last (highest-priority) value (since the dataframe should be sorted from lowest to highest priority scenario tag).

  4. Scenario tags that are not listed in scenarios.csv will be ignored completely (dropped from the dataframe).

Duplicate Values

If an attribute is defined multiple times (and for a timeseries, multiple times for the same timestamp), the last value entered in the CSV (i.e., furthest down the CSV rows) will be used.

Parameters:
  • filename – Name of CSV input file. Defaults to attributes.csv.

  • scenarios – List of optional scenario tags to filter input data in file. Defaults to [].

  • data – Additional data to add to the instance as named attributes. Defaults to {}.

Referencing Other CSVs for Timeseries Data

To keep the attributes.csv shorter, user can optionally enter the value of a timeseries as a file path to another CSV file instead of entering each timestamped data value in attributes.csv. This is done by using the None timestamp and entering a string filepath for the value. Absolute paths are preferred for the sake of being explicit, though relative paths will be parsed relative to the top-level new-modeling-toolkit folder.

There are two limitations of this functionality:

  1. It is not currently possible to β€œmix-and-match” timeseries data specified in the attributes.csv file and from other referenced CSV files. You must either (a) input timeseries data in attributes.csv with timestamps or (b) use the None timestamp and reference a different file.

  2. Timeseries data read from another CSV file does not currently benefit scenario-tagging capabilities. The filepath references themselves in attributes.csv can be scenario-tagged; however, the other CSV file is just read in as if it were a pd.Series with a DateTimeIndex.

Returns:

Instance of Component class.

Return type:

classmethod from_dataframe(*, input_df: DataFrame, attr_path: Path | None = None, scenarios: list[str] | None = None, data: dict | None = None, name: str | None = None)

Create an instance of the class from an input DataFrame.

The input DataFrame will optionally be filtered by a list of scenarios ordered from lowest to highest priority. At least one of attr_path or name must be specified in order to name the newly created object.

Parameters:
  • input_df – the input DataFrame to use to instantiate the class

  • attr_path – optional path to the CSV from which the input DataFrame was loaded

  • scenarios – optional list of scenarios used to filter the input DataFrame

  • data – optional dictionary of attribute data used to override data parsed from the input DataFrame

  • name – name for the new object

Returns:

instance of the class

Return type:

inst

classmethod get_timeseries_attribute_names(include_aliases: bool = False)
classmethod get_timeseries_default_freqs()
classmethod model_fields_with_aliases()

new_modeling_toolkit.core.linkage module

class AllToPolicy

Bases: _AllToPolicy

Fields:
field attribute: Annotated[str | None, Metadata(default_exclude=True)] = None
Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = True

field forward_dir_multiplier: ts.NumericTimeseries | None = None
field fully_deliverable: bool = True
field reverse_dir_multiplier: ts.NumericTimeseries | None = None
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

classmethod validate_single_xor_bidirectional_multiplier(values)

Validate that the linkage either has both β€˜forward_dir_multiplier’ & β€˜reverse_dir_multiplier’ defined, xor only has β€˜multiplier’ defined. The two types of multipliers shouldn’t exist at the same time.

class AnnualEnergyStandardContribution

Bases: _AllToPolicy

Fields:
field multiplier: Annotated[ts.NumericTimeseries | None, Metadata(excel_short_title='%')] = None
Constraints:
  • units =

  • excel_short_title = %

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = False

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'annual_energy_standard_contributions.csv'
class AssetToAssetGroup

Bases: Linkage

Fields:
field component_type_from_: str = 'assets'
field component_type_to_: str = 'asset_groups'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class AssetToCaisoTxConstraint

Bases: Linkage

Fields:
field component_type_from_: str = 'assets'
field component_type_to_: str = 'caiso_tx_constraints'
field eods_factor: float [Required]
field hsn_factor: float [Required]
field ssn_factor: float [Required]
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'assets_to_caiso_tx_constraints.csv'
class AssetToELCC

Bases: Linkage

Fields:
field attribute: Annotated[Literal['power', 'energy'], Metadata(default_exclude=True)] = 'power'
Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = True

field component_type_from_: str = 'assets'
field component_type_to_: str = 'elcc_surfaces'
field elcc_axis_index: int = 1
field elcc_axis_multiplier: float = 1
field multiplier: Annotated[float | None, Metadata(default_exclude=True)] = None
Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = True

field multiplier_unit: Annotated[str | None, Metadata(default_exclude=True)] = None
Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = True

classmethod has_axis_index_if_multiplier(values)
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'assets_to_elcc.csv'
class AssetToZone

Bases: Linkage

Fields:
field component_type_from_: str = 'assets'
field component_type_to_: str = 'zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class BiomassResourceToCandidateFuel

Bases: Linkage

Fields:
field component_type_from_: str = 'biomass_resources'
field component_type_to_: str = 'candidate_fuels'
field conversion_cost: ts.NumericTimeseries [Required]
field conversion_efficiency: ts.NumericTimeseries [Required]
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'biomass_resources_to_candidate_fuels.csv'
class CandidateFuelToFinalFuel

Bases: XToFinalFuel

Fields:
field blend_limit_fraction: ts.NumericTimeseries | None [Required]
field component_type_from_: str = 'candidate_fuels'
field component_type_to_: str = 'final_fuels'
field out_fuel_cost: ts.NumericTimeseries [Optional]
field out_gross_emissions: ts.NumericTimeseries [Optional]
field out_net_emissions: ts.NumericTimeseries [Optional]
field out_upstream_emissions: ts.NumericTimeseries [Optional]
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'candidate_fuels_to_final_fuels.csv'
class CandidateFuelToPollutant

Bases: Linkage

Fields:
field component_type_from_: str = 'candidate_fuels'
field component_type_to_: str = 'pollutants'
field gross_emission_factor: ts.NumericTimeseries | None [Required]
field gross_emissions_trajectory_override: ts.NumericTimeseries | None = None
field net_emission_factor: ts.NumericTimeseries | None [Required]
field net_emissions_trajectory_override: ts.NumericTimeseries | None = None
field out_gross_emissions: ts.NumericTimeseries [Optional]
field out_gross_emissions_CO2e: ts.NumericTimeseries [Optional]
field out_net_emissions: ts.NumericTimeseries [Optional]
field out_net_emissions_CO2e: ts.NumericTimeseries [Optional]
field out_upstream_emissions: ts.NumericTimeseries [Optional]
field out_upstream_emissions_CO2e: ts.NumericTimeseries [Optional]
field upstream_emission_factor: ts.NumericTimeseries | None [Required]
field upstream_emissions_trajectory_override: ts.NumericTimeseries | None = None
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'candidate_fuels_to_pollutants.csv'
class CandidateFuelToResource

Bases: Linkage

Linkage between new_modeling_toolkit.common.fuel.CandidateFuel and new_modeling_toolkit.common.resource.Resource.

Houses the data related to both resources & candidate fuels (e.g., fuel burn coefficients).

Fields:
field component_type_from_: str = 'candidate_fuels'
field component_type_to_: str = 'resources'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ELCCFacetToSurface

Bases: Linkage

Fields:
field component_type_from_: str = 'facets'
field component_type_to_: str = 'surface'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ELCCReliabilityContribution

Bases: _AllToPolicy

Fields:
  • attr_path ()

  • class_name ()

  • component_type_from_ ()

  • component_type_to_ ()

  • include ()

  • instance_from ()

  • instance_to ()

  • multiplier ()

  • name ()

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'elcc_reliability_contributions.csv'
class ERMContribution

Bases: _AllToPolicy

Fields:
field multiplier: Annotated[ts.NumericTimeseries | None, Metadata(excel_short_title='%')] [Optional]
Constraints:
  • units =

  • excel_short_title = %

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = False

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'erm_contributions.csv'
class ElectrolyzerToCandidateFuel

Bases: Linkage

Fields:
field component_type_from_: str = 'electrolyzers'
field component_type_to_: str = 'candidate_fuels'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ElectrolyzerToFuelZone

Bases: Linkage

Fields:
field component_type_from_: str = 'electrolyzers'
field component_type_to_: str = 'fuel_zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ElectrolyzerToZone

Bases: Linkage

Fields:
field component_type_from_: str = 'electrolyzers'
field component_type_to_: str = 'zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class EmissionsContribution

Bases: _AllToPolicy

Fields:
field multiplier: Annotated[ts.NumericTimeseries | None, Metadata(excel_short_title='tonne/MWh', units=units.tonne / units.MWh)] = None
Constraints:
  • units = metric_ton / megawatt_hour

  • excel_short_title = tonne/MWh

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = False

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'resource_fuel_emissions_contributions.csv'
class FinalFuelToAnnualEmissionsPolicy

Bases: AllToPolicy

Temporary subclass only so that final fuels are correctly linked to annual emissions policies.

Fields:
field component_type_from_: str = 'final_fuels'
field component_type_to_: str = 'policies'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class FinalFuelToFuelZone

Bases: Linkage

Fields:
field component_type_from_: str = 'final_fuels'
field component_type_to_: str = 'fuel_zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class FromZoneToPath

Bases: ZoneToTransmissionPath

Fields:
  • attr_path ()

  • class_name ()

  • component_type_from_ ()

  • component_type_to_ ()

  • from_zone (bool)

  • include ()

  • instance_from ()

  • instance_to ()

  • name ()

  • to_zone ()

field from_zone: bool = True
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = None
class FuelConversionPlantToCandidateFuel

Bases: Linkage

Fields:
field component_type_from_: str = 'fuel_conversion_plants'
field component_type_to_: str = 'candidate_fuels'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class FuelConversionPlantToFuelZone

Bases: Linkage

Fields:
field component_type_from_: str = 'fuel_conversion_plants'
field component_type_to_: str = 'fuel_zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class FuelConversionPlantToZone

Bases: Linkage

Fields:
field component_type_from_: str = 'fuel_conversion_plants'
field component_type_to_: str = 'zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class FuelStorageToCandidateFuel

Bases: Linkage

Fields:
field component_type_from_: str = 'fuel_storages'
field component_type_to_: str = 'candidate_fuels'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class FuelStorageToFuelZone

Bases: Linkage

Fields:
field component_type_from_: str = 'fuel_storages'
field component_type_to_: str = 'fuel_zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class FuelStorageToZone

Bases: Linkage

Fields:
field component_type_from_: str = 'fuel_storages'
field component_type_to_: str = 'zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class FuelZoneToCandidateFuel

Bases: Linkage

Fields:
field component_type_from_: str = 'fuel_zones'
field component_type_to_: str = 'candidate_fuels'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

property candidate_fuel
property fuel_zone
class FuelZoneToElectricZone

Bases: Linkage

Fields:
field component_type_from_: str = 'zones'
field component_type_to_: str = 'fuel_zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class HourlyEnergyStandardContribution

Bases: _AllToPolicy

Fields:
field multiplier: Annotated[ts.NumericTimeseries | None, Metadata(excel_short_title='%')] = None
Constraints:
  • units =

  • excel_short_title = %

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = False

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'hourly_energy_standard_contributions.csv'
class HybridStorageResourceToHybridVariableResource

Bases: Linkage

Fields:
field component_type_from_: str = 'hybrid_storage_resources'
field component_type_to_: str = 'hybrid_variable_resources'
field grid_charging_allowed: bool | None = False

If True, hybrid_storage’s power_input must not exceed hybrid_variable’s power_output.

field interconnection_limit_mw: ts.NumericTimeseries | None = None
field paired_charging_constraint_active_in_year: ts.NumericTimeseries [Optional]

If 1, the charging constraint is active in the year. If 0, the charging constraint is not active in the year.

field pairing_ratio: float | None = None

If specified, ratio of operational capacity of hybrid_variable to that of hybrid_storage resources. Usually set to 1.

Constraints:
  • ge = 0

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

revalidate()

Abstract method to run additional validations after Linkage.announce_linkage_to_instances.

SAVE_PATH: ClassVar[str | None] = 'hybrid_resources.csv'
class IncrementalReserveType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

HOURLY_PROFILE = 'hourly profile'
OPERATIONAL_CAPACITY = 'operational capacity'
class Linkage

Bases: Component

A generalized representation of all sorts of connection between either different component instances, or different instances of the same class. By definition and for convenience, the linkage has to be one-directional, even in reality this directionality might not mean much

Fields:
field component_type_from_: str [Required]
field component_type_to_: str [Required]
field instance_from: component.Component | None = None
field instance_to: component.Component | None = None
announce_linkage_to_instances()

Iterate through all linkages in Linkages._instances to append instances as attributes to mapped instances.

In other words, if we have:

r = Resource(name=”CCGT”, …) f = Fuel(name=”natural_gas”, …) l = Linkage(instance_from=r, instance_to=f)

This method will:
  • Append r.fuels = {β€œnatural_gas”: f}

  • Append f.resource = {β€œCCGT”: r}

So that it’s easy to find the necessary attributes from linked instances (e.g., fuel burn associated with a fuel being burned in a certain resource)

copy()

Copy a component instance (and optionally convert it to a new component class type).

classmethod dfs_to_csv(*, instances: pd.DataFrame, wb: Book, dir_str: DirStructure, compare_files: bool = True, dry_run: bool = False) β†’ None

Save DataFrame into (separate) component CSV files.

dict(**kwargs)

Need to exclude instance_from, instance_to attributes to avoid recursion error when saving to JSON.

classmethod from_dir(dir_path: PathLike, linkages_df: DataFrame, components_dict: dict[str, Component], linkages_csv_path: Path, scenarios: list = [])

Create Linkage instances based on prescribed CSV files.

This method relies on one class attribute:

SAVE_PATH: Optional filename for static & dynamic attributes of the Linkage instance

Parameters:
  • dir_path – Path to CSV file

  • instances_from – Dict of Component instances to reference in linkage.

  • instances_to – Dict of Component instances to reference in linkage.

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

classmethod to_excel(*, anchor_range, excel_api: ExcelApiCalls, **kwargs)

Small wrapper around Component.to_excel() because for now linkages need a formula to construct their name.

SAVE_PATH: ClassVar[str | None] = None
property name_from
property name_to
class LinkageRelationshipType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

MANY_TO_MANY = 'many_to_many'
MANY_TO_ONE = 'many_to_one'
ONE_TO_MANY = 'one_to_many'
ONE_TO_ONE = 'one_to_one'
class LoadToReserve

Bases: Linkage

Fields:
field component_type_from_: str = 'loads'
field component_type_to_: str = 'reserves'
field incremental_requirement_hourly_scalar: ts.FractionalTimeseries [Optional]
field incremental_requirement_hourly_scalar__type: ts.TimeseriesType = TimeseriesType.MODELED_YEAR
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'loads_to_reserves.csv'
class LoadToZone

Bases: Linkage

Fields:
field component_type_from_: str = 'loads'
field component_type_to_: str = 'zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ReliabilityContribution

Bases: _AllToPolicy

Fields:
field attribute: Annotated[str | None, Metadata(default_exclude=True)] = None
Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = True

field fully_deliverable: bool = True
field multiplier: Annotated[ts.NumericTimeseries | None, Metadata(excel_short_title='%')] = None
Constraints:
  • units =

  • excel_short_title = %

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = False

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'reliability_contributions.csv'
class ReserveToZone

Bases: Linkage

Fields:
field component_type_from_: str = 'reserves'
field component_type_to_: str = 'zones'
field incremental_requirement_hourly_scalar: ts.FractionalTimeseries [Optional] (alias 'requirement_fraction_of_gross_load')
field incremental_requirement_hourly_scalar__type: ts.TimeseriesType = TimeseriesType.MODELED_YEAR
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'reserves_to_zones.csv'
class ResourceToFuelZone

Bases: Linkage

Fields:
field component_type_from_: str = 'resources'
field component_type_to_: str = 'fuel_zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ResourceToOutageDistribution

Bases: Linkage

Fields:
field component_type_from_: str = 'resources'
field component_type_to_: str = 'outage_distributions'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ResourceToPollutant

Bases: Linkage

Defines the linkage between resources and pollutants. Used if emission factors are set on the resource to pollutant level rather than the resource to fuel to pollutant level.

Fields:
field component_type_from_: str = 'resources'
field component_type_to_: str = 'pollutants'
field emission_factor: ts.NumericTimeseries = None
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'resources_to_pollutants.csv'
class ResourceToReserve

Bases: Linkage

Fields:
field component_type_from_: str = 'resources'
field component_type_to_: str = 'reserves'
field dependent_on: Annotated[str, Metadata(default_exclude=True)] = 'setpoint'

Operating reserves are usually related to a resource’s setpoint (i.e., online head/footroom). Certain resources (e.g., inertia) are only related to online/committed capacity.**Note: RESOLVE cannot currently represent non-spinning reserves.**

Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = True

field exclusive: Annotated[bool, Metadata(default_exclude=True)] = True
Constraints:
  • units =

  • excel_short_title =

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = True

field incremental_requirement_annual_scalar: ts.NumericTimeseries [Optional]
field incremental_requirement_hourly_scalar: ts.NumericTimeseries [Optional] (alias 'incremental_requirement')
field incremental_requirement_hourly_scalar__type: ts.TimeseriesType = TimeseriesType.MODELED_YEAR
field max_fraction_of_capacity: Annotated[float, Field(ge=0, le=1)] = 0

Max % of a resource’s online capacity (e.g., committed capacity for unit commitment resources) that can be used to provide operating reserve.

Constraints:
  • ge = 0

  • le = 1

field scalar_type: IncrementalReserveType = IncrementalReserveType.OPERATIONAL_CAPACITY
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'resources_to_reserves.csv'
class ResourceToResourceGroup

Bases: Linkage

Fields:
field component_type_from_: str = 'resources'
field component_type_to_: str = 'resource_groups'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ResourceToZone

Bases: Linkage

Fields:
field component_type_from_: str = 'resources'
field component_type_to_: str = 'zones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class ToZoneToPath

Bases: ZoneToTransmissionPath

Fields:
  • attr_path ()

  • class_name ()

  • component_type_from_ ()

  • component_type_to_ ()

  • from_zone ()

  • include ()

  • instance_from ()

  • instance_to ()

  • name ()

  • to_zone (bool)

field to_zone: bool = True
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = None
class TrancheToAsset

Bases: Linkage

Fields:
field component_type_from_: str = 'tranches'
field component_type_to_: str = 'assets'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

class TransmissionPathToPollutant

Bases: Linkage

Defines the linkage between transmission paths and pollutants. Used to set emission factors for Tx lines.

Fields:
field component_type_from_: str = 'tx_paths'
field component_type_to_: str = 'pollutants'
field forward_dir_multiplier: ts.NumericTimeseries = None
field reverse_dir_multiplier: ts.NumericTimeseries = None
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'tx_paths_to_pollutants.csv'
class TxEmissionsContribution

Bases: EmissionsContribution

Fields:
field forward_dir_multiplier: Annotated[ts.NumericTimeseries | None, Metadata(excel_short_title='Rate', units=units.tonne / units.MWh)] = None
Constraints:
  • units = metric_ton / megawatt_hour

  • excel_short_title = Rate

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = False

field reverse_dir_multiplier: Annotated[ts.NumericTimeseries | None, Metadata(excel_short_title='Rate', units=units.tonne / units.MWh)] = None
Constraints:
  • units = metric_ton / megawatt_hour

  • excel_short_title = Rate

  • warning_bounds = (None, None)

  • show_year_headers = True

  • default_exclude = False

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'tx_emissions_contributions.csv'
class XToFinalFuel

Bases: Linkage

Fields:
field component_type_from_: str = 'component'
field component_type_to_: str = 'final_fuels'
field out_energy_demand: ts.NumericTimeseries [Optional]
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'component_to_final_fuels.csv'
class ZoneToTransmissionPath

Bases: Linkage

Fields:
field component_type_from_: str = 'zones'
field component_type_to_: str = 'tx_paths'
field from_zone: bool = False
field to_zone: bool = False
classmethod linkage_is_from_zone_xor_to_zone(values)

Validate that exactly one of from_zone and to_zone is set to True.

model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar[str | None] = 'zones_to_tx_paths.csv'
class ZoneToZone

Bases: Linkage

Fields:
field component_type_from_: str = 'parent_zones'
field component_type_to_: str = 'subzones'
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

new_modeling_toolkit.core.model module

class ConstraintOperator(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

EQUAL_TO = '=='
GREATER_THAN_OR_EQUAL_TO = '>='
LESS_THAN_OR_EQUAL_TO = '<='
class ModelTemplate(*args, **kwds)

Bases: ConcreteModel, ABC

Can’t make a child class that inherits both from Pydantic and Pyomo, so seems like this is all I can do for now.

TYPE: ModelType = 'Template'
property blocks: dict[str, Block]
property contains_integer_variables: bool

True if integer variables exist in the model

Type:

Returns

export_temporal_settings(output_dir: Path)
property integer_variables_list: list[Var]

Return a list of all integer or binary variable components

return_timepoints_connecting_chrono_periods(modeled_year: Timestamp, chrono_period: Timestamp) β†’ Tuple[Tuple[Timestamp, Timestamp, Timestamp], Tuple[Timestamp, Timestamp, Timestamp]]

Return the dispatch window indexes that connect two chrono periods- last timepoint of dispatch_window[t] <-> first timepoint of dispatch_window[t+1]

Parameters:
  • modeled_year – pd.Timestamp of model year index

  • chrono_period – pd.Timestamp of chrono_period[t] index

Returns: chrono_period_1_index(modeled_year: pd.Timestamp, dispatch_window[t]: pd.Timestamp, last timepoint in dispatch_window[t]),

chrono_period_2_index(modeled_year: pd.Timestamp, dispatch_window[t+1]: pd.Timestamp, first timepoint in dispatch_window[t+1])

solve(**kwargs)
sum_timepoint_component_slice_to_annual(model_component_slice: IndexedComponent_slice)

Computes the β€œannual sum” using dispatch-window-weights of a slice of a modeling component that is indexed by DISPATCH_WINDOWS and TIMESTAMPS, among other things. For example, if the power output of a resource is defined as:

block.power_output = pyo.Expression(model.MODELED_YEARS, model.DISPATCH_WINDOWS_AND_TIMESTAMPS, rule=_power_output_rule)

Then the β€œtotal annual power output” as determined using dispatch-window-weights for the 2030 snapshot year can be calculated by doing

sum_timepoint_component_slice_to_annual(block.power_output[2030, :, :])

Parameters:

model_component_slice – the slice of the component that should be summed

Returns:

an Expression of the weighted annual sum of the slice

Return type:

annual_sum

sum_weather_timestamp_component_slice_to_annual(model_component_slice: IndexedComponent_slice)

Computes the β€œannual sum” using a slice of a modeling component that is indexed by WEATHER_PERIODS and WEATHER_TIMESTAMPS. This works similarly to sum_timepoint_component_slice_to_annual, except there is no weighting by dispatch window.

That is, the sum of a weather_timestamp-indexed variable is simply the average value multiplied by number of hours in the modeled year.

Parameters:

model_component_slice – the slice of the component that should be summed

Returns:

an Expression of the weighted annual sum of the slice

Return type:

annual_sum

new_modeling_toolkit.core.three_way_linkage module

class CustomConstraintLinkage

Bases: ThreeWayLinkage

Fields:
field instance_1: Component | None [Required]
field instance_2: Component | None [Required]
field instance_3: Component | None [Required]
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

return_valid_index(index: Tuple[Timestamp])

Return index of variable to constrain

Parameters:

index – [modeled_year] for annual only or [modeled_year, dispatch_window, timestamp] for hourly

Returns: (additional index str, modeled year [,dispatch windows, timestamp if hourly constraint],)

classmethod to_excel(*, anchor_range, excel_api: ExcelApiCalls, **kwargs)

Since instances 1-3 have different names in table headers, need a custom to_excel method for custom constraints.

validate_custom_constraint_linkage()
property is_annual

Bool. Assumes a variable must be either hourly or annually indexed. Returns: True if variable index does not include hourly timestamps.

property is_hourly

Bool. Assumes a variable must be either hourly or annually indexed. Returns: True if index includes hourly timestamps.

property lhs_instance

Linked instance 2 as a LHS component of the custom constraint

Type:

Returns

property linked_component

Linked instance 3 as the component to constraint of the custom constraint

Type:

Returns

property pyomo_component

pyomo variable from the component formulation block

Type:

Returns

property rhs

Linked instance_1 as the RHS of the custom constraint

Type:

Returns

property variable_index: list

if the variable is index hourly, this will return [β€œMODELED_YEARS”, β€œDISPATCH_WINDOWS”, β€œTIMESTAMPS”]

Type:

Returns

Type:

Index labels for the pyomo variable being constrained. Ex

class SectorCandidateFuelBlending

Bases: ThreeWayLinkage

Three-way linkage used to set candidate fuel to final fuel blending by sector.

Fields:
field blend_override: FractionalTimeseries | None = None
model_post_init(_ModelMetaclass__context: Any) β†’ None

We need to both initialize private attributes and call the user-defined model_post_init method.

SAVE_PATH: ClassVar = 'sector_candidate_fuel_blending.csv'
class ThreeWayLinkage

Bases: Component

A generalized representation of all sorts of connection between either three component instances component instances, or three different instances of the same class. By definition and for convenience, the linkage has to be one-directional, even in reality this directionality might not mean much.

Note that this linkage type should only be used when chained Linkages do not suffice. A specific use case for this linkage type is controlling fuel switching within a given EnergyDemandSubsector instance. Such fuel switching is likely to be idiosyncratic to the instance. An example would be natural gas to hydrogen fuel switching within two industrial subsectors. One subsector may switch to entirely to hydrogen, while one might switch only 5% of natural gas demand. Such a linkage enables control of fuel switching extent within each subsector without a need for extensive preprocessing.

Fields:
field instance_1: Component | None [Required]
field instance_2: Component | None [Required]
field instance_3: Component | None [Required]
announce_linkage_to_instances()

Iterate through all linkages in ThreeWayLinkages._instances to append instances as attributes to mapped instances.

In other words, if we have:

s = EnergyDemandSubsector() f1 = Fuel() f2 = Fuel() three_way_linkage = ThreeWayLinkage(instance_1=s, instance_2=f1, instance_3=f2)

This method will:
  • Append s.three_way_linkage_attribute = {(f1.name,f2.name):three_way_linkage}

  • Append f1.three_way_linkage_attribute = {(s.name,f2.name):three_way_linkage}

  • Append f2.three_way_linkage_attribute = {(s.name,f1.name):three_way_linkage}

So that it’s easy to find the necessary attributes from linked instances (e.g., fuel switching from one final fuel to another within and energy-only subsector in PATHWAYS)

Note that three-way linkages as attributes under the components they are linking are denoted by a tuple of strings. Further, the attribute name itself cannot be cleanly mapped back to a single instance of a Component subclass because linked components may not be of the same class.

copy()

Copy a component instance (and optionally convert it to a new component class type).

classmethod dfs_to_csv(*, instances: DataFrame, wb: Book, dir_str: DirStructure, compare_files: bool = True, dry_run: bool = False) β†’ None

Save DataFrame into (separate) component CSV files.

classmethod from_dir(dir_path: PathLike, linkage_pairs: list[tuple[str, str, str]], components_dict: dict[str, Component], scenarios: list = [])

Create Linkage instances based on prescribed CSV files.

This method relies on one class attribute:

SAVE_PATH: Optional filename for static & dynamic attributes of the Linkage instance

Parameters:
  • dir_path – Path to CSV file

  • instances_1 – Dict of Component instances to reference in linkage.

  • instances_2 – Dict of Component instances to reference in linkage.

  • instances_3 – Dict of Component instances to reference in linkage.

classmethod to_excel(*, anchor_range, excel_api: ExcelApiCalls, **kwargs)

Small wrapper around Component.to_excel() because for now linkages need a formula to construct their name.

SAVE_PATH: ClassVar = None

Module contents