## scenarios.AlternativeGroup


Represents an alternative group with collection-like access to alternatives.


Usage

``` python
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

``` python
>>> 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](#active) | Alternative assigned to the active scenario for this group. |
| [base](#base) | Base alternative for this group. |
| [id](#id) | Group's unique identifier. |
| [name](#name) | Group's name. |
| [tables](#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__()](#__init__) | AlternativeGroup constructor. |
| [__iter__()](#__iter__) | Iterate through all alternatives in this group, parents before children. |
| [__repr__()](#__repr__) | Return a string representation of the AlternativeGroup. |
| [by_name()](#by_name) | Find an alternative by name. |
| [create()](#create) | Create a new alternative, optionally as a child of another. |
| [find_by_name()](#find_by_name) | Find alternatives by name. |

------------------------------------------------------------------------


#### \_\_init\_\_()


AlternativeGroup constructor.


Usage

``` python
__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

``` python
__iter__()
```


------------------------------------------------------------------------


#### \_\_repr\_\_()


Return a string representation of the AlternativeGroup.


Usage

``` python
__repr__()
```


------------------------------------------------------------------------


#### by_name()


Find an alternative by name.


Usage

``` python
by_name(name)
```


------------------------------------------------------------------------


#### create()


Create a new alternative, optionally as a child of another.


Usage

``` python
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

``` python
find_by_name(name)
```
