-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from comparisons import SequenceComparison | ||
from metric import Metric, MetricValue | ||
|
||
class Action: | ||
id: str | ||
name: str | ||
color: str | ||
icon: str | ||
metric_data: dict[Metric, MetricValue | None] | ||
|
||
class ActionDependency: | ||
id: str | ||
action: Action | ||
relation: SequenceComparison | ||
other_actions: list[Action] | ||
actions_in_order: bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from enum import Enum | ||
|
||
class SequenceComparison(Enum): | ||
STARTS_WITH = 1 | ||
DOESNT_START_WITH = 2 | ||
CONTAINS = 3 | ||
DOESNT_CONTAIN = 4 | ||
ENDS_WITH = 5 | ||
DOESNT_END_WITH = 6 | ||
|
||
class NumberComparison(Enum): | ||
EQUAL = 1 | ||
DOESNT_EQUAL = 2 | ||
LESS_THAN = 3 | ||
LESS_THAN_OR_EQUAL = 4 | ||
GREATER_THAN = 5 | ||
GREATER_THAN_OR_EQUAL = 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from comparisons import SequenceComparison, NumberComparison | ||
from metric import Metric | ||
from action import Action | ||
|
||
class ActionFilter: | ||
relation: SequenceComparison | ||
actions: list[Action] | ||
actions_in_order: bool | ||
|
||
class MetricFilter: | ||
metric: Metric | ||
relation: NumberComparison | ||
value: float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from enum import Enum | ||
|
||
class MetricEstimate(Enum): | ||
MANUAL = 1 | ||
SUM = 2 | ||
AVERAGE = 3 | ||
MINIMUM = 4 | ||
MAXIMUM = 5 | ||
LAST = 6 | ||
|
||
class MetricUnit: | ||
symbol: str | ||
place_after_value: bool | ||
value_format: str | ||
|
||
class Metric: | ||
id: str | ||
name: str | ||
unit: MetricUnit | ||
current_value: float | ||
estimate: MetricEstimate | ||
|
||
class MetricValue: | ||
value: float | ||
is_estimate: bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from metric import Metric, MetricValue | ||
from action import Action | ||
|
||
class Pathway: | ||
id: str | ||
actions: list[Action] | ||
metric_data: dict[Metric, MetricValue | None] | ||
|
17 changes: 17 additions & 0 deletions
17
source/package/adaptation_pathways/model/pathways_project.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from metric import Metric | ||
from action import Action, ActionDependency | ||
from pathway import Pathway | ||
from scenario import Scenario | ||
|
||
class PathwaysProject: | ||
id: str | ||
name: str | ||
organization: str | ||
start_year: int | ||
end_year: int | ||
conditions: list[Metric] | ||
criteria: list[Metric] | ||
actions: list[Action] | ||
action_dependencies: list[ActionDependency] | ||
pathways: list[Pathway] | ||
scenarios: list[Scenario] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from metric import Metric, MetricValue | ||
|
||
class TimeSeriesPoint: | ||
time: float | ||
data: MetricValue | None | ||
|
||
class Scenario: | ||
id: str | ||
name: str | ||
metric_data_over_time: dict[Metric, list[TimeSeriesPoint]] |
41 changes: 41 additions & 0 deletions
41
source/package/adaptation_pathways/services/pathway_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from model.filter import ActionFilter, MetricFilter | ||
from model.pathway import Pathway | ||
from model.action import Action | ||
from model.metric import Metric, MetricEstimate | ||
|
||
class PathwayService: | ||
def filter_pathways( | ||
all_pathways: list[Pathway], | ||
action_filters: list[ActionFilter], | ||
metric_filters: list[MetricFilter] | ||
) -> list[Pathway]: | ||
# Replace with actual filtering code | ||
return all_pathways | ||
|
||
def generate_pathways( | ||
all_actions: list[Action], | ||
all_metrics: list[Metric], | ||
action_constraints: list[ActionFilter], | ||
metric_constraints: list[MetricFilter], | ||
max_sequence_length: int | None = None | ||
) -> list[Pathway]: | ||
# Generate all pathways that don't violate the provided constraints | ||
# Estimate a value for each metric based on its Metric.estimate method | ||
return [] | ||
|
||
def estimate_metric( | ||
pathway: Pathway, | ||
metric: Metric, | ||
all_actions: list[Action], | ||
all_pathways: list[Pathway] | ||
) -> float: | ||
# For manual estimate, just use the existing data (if there is any) | ||
if metric.estimate is MetricEstimate.MANUAL: | ||
current_data = pathway.metric_data.get(metric) | ||
if (current_data is None or current_data.is_estimate): | ||
return 0 | ||
else: | ||
return current_data.value | ||
|
||
# Do the proper estimate respecting the Metric.estimate method | ||
return 0 |
11 changes: 11 additions & 0 deletions
11
source/package/adaptation_pathways/services/scenario_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from model.scenario import Scenario | ||
from model.metric import Metric | ||
|
||
class ScenarioService: | ||
def estimate_metric_at_time( | ||
scenario: Scenario, | ||
metric: Metric, | ||
time: float | ||
) -> float: | ||
# Replace with a linear interpolation/extrapolation using the nearest points | ||
return metric.current_value |