Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Task completion rate clarity #118

Merged
merged 5 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

- Repairs that had a weather delay extended repairs past the end of the shift now properly extend the repair into future shifts instead of completing early. This has a small negative impact on availability because that means some repairs can take longer than they had originally.
- Traveling to a system for a repair where the timing extends beyond the end of the shift, but into the next shift, is now registered as a shift delay just like travel weather delays that extend beyond the end of the current shift but before the start of the next shift. This has a small positive impact on availability because a turbine or cable may not start being repaired until weather is more consistently clear, rather than starting it and extending it for many shifts.
- `Windfarm.cable()` now correctly identifies 2 and 3 length cable naming conventions to differentiate which version of the cable id is being retrieved.

### General Updates

- `Metrics.equipment_labor_cost_breakdowns` now has a `by_equipment` boolean flag, so that the labor and equipment costs can be broken down by category and equipment. Additionally, `total_hours` has been added to the results, resulting in fewer computed metrics across the same set of breakdowns.
- "request canceled" and "complete" are now updated in the logging to directly state if it's a "repair" or "maintenance" task that was completed or canceled to ensure consistency across the logging messages. As a result, `Metrics.task_completion_rate()` can now correctly differentiate between the completed tasks effectively.

### Methodology Updates

Expand Down
12 changes: 6 additions & 6 deletions wombat/core/post_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,9 @@ def capacity_factor(self, which: str, frequency: str, by: str) -> pd.DataFrame:
return pd.DataFrame(production / potential, columns=columns)

def task_completion_rate(self, which: str, frequency: str) -> float | pd.DataFrame:
"""Calculates the task completion rate over a project's lifetime as a single
value, annual average, or monthly average for the whole windfarm or by turbine.

.. note:: This currently assumes that if there are multiple substations, that
the turbines are all connected to multiple.
"""Calculates the task completion rate (including tasks that are canceled after
a replacement event) over a project's lifetime as a single value, annual
average, or monthly average for the whole windfarm or by turbine.

Parameters
----------
Expand Down Expand Up @@ -625,8 +623,10 @@ def task_completion_rate(self, which: str, frequency: str) -> float | pd.DataFra
task_filter = ["maintenance", "repair"]

cols = ["env_datetime", "request_id"]
completion_filter = [f"{el} complete" for el in task_filter]
request_filter = [f"{el} request" for el in task_filter]
completion_filter = [
f"{task} {el}" for task in task_filter for el in ("complete", "canceled")
]
requests = self.events.loc[
self.events.action.isin(request_filter), cols
].reset_index(drop=True)
Expand Down
3 changes: 2 additions & 1 deletion wombat/core/repair_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ def purge_subassembly_requests(
return None

for request in requests:
which = "repair" if isinstance(request.details, Failure) else "maintenance"
self.env.log_action(
system_id=request.system_id,
system_name=request.system_name,
Expand All @@ -691,7 +692,7 @@ def purge_subassembly_requests(
system_ol=float("nan"),
part_ol=float("nan"),
agent="RepairManager",
action="request canceled",
action=f"{which} canceled",
reason="replacement required",
request_id=request.request_id,
)
Expand Down
4 changes: 3 additions & 1 deletion wombat/windfarm/windfarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ def cable(self, cable_id: tuple[str, str] | str) -> Cable:
The ``Cable`` object.
"""
if isinstance(cable_id, str):
edge_id = tuple(cable_id.split("::")[1:])
edge_id = tuple(cable_id.split("::"))
if len(edge_id) == 3:
edge_id = edge_id[1:]
else:
edge_id = cable_id
try:
Expand Down