scenarios.AlternativeGroup
Represents an alternative group with collection-like access to alternatives.
Usage
scenarios.AlternativeGroup(
scenario_manager,
net_alternative_group,
)An alternative group contains alternatives for specific tables or model components. Each group has a base alternative and potentially an active alternative.
Attributes
id: str-
Unique identifier for the group
name: str-
Name of the group
tables: list[str]-
Database tables associated with this group
base: Alternative-
Base alternative for this group
active: Alternative- Currently active alternative for this group
Examples
>>> network_group = db.alternative_groups["CS Network data"]
>>> print(f"Tables: {network_group.tables}")
>>> print(f"Active: {network_group.active.name}")
>>> print(f"Base: {network_group.base.name}")
>>>
>>> # Create a new alternative
>>> new_alt = network_group.create("My Network", parent=network_group.base)Attributes
| Name | Description |
|---|---|
| active | Alternative assigned to the active scenario for this group. |
| base | Base alternative for this group. |
| id | Group’s unique identifier. |
| name | Group’s name. |
| tables | Database tables associated with this group. |
active
Alternative assigned to the active scenario for this group.
active: Alternative
base
Base alternative for this group.
base: Alternative
id
Group’s unique identifier.
id: str
name
Group’s name.
name: str
tables
Database tables associated with this group.
tables: list[str]
Methods
| Name | Description |
|---|---|
| __init__() | AlternativeGroup constructor. |
| __iter__() | Iterate through all alternatives in this group, parents before children. |
| __repr__() | Return a string representation of the AlternativeGroup. |
| by_name() | Find an alternative by name. |
| create() | Create a new alternative, optionally as a child of another. |
| find_by_name() | Find alternatives by name. |
__init__()
AlternativeGroup constructor.
Usage
__init__(scenario_manager, net_alternative_group)Parameters
scenario_manager: IScenarioManager-
The underlying .NET scenario manager object
net_alternative_group: IAlternativeGroup- The .NET IAlternativeGroup object
__iter__()
Iterate through all alternatives in this group, parents before children.
Usage
__iter__()__repr__()
Return a string representation of the AlternativeGroup.
Usage
__repr__()by_name()
Find an alternative by name.
Usage
by_name(name)create()
Create a new alternative, optionally as a child of another.
Usage
create(name, parent=None)Parameters
name: str-
Name for the new alternative
parent: Alternative = None- Parent alternative (defaults to base alternative if None)
Raises
ValueError- If the alternative could not be created
find_by_name()
Find alternatives by name.
Usage
find_by_name(name)