Skip to content

Commit

Permalink
changes for imc
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Dec 6, 2023
1 parent ec7b093 commit 1890a24
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
6 changes: 3 additions & 3 deletions input/v3.1/kelheim-v3.1-25pct.kexi.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</module>

<module name="replanningAnnealer" >
<param name="activateAnnealingModule" value="true" />
<param name="activateAnnealingModule" value="false" />
<parameterset type="AnnealingVariable" >
<param name="annealParameter" value="globalInnovationRate" />
<param name="annealType" value="sigmoid" />
Expand All @@ -99,7 +99,7 @@
<param name="weight" value="0.10"/>
</parameterset>
<parameterset type="strategysettings">
<param name="strategyName" value="SubtourModeChoice"/>
<param name="strategyName" value="SelectBestKPlanModes"/>
<param name="subpopulation" value="person"/>
<param name="weight" value="0.10"/>
</parameterset>
Expand Down Expand Up @@ -132,7 +132,7 @@

<module name="informedModeChoice">
<param name="modes" value="car,pt,bike,walk,ride,drt"/>
<param name="topK" value="5"/>
<param name="topK" value="20"/>
<param name="constraintCheck" value="repair"/>
</module>

Expand Down
6 changes: 3 additions & 3 deletions input/v3.1/kelheim-v3.1-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</module>

<module name="replanningAnnealer" >
<param name="activateAnnealingModule" value="true" />
<param name="activateAnnealingModule" value="false" />
<parameterset type="AnnealingVariable" >
<param name="annealParameter" value="globalInnovationRate" />
<param name="annealType" value="sigmoid" />
Expand All @@ -100,7 +100,7 @@
<param name="weight" value="0.10"/>
</parameterset>
<parameterset type="strategysettings">
<param name="strategyName" value="SelectSubtourMode"/>
<param name="strategyName" value="SelectBestKPlanModes"/>
<param name="subpopulation" value="person"/>
<param name="weight" value="0.10"/>
</parameterset>
Expand Down Expand Up @@ -133,7 +133,7 @@

<module name="informedModeChoice">
<param name="modes" value="car,pt,bike,walk,ride"/>
<param name="topK" value="5"/>
<param name="topK" value="20"/>
<param name="constraintCheck" value="repair"/>
</module>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>matsim-all</artifactId>

<!-- PR-labelled release -->
<version>16.0-PR2982</version>
<version>16.0-PR2983</version>

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<!-- <version>16.0-SNAPSHOT</version>-->
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/matsim/run/RunKelheimScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.matsim.contrib.drt.extension.companions.DrtCompanionParams;
import org.matsim.contrib.drt.extension.companions.MultiModeDrtCompanionModule;
import org.matsim.contrib.drt.extension.estimator.MultiModalDrtLegEstimator;
import org.matsim.contrib.drt.extension.estimator.impl.ConstantDrtEstimator;
import org.matsim.contrib.drt.extension.estimator.impl.PessimisticDrtEstimator;
import org.matsim.contrib.drt.extension.estimator.run.DrtEstimatorConfigGroup;
import org.matsim.contrib.drt.extension.estimator.run.DrtEstimatorModule;
Expand Down Expand Up @@ -67,6 +66,7 @@
import org.matsim.modechoice.estimators.DefaultLegScoreEstimator;
import org.matsim.modechoice.estimators.FixedCostsEstimator;
import org.matsim.modechoice.pruning.DistanceBasedPruner;
import org.matsim.run.drt.OptimisticDrtEstimator;
import org.matsim.run.prepare.PrepareNetwork;
import org.matsim.run.prepare.PreparePopulation;
import org.matsim.simwrapper.SimWrapperConfigGroup;
Expand Down Expand Up @@ -365,7 +365,7 @@ public void handleEvent(PersonDepartureEvent event) {

controler.addOverridingModule(new DrtEstimatorModule()
.withInitialEstimator((cfg) -> switch (drtEstimator) {
case optimistic -> new ConstantDrtEstimator(cfg, 1, 200);
case optimistic -> new OptimisticDrtEstimator(cfg, 0.5, 200);
case pessimistic -> new PessimisticDrtEstimator(cfg);
}, "drt", "av"));

Expand Down
50 changes: 50 additions & 0 deletions src/main/java/org/matsim/run/drt/OptimisticDrtEstimator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.matsim.run.drt;

import org.matsim.contrib.drt.extension.estimator.DrtInitialEstimator;
import org.matsim.contrib.drt.fare.DrtFareParams;
import org.matsim.contrib.drt.routing.DrtRoute;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.core.utils.misc.OptionalTime;

/**
* Estimates using a constant detour factor and waiting time.
*/
public class OptimisticDrtEstimator implements DrtInitialEstimator {

private final DrtConfigGroup drtConfig;

/**
* Proportion of the max total travel time.
*/
private final double proportion;

/**
* Constant waiting time estimate in seconds.
*/
private final double waitingTime;

public OptimisticDrtEstimator(DrtConfigGroup drtConfig, double proportion, double waitingTime) {
this.drtConfig = drtConfig;
this.proportion = proportion;
this.waitingTime = waitingTime;
}

@Override
public Estimate estimate(DrtRoute route, OptionalTime departureTime) {

double distance = route.getDistance();
double travelTime = Math.max(route.getTravelTime().seconds(), route.getMaxTravelTime() * proportion);

double fare = 0;
if (drtConfig.getDrtFareParams().isPresent()) {
DrtFareParams fareParams = drtConfig.getDrtFareParams().get();
fare = fareParams.distanceFare_m * distance
+ fareParams.timeFare_h * travelTime / 3600.0
+ fareParams.baseFare;

fare = Math.max(fare, fareParams.minFarePerTrip);
}

return new Estimate(distance, travelTime, waitingTime, fare, 0);
}
}

0 comments on commit 1890a24

Please sign in to comment.