scenarios.Scenario
Represents a scenario in the MIKE+ model.
Usage
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
>>> # 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 assigned to this scenario. |
| children | Child scenarios derived from this scenario. |
| comment | Scenario’s comment. |
| id | Scenario’s unique identifier. |
| is_active | Whether this scenario is the currently active scenario. |
| is_base | Whether this is the base scenario. |
| name | Scenario’s name. |
| 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__() | Check if two scenarios are equal. |
| __init__() | Scenario constructor. |
| __repr__() | Get string representation of the Scenario object. |
| activate() | Make this the currently active scenario in the model. |
| contains_alternative() | Check if this scenario uses a specific alternative. |
| set_alternative() | Add/replace an alternative in this scenario. |
__eq__()
Check if two scenarios are equal.
Usage
__eq__(other)Returns
bool-
Whether
otheris a scenario with the same ID.
__init__()
Scenario constructor.
Usage
__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
__repr__()Returns
str-
The scenario’s name in the form
Scenario <name>.
activate()
Make this the currently active scenario in the model.
Usage
activate()Raises
ValueError- If MIKE+ fails to activate the scenario
contains_alternative()
Check if this scenario uses a specific alternative.
Usage
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
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