-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/maven/com.google.guava-guava-33…
….3.0-jre
- Loading branch information
Showing
5 changed files
with
70 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ion/src/main/java/org/matsim/application/prepare/network/params/ref/IndividualParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.matsim.application.prepare.network.params.ref; | ||
|
||
import it.unimi.dsi.fastutil.objects.Object2DoubleMap; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap; | ||
import org.matsim.application.prepare.Predictor; | ||
import org.matsim.application.prepare.network.params.NetworkModel; | ||
|
||
/** | ||
* Reference model that uses one specific speed factor for each link. | ||
*/ | ||
public final class IndividualParams implements NetworkModel { | ||
|
||
private static final Predictor INSTANCE = new Model(); | ||
|
||
@Override | ||
public Predictor speedFactor(String junctionType, String highwayType) { | ||
return INSTANCE; | ||
} | ||
|
||
private static final class Model implements Predictor { | ||
|
||
@Override | ||
public double predict(Object2DoubleMap<String> features, Object2ObjectMap<String, String> categories) { | ||
return predict(features, categories, new double[0]); | ||
} | ||
|
||
@Override | ||
public double predict(Object2DoubleMap<String> features, Object2ObjectMap<String, String> categories, double[] params) { | ||
if (params.length == 0) | ||
return 1; | ||
|
||
return params[(int) features.getDouble("idx")]; | ||
} | ||
|
||
@Override | ||
public double[] getData(Object2DoubleMap<String> features, Object2ObjectMap<String, String> categories) { | ||
return new double[]{ | ||
features.getDouble("idx") | ||
}; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters