Skip to content

Commit

Permalink
handle nan values
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed May 10, 2024
1 parent 51ebdfa commit 50b4ce9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface Predictor {

/**
* Predict value from given features.
* @return predicted value, maybe NaN if no prediction is possible.
*/
double predict(Object2DoubleMap<String> features, Object2ObjectMap<String, String> categories);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ private void applyChanges(Link link, Feature ft) {
}

double perLane = capacity.predict(ft.features(), ft.categories());
if (Double.isNaN(perLane)) {
return;
}

double cap = capacityEstimate(ft.features().getDouble("speed"));

Expand Down Expand Up @@ -181,6 +184,10 @@ private void applyChanges(Link link, Feature ft) {
speedModel.predict(ft.features(), ft.categories(), paramsOpt.getParams(ft.junctionType())) :
speedModel.predict(ft.features(), ft.categories());

if (Double.isNaN(speedFactor)) {
return;
}

if (speedFactor > speedFactorBounds[1]) {
log.warn("Reducing speed factor on {} from {} to {}", link.getId(), speedFactor, speedFactorBounds[1]);
speedFactor = speedFactorBounds[1];
Expand Down

0 comments on commit 50b4ce9

Please sign in to comment.