Skip to content

Commit d16ca05

Browse files
Merge branch 'moia-deployment' into prebooking-fix
2 parents 15cb17f + 8b61506 commit d16ca05

File tree

3 files changed

+191
-1
lines changed

3 files changed

+191
-1
lines changed

.github/workflows/moia-deploy-on-pr-merge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
run: mvn -pl org.matsim.contrib:sbb-extensions,org.matsim.contrib:drt,org.matsim.contrib:drt-extensions,org.matsim.contrib:discrete_mode_choice,org.matsim.contrib:simulatedannealing deploy -am --settings settings.xml -DskipTests=true -DaltSnapshotDeploymentRepository=github::default::https://maven.pkg.github.com/moia-oss/matsim-libs -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/moia-oss/matsim-libs
3131
- name: Trigger external development build
3232
run: |
33-
curl -XPOST -u "${{ secrets.PAT_USERNAME}}:${{secrets.PAT_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/moia-dev/matsim-external-development/dispatches --data '{"event_type": "build_application"}'
33+
curl -XPOST -u "${{ secrets.PAT_USERNAME}}:${{secrets.PAT_TOKEN}}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/moia-dev/transport-modeling/dispatches --data '{"event_type": "build_application"}'
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package org.matsim.contrib.drt.optimizer;
2+
3+
import com.google.common.base.Verify;
4+
import org.matsim.core.config.Config;
5+
import org.matsim.core.config.ReflectiveConfigGroup;
6+
7+
import java.util.List;
8+
import java.util.Optional;
9+
10+
/**
11+
* @author nkuehnel / MOIA
12+
*/
13+
public class DrtOptimizationConstraintsParams extends ReflectiveConfigGroup {
14+
15+
public static final String SET_NAME = "drtOptimizationConstraints";
16+
17+
public static String defaultConstraintSet = DrtOptimizationConstraintsSet.DEFAULT_PARAMS_NAME;
18+
19+
20+
public DrtOptimizationConstraintsParams() {
21+
super(SET_NAME);
22+
}
23+
24+
@Override
25+
protected void checkConsistency(Config config) {
26+
super.checkConsistency(config);
27+
List<DrtOptimizationConstraintsSet> drtOptimizationConstraintsSets = getDrtOptimizationConstraintsSets();
28+
29+
Verify.verify(!drtOptimizationConstraintsSets.isEmpty(),
30+
"At least one DrtOptimizationConstraintsParams is required.");
31+
Verify.verify(drtOptimizationConstraintsSets.stream()
32+
.anyMatch(params -> params.name.equals(defaultConstraintSet)),
33+
"Default DrtOptimizationConstraintsParams is required.");
34+
Verify.verify(drtOptimizationConstraintsSets.stream()
35+
.map(params -> params.name)
36+
.distinct()
37+
.count() == drtOptimizationConstraintsSets.size(),
38+
"Cannot have DrtOptimizationConstraintsParams with identical names.");
39+
}
40+
41+
public List<DrtOptimizationConstraintsSet> getDrtOptimizationConstraintsSets() {
42+
return getParameterSets(DrtOptimizationConstraintsSet.SET_NAME).stream()
43+
.filter(DrtOptimizationConstraintsSet.class::isInstance)
44+
.map(DrtOptimizationConstraintsSet.class::cast)
45+
.toList();
46+
}
47+
48+
public DrtOptimizationConstraintsSet addOrGetDefaultDrtOptimizationConstraintsSet() {
49+
Optional<DrtOptimizationConstraintsSet> drtOptParams = getDrtOptimizationConstraintsSets().stream()
50+
.filter(params -> params.name.equals(defaultConstraintSet))
51+
.findAny();
52+
if (drtOptParams.isEmpty()) {
53+
addParameterSet(new DrtOptimizationConstraintsSet());
54+
}
55+
return getDrtOptimizationConstraintsSets().stream()
56+
.filter(params -> params.name.equals(defaultConstraintSet))
57+
.findAny().orElseThrow();
58+
}
59+
60+
/**
61+
* for backwards compatibility with old drt config groups
62+
*/
63+
public void handleAddUnknownParam(final String paramName, final String value) {
64+
switch (paramName) {
65+
case "maxWaitTime":
66+
case "maxTravelTimeAlpha":
67+
case "maxTravelTimeBeta":
68+
case "maxAbsoluteDetour":
69+
case "maxDetourAlpha":
70+
case "maxDetourBeta":
71+
case "maxAllowedPickupDelay":
72+
case "rejectRequestIfMaxWaitOrTravelTimeViolated":
73+
case "maxWalkDistance":
74+
addOrGetDefaultDrtOptimizationConstraintsSet().addParam(paramName, value);
75+
break;
76+
default:
77+
super.handleAddUnknownParam(paramName, value);
78+
}
79+
}
80+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package org.matsim.contrib.drt.optimizer;
2+
3+
import com.google.common.base.Verify;
4+
import jakarta.validation.constraints.DecimalMin;
5+
import jakarta.validation.constraints.NotBlank;
6+
import jakarta.validation.constraints.PositiveOrZero;
7+
import org.matsim.core.config.Config;
8+
import org.matsim.core.config.ReflectiveConfigGroup;
9+
10+
public class DrtOptimizationConstraintsSet extends ReflectiveConfigGroup {
11+
12+
public static final String SET_NAME = "drtOptimizationConstraintsSet";
13+
public static final String DEFAULT_PARAMS_NAME = "default";
14+
15+
public DrtOptimizationConstraintsSet() {
16+
super(SET_NAME);
17+
}
18+
19+
@Parameter
20+
@Comment("name of optimization params")
21+
@NotBlank
22+
public String name = DEFAULT_PARAMS_NAME;
23+
24+
@Parameter
25+
@Comment("Max wait time for the bus to come (optimisation constraint).")
26+
@PositiveOrZero
27+
public double maxWaitTime = Double.NaN;// seconds
28+
29+
@Parameter
30+
@Comment("Defines the slope of the maxTravelTime estimation function (optimisation constraint), i.e. "
31+
+ "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). "
32+
+ "Alpha should not be smaller than 1.")
33+
@DecimalMin("1.0")
34+
public double maxTravelTimeAlpha = Double.NaN;// [-]
35+
36+
@Parameter
37+
@Comment("Defines the shift of the maxTravelTime estimation function (optimisation constraint), i.e. "
38+
+ "min(unsharedRideTime + maxAbsoluteDetour, maxTravelTimeAlpha * unsharedRideTime + maxTravelTimeBeta). "
39+
+ "Beta should not be smaller than 0.")
40+
@PositiveOrZero
41+
public double maxTravelTimeBeta = Double.NaN;// [s]
42+
43+
@Parameter
44+
@Comment(
45+
"Defines the maximum allowed absolute detour in seconds. Note that the detour is computed from the latest promised pickup time. " +
46+
"To enable the max detour constraint, maxAllowedPickupDelay has to be specified. maxAbsoluteDetour should not be smaller than 0, "
47+
+ "and should be higher than the offset maxDetourBeta. By default, this limit is disabled (i.e. set to Inf)")
48+
@PositiveOrZero
49+
public double maxAbsoluteDetour = Double.POSITIVE_INFINITY;// [s]
50+
51+
@Parameter
52+
@Comment(
53+
"Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised "
54+
+ "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel "
55+
+ "time constrain is used. This is the ratio part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourBeta).")
56+
@DecimalMin("1.0")
57+
public double maxDetourAlpha = Double.POSITIVE_INFINITY;
58+
59+
@Parameter
60+
@Comment(
61+
"Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised "
62+
+ "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel "
63+
+ "time constrain is used. This is the constant part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourAlpha).")
64+
@PositiveOrZero
65+
public double maxDetourBeta = Double.POSITIVE_INFINITY;// [s]
66+
67+
@Parameter
68+
@Comment(
69+
"Defines the maximum delay allowed from the initial scheduled pick up time. Once the initial pickup time is offered, the latest promised"
70+
+ "pickup time is calculated based on initial scheduled pickup time + maxAllowedPickupDelay. "
71+
+ "By default, this limit is disabled. If enabled, a value between 0 and 240 is a good choice.")
72+
@PositiveOrZero
73+
public double maxAllowedPickupDelay = Double.POSITIVE_INFINITY;// [s]
74+
75+
@Parameter
76+
@Comment("If true, the max travel and wait times of a submitted request"
77+
+ " are considered hard constraints (the request gets rejected if one of the constraints is violated)."
78+
+ " If false, the max travel and wait times are considered soft constraints (insertion of a request that"
79+
+ " violates one of the constraints is allowed, but its cost is increased by additional penalty to make"
80+
+ " it relatively less attractive). Penalisation of insertions can be customised by injecting a customised"
81+
+ " InsertionCostCalculator.PenaltyCalculator")
82+
public boolean rejectRequestIfMaxWaitOrTravelTimeViolated = true;//TODO consider renaming maxWalkDistance to max access/egress distance (or even have 2 separate params)
83+
84+
@Parameter
85+
@Comment(
86+
"Maximum beeline distance (in meters) to next stop location in stopbased system for access/egress walk leg to/from drt."
87+
+ " If no stop can be found within this maximum distance will return null (in most cases caught by fallback routing module).")
88+
@PositiveOrZero // used only for stopbased DRT scheme
89+
public double maxWalkDistance = Double.MAX_VALUE;// [m];
90+
91+
92+
@Parameter
93+
@Comment(
94+
"Time before reaching a planned dropoff from which it is not allowed to insert new detours for new requests. I.e.," +
95+
" if set to 180, then a vehicle will not divert to pickup or dropoff a new passenger once a boarded passenger is only " +
96+
"3 minutes away from her destination, even though her time window would allow it." +
97+
" Delayed detours just before arrival are usually perceived very negatively.")
98+
@PositiveOrZero
99+
public double lateDiversionthreshold = 0; // [s];
100+
101+
102+
@Override
103+
protected void checkConsistency(Config config) {
104+
super.checkConsistency(config);
105+
if ((maxDetourAlpha != Double.POSITIVE_INFINITY && maxDetourBeta != Double.POSITIVE_INFINITY) || maxAbsoluteDetour != Double.POSITIVE_INFINITY) {
106+
Verify.verify(maxAllowedPickupDelay != Double.POSITIVE_INFINITY, "Detour constraints are activated, " +
107+
"maxAllowedPickupDelay must be specified! A value between 0 and 240 seconds can be a good choice for maxAllowedPickupDelay.");
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)