Skip to content

Commit

Permalink
Bugfix. Division by zero in OD-Calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Strobel committed Dec 8, 2023
1 parent b6be7f0 commit 36c978f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/kotlin/de/uniwuerzburg/omod/core/Omod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ class Omod(
// Normalize
val omodProb = omodWeights[odZone]!! / weightSumOMOD
val odProb = odWeights[odZone]!! / weightSumOD
factors[odZone] = odProb / omodProb
factors[odZone] = if (omodProb <= 0) { // Can't calibrate with k-factor if OMOD prob is 0 %
0.0
} else {
odProb / omodProb
}
}
return Pair(activity, factors)
}
Expand Down Expand Up @@ -367,10 +371,15 @@ class Omod(
} else {
for (destOdZone in originOdZone.destinations.map { it.first }) {
// Normalize
val gamgProb = omodWeights[destOdZone]!! / weightSumOMOD
val omodProb = omodWeights[destOdZone]!! / weightSumOMOD
val odProb = odWeights[destOdZone]!! / weightSumOD

factors[Pair(originOdZone, destOdZone)] = odProb / gamgProb
// Can't calibrate with k-factor if OMOD prob is 0 %
factors[Pair(originOdZone, destOdZone)] = if (omodProb <= 0) {
0.0
} else {
odProb / omodProb
}
}
}
}
Expand Down

0 comments on commit 36c978f

Please sign in to comment.