bcgov / bcgov/wps

Investigate speed of Critical Hours calculation

Open
#1,794 1 comment 0 reactions 0 assignees View on GitHub
4Refinement Task
Dominant language
Python
Stars
65
Forks
11
Avg merge
1d 2h
Merged PRs (30d)
70

Description

**Describe the task**
The current algorithm for calculating Critical Hours is at risk of being considered slllloooooowwwww because it's just brute-forcing. With a smarter algorithm we could make this calculation much more efficient and get results much more quickly.

**Acceptance Criteria**
- [ ] Research how long it takes to calculate critical hours for (a) 1 station, (b) many stations (with "many" being arbitrarily defined - perhaps 20-30?)
- once this has been investigated, consult with team & PO - is our current solution quick enough? If not, proceed to next AC
- [ ] It should take time on the order of milliseconds to calculate 1 station's critical hours, and it should take less than 1 second to calculate the critical hours for "many" (20? 30? more?) stations (in 1 request). If time exceeds 1 second, then write a ticket to make it faster

**Additional context**
- possibly use Newton's method (algo is implemented in scikit), apply it to vector of values using pandas' `apply()`

Contributor guide

Open the contributing guide

Research direction

Locate the existing Critical Hours calculation entry point and benchmark one station versus many stations, defining “many” as part of the investigation. Compare the results with the millisecond and one-second acceptance criteria, then consult the team and PO; if the limit is exceeded, record a follow-up ticket for optimization.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python, scikit-learn
Domain
performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.