CPD Results
The following document contains the results of PMD's CPD 7.0.0.
Duplications
| File | Line |
|---|---|
| org/opentrafficsim/road/gtu/lane/tactical/following/IdmOld.java | 158 |
| org/opentrafficsim/road/gtu/lane/tactical/following/IdmPlusOld.java | 175 |
}
/** {@inheritDoc} */
@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);
}
/** {@inheritDoc} */
@Override
public final void setA(final Acceleration a)
{
this.a = a;
}
/** {@inheritDoc} */
@Override
public final void setT(final Duration t)
{
this.tSafe = t;
}
/** {@inheritDoc} */
@Override
public final void setFspeed(final double fSpeed)
{
this.delta = fSpeed;
}
// The following is inherited from CarFollowingModel
/** {@inheritDoc} */
@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.");
}
/** {@inheritDoc} */
@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.");
}
/** {@inheritDoc} */
@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));
}
/** {@inheritDoc} */
@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 Speed; the speed limit
* @param followerMaximumSpeed Speed; the maximum speed that the follower can drive
* @return DoubleScalarRel<SpeedUnit>; 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);
}
/** {@inheritDoc} */
@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);
}
/** {@inheritDoc} */
@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 | 496 |
| org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 606 |
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/network/factory/LaneFactory.java | 179 |
| org/opentrafficsim/road/network/factory/LaneFactory.java | 205 |
this.laneType0 = laneType;
this.speedLimit0 = speedLimit;
Length width = getWidth(Type.SOLID);
List<CrossSectionSlice> slices = LaneGeometryUtil.getSlices(this.line, this.offset.plus(this.offsetStart), width);
PolyLine2d centerLine = this.line.flattenOffset(LaneGeometryUtil.getCenterOffsets(this.line, slices), SEGMENTS);
PolyLine2d leftEdge = this.line.flattenOffset(LaneGeometryUtil.getLeftEdgeOffsets(this.line, slices), SEGMENTS);
PolyLine2d rightEdge = this.line.flattenOffset(LaneGeometryUtil.getRightEdgeOffsets(this.line, slices), SEGMENTS);
Polygon2d contour = LaneGeometryUtil.getContour(leftEdge, rightEdge);
this.firstStripe = Try.assign(() -> new Stripe(Type.SOLID, this.link, new OtsLine2d(centerLine), contour, slices),
"Unexpected exception while building link.");
return this;
}
/**
* Prepare the factory to add lanes from right to left.
* @param rightLanes double; number of lanes right from the link design line
* @param laneWidth Length; lane width
* @param laneType LaneType; lane type
* @param speedLimit Speed; 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 | 163 |
| org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1059 |
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/gtu/lane/perception/categories/neighbors/AccPerception.java | 52 |
| org/opentrafficsim/road/gtu/lane/perception/categories/neighbors/CaccPerception.java | 53 |
public AccPerception(final LanePerception perception, final HeadwayGtuType sensors)
{
super(perception);
this.sensors = sensors;
}
/** {@inheritDoc} */
@Override
public void updateAll() throws GtuException, NetworkException, ParameterException
{
// lazy evaluation
}
/** {@inheritDoc} */
@Override
public PerceptionCollectable<HeadwayGtu, LaneBasedGtu> getLeaders()
{
return computeIfAbsent("leaders", () -> computeLeaders());
}
/**
* Computes leaders.
* @return perception iterable for leaders
*/
private PerceptionCollectable<HeadwayGtu, LaneBasedGtu> computeLeaders()
{
try
{
LaneStructureRecord record = getPerception().getLaneStructure().getRootRecord();
Length pos = record.getStartDistance().neg();
pos = pos.plus(getGtu().getFront().dx());
boolean ignoreIfUpstream = true;
return new DownstreamNeighboursIterableACC(getGtu(), record, Length.max(Length.ZERO, pos), | |
| File | Line |
|---|---|
| org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1116 |
| org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1209 |
}
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<Lane>; list of Lanes
* @param simulator OtsSimulatorInterface; the simulator
* @param widthGenerator WidthGenerator; the width generator
* @param ignoreList LaneCombinationList; lane combinations to ignore
* @param permittedList LaneCombinationList; lane combinations that are permitted by traffic control
* @throws OtsGeometryException in case of geometry exception
*/
public static void buildConflictsParallelBig(final List<Lane> lanes, final OtsSimulatorInterface simulator, | |
| File | Line |
|---|---|
| org/opentrafficsim/road/gtu/lane/tactical/util/lmrs/Cooperation.java | 49 |
| org/opentrafficsim/road/gtu/lane/tactical/util/lmrs/Cooperation.java | 140 |
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 | 117 |
| org/opentrafficsim/road/gtu/lane/tactical/following/SequentialFixedAccelerationModel.java | 183 |
}
/** {@inheritDoc} */
@Override
public final void setA(final Acceleration a)
{
//
}
/** {@inheritDoc} */
@Override
public final void setT(final Duration t)
{
//
}
/** {@inheritDoc} */
@Override
public final void setFspeed(final double fSpeed)
{
//
}
// The following is inherited from CarFollowingModel
/** {@inheritDoc} */
@Override
public final Speed desiredSpeed(final Parameters parameters, final SpeedLimitInfo speedInfo) throws ParameterException
{
return null;
}
/** {@inheritDoc} */
@Override
public final Length desiredHeadway(final Parameters parameters, final Speed speed) throws ParameterException
{
return null;
}
/** {@inheritDoc} */
@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 | 1057 |
| org/opentrafficsim/road/network/lane/conflict/ConflictBuilder.java | 1178 |
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/tactical/util/lmrs/Cooperation.java | 35 |
| org/opentrafficsim/road/gtu/lane/tactical/util/lmrs/Cooperation.java | 77 |
| org/opentrafficsim/road/gtu/lane/tactical/util/lmrs/Cooperation.java | 126 |
Cooperation PASSIVE = new Cooperation()
{
/** {@inheritDoc} */
@Override
public Acceleration cooperate(final LanePerception perception, final Parameters params, final SpeedLimitInfo sli,
final CarFollowingModel cfm, final LateralDirectionality lat, final Desire ownDesire)
throws ParameterException, OperationalPlanException
{
if ((lat.isLeft() && !perception.getLaneStructure().getExtendedCrossSection().contains(RelativeLane.LEFT))
|| (lat.isRight() && !perception.getLaneStructure().getExtendedCrossSection().contains(RelativeLane.RIGHT)))
{
return new Acceleration(Double.MAX_VALUE, AccelerationUnit.SI);
}
Acceleration b = params.getParameter(ParameterTypes.B); | |
| File | Line |
|---|---|
| org/opentrafficsim/road/gtu/lane/perception/categories/neighbors/AccPerception.java | 121 |
| org/opentrafficsim/road/gtu/lane/perception/categories/neighbors/CaccPerception.java | 122 |
DownstreamNeighboursIterableACC(final LaneBasedGtu perceivingGtu, final LaneRecordInterface<?> root,
final Length initialPosition, final Length maxDistance, final RelativePosition relativePosition,
final HeadwayGtuType headwayGtuType, final RelativeLane lane, final boolean ignoreIfUpstream)
{
super(perceivingGtu, root, initialPosition, maxDistance, relativePosition, headwayGtuType, lane, ignoreIfUpstream);
}
/** {@inheritDoc} */
@Override
protected Entry getNext(final LaneRecordInterface<?> record, final Length position, final Integer counter)
throws GtuException
{
Entry next;
do
{
next = super.getNext(record, position, counter);
}
// skip leaders that are not the direct leader and that are not CACC
while (next != null && first() != null); | |
| 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);
}
/** {@inheritDoc} */
@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 | 857 |
| org/opentrafficsim/road/network/lane/Lane.java | 887 |
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()) | |
