Skip to content

Instantly share code, notes, and snippets.

@mikepaszkiewicz
Created January 19, 2021 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikepaszkiewicz/d56bd624364f3ef7cb5a00e014ca1a4f to your computer and use it in GitHub Desktop.
Save mikepaszkiewicz/d56bd624364f3ef7cb5a00e014ca1a4f to your computer and use it in GitHub Desktop.
function deriveRunnerLaborHours(pred: CapacityPreds, max_callout_rate: number) {
if (pred.runner_hours_predicted === 0) {
return { finalCapacity: 0 }
}
let predictedDrhWithLimits: number = null
if (pred.drh_predicted < MIN_DRH) {
predictedDrhWithLimits = MIN_DRH
} else if (pred.drh_predicted > MAX_DRH) {
predictedDrhWithLimits = MAX_DRH
} else {
predictedDrhWithLimits = pred.drh_predicted
}
const baseRunnerHoursForecasted =
pred.demand_predicted / predictedDrhWithLimits
const calloutRate = Math.min(max_callout_rate, pred.predicted_callout)
const runnerHoursForecastedWithCallout =
baseRunnerHoursForecasted / (1 - calloutRate)
const capacityNeededWithCalloutsRoundedToNextInteger = Math.ceil(
runnerHoursForecastedWithCallout
)
const finalCapacity = Math.max(
MIN_RUNNER_PER_HOUR,
capacityNeededWithCalloutsRoundedToNextInteger
)
// console.log(pred.datetime, baseRunnerHoursForecasted, finalCapacity)
return {
baseRunnerHoursForecasted,
calloutRate,
runnerHoursForecastedWithCallout,
capacityNeededWithCalloutsRoundedToNextInteger,
finalCapacity,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment