## scenarios.Scenario


Represents a scenario in the MIKE+ model.


Usage

``` python
scenarios.Scenario(
    scenario_manager,
    net_scenario,
)
```


A scenario is a collection of alternatives from different alternative groups. Scenarios form a hierarchical tree structure with parent-child relationships.


## Attributes


`id: str`  
Unique identifier for the scenario

`name: str`  
Name of the scenario

`parent: Scenario or None`  
Parent scenario (None if base scenario)

`children: list[Scenario]`  
Child scenarios derived from this one

`alternatives: list[Alternative]`  
Alternatives assigned to this scenario

`is_active: bool`  
Whether this is the currently active scenario

`is_base: bool`  
Whether this is the base scenario

`comment: str`  
User comment attached to this scenario


## Examples

``` python
>>> # Activate a scenario
>>> db.scenarios.create("Future Development")
>>> scenario = db.scenarios.by_name("Future Development")
>>> scenario.activate()
>>>
>>> # See which alternatives are used
>>> for alt in scenario.alternatives:
...     print(f"{alt.group.name}: {alt.name}")
```


## Attributes

| Name | Description |
|----|----|
| [alternatives](#alternatives) | Alternatives assigned to this scenario. |
| [children](#children) | Child scenarios derived from this scenario. |
| [comment](#comment) | Scenario's comment. |
| [id](#id) | Scenario's unique identifier. |
| [is_active](#is_active) | Whether this scenario is the currently active scenario. |
| [is_base](#is_base) | Whether this is the base scenario. |
| [name](#name) | Scenario's name. |
| [parent](#parent) | Parent scenario (None if this is the base scenario). |

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


#### alternatives


Alternatives assigned to this scenario.


`alternatives: list[Alternative]`


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


#### children


Child scenarios derived from this scenario.


`children: list[Scenario]`


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


#### comment


Scenario's comment.


`comment: str`


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


#### id


Scenario's unique identifier.


`id: str`


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


#### is_active


Whether this scenario is the currently active scenario.


`is_active: bool`


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


#### is_base


Whether this is the base scenario.


`is_base: bool`


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


#### name


Scenario's name.


`name: str`


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


#### parent


Parent scenario (None if this is the base scenario).


`parent: Scenario | None`


## Methods

| Name | Description |
|----|----|
| [__eq__()](#__eq__) | Check if two scenarios are equal. |
| [__init__()](#__init__) | Scenario constructor. |
| [__repr__()](#__repr__) | Get string representation of the Scenario object. |
| [activate()](#activate) | Make this the currently active scenario in the model. |
| [contains_alternative()](#contains_alternative) | Check if this scenario uses a specific alternative. |
| [set_alternative()](#set_alternative) | Add/replace an alternative in this scenario. |

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


#### \_\_eq\_\_()


Check if two scenarios are equal.


Usage

``` python
__eq__(other)
```


##### Returns


`bool`  
Whether `other` is a scenario with the same ID.


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


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


Scenario constructor.


Usage

``` python
__init__(scenario_manager, net_scenario)
```


##### Parameters


`scenario_manager: IScenarioManager`  
The underlying scenario manager

`net_scenario: IScenario`  
The .NET IScenario object


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


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


Get string representation of the Scenario object.


Usage

``` python
__repr__()
```


##### Returns


`str`  
The scenario's name in the form `Scenario <name>`.


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


#### activate()


Make this the currently active scenario in the model.


Usage

``` python
activate()
```


##### Raises


`ValueError`  
If MIKE+ fails to activate the scenario


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


#### contains_alternative()


Check if this scenario uses a specific alternative.


Usage

``` python
contains_alternative(alternative)
```


##### Parameters


`alternative: Alternative`  
The alternative to check for


##### Returns


`bool`  
True if this scenario uses the alternative, False otherwise


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


#### set_alternative()


Add/replace an alternative in this scenario.


Usage

``` python
set_alternative(alternative)
```


##### Parameters


`alternative: Alternative`  
The alternative to add to this scenario. If the scenario already has an alternative for the same group, it will be replaced.


##### Raises


`ValueError`  
If the alternative could not be assigned to the scenario
