CPD Results
The following document contains the results of PMD's CPD 7.3.0.
Duplications
File | Line |
---|---|
org/opentrafficsim/road/gtu/lane/tactical/following/IdmOld.java | 153 |
org/opentrafficsim/road/gtu/lane/tactical/following/IdmPlusOld.java | 170 |
} @Override public final String getLongName() { return String.format("%s (a=%.1fm/s\u00b2, b=%.1fm/s\u00b2, s0=%.1fm, tSafe=%.1fs, delta=%.2f)", getName(), this.a.getSI(), this.b.getSI(), this.s0.getSI(), this.tSafe.getSI(), this.delta); } @Override public final void setA(final Acceleration a) { this.a = a; } @Override public final void setT(final Duration t) { this.tSafe = t; } @Override public final void setFspeed(final double fSpeed) { this.delta = fSpeed; } // The following is inherited from CarFollowingModel @Override public final Speed desiredSpeed(final Parameters parameters, final SpeedLimitInfo speedInfo) throws ParameterException { throw new UnsupportedOperationException("Old car-following model does not support desired speed."); } @Override public final Length desiredHeadway(final Parameters parameters, final Speed speed) throws ParameterException { throw new UnsupportedOperationException("Old car-following model does not support desired headway."); } @Override public final Acceleration followingAcceleration(final Parameters parameters, final Speed speed, final SpeedLimitInfo speedInfo, final PerceptionIterable<? extends Headway> leaders) throws ParameterException { Length headway; Speed leaderSpeed; if (leaders.isEmpty()) { headway = new Length(Double.MAX_VALUE, LengthUnit.SI); leaderSpeed = speed; } else { Headway leader = leaders.first(); headway = leader.getDistance(); leaderSpeed = leader.getSpeed(); } return this.computeAcceleration(speed, speedInfo.getSpeedInfo(SpeedLimitTypes.MAX_VEHICLE_SPEED), leaderSpeed, headway, speedInfo.getSpeedInfo(SpeedLimitTypes.FIXED_SIGN)); } @Override public final String toString() { return "IDMOld [s0=" + this.s0 + ", a=" + this.a + ", b=" + this.b + ", tSafe=" + this.tSafe + ", stepSize=" |
File | Line |
---|---|
org/opentrafficsim/road/gtu/lane/tactical/following/IdmOld.java | 78 |
org/opentrafficsim/road/gtu/lane/tactical/following/IdmPlusOld.java | 84 |
public IdmOld(final Acceleration a, final Acceleration b, final Length s0, final Duration tSafe, final double delta) { this.a = a; this.b = b; this.s0 = s0; this.tSafe = tSafe; this.delta = delta; } /** * Desired speed (taking into account the urge to drive a little faster or slower than the posted speed limit). * @param speedLimit the speed limit * @param followerMaximumSpeed the maximum speed that the follower can drive * @return the desired speed */ private Speed vDes(final Speed speedLimit, final Speed followerMaximumSpeed) { return new Speed(Math.min(this.delta * speedLimit.getSI(), followerMaximumSpeed.getSI()), SpeedUnit.SI); } @Override public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed, final Speed leaderSpeed, final Length headway, final Speed speedLimit) { return computeAcceleration(followerSpeed, followerMaximumSpeed, leaderSpeed, headway, speedLimit, DEFAULT_STEP_SIZE); } @Override public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed, final Speed leaderSpeed, final Length headway, final Speed speedLimit, final Duration stepSize) { |
File | Line |
---|---|
org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 486 |
org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 593 |
Length longitudinalPosition2 = lane2.getLength().times(f2start); Length length1 = lane1.getLength().times(Math.abs(f1end - f1start)); Length length2 = lane2.getLength().times(Math.abs(f2end - f2start)); // Get geometries Polygon2d geometry1 = getGeometry(lane1, f1start, f1end, widthGenerator); Polygon2d geometry2 = getGeometry(lane2, f2start, f2end, widthGenerator); // Determine conflict rule ConflictRule conflictRule; if (lane1.getLink().getPriority().isBusStop() || lane2.getLink().getPriority().isBusStop()) { Throw.when(lane1.getLink().getPriority().isBusStop() && lane2.getLink().getPriority().isBusStop(), IllegalArgumentException.class, "Merge conflict between two links with bus stop priority not supported."); // TODO: handle bus priority on the model side conflictRule = new BusStopConflictRule(simulator, DefaultsNl.BUS); } else { conflictRule = new DefaultConflictRule(); } // Make conflict Conflict.generateConflictPair(ConflictType.MERGE, conflictRule, permitted, lane1, longitudinalPosition1, length1, |
File | Line |
---|---|
org/opentrafficsim/road/gtu/lane/perception/categories/neighbors/DirectNeighborsPerception.java | 176 |
org/opentrafficsim/road/gtu/lane/perception/categories/neighbors/DirectNeighborsPerception.java | 224 |
RelativePosition.FRONT, RelativePosition.FRONT, RelativePosition.FRONT, RelativePosition.REAR), ""); return new AbstractPerceptionReiterable<>(Try.assign(() -> getGtu(), "GtuException")) { @Override protected Iterator<PrimaryIteratorEntry> primaryIterator() { Iterator<Entry<LaneBasedGtu>> iterator = iterable.iterator(); return new Iterator<>() { @Override public boolean hasNext() { return iterator.hasNext(); } @Override public AbstractPerceptionReiterable<LaneBasedGtu, HeadwayGtu, LaneBasedGtu>.PrimaryIteratorEntry next() { Entry<LaneBasedGtu> entry = iterator.next(); return new PrimaryIteratorEntry(entry.object(), entry.distance()); } }; } @Override protected HeadwayGtu perceive(final LaneBasedGtu object, final Length distance) throws GtuException, ParameterException { return DirectNeighborsPerception.this.headwayGtuType.createDownstreamGtu(getObject(), object, distance); |
File | Line |
---|---|
org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 157 |
org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1029 |
long combinationsDone = totalCombinations - ((long) (lanes.size() - i)) * ((long) (lanes.size() - i)) / 2; if (combinationsDone / 100000000 > lastReported) { simulator.getLogger().always() .debug(String.format( "generating conflicts at %.0f%% (generated %d merge conflicts, %d split " + "conflicts, %d crossing conflicts)", 100.0 * combinationsDone / totalCombinations, numberMergeConflicts.get(), numberSplitConflicts.get(), numberCrossConflicts.get())); lastReported = combinationsDone / 100000000; } Lane lane1 = lanes.get(i); Set<Lane> down1 = lane1.nextLanes(null); Set<Lane> up1 = lane1.prevLanes(null); for (int j = i + 1; j < lanes.size(); j++) { Lane lane2 = lanes.get(j); if (ignoreList.contains(lane1, lane2)) { continue; } |
File | Line |
---|---|
org/opentrafficsim/road/network/factory/LaneFactory.java | 180 |
org/opentrafficsim/road/network/factory/LaneFactory.java | 207 |
this.laneType0 = laneType; this.speedLimit0 = speedLimit; Length width = DefaultsRoadNl.SOLID.getWidth(); Length offsetStripeStart = this.offset.plus(this.offsetStart); Length offsetStripeEnd = this.offset.plus(this.offsetEnd); ContinuousDoubleFunction offsetFunc = FractionalLengthData.of(0.0, offsetStripeStart.si, 1.0, offsetStripeEnd.si); ContinuousDoubleFunction widthFunc = FractionalLengthData.of(0.0, width.si, 1.0, width.si); this.firstStripe = Try.assign( () -> new Stripe("1", DefaultsRoadNl.SOLID, this.link, CrossSectionGeometry.of(this.line, SEGMENTS, offsetFunc, widthFunc)), "Unexpected exception while building link."); return this; } /** * Prepare the factory to add lanes from right to left. * @param rightLanes number of lanes right from the link design line * @param laneWidth lane width * @param laneType lane type * @param speedLimit speed limit * @return LaneFactory this lane factory for method chaining */ public LaneFactory rightToLeft(final double rightLanes, final Length laneWidth, final LaneType laneType, |
File | Line |
---|---|
org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1086 |
org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1177 |
} long time = System.currentTimeMillis(); // wait max 60 sec for last maxqueue jobs while (numberOfJobs.get() > 0 && System.currentTimeMillis() - time < 60000) { try { Thread.sleep(10); } catch (InterruptedException exception) { // ignore } } executor.shutdown(); while (!executor.isTerminated()) { try { Thread.sleep(1); } catch (InterruptedException exception) { // ignore } } simulator.getLogger().always() .debug(String.format( "generating conflicts complete (generated %d merge conflicts, %d split " + "conflicts, %d crossing conflicts)", numberMergeConflicts.get(), numberSplitConflicts.get(), numberCrossConflicts.get())); } /** * Build conflicts on list of lanes; parallel implementation. Big jobs. * @param lanes list of Lanes * @param simulator the simulator * @param widthGenerator the width generator * @param ignoreList lane combinations to ignore * @param permittedList lane combinations that are permitted by traffic control */ public static void buildConflictsParallelBig(final List<Lane> lanes, final OtsSimulatorInterface simulator, |
File | Line |
---|---|
org/opentrafficsim/road/gtu/lane/tactical/util/lmrs/Cooperation.java | 47 |
org/opentrafficsim/road/gtu/lane/tactical/util/lmrs/Cooperation.java | 131 |
Acceleration a = new Acceleration(Double.MAX_VALUE, AccelerationUnit.SI); double dCoop = params.getParameter(DCOOP); Speed ownSpeed = perception.getPerceptionCategory(EgoPerception.class).getSpeed(); RelativeLane relativeLane = new RelativeLane(lat, 1); for (HeadwayGtu leader : perception.getPerceptionCategory(NeighborsPerception.class).getLeaders(relativeLane)) { Parameters params2 = leader.getParameters(); double desire = lat.equals(LateralDirectionality.LEFT) ? params2.getParameter(DRIGHT) : lat.equals(LateralDirectionality.RIGHT) ? params2.getParameter(DLEFT) : 0; if (desire >= dCoop && (leader.getSpeed().gt0() || leader.getDistance().gt0())) |
File | Line |
---|---|
org/opentrafficsim/road/gtu/lane/tactical/following/FixedAccelerationModel.java | 110 |
org/opentrafficsim/road/gtu/lane/tactical/following/SequentialFixedAccelerationModel.java | 177 |
} @Override public final void setA(final Acceleration a) { // } @Override public final void setT(final Duration t) { // } @Override public final void setFspeed(final double fSpeed) { // } // The following is inherited from CarFollowingModel @Override public final Speed desiredSpeed(final Parameters parameters, final SpeedLimitInfo speedInfo) throws ParameterException { return null; } @Override public final Length desiredHeadway(final Parameters parameters, final Speed speed) throws ParameterException { return null; } @Override public final Acceleration followingAcceleration(final Parameters parameters, final Speed speed, final SpeedLimitInfo speedInfo, final PerceptionIterable<? extends Headway> leaders) throws ParameterException { return null; } |
File | Line |
---|---|
org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1027 |
org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1146 |
for (int i = 0; i < lanes.size(); i++) { long combinationsDone = totalCombinations - ((long) (lanes.size() - i)) * ((long) (lanes.size() - i - 1)) / 2; if (combinationsDone / 100000000 > lastReported) { simulator.getLogger().always() .debug(String.format( "generating conflicts at %.0f%% (generated %d merge conflicts, %d split " + "conflicts, %d crossing conflicts)", 100.0 * combinationsDone / totalCombinations, numberMergeConflicts.get(), numberSplitConflicts.get(), numberCrossConflicts.get())); lastReported = combinationsDone / 100000000; } |
File | Line |
---|---|
org/opentrafficsim/road/gtu/lane/perception/structure/LaneStructure.java | 248 |
org/opentrafficsim/road/gtu/lane/perception/structure/LaneStructure.java | 347 |
public Iterable<Entry<LaneBasedGtu>> getUpstreamGtus(final RelativeLane relativeLane, final RelativePosition.Type egoPosition, final RelativePosition.Type otherPosition, final RelativePosition.Type egoDistancePosition, final RelativePosition.Type otherDistancePosition) { update(); Length dx = LaneStructure.this.egoGtu.getRelativePositions().get(egoPosition).dx(); Length dxDistance = LaneStructure.this.egoGtu.getRelativePositions().get(egoDistancePosition).dx(); return new NavigatingIterable<>(LaneBasedGtu.class, this.upstream, start((record) -> startUpstream(record, egoPosition), relativeLane), (record) -> { |
File | Line |
---|---|
org/opentrafficsim/road/network/lane/object/detector/LoopDetector.java | 638 |
org/opentrafficsim/road/network/lane/object/detector/LoopDetector.java | 754 |
return new Table("periodic", "periodic measurements", columns) { @Override public Iterator<Row> iterator() { Iterator<LoopDetector> iterator = detectors.iterator(); Predicate<Entry<GtuType, GtuTypeData>> gtuTypeEntryFilter = (entry) -> !includeGtuTypeColumn && entry.getKey() == null || Arrays.stream(gtuTypes).anyMatch((g) -> Objects.equals(g, entry.getKey())); return new Iterator<>() { /** GTU type data iterator. */ private Iterator<Entry<GtuType, GtuTypeData>> dataIterator = Collections.emptyIterator(); /** Index iterator. */ private Iterator<Integer> indexIterator = Collections.emptyIterator(); |
File | Line |
---|---|
org/opentrafficsim/road/gtu/lane/control/LinearCacc.java | 33 |
org/opentrafficsim/road/gtu/lane/control/PloegCacc.java | 31 |
public LinearCacc(final DelayedActuation delayedActuation) { super(delayedActuation); } @Override public Acceleration getFollowingAcceleration(final LaneBasedGtu gtu, final PerceptionCollectable<HeadwayGtu, LaneBasedGtu> leaders, final Parameters settings) throws ParameterException { HeadwayGtu leader = leaders.first(); if (leader.getAcceleration() == null) { // ACC mode return super.getFollowingAcceleration(gtu, leaders, settings); } double es = leader.getDistance().si - gtu.getSpeed().si * settings.getParameter(TDCACC).si - settings.getParameter(X0).si; double ev = leader.getSpeed().si - gtu.getSpeed().si; |
File | Line |
---|---|
org/opentrafficsim/road/network/lane/Lane.java | 841 |
org/opentrafficsim/road/network/lane/Lane.java | 870 |
public final LaneBasedGtu getGtuAhead(final Length position, final RelativePosition.Type relativePosition, final Time when) throws GtuException { List<LaneBasedGtu> list = this.gtuList.get(when); if (list.isEmpty()) { return null; } int[] search = lineSearch((final int index) -> { LaneBasedGtu gtu = list.get(index); return gtu.position(this, gtu.getRelativePositions().get(relativePosition), when).si; }, list.size(), position.si); if (search[1] < list.size()) |