File tree Expand file tree Collapse file tree
raptor/src/main/java/org/opentripplanner/raptor/api/request Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import java .time .Duration ;
44import java .util .ArrayList ;
55import java .util .BitSet ;
6+ import java .util .HashSet ;
67import java .util .List ;
78import java .util .stream .IntStream ;
89import javax .annotation .Nullable ;
@@ -144,18 +145,21 @@ private List<RaptorViaConnection> validateConnections(List<BuilderStopAndTransfe
144145 .toList ();
145146
146147 // Compare all pairs to check for duplicates and non-optimal connections
148+ var connectionsToRemove = new HashSet <RaptorViaConnection >();
147149 for (int i = 0 ; i < list .size (); ++i ) {
148150 var a = list .get (i );
149151 for (int j = i + 1 ; j < list .size (); ++j ) {
150152 var b = list .get (j );
151- if (a .isBetterOrEqual (b ) || b .isBetterOrEqual (a )) {
152- throw new IllegalArgumentException (
153- "All connection need to be pareto-optimal: (" + a + ") <-> (" + b + ")"
154- );
153+ if (a .isBetterOrEqual (b )) {
154+ connectionsToRemove .add (b );
155+ continue ;
156+ }
157+ if (b .isBetterOrEqual (a )) {
158+ connectionsToRemove .add (a );
155159 }
156160 }
157161 }
158- return list ;
162+ return list . stream (). filter ( connection -> ! connectionsToRemove . contains ( connection )). toList () ;
159163 }
160164
161165 public abstract static sealed class AbstractBuilder <T extends AbstractBuilder > {
You can’t perform that action at this time.
0 commit comments