Skip to content

Commit

Permalink
add missing classes
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuehnel committed Jun 11, 2024
1 parent 774ba43 commit cfa2fa7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.matsim.contrib.drt.optimizer.constraints;

import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.population.Person;
import org.matsim.utils.objectattributes.attributable.Attributes;

/**
* @author nkuehnel / MOIA
*/
public interface ConstraintSetChooser {

DrtOptimizationConstraintsSet chooseConstraintSet(double departureTime, Link accessActLink, Link egressActLink, Person person,
Attributes tripAttributes);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.matsim.contrib.drt.routing;

import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet;
import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet;

/**
* @author nkuehnel / MOIA
*/
public class DefaultDrtRouteConstraintsCalculator implements DrtRouteConstraintsCalculator {

/**
* Calculates the maximum travel time defined as: drtCfg.getMaxTravelTimeAlpha() * unsharedRideTime + drtCfg.getMaxTravelTimeBeta()
*
* @param constraintsSet
* @param unsharedRideTime ride time of the direct (shortest-time) route
* @return maximum travel time
*/
@Override
public double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime) {
if(constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) {
return defaultSet.maxTravelTimeAlpha * unsharedRideTime
+ defaultSet.maxTravelTimeBeta;
} else {
throw new IllegalArgumentException("Constraint set is not a default set");
}
}

/**
* Calculates the maximum ride time defined as: drtCfg.maxDetourAlpha * unsharedRideTime + drtCfg.maxDetourBeta
*
* @param constraintsSet
* @param unsharedRideTime ride time of the direct (shortest-time) route
* @return maximum ride time
*/
@Override
public double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime) {
if(constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) {
return Math.min(unsharedRideTime + defaultSet.maxAbsoluteDetour,
defaultSet.maxDetourAlpha * unsharedRideTime
+ defaultSet.maxDetourBeta);
} else {
throw new IllegalArgumentException("Constraint set is not a default set");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.matsim.contrib.drt.routing;

import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsSet;

/**
* @author nkuehnel / MOIA
*/
public interface DrtRouteConstraintsCalculator {

double getMaxTravelTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime);

double getMaxRideTime(DrtOptimizationConstraintsSet constraintsSet, double unsharedRideTime);
}

0 comments on commit cfa2fa7

Please sign in to comment.