The following document contains the results of PMD's CPD 6.4.0.
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 317 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 335 |
this.simulator = (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator; try { OTSNode from = new OTSNode(this.network, "From", new OTSPoint3D(0, 0, 0)); OTSNode end = new OTSNode(this.network, "End", new OTSPoint3D(2000, 0, 0)); OTSNode from2a = new OTSNode(this.network, "From2a", new OTSPoint3D(0, -50, 0)); OTSNode from2b = new OTSNode(this.network, "From2b", new OTSPoint3D(490, -2, 0)); OTSNode firstVia = new OTSNode(this.network, "Via1", new OTSPoint3D(500, 0, 0)); OTSNode end2a = new OTSNode(this.network, "End2a", new OTSPoint3D(1020, -2, 0)); OTSNode end2b = new OTSNode(this.network, "End2b", new OTSPoint3D(2000, -50, 0)); OTSNode secondVia = new OTSNode(this.network, "Via2", new OTSPoint3D(1000, 0, 0)); CompoundProperty cp = null; try { cp = new CompoundProperty("", "", "", this.props, false, 0); } catch (PropertyException exception2) { exception2.printStackTrace(); } String networkType = (String) cp.findByKey("Network").getValue(); boolean merge = networkType.startsWith("M"); int lanesOnMain = Integer.parseInt(networkType.split(" ")[merge ? 1 : 5]); int lanesOnBranch = Integer.parseInt(networkType.split(" ")[3]); int lanesOnCommon = lanesOnMain + lanesOnBranch; int lanesOnCommonCompressed = Integer.parseInt(networkType.split(" ")[merge ? 5 : 1]); LaneType laneType = LaneType.TWO_WAY_LANE; // Get car-following model name String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.props, false, 0); Property<?> cfmp = propertyContainer.findByKey("CarFollowingModel"); if (null == cfmp) { throw new Error("Cannot find \"Car following model\" property"); } if (cfmp instanceof SelectionProperty) { carFollowingModelName = ((SelectionProperty) cfmp).getValue(); } else { throw new Error("\"Car following model\" property has wrong type"); } // Get car-following model parameter for (Property<?> ap : new CompoundProperty("", "", "", this.props, false, 0)) { if (ap instanceof CompoundProperty) { cp = (CompoundProperty) ap; if (ap.getKey().contains("IDM")) { // System.out.println("Car following model name appears to be " + ap.getKey()); Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } // Get lane change model cfmp = propertyContainer.findByKey("LaneChanging"); if (null == cfmp) { throw new Error("Cannot find \"Lane changing\" property"); } if (cfmp instanceof SelectionProperty) { String laneChangeModelName = ((SelectionProperty) cfmp).getValue(); if ("Egoistic".equals(laneChangeModelName)) { this.laneChangeModel = new Egoistic(); } else if ("Altruistic".equals(laneChangeModelName)) { this.laneChangeModel = new Altruistic(); } else { throw new Error("Lane changing " + laneChangeModelName + " not implemented"); } } else { throw new Error("\"Lane changing\" property has wrong type"); } if (merge) { // provide a route -- at the merge point, the GTU can otherwise decide to "go back" ArrayList<Node> mainRouteNodes = new ArrayList<>(); mainRouteNodes.add(firstVia); mainRouteNodes.add(secondVia); mainRouteNodes.add(end); Route mainRoute = new Route("main", mainRouteNodes); this.routeGenerator = new FixedRouteGenerator(mainRoute); } else { // determine the routes List<FrequencyAndObject<Route>> routeProbabilities = new ArrayList<>(); ArrayList<Node> mainRouteNodes = new ArrayList<>(); mainRouteNodes.add(firstVia); mainRouteNodes.add(secondVia); mainRouteNodes.add(end); Route mainRoute = new Route("main", mainRouteNodes); routeProbabilities.add(new FrequencyAndObject<>(lanesOnMain, mainRoute)); ArrayList<Node> sideRouteNodes = new ArrayList<>(); sideRouteNodes.add(firstVia); sideRouteNodes.add(secondVia); sideRouteNodes.add(end2a); sideRouteNodes.add(end2b); Route sideRoute = new Route("side", sideRouteNodes); routeProbabilities.add(new FrequencyAndObject<>(lanesOnBranch, sideRoute)); try { this.routeGenerator = new ProbabilisticRouteGenerator(routeProbabilities, new MersenneTwister(1234)); } catch (ProbabilityException exception) { exception.printStackTrace(); } } // Get remaining properties for (Property<?> ap : new CompoundProperty("", "", "", this.props, false, 0)) { if (ap instanceof SelectionProperty) { SelectionProperty sp = (SelectionProperty) ap; if ("TacticalPlanner".equals(sp.getKey())) { String tacticalPlannerName = sp.getValue(); if ("IDM".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingTacticalPlannerFactory(this.carFollowingModelCars)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingTacticalPlannerFactory(this.carFollowingModelTrucks)); } else if ("MOBIL/IDM".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(new LaneBasedCFLCTacticalPlannerFactory( this.carFollowingModelCars, this.laneChangeModel)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(new LaneBasedCFLCTacticalPlannerFactory( this.carFollowingModelTrucks, this.laneChangeModel)); } else if ("DIRECTED/IDM".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingDirectedChangeTacticalPlannerFactory( this.carFollowingModelCars)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingDirectedChangeTacticalPlannerFactory( this.carFollowingModelTrucks)); } else if ("LMRS".equals(tacticalPlannerName)) { // provide default parameters with the car-following model this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory())); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory())); } else if ("Toledo".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(new ToledoFactory()); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(new ToledoFactory()); } else { throw new Error("Don't know how to create a " + tacticalPlannerName + " tactical planner"); } } } else if (ap instanceof ProbabilityDistributionProperty) { ProbabilityDistributionProperty pdp = (ProbabilityDistributionProperty) ap; String modelName = ap.getKey(); if (modelName.equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } } else if (ap instanceof ContinuousProperty) { ContinuousProperty contP = (ContinuousProperty) ap; if (contP.getKey().startsWith("Flow")) { this.averageHeadway = new Duration(3600.0 / contP.getValue(), SECOND); this.minimumHeadway = new Duration(3, SECOND); this.headwayGenerator = new DistErlang(new MersenneTwister(1234), 4, DoubleScalar.minus(this.averageHeadway, this.minimumHeadway).getSI()); } } else if (ap instanceof CompoundProperty) { CompoundProperty compoundProperty = (CompoundProperty) ap; if (ap.getKey().equals("Output")) { continue; // Output settings are handled elsewhere } if (ap.getKey().contains("IDM")) { Acceleration a = IDMPropertySet.getA(compoundProperty); Acceleration b = IDMPropertySet.getB(compoundProperty); Length s0 = IDMPropertySet.getS0(compoundProperty); Duration tSafe = IDMPropertySet.getTSafe(compoundProperty); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } if (merge) { setupGenerator(LaneFactory.makeMultiLane(this.network, "From2a to From2b", from2a, from2b, null, lanesOnBranch, 0, lanesOnCommon - lanesOnBranch, laneType, this.speedLimit, this.simulator)); LaneFactory.makeMultiLaneBezier(this.network, "From2b to FirstVia", from2a, from2b, firstVia, secondVia, lanesOnBranch, lanesOnCommon - lanesOnBranch, lanesOnCommon - lanesOnBranch, laneType, this.speedLimit, this.simulator); } else { LaneFactory.makeMultiLaneBezier(this.network, "SecondVia to end2a", firstVia, secondVia, end2a, end2b, lanesOnBranch, lanesOnCommon - lanesOnBranch, lanesOnCommon - lanesOnBranch, laneType, this.speedLimit, this.simulator); setupSink(LaneFactory.makeMultiLane(this.network, "end2a to end2b", end2a, end2b, null, lanesOnBranch, lanesOnCommon - lanesOnBranch, 0, laneType, this.speedLimit, this.simulator), laneType); } Lane[] startLanes = LaneFactory.makeMultiLane(this.network, "From to FirstVia", from, firstVia, null, merge ? lanesOnMain : lanesOnCommonCompressed, laneType, this.speedLimit, this.simulator); setupGenerator(startLanes); Lane[] common = LaneFactory.makeMultiLane(this.network, "FirstVia to SecondVia", firstVia, secondVia, null, lanesOnCommon, laneType, this.speedLimit, this.simulator); if (merge) { for (int i = lanesOnCommonCompressed; i < lanesOnCommon; i++) { setupBlock(common[i]); } } setupSink( LaneFactory.makeMultiLane(this.network, "SecondVia to end", secondVia, end, null, merge ? lanesOnCommonCompressed : lanesOnMain, laneType, this.speedLimit, this.simulator), laneType); for (int index = 0; index < lanesOnCommon; index++) { this.paths.add(new ArrayList<Lane>()); Lane lane = common[index]; // Follow back while (lane.prevLanes(this.gtuType).size() > 0) { if (lane.prevLanes(this.gtuType).size() > 1) { throw new NetworkException("This network should not have lane merge points"); } lane = lane.prevLanes(this.gtuType).keySet().iterator().next(); } // Follow forward while (true) { this.paths.get(index).add(lane); int branching = lane.nextLanes(this.gtuType).size(); if (branching == 0) { break; } if (branching > 1) { throw new NetworkException("This network should not have lane split points"); } lane = lane.nextLanes(this.gtuType).keySet().iterator().next(); } } this.simulator.scheduleEventAbs(new Time(0.999, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); |
File | Line |
---|---|
ahfe\AHFEAnimation.java | 129 |
ahfe\AHFESimulation.java | 126 |
public AHFEAnimation(final Integer replication, final String anticipationStrategy, final Duration reactionTime, final Duration anticipationTime, final double truckFraction, final double distanceError, final double speedError, final double accelerationError, final Frequency leftDemand, final Frequency rightDemand, final double leftFraction) { super(); this.replication = replication; this.anticipationStrategy = anticipationStrategy; this.reactionTime = reactionTime; this.anticipationTime = anticipationTime; this.truckFraction = truckFraction; this.distanceError = distanceError; this.speedError = speedError; this.accelerationError = accelerationError; this.leftDemand = leftDemand; this.rightDemand = rightDemand; this.leftFraction = leftFraction; } /** * @return replication. */ public Integer getReplication() { return this.replication; } /** * @return anticipationStrategy. */ public String getAnticipationStrategy() { return this.anticipationStrategy; } /** * @return reactionTime. */ public Duration getReactionTime() { return this.reactionTime; } /** * @return anticipationTime. */ public Duration getAnticipationTime() { return this.anticipationTime; } /** * @return truckFraction. */ public double getTruckFraction() { return this.truckFraction; } /** * @return distanceError. */ public double getDistanceError() { return this.distanceError; } /** * @return speedError. */ public double getSpeedError() { return this.speedError; } /** * @return accelerationError. */ public double getAccelerationError() { return this.accelerationError; } /** * @return leftDemand. */ public Frequency getLeftDemand() { return this.leftDemand; } /** * @return rightDemand. */ public Frequency getRightDemand() { return this.rightDemand; } /** * @return leftFraction. */ public double getLeftFraction() { return this.leftFraction; } /** * Main program. * @param args String[]; the command line arguments * @throws SimRuntimeException should never happen */ public static void main(final String[] args) throws SimRuntimeException { AbstractGTU.ALIGNED = false; long t1 = System.currentTimeMillis(); boolean autorun = false; int replication = 1; String anticipationStrategy = "none"; Duration reactionTime = Duration.createSI(0.0); Duration anticipationTime = Duration.ZERO; double truckFraction = 0.05; double distanceError = 0.0; // 0.05; double speedError = 0.0; // 0.01; double accelerationError = 0.0; // 0.10; Frequency leftDemand = new Frequency(3500.0, FrequencyUnit.PER_HOUR); Frequency rightDemand = new Frequency(3200.0, FrequencyUnit.PER_HOUR); double leftFraction = 0.55; String scenario = "test"; for (String arg : args) { int equalsPos = arg.indexOf("="); if (equalsPos >= 0) { // set something String key = arg.substring(0, equalsPos); String value = arg.substring(equalsPos + 1); if ("autorun".equalsIgnoreCase(key)) { if ("true".equalsIgnoreCase(value)) { autorun = true; } else if ("false".equalsIgnoreCase(value)) { autorun = false; } else { System.err.println("bad autorun value " + value + " (ignored)"); } } else if ("replication".equalsIgnoreCase(key)) { try { replication = Integer.parseInt(value); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable replication number \"" + value + "\""); } } else if ("anticipation".equalsIgnoreCase(key)) { if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("constant_speed") || value.equalsIgnoreCase("constant_acceleration")) { anticipationStrategy = value; } else { System.err.println("Ignoring unparsable anticipation \"" + value + "\""); } } else if ("reactiontime".equalsIgnoreCase(key)) { try { reactionTime = Duration.createSI(java.lang.Double.parseDouble(value)); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable reaction time \"" + value + "\""); } } else if ("anticipationtime".equalsIgnoreCase(key)) { try { anticipationTime = Duration.createSI(java.lang.Double.parseDouble(value)); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable anticipation time \"" + value + "\""); } } else if ("truckfraction".equalsIgnoreCase(key)) { try { truckFraction = java.lang.Double.parseDouble(value); Throw.when(truckFraction < 0.0 || truckFraction > 1.0, IllegalArgumentException.class, "Truck fraction must be between 0 and 1."); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable truck fraction \"" + value + "\""); } } else if ("distanceerror".equalsIgnoreCase(key)) { try { distanceError = java.lang.Double.parseDouble(value); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable distance error \"" + value + "\""); } } else if ("speederror".equalsIgnoreCase(key)) { try { speedError = java.lang.Double.parseDouble(value); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable speed error \"" + value + "\""); } } else if ("accelerationerror".equalsIgnoreCase(key)) { try { accelerationError = java.lang.Double.parseDouble(value); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable acceleration error \"" + value + "\""); } } else if ("leftdemand".equalsIgnoreCase(key)) { try { leftDemand = new Frequency(java.lang.Double.parseDouble(value), FrequencyUnit.PER_HOUR); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable left demand \"" + value + "\""); } } else if ("rightdemand".equalsIgnoreCase(key)) { try { rightDemand = new Frequency(java.lang.Double.parseDouble(value), FrequencyUnit.PER_HOUR); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable right demand \"" + value + "\""); } } else if ("leftfraction".equalsIgnoreCase(key)) { try { leftFraction = java.lang.Double.parseDouble(value); } catch (NumberFormatException nfe) { System.err.println("Ignoring unparsable left fraction \"" + value + "\""); } } else if ("scenario".equalsIgnoreCase(key)) { scenario = value; } else { System.out.println("Ignoring unknown setting " + arg); } } else { // not a flag System.err.println("Ignoring argument " + arg); } } final boolean finalAutoRun = autorun; final int finalReplication = replication; final String finalAnticipationStrategy = anticipationStrategy; final Duration finalReactionTime = reactionTime; final Duration finalAnticipationTime = anticipationTime; final double finalTruckFraction = truckFraction; final double finalDistanceError = distanceError; final double finalSpeedError = speedError; final double finalAccelerationError = accelerationError; final Frequency finalLeftDemand = leftDemand; final Frequency finalRightDemand = rightDemand; final double finalLeftFraction = leftFraction; final String finalScenario = scenario; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 724 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 743 |
}, XMLNetworks.this.getColorer(), templateDistribution, GeneratorPositions.create(initialPositions, this.stream), this.network, this.simulator, /*- new LaneBasedGTUGenerator.RoomChecker() { @Override public Speed canPlace(Speed leaderSpeed, org.djunits.value.vdouble.scalar.Length headway, LaneBasedGTUCharacteristics laneBasedGTUCharacteristics) throws NetworkException { // This implementation simply returns null if the headway is less than the headway wanted for driving at // the current speed of the leader if (headway.lt(laneBasedGTUCharacteristics .getStrategicalPlanner() .getDrivingCharacteristics() .getGTUFollowingModel() .minimumHeadway(leaderSpeed, leaderSpeed, new Length(0.1, LengthUnit.METER), new Length(Double.MAX_VALUE, LengthUnit.SI), lane.getSpeedLimit(XMLNetworkModel.this.gtuType), laneBasedGTUCharacteristics.getMaximumSpeed()))) { return null; } return leaderSpeed; } } */ roomChecker, this.idGenerator); } /** * @param randStream the random stream to use * @param lane reference lane to generate GTUs on * @param lengthDistribution distribution of the GTU length * @param widthDistribution distribution of the GTU width * @param maximumSpeedDistribution distribution of the GTU's maximum speed * @param initialPositions initial position(s) of the GTU on the Lane(s) * @param strategicalPlannerFactory factory to generate the strategical planner for the GTU * @return template for a GTU * @throws GTUException when characteristics cannot be initialized */ LaneBasedTemplateGTUType makeTemplate(final StreamInterface randStream, final Lane lane, final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> lengthDistribution, final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> widthDistribution, final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> maximumSpeedDistribution, final Set<DirectedLanePosition> initialPositions, final LaneBasedStrategicalPlannerFactory<LaneBasedStrategicalPlanner> strategicalPlannerFactory) throws GTUException { return new LaneBasedTemplateGTUType(this.gtuType, new Generator<Length>() { @Override public Length draw() { return lengthDistribution.draw(); } }, new Generator<Length>() { @Override public Length draw() { return widthDistribution.draw(); } }, new Generator<Speed>() { @Override public Speed draw() { return maximumSpeedDistribution.draw(); } }, /*-new Generator<LaneBasedStrategicalPlanner>() { public LaneBasedStrategicalPlanner draw() throws ProbabilityException, ParameterException { BehavioralCharacteristics parameters = DefaultsFactory.getDefaultBehavioralCharacteristics(); parameters.setParameter(ParameterTypes.LOOKAHEAD, new Length(450.0, LengthUnit.METER)); try { return new LaneBasedStrategicalRoutePlanner(parameters, tacticalPlanner, XMLNetworkModel.this.routeGenerator.draw()); } catch (GTUException exception) { throw new ParameterException(exception); } } }*/ strategicalPlannerFactory, this.routeGenerator); } /** * Append a sink to each lane of an array of Lanes. * @param lanes Lane[]; the array of lanes * @param laneType the LaneType for cars * @return Lane[]; the lanes * @throws NetworkException on network inconsistency * @throws OTSGeometryException on problem making the path for a link */ private Lane[] setupSink(final Lane[] lanes, final LaneType laneType) throws NetworkException, OTSGeometryException { CrossSectionLink link = lanes[0].getParentLink(); Node to = link.getEndNode(); Node from = link.getStartNode(); double endLinkLength = 50; // [m] double endX = to.getPoint().x + (endLinkLength / link.getLength().getSI()) * (to.getPoint().x - from.getPoint().x); double endY = to.getPoint().y + (endLinkLength / link.getLength().getSI()) * (to.getPoint().y - from.getPoint().y); Node end = new OTSNode(this.network, link.getId() + "END", new OTSPoint3D(endX, endY, to.getPoint().z)); CrossSectionLink endLink = LaneFactory.makeLink(this.network, link.getId() + "endLink", to, end, null, this.simulator); for (Lane lane : lanes) { // Overtaking left and right allowed on the sinkLane Lane sinkLane = new Lane(endLink, lane.getId() + "." + "sinkLane", lane.getLateralCenterPosition(1.0), lane.getLateralCenterPosition(1.0), lane.getWidth(1.0), lane.getWidth(1.0), laneType, this.speedLimit, new OvertakingConditions.LeftAndRight()); new SinkSensor(sinkLane, new Length(10.0, METER), this.simulator); } return lanes; } /** * Put a block at the end of a Lane. * @param lane Lane; the lane on which the block is placed * @return Lane; the lane * @throws NamingException on ??? * @throws NetworkException on network inconsistency * @throws SimRuntimeException on ??? * @throws GTUException when construction of the GTU (the block is a GTU) fails * @throws OTSGeometryException when the initial path is wrong */ private Lane setupBlock(final Lane lane) throws NamingException, NetworkException, SimRuntimeException, GTUException, OTSGeometryException { |
File | Line |
---|---|
ahfe\AHFEAnimation.java | 451 |
ahfe\AHFESimulation.java | 447 |
int reportTimeClick = 60; while (true) { int currentTime = (int) model.getSimulator().getSimulatorTime().si; if (currentTime >= lastReportedTime + reportTimeClick) { lastReportedTime = currentTime / reportTimeClick * reportTimeClick; System.out.println("time is " + model.getSimulator().getSimulatorTime()); } try { model.getSimulator().step(); } catch (SimRuntimeException sre) { if (sre.getCause() != null && sre.getCause().getCause() != null && sre.getCause().getCause().getMessage().equals( "Model has calcalated a negative infinite or negative max value acceleration.")) { System.err.println("Collision detected."); String file = finalScenario + ".csv.zip"; FileOutputStream fos = null; ZipOutputStream zos = null; OutputStreamWriter osw = null; BufferedWriter bw = null; try { fos = new FileOutputStream(file); zos = new ZipOutputStream(fos); zos.putNextEntry(new ZipEntry(finalScenario + ".csv")); osw = new OutputStreamWriter(zos); bw = new BufferedWriter(osw); bw.write("Collision"); bw.write(model.getSimulator().getSimulatorTime().toString()); } catch (IOException exception2) { throw new RuntimeException("Could not write to file.", exception2); } // close file on fail finally { try { if (bw != null) { bw.close(); } if (osw != null) { osw.close(); } if (zos != null) { zos.close(); } if (fos != null) { fos.close(); } } catch (IOException ex) { ex.printStackTrace(); } } } else { System.out.println("Simulation ends; time is " + model.getSimulator().getSimulatorTime()); if (model.sampler != null) { model.sampler.writeToFile(finalScenario + ".csv"); } } long t2 = System.currentTimeMillis(); System.out.println("Run took " + (t2 - t1) / 1000 + "s."); System.exit(0); break; } } } } catch (SimRuntimeException | NamingException | OTSSimulationException | PropertyException exception) { exception.printStackTrace(); } } }); } /** The simulator. */ private SimulatorInterface<Time, Duration, SimTimeDoubleUnit> simulator; /** {@inheritDoc} */ @Override public final String shortName() { return "AFFE Simulation"; } /** {@inheritDoc} */ @Override public final String description() { return "Simulation for AHFE congress"; } /** {@inheritDoc} */ @Override protected final OTSModelInterface makeModel() throws OTSSimulationException { return new AHFEModel(); } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 429 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 452 |
CrossSectionLink endLink = LaneFactory.makeLink(this.network, "endLink", to, end, null, simulator); // No overtaking, single lane Lane sinkLane = new Lane(endLink, "sinkLane", this.lane.getLateralCenterPosition(1.0), this.lane.getLateralCenterPosition(1.0), this.lane.getWidth(1.0), this.lane.getWidth(1.0), laneType, this.speedLimit, new OvertakingConditions.None()); new SinkSensor(sinkLane, new Length(10.0, METER), this.simulator); String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); Property<?> cfmp = propertyContainer.findByKey("CarFollowingModel"); if (null == cfmp) { throw new Error("Cannot find \"Car following model\" property"); } if (cfmp instanceof SelectionProperty) { carFollowingModelName = ((SelectionProperty) cfmp).getValue(); } else { throw new Error("\"Car following model\" property has wrong type"); } for (Property<?> ap : new CompoundProperty("", "", "", this.properties, false, 0)) { if (ap instanceof SelectionProperty) { SelectionProperty sp = (SelectionProperty) ap; if ("CarFollowingModel".equals(sp.getKey())) { carFollowingModelName = sp.getValue(); } } else if (ap instanceof ProbabilityDistributionProperty) { ProbabilityDistributionProperty pdp = (ProbabilityDistributionProperty) ap; String modelName = ap.getKey(); if (modelName.equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } } else if (ap instanceof CompoundProperty) { CompoundProperty cp = (CompoundProperty) ap; if (ap.getKey().equals("OutputGraphs")) { continue; // Output settings are handled elsewhere } if (ap.getKey().contains("IDM")) { Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 304 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 291 |
for (Property<?> p : this.fundamentalDiagramProperties) { if (p instanceof SelectionProperty) { SelectionProperty sp = (SelectionProperty) p; if ("CarFollowingModel".equals(sp.getKey())) { String modelName = sp.getValue(); if (modelName.equals("IDM")) { this.carFollowingModelCars = new IDMOld(new Acceleration(1, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2, METER), new Duration(1, SECOND), 1d); this.carFollowingModelTrucks = new IDMOld(new Acceleration(0.5, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2, METER), new Duration(1, SECOND), 1d); } else if (modelName.equals("IDM+")) { this.carFollowingModelCars = new IDMPlusOld(new Acceleration(1, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2, METER), new Duration(1, SECOND), 1d); this.carFollowingModelTrucks = new IDMPlusOld(new Acceleration(0.5, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2, METER), new Duration(1, SECOND), 1d); } else { throw new Error("Car following model " + modelName + " not implemented"); } } else { throw new Error("Unhandled SelectionProperty " + p.getKey()); } } else if (p instanceof ProbabilityDistributionProperty) { ProbabilityDistributionProperty pdp = (ProbabilityDistributionProperty) p; String modelName = p.getKey(); if (modelName.equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } else { throw new Error("Unhandled ProbabilityDistributionProperty " + p.getKey()); } } else { throw new Error("Unhandled property: " + p); } } // 1500 [veh / hour] == 2.4s headway this.headway = new Duration(3600.0 / 1500.0, SECOND); try { // Schedule creation of the first car (this will re-schedule itself one headway later, etc.). this.simulator.scheduleEventAbs(Time.ZERO, this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator.scheduleEventAbs(new Time(300, TimeUnit.BASE_SECOND), this, this, "createBlock", null); // Remove the block at t = 7 minutes this.simulator.scheduleEventAbs(new Time(420, TimeUnit.BASE_SECOND), this, this, "removeBlock", null); // Schedule regular updates of the graph for (int t = 1; t <= 1800; t++) { this.simulator.scheduleEventAbs(new Time(t - 0.001, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 651 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 670 |
this.simulator.scheduleEventAbs(new Time(0.999, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); } catch (NamingException | NetworkException | GTUException | OTSGeometryException | ProbabilityException | PropertyException | ParameterException exception1) { exception1.printStackTrace(); } } /** * Add a generator to an array of Lane. * @param lanes Lane[]; the lanes that must get a generator at the start * @return Lane[]; the lanes * @throws GTUException when lane position out of bounds * @throws SimRuntimeException when generation scheduling fails * @throws ProbabilityException when probability distribution is wrong * @throws ParameterException when a parameter is missing for the perception of the GTU */ private Lane[] setupGenerator(final Lane[] lanes) throws SimRuntimeException, GTUException, ProbabilityException, ParameterException { for (Lane lane : lanes) { makeGenerator(lane); // Object[] arguments = new Object[1]; // arguments[0] = lane; // this.simulator.scheduleEventAbs(Time.ZERO, this, this, "generateCar", arguments); } return lanes; } /** * Build a generator. * @param lane Lane; the lane on which the generated GTUs are placed * @return LaneBasedGTUGenerator * @throws GTUException when lane position out of bounds * @throws SimRuntimeException when generation scheduling fails * @throws ProbabilityException when probability distribution is wrong * @throws ParameterException when a parameter is missing for the perception of the GTU */ private LaneBasedGTUGenerator makeGenerator(final Lane lane) throws GTUException, SimRuntimeException, ProbabilityException, ParameterException { Distribution<LaneBasedTemplateGTUType> distribution = new Distribution<>(this.stream); Length initialPosition = new Length(16, METER); Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1); initialPositions.add(new DirectedLanePosition(lane, initialPosition, GTUDirectionality.DIR_PLUS)); LaneBasedTemplateGTUType template = makeTemplate(this.stream, lane, new ContinuousDistDoubleScalar.Rel<Length, LengthUnit>(new DistUniform(this.stream, 3, 6), METER), new ContinuousDistDoubleScalar.Rel<Length, LengthUnit>(new DistUniform(this.stream, 1.6, 2.0), METER), new ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit>(new DistUniform(this.stream, 140, 180), KM_PER_HOUR), initialPositions, this.strategicalPlannerGeneratorCars); // System.out.println("Constructed template " + template); distribution.add(new FrequencyAndObject<>(this.carProbability, template)); template = makeTemplate(this.stream, lane, new ContinuousDistDoubleScalar.Rel<Length, LengthUnit>(new DistUniform(this.stream, 8, 14), METER), new ContinuousDistDoubleScalar.Rel<Length, LengthUnit>(new DistUniform(this.stream, 2.0, 2.5), METER), new ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit>(new DistUniform(this.stream, 100, 140), KM_PER_HOUR), initialPositions, this.strategicalPlannerGeneratorTrucks); // System.out.println("Constructed template " + template); distribution.add(new FrequencyAndObject<>(1.0 - this.carProbability, template)); LaneBasedTemplateGTUTypeDistribution templateDistribution = new LaneBasedTemplateGTUTypeDistribution(distribution); LaneBasedGTUGenerator.RoomChecker roomChecker = new CFRoomChecker(); return new LaneBasedGTUGenerator(lane.getId(), new Generator<Duration>() { @SuppressWarnings("synthetic-access") @Override public Duration draw() { return new Duration(XMLNetworkModel.this.headwayGenerator.draw(), DurationUnit.SECOND); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 517 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 539 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 535 |
new LaneBasedStrategicalRoutePlannerFactory(new ToledoFactory()); } else { throw new Error("Don't know how to create a " + tacticalPlannerName + " tactical planner"); } } } else if (ap instanceof ProbabilityDistributionProperty) { ProbabilityDistributionProperty pdp = (ProbabilityDistributionProperty) ap; String modelName = ap.getKey(); if (modelName.equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } } else if (ap instanceof ContinuousProperty) { ContinuousProperty contP = (ContinuousProperty) ap; if (contP.getKey().startsWith("Flow")) { this.averageHeadway = new Duration(3600.0 / contP.getValue(), SECOND); this.minimumHeadway = new Duration(3, SECOND); this.headwayGenerator = new DistErlang(new MersenneTwister(1234), 4, DoubleScalar.minus(this.averageHeadway, this.minimumHeadway).getSI()); } } else if (ap instanceof CompoundProperty) { CompoundProperty compoundProperty = (CompoundProperty) ap; if (ap.getKey().equals("Output")) { continue; // Output settings are handled elsewhere } if (ap.getKey().contains("IDM")) { Acceleration a = IDMPropertySet.getA(compoundProperty); Acceleration b = IDMPropertySet.getB(compoundProperty); Length s0 = IDMPropertySet.getS0(compoundProperty); Duration tSafe = IDMPropertySet.getTSafe(compoundProperty); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } if (merge) { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 309 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 316 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 296 |
if ("CarFollowingModel".equals(sp.getKey())) { String modelName = sp.getValue(); if (modelName.equals("IDM")) { this.carFollowingModelCars = new IDMOld(new Acceleration(1, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2, METER), new Duration(1, SECOND), 1d); this.carFollowingModelTrucks = new IDMOld(new Acceleration(0.5, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2, METER), new Duration(1, SECOND), 1d); } else if (modelName.equals("IDM+")) { this.carFollowingModelCars = new IDMPlusOld(new Acceleration(1, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2, METER), new Duration(1, SECOND), 1d); this.carFollowingModelTrucks = new IDMPlusOld(new Acceleration(0.5, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2, METER), new Duration(1, SECOND), 1d); } else { throw new Error("Car following model " + modelName + " not implemented"); } } else { throw new Error("Unhandled SelectionProperty " + p.getKey()); } } else if (p instanceof ProbabilityDistributionProperty) { ProbabilityDistributionProperty pdp = (ProbabilityDistributionProperty) p; String modelName = p.getKey(); if (modelName.equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } else { throw new Error("Unhandled ProbabilityDistributionProperty " + p.getKey()); } } else { throw new Error("Unhandled property: " + p); } } // 1500 [veh / hour] == 2.4s headway this.headway = new Duration(3600.0 / 1500.0, SECOND); try { // Schedule creation of the first car (this will re-schedule itself one headway later, etc.). this.simulator.scheduleEventAbs(Time.ZERO, this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator.scheduleEventAbs(new Time(300, TimeUnit.BASE_SECOND), this, this, "createBlock", null); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 192 |
org\opentrafficsim\demo\carFollowing\Straight.java | 186 |
this.model = new SequentialModel(this.savedUserModifiedProperties); return this.model; } /** * @return an info pane to be added to the tabbed pane. */ protected final JComponent makeInfoPane() { // Make the info tab String helpSource = "/" + StraightModel.class.getPackage().getName().replace('.', '/') + "/IDMPlus.html"; URL page = StraightModel.class.getResource(helpSource); if (page != null) { try { HTMLPanel htmlPanel = new HTMLPanel(page); return new JScrollPane(htmlPanel); } catch (IOException exception) { exception.printStackTrace(); } } return new JPanel(); } /** {@inheritDoc} */ @Override protected final void addTabs(final SimpleSimulatorInterface simulator) throws OTSSimulationException, PropertyException { // Make the tab with the plots Property<?> output = new CompoundProperty("", "", "", this.properties, false, 0).findByKey("OutputGraphs"); if (null == output) { throw new Error("Cannot find output properties"); } ArrayList<BooleanProperty> graphs = new ArrayList<>(); if (output instanceof CompoundProperty) { CompoundProperty outputProperties = (CompoundProperty) output; for (Property<?> ap : outputProperties.getValue()) { if (ap instanceof BooleanProperty) { BooleanProperty bp = (BooleanProperty) ap; if (bp.getValue()) { graphs.add(bp); } } } } else { throw new Error("output properties should be compound"); } int graphCount = graphs.size(); int columns = (int) Math.ceil(Math.sqrt(graphCount)); int rows = 0 == columns ? 0 : (int) Math.ceil(graphCount * 1.0 / columns); TablePanel charts = new TablePanel(columns, rows); for (int i = 0; i < graphCount; i++) { String graphName = graphs.get(i).getKey(); Container container = null; LaneBasedGTUSampler graph; if (graphName.contains("Trajectories")) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 363 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 334 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 381 |
for (Property<?> ap : new CompoundProperty("", "", "", this.props, false, 0)) { if (ap instanceof CompoundProperty) { cp = (CompoundProperty) ap; if (ap.getKey().contains("IDM")) { // System.out.println("Car following model name appears to be " + ap.getKey()); Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } // Get lane change model cfmp = propertyContainer.findByKey("LaneChanging"); if (null == cfmp) { throw new Error("Cannot find \"Lane changing\" property"); } if (cfmp instanceof SelectionProperty) { String laneChangeModelName = ((SelectionProperty) cfmp).getValue(); if ("Egoistic".equals(laneChangeModelName)) { this.laneChangeModel = new Egoistic(); } else if ("Altruistic".equals(laneChangeModelName)) { this.laneChangeModel = new Altruistic(); } else { throw new Error("Lane changing " + laneChangeModelName + " not implemented"); } } else { throw new Error("\"Lane changing\" property has wrong type"); } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 139 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 157 |
Straight straight = new Straight(); List<Property<?>> localProperties = straight.getProperties(); try { localProperties.add(new ProbabilityDistributionProperty("TrafficComposition", "Traffic composition", "<html>Mix of passenger cars and trucks</html>", new String[] { "passenger car", "truck" }, new Double[] { 0.8, 0.2 }, false, 10)); } catch (PropertyException exception) { exception.printStackTrace(); } localProperties.add(new SelectionProperty("CarFollowingModel", "Car following model", "<html>The car following model determines " + "the acceleration that a vehicle will make taking into account " + "nearby vehicles, infrastructural restrictions (e.g. speed limit, " + "curvature of the road) capabilities of the vehicle and personality " + "of the driver.</html>", new String[] { "IDM", "IDM+" }, 1, false, 1)); localProperties.add(IDMPropertySet.makeIDMPropertySet("IDMCar", "Car", new Acceleration(1.0, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2.0, METER), new Duration(1.0, SECOND), 2)); localProperties.add(IDMPropertySet.makeIDMPropertySet("IDMTruck", "Truck", new Acceleration(0.5, METER_PER_SECOND_2), new Acceleration(1.25, METER_PER_SECOND_2), new Length(2.0, METER), new Duration(1.0, SECOND), 3)); straight.buildAnimator(Time.ZERO, Duration.ZERO, new Duration(3600.0, SECOND), localProperties, null, true); straight.panel.getTabbedPane().addTab("info", straight.makeInfoPane()); } catch (SimRuntimeException | NamingException | OTSSimulationException | PropertyException exception) { exception.printStackTrace(); } } }); } /** {@inheritDoc} */ @Override protected final void addAnimationToggles() { AnimationToggles.setTextAnimationTogglesStandard(this); } /** {@inheritDoc} */ @Override protected final OTSModelInterface makeModel() { this.model = new StraightModel(this.savedUserModifiedProperties); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 203 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 215 |
URL page = StraightModel.class.getResource(helpSource); if (page != null) { try { HTMLPanel htmlPanel = new HTMLPanel(page); return new JScrollPane(htmlPanel); } catch (IOException exception) { exception.printStackTrace(); } } return new JPanel(); } /** {@inheritDoc} */ @Override protected final void addTabs(final SimpleSimulatorInterface simulator) throws OTSSimulationException, PropertyException { // Make the tab with the plots Property<?> output = new CompoundProperty("", "", "", this.properties, false, 0).findByKey("OutputGraphs"); if (null == output) { throw new Error("Cannot find output properties"); } ArrayList<BooleanProperty> graphs = new ArrayList<>(); if (output instanceof CompoundProperty) { CompoundProperty outputProperties = (CompoundProperty) output; for (Property<?> ap : outputProperties.getValue()) { if (ap instanceof BooleanProperty) { BooleanProperty bp = (BooleanProperty) ap; if (bp.getValue()) { graphs.add(bp); } } } } else { throw new Error("output properties should be compound"); } int graphCount = graphs.size(); int columns = (int) Math.ceil(Math.sqrt(graphCount)); int rows = 0 == columns ? 0 : (int) Math.ceil(graphCount * 1.0 / columns); TablePanel charts = new TablePanel(columns, rows); for (int i = 0; i < graphCount; i++) { String graphName = graphs.get(i).getKey(); Container container = null; LaneBasedGTUSampler graph; if (graphName.contains("Trajectories")) { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 197 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 215 |
URL page = StraightModel.class.getResource(helpSource); if (page != null) { try { HTMLPanel htmlPanel = new HTMLPanel(page); return new JScrollPane(htmlPanel); } catch (IOException exception) { exception.printStackTrace(); } } return new JPanel(); } /** {@inheritDoc} */ @Override protected final void addTabs(final SimpleSimulatorInterface simulator) throws OTSSimulationException, PropertyException { // Make the tab with the plots Property<?> output = new CompoundProperty("", "", "", this.properties, false, 0).findByKey("OutputGraphs"); if (null == output) { throw new Error("Cannot find output properties"); } ArrayList<BooleanProperty> graphs = new ArrayList<>(); if (output instanceof CompoundProperty) { CompoundProperty outputProperties = (CompoundProperty) output; for (Property<?> ap : outputProperties.getValue()) { if (ap instanceof BooleanProperty) { BooleanProperty bp = (BooleanProperty) ap; if (bp.getValue()) { graphs.add(bp); } } } } else { throw new Error("output properties should be compound"); } int graphCount = graphs.size(); int columns = (int) Math.ceil(Math.sqrt(graphCount)); int rows = 0 == columns ? 0 : (int) Math.ceil(graphCount * 1.0 / columns); TablePanel charts = new TablePanel(columns, rows); for (int i = 0; i < graphCount; i++) { String graphName = graphs.get(i).getKey(); Container container = null; LaneBasedGTUSampler graph; if (graphName.contains("TrajectoryPlot")) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 502 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 524 |
} else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } /* * System.out.println("Created " + carFollowingModelName + " for " + p.getKey()); * System.out.println("a: " + a); System.out.println("b: " + b); System.out.println("s0: " + s0); * System.out.println("tSafe: " + tSafe); */ } } } // 1500 [veh / hour] == 2.4s headway this.headway = new Duration(3600.0 / 1500.0, SECOND); // Schedule creation of the first car (it will re-schedule itself one headway later, etc.). this.simulator.scheduleEventAbs(Time.ZERO, this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator.scheduleEventAbs(new Time(300, TimeUnit.BASE_SECOND), this, this, "createBlock", null); // Remove the block at t = 7 minutes this.simulator.scheduleEventAbs(new Time(420, TimeUnit.BASE_SECOND), this, this, "removeBlock", null); // Schedule regular updates of the graphs for (int t = 1; t <= 1800; t++) { this.simulator.scheduleEventAbs(new Time(t - 0.001, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); } } catch (SimRuntimeException | NamingException | NetworkException | OTSGeometryException | PropertyException exception) { exception.printStackTrace(); } } /** * Notify the contour plots that the underlying data has changed. */ protected final void drawGraphs() { for (LaneBasedGTUSampler plot : this.plots) { plot.reGraph(); } } /** * Set up the block. */ protected final void createBlock() { Length initialPosition = new Length(4000, METER); Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1); try { initialPositions.add(new DirectedLanePosition(this.lane, initialPosition, GTUDirectionality.DIR_PLUS)); Parameters parameters = DefaultsFactory.getDefaultParameters(); this.block = new LaneBasedIndividualGTU("999999", this.gtuType, new Length(4, METER), new Length(1.8, METER), |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 456 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 371 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 342 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 389 |
Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } // Get lane change model cfmp = propertyContainer.findByKey("LaneChanging"); if (null == cfmp) { throw new Error("Cannot find \"Lane changing\" property"); } if (cfmp instanceof SelectionProperty) { String laneChangeModelName = ((SelectionProperty) cfmp).getValue(); if ("Egoistic".equals(laneChangeModelName)) { this.laneChangeModel = new Egoistic(); } else if ("Altruistic".equals(laneChangeModelName)) { this.laneChangeModel = new Altruistic(); } else { throw new Error("Lane changing " + laneChangeModelName + " not implemented"); } } else { throw new Error("\"Lane changing\" property has wrong type"); } |
File | Line |
---|---|
org\opentrafficsim\demo\lanechange\LaneChangeGraph.java | 486 |
org\opentrafficsim\demo\lanechange\SuitabilityGraph.java | 336 |
public final int addSeries(final String seriesName) { this.xValues.add(new ArrayList<Double>()); this.yValues.add(new ArrayList<Double>()); this.seriesKeys.add(seriesName); return this.xValues.size() - 1; } /** * Add an XY pair to the data. * @param seriesKey int; key to the data series * @param x double; x value of the pair * @param y double; y value of the pair */ public final void addXYPair(final int seriesKey, final double x, final double y) { this.xValues.get(seriesKey).add(x); this.yValues.get(seriesKey).add(y); } /** {@inheritDoc} */ @Override public final int getSeriesCount() { return this.seriesKeys.size(); } /** {@inheritDoc} */ @Override public final Comparable<?> getSeriesKey(final int series) { return this.seriesKeys.get(series); } /** {@inheritDoc} */ @Override public final int indexOf(@SuppressWarnings("rawtypes") final Comparable seriesKey) { return this.seriesKeys.indexOf(seriesKey); } /** {@inheritDoc} */ @Override public final void addChangeListener(final DatasetChangeListener listener) { this.listenerList.add(DatasetChangeListener.class, listener); } /** {@inheritDoc} */ @Override public final void removeChangeListener(final DatasetChangeListener listener) { this.listenerList.remove(DatasetChangeListener.class, listener); } /** {@inheritDoc} */ @Override public final DatasetGroup getGroup() { return this.datasetGroup; } /** {@inheritDoc} */ @Override public final void setGroup(final DatasetGroup group) { this.datasetGroup = group; } /** {@inheritDoc} */ @Override public final DomainOrder getDomainOrder() |
File | Line |
---|---|
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo.java | 213 |
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java | 233 |
return TrafCODDemo.this.trafCOD.getSimulator(); } /** {@inheritDoc} */ @Override public final OTSNetwork getNetwork() { return this.network; } /** {@inheritDoc} */ @Override public void notify(final EventInterface event) throws RemoteException { EventType type = event.getType(); Object[] payload = (Object[]) event.getContent(); if (TrafficController.TRAFFICCONTROL_CONTROLLER_EVALUATING.equals(type)) { // System.out.println("Evalution starts at " + getSimulator().getSimulatorTime()); return; } else if (TrafficController.TRAFFICCONTROL_CONFLICT_GROUP_CHANGED.equals(type)) { System.out.println("Conflict group changed from " + ((String) payload[1]) + " to " + ((String) payload[2])); } else if (TrafficController.TRAFFICCONTROL_TRACED_VARIABLE_UPDATED.equals(type)) { System.out.println(String.format("Variable changed %s <- %d %s", payload[1], payload[4], payload[5])); } else if (TrafficController.TRAFFICCONTROL_CONTROLLER_WARNING.equals(type)) { System.out.println("Warning " + payload[1]); } else { System.out.print("TrafCODDemo received event of type " + event.getType() + ", payload ["); String separator = ""; for (Object o : payload) { System.out.print(separator + o); separator = ","; } System.out.println("]"); } } } } |
File | Line |
---|---|
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java | 306 |
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo.java | 213 |
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java | 233 |
return DemoTrafcodAndTurbo.this.trafCOD.getSimulator(); } /** {@inheritDoc} */ @Override public final OTSNetwork getNetwork() { return this.network; } /** {@inheritDoc} */ @Override public void notify(final EventInterface event) throws RemoteException { EventType type = event.getType(); Object[] payload = (Object[]) event.getContent(); if (TrafficController.TRAFFICCONTROL_CONTROLLER_EVALUATING.equals(type)) { // System.out.println("Evaluation starts at " + // getSimulator().getSimulatorTime()); return; } else if (TrafficController.TRAFFICCONTROL_CONFLICT_GROUP_CHANGED.equals(type)) { System.out.println("Conflict group changed from " + ((String) payload[1]) + " to " + ((String) payload[2])); } else if (TrafficController.TRAFFICCONTROL_TRACED_VARIABLE_UPDATED.equals(type)) { System.out.println(String.format("Variable changed %s <- %d %s", payload[1], payload[4], payload[5])); } else if (TrafficController.TRAFFICCONTROL_CONTROLLER_WARNING.equals(type)) { System.out.println("Warning " + payload[1]); } else { System.out.print("TrafCODDemo received event of type " + event.getType() + ", payload ["); String separator = ""; for (Object o : payload) { System.out.print(separator + o); separator = ","; } System.out.println("]"); } } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 507 |
org\opentrafficsim\demo\carFollowing\Straight.java | 464 |
if (ap.getKey().equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } } else if (ap instanceof CompoundProperty) { CompoundProperty cp = (CompoundProperty) ap; if (ap.getKey().equals("OutputGraphs")) { continue; // Output settings are handled elsewhere } if (ap.getKey().contains("IDM")) { // System.out.println("Car following model name appears to be " + ap.getKey()); Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 284 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 273 |
OTSNode from = new OTSNode(this.network, "From", new OTSPoint3D(getMinimumDistance().getSI(), 0, 0)); OTSNode to = new OTSNode(this.network, "To", new OTSPoint3D(getMaximumDistance().getSI(), 0, 0)); OTSNode end = new OTSNode(this.network, "End", new OTSPoint3D(getMaximumDistance().getSI() + 50.0, 0, 0)); LaneType laneType = LaneType.TWO_WAY_LANE; this.lane = LaneFactory.makeLane(this.network, "Lane", from, to, null, laneType, this.speedLimit, this.simulator); CrossSectionLink endLink = LaneFactory.makeLink(this.network, "endLink", to, end, null, simulator); // No overtaking, single lane Lane sinkLane = new Lane(endLink, "sinkLane", this.lane.getLateralCenterPosition(1.0), this.lane.getLateralCenterPosition(1.0), this.lane.getWidth(1.0), this.lane.getWidth(1.0), laneType, this.speedLimit, new OvertakingConditions.None()); new SinkSensor(sinkLane, new Length(10.0, METER), this.simulator); } catch (NamingException | NetworkException | OTSGeometryException exception) |
File | Line |
---|---|
org\opentrafficsim\demo\timing\TimeCircularRoadAnimation.java | 58 |
org\opentrafficsim\demo\timing\TimeCircularRoadSimulation.java | 79 |
} } } activeProperties.add(new ProbabilityDistributionProperty("TrafficComposition", "Traffic composition", "<html>Mix of passenger cars and trucks</html>", new String[] { "passenger car", "truck" }, new Double[] { 0.8, 0.2 }, false, 5)); CompoundProperty modelSelection = new CompoundProperty("ModelSelection", "Model selection", "Modeling specific settings", null, false, 300); modelSelection.add(new SelectionProperty("SimulationScale", "Simulation scale", "Level of detail of the simulation", new String[] { "Micro", "Macro", "Meta" }, 0, true, 0)); modelSelection.add(new SelectionProperty("CarFollowingModel", "Car following model", "", new String[] { "IDM", "IDM+" }, 1, false, 1)); modelSelection.add(IDMPropertySet.makeIDMPropertySet("IDMCar", "Car", new Acceleration(1.56, METER_PER_SECOND_2), new Acceleration(2.09, METER_PER_SECOND_2), new Length(3.0, METER), new Duration(1.2, SECOND), 2)); modelSelection .add(IDMPropertySet.makeIDMPropertySet("IDMTruck", "Truck", new Acceleration(0.75, METER_PER_SECOND_2), new Acceleration(1.25, METER_PER_SECOND_2), new Length(3.0, METER), new Duration(1.2, SECOND), 3)); activeProperties.add(modelSelection); SimpleAnimator sim = (SimpleAnimator) simulation.buildAnimator(Time.ZERO, Duration.ZERO, |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 525 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 486 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 504 |
if ("MOBIL/IDM".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(new LaneBasedCFLCTacticalPlannerFactory( this.carFollowingModelCars, this.laneChangeModel)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(new LaneBasedCFLCTacticalPlannerFactory( this.carFollowingModelTrucks, this.laneChangeModel)); } else if ("DIRECTED/IDM".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingDirectedChangeTacticalPlannerFactory( this.carFollowingModelCars)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingDirectedChangeTacticalPlannerFactory( this.carFollowingModelTrucks)); } else if ("LMRS".equals(tacticalPlannerName)) { // provide default parameters with the car-following model this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory())); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory())); } else if ("Toledo".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(new ToledoFactory()); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(new ToledoFactory()); } else { throw new Error("Don't know how to create a " + tacticalPlannerName + " tactical planner"); } } } else if (ap instanceof ProbabilityDistributionProperty) { ProbabilityDistributionProperty pdp = (ProbabilityDistributionProperty) ap; |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 507 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 487 |
if (ap.getKey().equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } } else if (ap instanceof CompoundProperty) { CompoundProperty cp = (CompoundProperty) ap; if (ap.getKey().equals("OutputGraphs")) { continue; // Output settings are handled elsewhere } if (ap.getKey().contains("IDM")) { // System.out.println("Car following model name appears to be " + ap.getKey()); Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 404 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 427 |
private Speed speedLimit = new Speed(100, KM_PER_HOUR); /** * @return List<Lane*gt;; the set of lanes for the specified index */ public List<Lane> getPath() { return new ArrayList<>(this.path); } /** {@inheritDoc} */ @Override public final void constructModel(final SimulatorInterface<Time, Duration, SimTimeDoubleUnit> theSimulator) throws SimRuntimeException { this.simulator = (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator; try { OTSNode from = new OTSNode(this.network, "From", new OTSPoint3D(getMinimumDistance().getSI(), 0, 0)); OTSNode to = new OTSNode(this.network, "To", new OTSPoint3D(getMaximumDistance().getSI(), 0, 0)); OTSNode end = new OTSNode(this.network, "End", new OTSPoint3D(getMaximumDistance().getSI() + 50.0, 0, 0)); LaneType laneType = LaneType.TWO_WAY_LANE; this.lane = LaneFactory.makeLane(this.network, "Lane", from, to, null, laneType, this.speedLimit, this.simulator); this.path.add(this.lane); CrossSectionLink endLink = LaneFactory.makeLink(this.network, "endLink", to, end, null, simulator); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 107 |
org\opentrafficsim\demo\carFollowing\Straight.java | 102 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 120 |
public SequentialLanes() throws PropertyException { List<Property<?>> outputProperties = new ArrayList<>(); outputProperties.add(new BooleanProperty("DensityPlot", "Density", "Density contour plot", true, false, 0)); outputProperties.add(new BooleanProperty("FlowPlot", "Flow", "Flow contour plot", true, false, 1)); outputProperties.add(new BooleanProperty("SpeedPlot", "Speed", "Speed contour plot", true, false, 2)); outputProperties .add(new BooleanProperty("AccelerationPlot", "Acceleration", "Acceleration contour plot", true, false, 3)); outputProperties.add( new BooleanProperty("TrajectoryPlot", "Trajectories", "Trajectory (time/distance) diagram", true, false, 4)); this.properties.add(new CompoundProperty("OutputGraphs", "Output graphs", "Select the graphical output", outputProperties, true, 1000)); } /** {@inheritDoc} */ @Override public final void stopTimersThreads() { super.stopTimersThreads(); this.model = null; } /** * Main program. * @param args String[]; the command line arguments (not used) * @throws SimRuntimeException when simulation cannot be created with given parameters */ public static void main(final String[] args) throws SimRuntimeException { SwingUtilities.invokeLater(new Runnable() { @SuppressWarnings("synthetic-access") @Override public void run() { try { |
File | Line |
---|---|
ahfe\AHFEAnimation.java | 605 |
ahfe\AHFESimulation.java | 594 |
InputStream stream = URLResource.getResourceAsStream("/AHFE/Network.xml"); XmlNetworkLaneParser nlp = new XmlNetworkLaneParser((DEVSSimulatorInterface.TimeDoubleUnit) theSimulator); this.network = new OTSNetwork("AHFE"); nlp.build(stream, this.network, true); // Space-time regions for sampler LinkData linkData = new LinkData((CrossSectionLink) this.network.getLink("LEFTIN")); registerLinkToSampler(linkData, ignoreStart, linkData.getLength()); linkData = new LinkData((CrossSectionLink) this.network.getLink("RIGHTIN")); registerLinkToSampler(linkData, ignoreStart, linkData.getLength()); linkData = new LinkData((CrossSectionLink) this.network.getLink("CONVERGE")); registerLinkToSampler(linkData, Length.ZERO, linkData.getLength()); linkData = new LinkData((CrossSectionLink) this.network.getLink("WEAVING")); registerLinkToSampler(linkData, Length.ZERO, linkData.getLength()); linkData = new LinkData((CrossSectionLink) this.network.getLink("END")); registerLinkToSampler(linkData, Length.ZERO, linkData.getLength().minus(ignoreEnd)); // Generator AHFEUtil.createDemand(this.network, AHFEAnimation.this.getColorer(), |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 119 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 108 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 135 |
public XMLNetworks() { this.properties.add(new SelectionProperty( "Network", "Network", "Network", new String[] { "Merge 1 plus 1 into 1", "Merge 2 plus 1 into 2", "Merge 2 plus 2 into 4", "Split 1 into 1 plus 1", "Split 2 into 1 plus 2", "Split 4 into 2 plus 2" }, 0, false, 0)); this.properties.add(new SelectionProperty("TacticalPlanner", "Tactical planner", "<html>The tactical planner determines if a lane change is desired and possible.</html>", new String[] { "MOBIL/IDM", "DIRECTED/IDM", "LMRS", "Toledo" }, 0, false, 600)); this.properties.add(new SelectionProperty("LaneChanging", "Lane changing", "<html>The lane change friendliness (if used -- eg just for MOBIL.</html>", new String[] { "Egoistic", "Altruistic" }, 0, false, 600)); this.properties.add(new ContinuousProperty("FlowPerInputLane", "Flow per input lane", "Traffic flow per input lane", 500d, 0d, 3000d, "%.0f veh/h", false, 1)); } /** {@inheritDoc} */ @Override public final void stopTimersThreads() { super.stopTimersThreads(); this.model = null; } /** {@inheritDoc} */ @Override protected final void addAnimationToggles() { AnimationToggles.setTextAnimationTogglesStandard(this); } /** {@inheritDoc} */ @Override protected final OTSModelInterface makeModel() { this.model = new XMLNetworkModel(this.savedUserModifiedProperties); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 138 |
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 167 |
List<Property<?>> propertyList = circularLane.getProperties(); try { propertyList.add(new ProbabilityDistributionProperty("TrafficComposition", "Traffic composition", "<html>Mix of passenger cars and trucks</html>", new String[] { "passenger car", "truck" }, new Double[] { 0.8, 0.2 }, false, 10)); } catch (PropertyException exception) { exception.printStackTrace(); } propertyList.add(new SelectionProperty("CarFollowingModel", "Car following model", "<html>The car following model determines " + "the acceleration that a vehicle will make taking into account " + "nearby vehicles, infrastructural restrictions (e.g. speed limit, " + "curvature of the road) capabilities of the vehicle and personality " + "of the driver.</html>", new String[] { "IDM", "IDM+" }, 1, false, 1)); propertyList.add(IDMPropertySet.makeIDMPropertySet("IDMCar", "Car", new Acceleration(1.0, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2.0, METER), new Duration(1.0, SECOND), 2)); propertyList.add(IDMPropertySet.makeIDMPropertySet("IDMTruck", "Truck", new Acceleration(0.5, METER_PER_SECOND_2), new Acceleration(1.25, METER_PER_SECOND_2), new Length(2.0, METER), new Duration(1.0, SECOND), 3)); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CrossingTrafficLights.java | 142 |
org\opentrafficsim\demo\carFollowing\OpenStreetMap.java | 104 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 145 |
org\opentrafficsim\demo\carFollowing\Straight.java | 140 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 158 |
List<Property<?>> localProperties = crossingTrafficLights.getProperties(); try { localProperties.add(new ProbabilityDistributionProperty("TrafficComposition", "Traffic composition", "<html>Mix of passenger cars and trucks</html>", new String[] { "passenger car", "truck" }, new Double[] { 0.8, 0.2 }, false, 10)); } catch (PropertyException exception) { exception.printStackTrace(); } localProperties.add(new SelectionProperty("CarFollowingModel", "Car following model", "<html>The car following model determines " + "the acceleration that a vehicle will make taking into account " + "nearby vehicles, infrastructural restrictions (e.g. speed limit, " + "curvature of the road) capabilities of the vehicle and personality " + "of the driver.</html>", new String[] { "IDM", "IDM+" }, 1, false, 1)); localProperties.add(IDMPropertySet.makeIDMPropertySet("IDMCar", "Car", new Acceleration(1.0, METER_PER_SECOND_2), new Acceleration(1.5, METER_PER_SECOND_2), new Length(2.0, METER), new Duration(1.0, SECOND), 2)); localProperties.add(IDMPropertySet.makeIDMPropertySet("IDMTruck", "Truck", new Acceleration(0.5, METER_PER_SECOND_2), new Acceleration(1.25, METER_PER_SECOND_2), new Length(2.0, METER), new Duration(1.0, SECOND), 3)); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 154 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 143 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 170 |
this.model = new XMLNetworkModel(this.savedUserModifiedProperties); return this.model; } /** {@inheritDoc} */ @Override protected final void addTabs(final SimpleSimulatorInterface simulator) { int graphCount = this.model.pathCount(); int columns = 1; int rows = 0 == columns ? 0 : (int) Math.ceil(graphCount * 1.0 / columns); TablePanel charts = new TablePanel(columns, rows); for (int graphIndex = 0; graphIndex < graphCount; graphIndex++) { TrajectoryPlot tp = new TrajectoryPlot("Trajectories on lane " + (graphIndex + 1), new Duration(0.5, SECOND), this.model.getPath(graphIndex), simulator); tp.setTitle("Trajectory Graph"); tp.setExtendedState(Frame.MAXIMIZED_BOTH); LaneBasedGTUSampler graph = tp; Container container = tp.getContentPane(); charts.setCell(container, graphIndex % columns, graphIndex / columns); this.model.getPlots().add(graph); } addTab(getTabCount(), "statistics", charts); } /** {@inheritDoc} */ @Override public final String shortName() { return "Test networks"; |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 103 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 109 |
org\opentrafficsim\demo\carFollowing\Straight.java | 104 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 122 |
List<Property<?>> outputProperties = new ArrayList<>(); outputProperties.add(new BooleanProperty("DensityPlot", "Density", "Density contour plot", true, false, 0)); outputProperties.add(new BooleanProperty("FlowPlot", "Flow", "Flow contour plot", true, false, 1)); outputProperties.add(new BooleanProperty("SpeedPlot", "Speed", "Speed contour plot", true, false, 2)); outputProperties .add(new BooleanProperty("AccelerationPlot", "Acceleration", "Acceleration contour plot", true, false, 3)); outputProperties.add( new BooleanProperty("TrajectoryPlot", "Trajectories", "Trajectory (time/distance) diagram", true, false, 4)); this.properties.add(new CompoundProperty("OutputGraphs", "Output graphs", "Select the graphical output", outputProperties, true, 1000)); } /** {@inheritDoc} */ @Override public final void stopTimersThreads() { super.stopTimersThreads(); this.model = null; } /** * Main program. * @param args String[]; the command line arguments (not used) * @throws SimRuntimeException should never happen */ public static void main(final String[] args) throws SimRuntimeException { SwingUtilities.invokeLater(new Runnable() { @Override |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 519 |
org\opentrafficsim\demo\carFollowing\Straight.java | 476 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 368 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 339 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 386 |
if (ap.getKey().contains("IDM")) { // System.out.println("Car following model name appears to be " + ap.getKey()); Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } |
File | Line |
---|---|
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java | 227 |
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java | 244 |
trafficLights.add(new SimpleTrafficLight(String.format("TL%02d", stream), lane, lane.getLength().minus(stopLineMargin), (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator)); sensors.add(new TrafficLightSensor(String.format("D%02d1", stream), lane, lane.getLength().minus(headDetectorMargin), lane, lane.getLength().minus(headDetectorMargin).plus(headDetectorLength), null, RelativePosition.FRONT, RelativePosition.REAR, (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator, Compatible.EVERYTHING)); sensors.add(new TrafficLightSensor(String.format("D%02d2", stream), lane, lane.getLength().minus(longDetectorMargin), lane, lane.getLength().minus(longDetectorMargin).plus(longDetectorLength), null, RelativePosition.FRONT, RelativePosition.REAR, (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator, Compatible.EVERYTHING)); } |
File | Line |
---|---|
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java | 243 |
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java | 182 |
.getCrossSectionElement("FORWARD"); trafficLights.add(new SimpleTrafficLight(String.format("TL%02d", stream), lane, lane.getLength().minus(stopLineMargin), (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator)); sensors.add(new TrafficLightSensor(String.format("D%02d1", stream), lane, lane.getLength().minus(headDetectorMargin), lane, lane.getLength().minus(headDetectorMargin).plus(headDetectorLength), null, RelativePosition.FRONT, RelativePosition.REAR, (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator, Compatible.EVERYTHING)); sensors.add(new TrafficLightSensor(String.format("D%02d2", stream), lane, lane.getLength().minus(longDetectorMargin), lane, lane.getLength().minus(longDetectorMargin).plus(longDetectorLength), null, RelativePosition.FRONT, RelativePosition.REAR, (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator, Compatible.EVERYTHING)); |
File | Line |
---|---|
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java | 227 |
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java | 183 |
trafficLights.add(new SimpleTrafficLight(String.format("TL%02d", stream), lane, lane.getLength().minus(stopLineMargin), (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator)); sensors.add(new TrafficLightSensor(String.format("D%02d1", stream), lane, lane.getLength().minus(headDetectorMargin), lane, lane.getLength().minus(headDetectorMargin).plus(headDetectorLength), null, RelativePosition.FRONT, RelativePosition.REAR, (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator, Compatible.EVERYTHING)); sensors.add(new TrafficLightSensor(String.format("D%02d2", stream), lane, lane.getLength().minus(longDetectorMargin), lane, lane.getLength().minus(longDetectorMargin).plus(longDetectorLength), null, RelativePosition.FRONT, RelativePosition.REAR, (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator, Compatible.EVERYTHING)); |
File | Line |
---|---|
org\opentrafficsim\demo\conflict\TJunctionDemo.java | 141 |
org\opentrafficsim\demo\conflict\TurboRoundaboutDemo.java | 154 |
this.simulator.scheduleEventRel(new Duration(30.0, DurationUnit.SECOND), this, this, "changePhase", new Object[] { trafficLight }); break; } case YELLOW: { trafficLight.setTrafficLightColor(TrafficLightColor.RED); this.simulator.scheduleEventRel(new Duration(56.0, DurationUnit.SECOND), this, this, "changePhase", new Object[] { trafficLight }); break; } case GREEN: { trafficLight.setTrafficLightColor(TrafficLightColor.YELLOW); this.simulator.scheduleEventRel(new Duration(4.0, DurationUnit.SECOND), this, this, "changePhase", new Object[] { trafficLight }); break; } default: { // } } } /** {@inheritDoc} */ @Override public SimulatorInterface<Time, Duration, SimTimeDoubleUnit> getSimulator() { return this.simulator; } /** {@inheritDoc} */ @Override public OTSNetwork getNetwork() { return this.network; } } /** * Main program. * @param args String[]; the command line arguments (not used) * @throws SimRuntimeException should never happen */ public static void main(final String[] args) throws SimRuntimeException { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 236 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 229 |
org\opentrafficsim\demo\carFollowing\Straight.java | 224 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 242 |
ArrayList<BooleanProperty> graphs = new ArrayList<BooleanProperty>(); if (output instanceof CompoundProperty) { CompoundProperty outputProperties = (CompoundProperty) output; for (Property<?> ap : outputProperties.getValue()) { if (ap instanceof BooleanProperty) { BooleanProperty bp = (BooleanProperty) ap; if (bp.getValue()) { graphs.add(bp); } } } } else { throw new Error("output properties should be compound"); } int graphCount = graphs.size(); int columns = (int) Math.ceil(Math.sqrt(graphCount)); int rows = 0 == columns ? 0 : (int) Math.ceil(graphCount * 1.0 / columns); TablePanel charts = new TablePanel(columns, rows); for (int i = 0; i < graphCount; i++) { String graphName = graphs.get(i).getKey(); Container container = null; LaneBasedGTUSampler graph; |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 456 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 522 |
org\opentrafficsim\demo\carFollowing\Straight.java | 478 |
Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } |
File | Line |
---|---|
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java | 198 |
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java | 166 |
new ConflictBuilder.FixedWidthGenerator(new Length(2.0, LengthUnit.SI))); // CrossSectionLink csLink = ((CrossSectionLink) // this.network.getLink("WWW")); // Lane lane = (Lane) csLink.getCrossSectionElement("RIGHT"); // GTUColorer gtuColorer = null; // setupBlock(lane, (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator, // gtuColorer ); String[] directions = { "E", "S", "W", "N" }; // Add the traffic lights and the detectors Set<TrafficLight> trafficLights = new HashSet<>(); Set<TrafficLightSensor> sensors = new HashSet<>(); Length stopLineMargin = new Length(0.1, LengthUnit.METER); Length headDetectorLength = new Length(1, LengthUnit.METER); Length headDetectorMargin = stopLineMargin.plus(headDetectorLength).plus(new Length(3, LengthUnit.METER)); Length longDetectorLength = new Length(30, LengthUnit.METER); Length longDetectorMargin = stopLineMargin.plus(longDetectorLength).plus(new Length(10, LengthUnit.METER)); int stream = 1; for (String direction : directions) { for (int laneNumber = 3; laneNumber >= 1; laneNumber--) { Lane lane = (Lane) ((CrossSectionLink) this.network.getLink(direction + "S", direction + "C")) |
File | Line |
---|---|
org\opentrafficsim\demo\lanechange\LaneChangeGraph.java | 557 |
org\opentrafficsim\demo\lanechange\SuitabilityGraph.java | 407 |
public final DomainOrder getDomainOrder() { return DomainOrder.ASCENDING; } /** {@inheritDoc} */ @Override public final int getItemCount(final int series) { return this.xValues.get(series).size(); } /** {@inheritDoc} */ @Override public final Number getX(final int series, final int item) { return this.xValues.get(series).get(item); } /** {@inheritDoc} */ @Override public final double getXValue(final int series, final int item) { return this.xValues.get(series).get(item); } /** {@inheritDoc} */ @Override public final Number getY(final int series, final int item) { return this.yValues.get(series).get(item); } /** {@inheritDoc} */ @Override public final double getYValue(final int series, final int item) { return this.yValues.get(series).get(item); } } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 479 |
org\opentrafficsim\demo\carFollowing\Straight.java | 435 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 458 |
String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); Property<?> cfmp = propertyContainer.findByKey("CarFollowingModel"); if (null == cfmp) { throw new Error("Cannot find \"Car following model\" property"); } if (cfmp instanceof SelectionProperty) { carFollowingModelName = ((SelectionProperty) cfmp).getValue(); } else { throw new Error("\"Car following model\" property has wrong type"); } for (Property<?> ap : new CompoundProperty("", "", "", this.properties, false, 0)) { if (ap instanceof SelectionProperty) { SelectionProperty sp = (SelectionProperty) ap; if ("CarFollowingModel".equals(sp.getKey())) { carFollowingModelName = sp.getValue(); } } else if (ap instanceof ProbabilityDistributionProperty) { ProbabilityDistributionProperty pdp = (ProbabilityDistributionProperty) ap; |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 412 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 435 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 263 |
} /** {@inheritDoc} */ @Override public final void constructModel(final SimulatorInterface<Time, Duration, SimTimeDoubleUnit> theSimulator) throws SimRuntimeException { this.simulator = (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator; try { OTSNode from = new OTSNode(this.network, "From", new OTSPoint3D(getMinimumDistance().getSI(), 0, 0)); OTSNode to = new OTSNode(this.network, "To", new OTSPoint3D(getMaximumDistance().getSI(), 0, 0)); OTSNode end = new OTSNode(this.network, "End", new OTSPoint3D(getMaximumDistance().getSI() + 50.0, 0, 0)); LaneType laneType = LaneType.TWO_WAY_LANE; this.lane = LaneFactory.makeLane(this.network, "Lane", from, to, null, laneType, this.speedLimit, this.simulator); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 499 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 368 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 339 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 386 |
if (ap.getKey().contains("IDM")) { Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { |
File | Line |
---|---|
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java | 144 |
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java | 119 |
JScrollPane scrollPane = new JScrollPane(DemoTrafcodAndTurbo.this.controllerDisplayPanel); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(scrollPane); addTab(getTabCount() - 1, this.trafCOD.getId(), wrapper); } /** {@inheritDoc} */ @Override protected final OTSModelInterface makeModel() throws OTSSimulationException { return new TrafCODModel(); } /** {@inheritDoc} */ @Override protected final void addAnimationToggles() { AnimationToggles.setTextAnimationTogglesStandard(this); } /** {@inheritDoc} */ @Override protected final Double makeAnimationRectangle() { return new Rectangle2D.Double(-200, -200, 400, 400); } /** * The simulation model. */ class TrafCODModel extends EventProducer implements OTSModelInterface, EventListenerInterface { /** */ private static final long serialVersionUID = 20161020L; /** The network. */ private OTSNetwork network; @SuppressWarnings("synthetic-access") @Override public void constructModel(final SimulatorInterface<Time, Duration, SimTimeDoubleUnit> theSimulator) throws SimRuntimeException { try { URL url = URLResource.getResource("/conflictAndControl/TurboRoundaboutAndSignal.xml"); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 84 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 84 |
public FundamentalDiagrams() { try { this.properties.add(new SelectionProperty("CarFollowingModel", "Car following model", "<html>The car following model determines " + "the acceleration that a vehicle will make taking into account nearby vehicles, " + "infrastructural restrictions (e.g. speed limit, curvature of the road) " + "capabilities of the vehicle and personality of the driver.</html>", new String[] { "IDM", "IDM+" }, 1, false, 500)); this.properties.add(new ProbabilityDistributionProperty("TrafficComposition", "Traffic composition", "<html>Mix of passenger cars and trucks</html>", new String[] { "passenger car", "truck" }, new Double[] { 0.8, 0.2 }, false, 10)); } catch (PropertyException exception) { exception.printStackTrace(); } } /** {@inheritDoc} */ @Override public final void stopTimersThreads() { super.stopTimersThreads(); this.model = null; } /** * Main program. * @param args String[]; the command line arguments (not used) * @throws SimRuntimeException on ??? */ public static void main(final String[] args) throws SimRuntimeException { // Create the simulation and wrap its panel in a JFrame. It does not get much easier/shorter than this... SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 431 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 437 |
initialPositions.add(new DirectedLanePosition(this.getLane(), initialPosition, GTUDirectionality.DIR_PLUS)); Length vehicleLength = new Length(generateTruck ? 15 : 4, METER); GTUFollowingModelOld gtuFollowingModel = generateTruck ? this.carFollowingModelTrucks : this.carFollowingModelCars; if (null == gtuFollowingModel) { throw new Error("gtuFollowingModel is null"); } Parameters parameters = DefaultsFactory.getDefaultParameters(); // LaneBasedBehavioralCharacteristics drivingCharacteristics = // new LaneBasedBehavioralCharacteristics(gtuFollowingModel, this.laneChangeModel); LaneBasedIndividualGTU gtu = new LaneBasedIndividualGTU("" + (++this.carsCreated), this.gtuType, vehicleLength, new Length(1.8, METER), new Speed(200, KM_PER_HOUR), vehicleLength.multiplyBy(0.5), this.simulator, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner( new LaneBasedGTUFollowingTacticalPlanner(gtuFollowingModel, gtu), gtu); gtu.setParameters(parameters); gtu.initWithAnimation(strategicalPlanner, initialPositions, initialSpeed, DefaultCarAnimation.class, |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 764 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 784 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 783 |
LaneBasedTemplateGTUType makeTemplate(final StreamInterface randStream, final Lane lane, final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> lengthDistribution, final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> widthDistribution, final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> maximumSpeedDistribution, final Set<DirectedLanePosition> initialPositions, final LaneBasedStrategicalPlannerFactory<LaneBasedStrategicalPlanner> strategicalPlannerFactory) throws GTUException { return new LaneBasedTemplateGTUType(this.gtuType, new Generator<Length>() { @Override public Length draw() { return lengthDistribution.draw(); } }, new Generator<Length>() { @Override public Length draw() { return widthDistribution.draw(); } }, new Generator<Speed>() { @Override public Speed draw() { return maximumSpeedDistribution.draw(); } }, /*-new Generator<LaneBasedStrategicalPlanner>() { public LaneBasedStrategicalPlanner draw() throws ProbabilityException, ParameterException { BehavioralCharacteristics parameters = DefaultsFactory.getDefaultBehavioralCharacteristics(); parameters.setParameter(ParameterTypes.LOOKAHEAD, new Length(450.0, LengthUnit.METER)); try { return new LaneBasedStrategicalRoutePlanner(parameters, tacticalPlanner, XMLNetworkModel.this.routeGenerator.draw()); } catch (GTUException exception) { throw new ParameterException(exception); } } }*/ strategicalPlannerFactory, this.routeGenerator); } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 427 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 510 |
org\opentrafficsim\demo\carFollowing\Straight.java | 467 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 490 |
} } else if (ap instanceof CompoundProperty) { CompoundProperty cp = (CompoundProperty) ap; if (ap.getKey().equals("OutputGraphs")) { continue; // Output settings are handled elsewhere } if (ap.getKey().contains("IDM")) { Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new SimRuntimeException("Unknown gtu following model: " + carFollowingModelName); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 431 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 437 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 621 |
org\opentrafficsim\demo\carFollowing\Straight.java | 593 |
initialPositions.add(new DirectedLanePosition(this.getLane(), initialPosition, GTUDirectionality.DIR_PLUS)); Length vehicleLength = new Length(generateTruck ? 15 : 4, METER); GTUFollowingModelOld gtuFollowingModel = generateTruck ? this.carFollowingModelTrucks : this.carFollowingModelCars; if (null == gtuFollowingModel) { throw new Error("gtuFollowingModel is null"); } Parameters parameters = DefaultsFactory.getDefaultParameters(); // LaneBasedBehavioralCharacteristics drivingCharacteristics = // new LaneBasedBehavioralCharacteristics(gtuFollowingModel, this.laneChangeModel); LaneBasedIndividualGTU gtu = new LaneBasedIndividualGTU("" + (++this.carsCreated), this.gtuType, vehicleLength, new Length(1.8, METER), new Speed(200, KM_PER_HOUR), vehicleLength.multiplyBy(0.5), this.simulator, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner( new LaneBasedGTUFollowingTacticalPlanner(gtuFollowingModel, gtu), gtu); gtu.setParameters(parameters); gtu.initWithAnimation(strategicalPlanner, initialPositions, initialSpeed, DefaultCarAnimation.class, |
File | Line |
---|---|
ahfe\AHFEAnimation.java | 623 |
ahfe\AHFESimulation.java | 612 |
AHFEUtil.createDemand(this.network, AHFEAnimation.this.getColorer(), (DEVSSimulatorInterface.TimeDoubleUnit) theSimulator, getReplication(), getAnticipationStrategy(), getReactionTime(), getAnticipationTime(), getTruckFraction(), SIMEND, getLeftDemand(), getRightDemand(), getLeftFraction(), getDistanceError(), getSpeedError(), getAccelerationError()); } catch (Exception exception) { exception.printStackTrace(); } } /** * Register a link to the sampler, so data is sampled there. * @param linkData link data * @param startDistance start distance on link * @param endDistance end distance on link */ private void registerLinkToSampler(final LinkData linkData, final Length startDistance, final Length endDistance) { for (LaneDataInterface laneData : linkData.getLaneDatas()) { Length start = laneData.getLength().multiplyBy(startDistance.si / linkData.getLength().si); Length end = laneData.getLength().multiplyBy(endDistance.si / linkData.getLength().si); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 456 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 501 |
Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 431 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 437 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 621 |
org\opentrafficsim\demo\carFollowing\Straight.java | 593 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 413 |
initialPositions.add(new DirectedLanePosition(this.getLane(), initialPosition, GTUDirectionality.DIR_PLUS)); Length vehicleLength = new Length(generateTruck ? 15 : 4, METER); GTUFollowingModelOld gtuFollowingModel = generateTruck ? this.carFollowingModelTrucks : this.carFollowingModelCars; if (null == gtuFollowingModel) { throw new Error("gtuFollowingModel is null"); } Parameters parameters = DefaultsFactory.getDefaultParameters(); // LaneBasedBehavioralCharacteristics drivingCharacteristics = // new LaneBasedBehavioralCharacteristics(gtuFollowingModel, this.laneChangeModel); LaneBasedIndividualGTU gtu = new LaneBasedIndividualGTU("" + (++this.carsCreated), this.gtuType, vehicleLength, new Length(1.8, METER), new Speed(200, KM_PER_HOUR), vehicleLength.multiplyBy(0.5), this.simulator, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner( new LaneBasedGTUFollowingTacticalPlanner(gtuFollowingModel, gtu), gtu); gtu.setParameters(parameters); gtu.initWithAnimation(strategicalPlanner, initialPositions, initialSpeed, DefaultCarAnimation.class, |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 459 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 525 |
org\opentrafficsim\demo\carFollowing\Straight.java | 481 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 374 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 558 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 345 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 580 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 392 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 576 |
Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { this.carFollowingModelTrucks = gtuFollowingModel; } else { throw new Error("Cannot determine gtu type for " + ap.getKey()); } } } } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 392 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 382 |
initialPositions.add(new DirectedLanePosition(this.getLane(), initialPosition, GTUDirectionality.DIR_PLUS)); Parameters parameters = DefaultsFactory.getDefaultParameters(); // LaneBasedBehavioralCharacteristics drivingCharacteristics = // new LaneBasedBehavioralCharacteristics(this.carFollowingModelCars, this.laneChangeModel); this.block = new LaneBasedIndividualGTU("999999", this.gtuType, new Length(4, METER), new Length(1.8, METER), Speed.ZERO, Length.createSI(2.0), this.simulator, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner( new LaneBasedGTUFollowingTacticalPlanner(this.carFollowingModelCars, this.block), this.block); this.block.setParameters(parameters); this.block.initWithAnimation(strategicalPlanner, initialPositions, Speed.ZERO, DefaultCarAnimation.class, |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 284 |
org\opentrafficsim\demo\carFollowing\Straight.java | 422 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 445 |
OTSNode from = new OTSNode(this.network, "From", new OTSPoint3D(getMinimumDistance().getSI(), 0, 0)); OTSNode to = new OTSNode(this.network, "To", new OTSPoint3D(getMaximumDistance().getSI(), 0, 0)); OTSNode end = new OTSNode(this.network, "End", new OTSPoint3D(getMaximumDistance().getSI() + 50.0, 0, 0)); LaneType laneType = LaneType.TWO_WAY_LANE; this.lane = LaneFactory.makeLane(this.network, "Lane", from, to, null, laneType, this.speedLimit, this.simulator); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 387 |
org\opentrafficsim\demo\carFollowing\Straight.java | 448 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 471 |
throw new SimRuntimeException("\"Car following model\" property has wrong type"); } for (Property<?> ap : new CompoundProperty("", "", "", this.properties, false, 0)) { // System.out.println("Handling property " + ap.getKey()); if (ap instanceof SelectionProperty) { SelectionProperty sp = (SelectionProperty) ap; if ("CarFollowingModel".equals(sp.getKey())) { carFollowingModelName = sp.getValue(); } } else if (ap instanceof ProbabilityDistributionProperty) { ProbabilityDistributionProperty pdp = (ProbabilityDistributionProperty) ap; String modelName = ap.getKey(); if (modelName.equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } } else if (ap instanceof IntegerProperty) |
File | Line |
---|---|
strategies\LmrsStrategies.java | 622 |
strategies\StrategiesDemo.java | 612 |
origin, destination, VehicleModel.NONE); } } /** Perception factory. */ class LmrsStrategiesPerceptionFactory implements PerceptionFactory { /** {@inheritDoc} */ @Override public LanePerception generatePerception(final LaneBasedGTU gtu) { LanePerception perception = new CategoricalLanePerception(gtu); perception.addPerceptionCategory(new DirectEgoPerception(perception)); perception.addPerceptionCategory(new DirectInfrastructurePerception(perception)); perception.addPerceptionCategory(new DirectNeighborsPerception(perception, HeadwayGtuType.WRAP)); perception.addPerceptionCategory(new AnticipationTrafficPerception(perception)); return perception; } /** {@inheritDoc} */ @Override public Parameters getParameters() throws ParameterException { return new ParameterSet().setDefaultParameter(ParameterTypes.LOOKAHEAD) .setDefaultParameter(ParameterTypes.LOOKBACKOLD).setDefaultParameter(ParameterTypes.PERCEPTION) .setDefaultParameter(ParameterTypes.LOOKBACK); } } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 367 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 338 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 385 |
org\opentrafficsim\demo\PropertiesParser.java | 85 |
cp = (CompoundProperty) ap; if (ap.getKey().contains("IDM")) { // System.out.println("Car following model name appears to be " + ap.getKey()); Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 403 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 409 |
org\opentrafficsim\demo\carFollowing\Straight.java | 565 |
FundamentalDiagrams.this.getColorer()); } catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException exception) { exception.printStackTrace(); } } /** * Remove the block. */ protected final void removeBlock() { this.block.destroy(); this.block = null; } /** * Generate cars at a fixed rate (implemented by re-scheduling this method). */ protected final void generateCar() { boolean generateTruck = this.randomGenerator.nextDouble() > this.carProbability; Length initialPosition = new Length(0, METER); Speed initialSpeed = new Speed(100, KM_PER_HOUR); Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1); try { initialPositions.add(new DirectedLanePosition(this.getLane(), initialPosition, GTUDirectionality.DIR_PLUS)); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 337 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 308 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 355 |
String networkType = (String) cp.findByKey("Network").getValue(); boolean merge = networkType.startsWith("M"); int lanesOnMain = Integer.parseInt(networkType.split(" ")[merge ? 1 : 5]); int lanesOnBranch = Integer.parseInt(networkType.split(" ")[3]); int lanesOnCommon = lanesOnMain + lanesOnBranch; int lanesOnCommonCompressed = Integer.parseInt(networkType.split(" ")[merge ? 5 : 1]); LaneType laneType = LaneType.TWO_WAY_LANE; // Get car-following model name String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.props, false, 0); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 430 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 317 |
String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); Property<?> cfmp = propertyContainer.findByKey("CarFollowingModel"); if (null == cfmp) { throw new Error("Cannot find \"Car following model\" property"); } if (cfmp instanceof SelectionProperty) { carFollowingModelName = ((SelectionProperty) cfmp).getValue(); } else { throw new Error("\"Car following model\" property has wrong type"); } // Get car-following model parameter for (Property<?> ap : new CompoundProperty("", "", "", this.properties, false, 0)) { if (ap instanceof CompoundProperty) { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 392 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 400 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 382 |
initialPositions.add(new DirectedLanePosition(this.getLane(), initialPosition, GTUDirectionality.DIR_PLUS)); Parameters parameters = DefaultsFactory.getDefaultParameters(); // LaneBasedBehavioralCharacteristics drivingCharacteristics = // new LaneBasedBehavioralCharacteristics(this.carFollowingModelCars, this.laneChangeModel); this.block = new LaneBasedIndividualGTU("999999", this.gtuType, new Length(4, METER), new Length(1.8, METER), Speed.ZERO, Length.createSI(2.0), this.simulator, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner( new LaneBasedGTUFollowingTacticalPlanner(this.carFollowingModelCars, this.block), this.block); this.block.setParameters(parameters); this.block.initWithAnimation(strategicalPlanner, initialPositions, Speed.ZERO, DefaultCarAnimation.class, |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 426 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 477 |
try { // Get car-following model name String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); Property<?> cfmp = propertyContainer.findByKey("CarFollowingModel"); if (null == cfmp) { throw new Error("Cannot find \"Car following model\" property"); } if (cfmp instanceof SelectionProperty) { carFollowingModelName = ((SelectionProperty) cfmp).getValue(); } else { throw new Error("\"Car following model\" property has wrong type"); } // Get car-following model parameter for (Property<?> ap : new CompoundProperty("", "", "", this.properties, false, 0)) { if (ap instanceof CompoundProperty) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SuperDemo.java | 310 |
org\opentrafficsim\demo\timing\TimeCircularRoadAnimation.java | 68 |
org\opentrafficsim\demo\timing\TimeCircularRoadSimulation.java | 89 |
+ "of the driver.</html>", new String[] { "IDM", "IDM+" }, 1, false, 1)); modelSelection.add(IDMPropertySet.makeIDMPropertySet("IDMCar", "Car", new Acceleration(1.56, METER_PER_SECOND_2), new Acceleration(2.09, METER_PER_SECOND_2), new Length(3.0, METER), new Duration(1.2, SECOND), 2)); modelSelection.add(IDMPropertySet.makeIDMPropertySet("IDMTruck", "Truck", new Acceleration(0.75, METER_PER_SECOND_2), new Acceleration(1.25, METER_PER_SECOND_2), new Length(3.0, METER), new Duration( 1.2, SECOND), 3)); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 436 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 519 |
org\opentrafficsim\demo\carFollowing\Straight.java | 476 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 499 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 368 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 339 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 386 |
org\opentrafficsim\demo\PropertiesParser.java | 86 |
if (ap.getKey().contains("IDM")) { Acceleration a = IDMPropertySet.getA(cp); Acceleration b = IDMPropertySet.getB(cp); Length s0 = IDMPropertySet.getS0(cp); Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new SimRuntimeException("Unknown gtu following model: " + carFollowingModelName); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 284 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 302 |
cp = new AccelerationContourPlot("Acceleration Graph", this.model.getPath()); cp.setTitle("Acceleration Contour Graph"); } else { throw new Error("Unhandled type of contourplot: " + graphName); } graph = cp; container = cp.getContentPane(); } // Add the container to the matrix charts.setCell(container, i % columns, i / columns); this.model.getPlots().add(graph); } addTab(getTabCount(), "statistics", charts); } /** {@inheritDoc} */ @Override public final String shortName() { return "Straight lane"; } /** {@inheritDoc} */ @Override public final String description() { return "<html><h1>Simulation of a straight one-lane road with opening bridge</H1>" + "Simulation of a single lane road of 5 km length. Vehicles are generated at a constant rate of " + "1500 veh/hour. At time 300s a blockade is inserted at position 4km; this blockade is removed at " + "time 420s. This blockade simulates a bridge opening.<br>" + "The blockade causes a traffic jam that slowly dissolves after the blockade is removed.<br>" + "Selected trajectory and contour plots are generated during the simulation.</html>"; } /** * Simulate a single lane road of 5 km length. Vehicles are generated at a constant rate of 1500 veh/hour. At time 300s a * blockade is inserted at position 4 km; this blockade is removed at time 500s. The used car following algorithm is IDM+ * <a href="http://opentrafficsim.org/downloads/MOTUS%20reference.pdf"><i>Integrated Lane Change Model with Relaxation and * Synchronization</i>, by Wouter J. Schakel, Victor L. Knoop and Bart van Arem, 2012</a>. <br> * Output is a set of block charts: * <ul> * <li>Traffic density</li> * <li>Speed</li> * <li>Flow</li> * <li>Acceleration</li> * </ul> * All these graphs display simulation time along the horizontal axis and distance along the road along the vertical axis. * <p> * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. * <br> * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. * <p> * $LastChangedDate: 2018-09-19 13:55:45 +0200 (Wed, 19 Sep 2018) $, @version $Revision: 4006 $, by $Author: averbraeck $, * initial version ug 1, 2014 <br> * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> */ class StraightModel implements OTSModelInterface, UNITS |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 873 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 892 |
return lane; } /** * Notify the contour plots that the underlying data has changed. */ protected final void drawGraphs() { for (LaneBasedGTUSampler plot : this.plots) { plot.reGraph(); } // Re schedule this method try { this.simulator.scheduleEventAbs(new Time(this.simulator.getSimulatorTime().getSI() + 1, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); } catch (SimRuntimeException exception) { exception.printStackTrace(); } } /** * Generate cars at a fixed rate (implemented by re-scheduling this method). * @param lane Lane; the lane on which the generated cars are placed */ // protected final void generateCar(final Lane lane) // { // Length initialPosition = new Length(16, METER); // Speed initialSpeed = new Speed(50, KM_PER_HOUR); // boolean generate = true; // // Check if there is sufficient room // // Find the first vehicle on the lane // LaneBasedGTU leader = null; // Time when = new Time(this.simulator.getSimulatorTime().si, TimeUnit.SI); // try // { // leader = lane.getGtuAhead(initialPosition, GTUDirectionality.DIR_PLUS, RelativePosition.REAR, when); // if (null != leader) // { // double headway = // leader.fractionalPosition(lane, leader.getRear()) * lane.getLength().si - initialPosition.si - 15.0 / 2; // if (headway < 0.1) // { // System.out.println("Not generating GTU due to insufficient room"); // generate = false; // } // double leaderSpeed = leader.getSpeed().si; // if (leaderSpeed < initialSpeed.si) // { // // What distance will it take to reduce speed to 0 with a decent deceleration? // double decentDeceleration = 5; // [m/s/s] // double deltaT = initialSpeed.si / decentDeceleration; // double distance = 0.5 * decentDeceleration * deltaT * deltaT; // if (distance > headway) // { // System.out.println("Not generating GTU due to slow driving GTU within emergency stop range"); // generate = false; // } // } // } // } // catch (GTUException exception1) // { // exception1.printStackTrace(); // } // try // { // if (generate) // { // boolean generateTruck = this.randomGenerator.nextDouble() > this.carProbability; // Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1); // initialPositions.add(new DirectedLanePosition(lane, initialPosition, GTUDirectionality.DIR_PLUS)); // Length vehicleLength = new Length(generateTruck ? 15 : 4, METER); // GTUFollowingModel gtuFollowingModel = generateTruck ? this.carFollowingModelTrucks : this.carFollowingModelCars; // double speed = this.disttria.draw(); // // LaneBasedDrivingCharacteristics drivingCharacteristics = // new LaneBasedDrivingCharacteristics(gtuFollowingModel, this.laneChangeModel); // drivingCharacteristics.setForwardHeadwayDistance(new Length(450.0, LengthUnit.METER)); // LaneBasedStrategicalPlanner strategicalPlanner = // new LaneBasedStrategicalRoutePlanner(drivingCharacteristics, this.tacticalPlanner, // this.routeGenerator.draw()); // new LaneBasedIndividualGTU("" + (++this.carsCreated), this.gtuType, initialPositions, initialSpeed, // vehicleLength, new Length(1.8, METER), new Speed(speed, KM_PER_HOUR), this.simulator, // strategicalPlanner, new LanePerceptionFull(), DefaultCarAnimation.class, this.gtuColorer, this.network); // } // Object[] arguments = new Object[1]; // arguments[0] = lane; // this.simulator.scheduleEventRel(new Duration(this.headwayGenerator.draw(), SECOND), this, this, "generateCar", // arguments); // } // catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException // | ProbabilityException exception) // { // exception.printStackTrace(); // } // } /** {@inheritDoc} */ @Override public SimulatorInterface<Time, Duration, SimTimeDoubleUnit> getSimulator() { return this.simulator; } /** {@inheritDoc} */ @Override public OTSNetwork getNetwork() { return this.network; } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 430 |
org\opentrafficsim\demo\carFollowing\Straight.java | 435 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 458 |
String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); Property<?> cfmp = propertyContainer.findByKey("CarFollowingModel"); if (null == cfmp) { throw new Error("Cannot find \"Car following model\" property"); } if (cfmp instanceof SelectionProperty) { carFollowingModelName = ((SelectionProperty) cfmp).getValue(); } else { throw new Error("\"Car following model\" property has wrong type"); } // Get car-following model parameter for (Property<?> ap : new CompoundProperty("", "", "", this.properties, false, 0)) { if (ap instanceof CompoundProperty) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 365 |
org\opentrafficsim\demo\carFollowing\Straight.java | 519 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 541 |
this.simulator.scheduleEventAbs(Time.ZERO, this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator.scheduleEventAbs(new Time(300, TimeUnit.BASE_SECOND), this, this, "createBlock", null); // Remove the block at t = 7 minutes this.simulator.scheduleEventAbs(new Time(420, TimeUnit.BASE_SECOND), this, this, "removeBlock", null); // Schedule regular updates of the graph for (int t = 1; t <= 1800; t++) { this.simulator.scheduleEventAbs(new Time(t - 0.001, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); } } catch (SimRuntimeException exception) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 479 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 317 |
String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); Property<?> cfmp = propertyContainer.findByKey("CarFollowingModel"); if (null == cfmp) { throw new Error("Cannot find \"Car following model\" property"); } if (cfmp instanceof SelectionProperty) { carFollowingModelName = ((SelectionProperty) cfmp).getValue(); } else { throw new Error("\"Car following model\" property has wrong type"); } for (Property<?> ap : new CompoundProperty("", "", "", this.properties, false, 0)) { if (ap instanceof SelectionProperty) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 832 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 893 |
} /** * Notify the contour plots that the underlying data has changed. */ protected final void drawGraphs() { for (LaneBasedGTUSampler plot : this.plots) { plot.reGraph(); } // Re schedule this method try { this.simulator.scheduleEventAbs(new Time(this.simulator.getSimulatorTime().getSI() + 1, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); } catch (SimRuntimeException exception) { exception.printStackTrace(); } } /** * Generate cars at a fixed rate (implemented by re-scheduling this method). * @param lane Lane; the lane on which the generated cars are placed */ // protected final void generateCar(final Lane lane) // { // Length initialPosition = new Length(16, METER); // Speed initialSpeed = new Speed(50, KM_PER_HOUR); // boolean generate = true; // // Check if there is sufficient room // // Find the first vehicle on the lane // LaneBasedGTU leader = null; // Time when = new Time(this.simulator.getSimulatorTime().si, TimeUnit.SI); // try // { // leader = lane.getGtuAhead(initialPosition, GTUDirectionality.DIR_PLUS, RelativePosition.REAR, when); // if (null != leader) // { // double headway = // leader.fractionalPosition(lane, leader.getRear()) * lane.getLength().si - initialPosition.si - 15.0 / 2; // if (headway < 0.1) // { // System.out.println("Not generating GTU due to insufficient room"); // generate = false; // } // double leaderSpeed = leader.getSpeed().si; // if (leaderSpeed < initialSpeed.si) // { // // What distance will it take to reduce speed to 0 with a decent deceleration? // double decentDeceleration = 5; // [m/s/s] // double deltaT = initialSpeed.si / decentDeceleration; // double distance = 0.5 * decentDeceleration * deltaT * deltaT; // if (distance > headway) // { // System.out.println("Not generating GTU due to slow driving GTU within emergency stop range"); // generate = false; // } // } // } // } // catch (GTUException exception1) // { // exception1.printStackTrace(); // } // try // { // if (generate) // { // boolean generateTruck = this.randomGenerator.nextDouble() > this.carProbability; // Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1); // initialPositions.add(new DirectedLanePosition(lane, initialPosition, GTUDirectionality.DIR_PLUS)); // Length vehicleLength = new Length(generateTruck ? 15 : 4, METER); // GTUFollowingModel gtuFollowingModel = generateTruck ? this.carFollowingModelTrucks : this.carFollowingModelCars; // double speed = this.disttria.draw(); // // LaneBasedDrivingCharacteristics drivingCharacteristics = // new LaneBasedDrivingCharacteristics(gtuFollowingModel, this.laneChangeModel); // drivingCharacteristics.setForwardHeadwayDistance(new Length(450.0, LengthUnit.METER)); // LaneBasedStrategicalPlanner strategicalPlanner = // new LaneBasedStrategicalRoutePlanner(drivingCharacteristics, this.tacticalPlanner, // this.routeGenerator.draw()); // new LaneBasedIndividualGTU("" + (++this.carsCreated), this.gtuType, initialPositions, initialSpeed, // vehicleLength, new Length(1.8, METER), new Speed(speed, KM_PER_HOUR), this.simulator, // strategicalPlanner, new LanePerceptionFull(), DefaultCarAnimation.class, this.gtuColorer, this.network); // } // Object[] arguments = new Object[1]; // arguments[0] = lane; // this.simulator.scheduleEventRel(new Duration(this.headwayGenerator.draw(), SECOND), this, this, "generateCar", // arguments); // } // catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException // | ProbabilityException exception) // { // exception.printStackTrace(); // } // } /** {@inheritDoc} */ @Override public SimulatorInterface<Time, Duration, SimTimeDoubleUnit> getSimulator() { return this.simulator; } /** {@inheritDoc} */ @Override public OTSNetwork getNetwork() { return this.network; } /** * The route colorer to show whether GTUs stay on the main route or go right at the split. * <p> * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. <br> * All rights reserved. <br> * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. * </p> * $LastChangedDate: 2016-12-13 02:02:22 +0100 (Tue, 13 Dec 2016) $, @version $Revision: 2930 $, by $Author: wjschakel $, * initial version Jan 3, 2016 <br> * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> */ private class DirectionGTUColorer implements GTUColorer |
File | Line |
---|---|
ahfe\AHFEAnimation.java | 62 |
ahfe\AHFESimulation.java | 59 |
{ /** Warm-up time. */ static final Time WARMUP = Time.createSI(360); /** Simulation time, including warm-up time. */ static final Time SIMEND = Time.createSI(360 + 3600); /** Distance to not consider at start of the network. */ private static Length ignoreStart = Length.createSI(2900); // Not 100m on pre-link, so 3000 total /** Distance to not consider at end of the network. */ private static Length ignoreEnd = Length.createSI(1000); /** */ private static final long serialVersionUID = 20170228L; /** Replication. */ private final Integer replication; /** Anticipation strategy. */ private final String anticipationStrategy; /** Reaction time. */ private final Duration reactionTime; /** Future anticipation time. */ private final Duration anticipationTime; /** Truck fraction. */ private final double truckFraction; /** Distance error. */ private final double distanceError; /** Speed error. */ private final double speedError; /** Acceleration error. */ private final double accelerationError; /** Left demand. */ private final Frequency leftDemand; /** Right demand. */ private final Frequency rightDemand; /** Left fraction, per road. */ private final double leftFraction; /** Sampler. */ Sampler<GtuData> sampler; /** * @param replication replication * @param anticipationStrategy anticipation strategy * @param reactionTime reaction time * @param anticipationTime anticipation time * @param truckFraction truck fraction * @param distanceError distance error * @param speedError speed error * @param accelerationError acceleration error * @param leftFraction left demand * @param rightDemand right demand * @param leftDemand left fraction, per road */ @SuppressWarnings("checkstyle:parameternumber") public AHFEAnimation(final Integer replication, final String anticipationStrategy, final Duration reactionTime, |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 874 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 832 |
} /** * Notify the contour plots that the underlying data has changed. */ protected final void drawGraphs() { for (LaneBasedGTUSampler plot : this.plots) { plot.reGraph(); } // Re schedule this method try { this.simulator.scheduleEventAbs(new Time(this.simulator.getSimulatorTime().getSI() + 1, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); } catch (SimRuntimeException exception) { exception.printStackTrace(); } } /** * Generate cars at a fixed rate (implemented by re-scheduling this method). * @param lane Lane; the lane on which the generated cars are placed */ // protected final void generateCar(final Lane lane) // { // Length initialPosition = new Length(16, METER); // Speed initialSpeed = new Speed(50, KM_PER_HOUR); // boolean generate = true; // // Check if there is sufficient room // // Find the first vehicle on the lane // LaneBasedGTU leader = null; // Time when = new Time(this.simulator.getSimulatorTime().si, TimeUnit.SI); // try // { // leader = lane.getGtuAhead(initialPosition, GTUDirectionality.DIR_PLUS, RelativePosition.REAR, when); // if (null != leader) // { // double headway = // leader.fractionalPosition(lane, leader.getRear()) * lane.getLength().si - initialPosition.si - 15.0 / 2; // if (headway < 0.1) // { // System.out.println("Not generating GTU due to insufficient room"); // generate = false; // } // double leaderSpeed = leader.getSpeed().si; // if (leaderSpeed < initialSpeed.si) // { // // What distance will it take to reduce speed to 0 with a decent deceleration? // double decentDeceleration = 5; // [m/s/s] // double deltaT = initialSpeed.si / decentDeceleration; // double distance = 0.5 * decentDeceleration * deltaT * deltaT; // if (distance > headway) // { // System.out.println("Not generating GTU due to slow driving GTU within emergency stop range"); // generate = false; // } // } // } // } // catch (GTUException exception1) // { // exception1.printStackTrace(); // } // try // { // if (generate) // { // boolean generateTruck = this.randomGenerator.nextDouble() > this.carProbability; // Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1); // initialPositions.add(new DirectedLanePosition(lane, initialPosition, GTUDirectionality.DIR_PLUS)); // Length vehicleLength = new Length(generateTruck ? 15 : 4, METER); // GTUFollowingModel gtuFollowingModel = generateTruck ? this.carFollowingModelTrucks : this.carFollowingModelCars; // double speed = this.disttria.draw(); // // LaneBasedDrivingCharacteristics drivingCharacteristics = // new LaneBasedDrivingCharacteristics(gtuFollowingModel, this.laneChangeModel); // drivingCharacteristics.setForwardHeadwayDistance(new Length(450.0, LengthUnit.METER)); // LaneBasedStrategicalPlanner strategicalPlanner = // new LaneBasedStrategicalRoutePlanner(drivingCharacteristics, this.tacticalPlanner, // this.routeGenerator.draw()); // new LaneBasedIndividualGTU("" + (++this.carsCreated), this.gtuType, initialPositions, initialSpeed, // vehicleLength, new Length(1.8, METER), new Speed(speed, KM_PER_HOUR), this.simulator, // strategicalPlanner, new LanePerceptionFull(), DefaultCarAnimation.class, this.gtuColorer, this.network); // } // Object[] arguments = new Object[1]; // arguments[0] = lane; // this.simulator.scheduleEventRel(new Duration(this.headwayGenerator.draw(), SECOND), this, this, "generateCar", // arguments); // } // catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException // | ProbabilityException exception) // { // exception.printStackTrace(); // } // } /** {@inheritDoc} */ @Override public SimulatorInterface<Time, Duration, SimTimeDoubleUnit> getSimulator() { return this.simulator; } /** {@inheritDoc} */ @Override public OTSNetwork getNetwork() { return this.network; } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 610 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 648 |
this.simulator.scheduleEventRel(this.headway, this, this, "generateCar", null); } catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException exception) { exception.printStackTrace(); } } /** {@inheritDoc} */ @Override public final SimulatorInterface<Time, Duration, SimTimeDoubleUnit> getSimulator() { return this.simulator; } /** {@inheritDoc} */ @Override public OTSNetwork getNetwork() { return this.network; } /** * @return contourPlots */ public final List<LaneBasedGTUSampler> getPlots() { return this.plots; } /** * @return minimumDistance */ public final Length getMinimumDistance() { return this.minimumDistance; } /** * @return maximumDistance */ public final Length getMaximumDistance() { return this.maximumDistance; } /** * @return lane. */ public Lane getLane() { return this.lane; } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 504 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 558 |
org\opentrafficsim\demo\carFollowing\XMLNetworks2.java | 580 |
org\opentrafficsim\demo\carFollowing\XMLSampler.java | 576 |
Duration tSafe = IDMPropertySet.getTSafe(cp); GTUFollowingModelOld gtuFollowingModel = null; if (carFollowingModelName.equals("IDM")) { gtuFollowingModel = new IDMOld(a, b, s0, tSafe, 1.0); } else if (carFollowingModelName.equals("IDM+")) { gtuFollowingModel = new IDMPlusOld(a, b, s0, tSafe, 1.0); } else { throw new Error("Unknown gtu following model: " + carFollowingModelName); } if (ap.getKey().contains("Car")) { this.carFollowingModelCars = gtuFollowingModel; } else if (ap.getKey().contains("Truck")) { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 519 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 541 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 352 |
this.simulator.scheduleEventAbs(Time.ZERO, this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator.scheduleEventAbs(new Time(300, TimeUnit.BASE_SECOND), this, this, "createBlock", null); // Remove the block at t = 7 minutes this.simulator.scheduleEventAbs(new Time(420, TimeUnit.BASE_SECOND), this, this, "removeBlock", null); // Schedule regular updates of the graphs for (int t = 1; t <= 1800; t++) { this.simulator.scheduleEventAbs(new Time(t - 0.001, TimeUnit.BASE_SECOND), this, this, "drawGraphs", null); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 583 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 437 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 443 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 627 |
org\opentrafficsim\demo\carFollowing\Straight.java | 599 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 419 |
throw new GTUException("gtuFollowingModel is null"); } Parameters parameters = DefaultsFactory.getDefaultParameters(); LaneBasedIndividualGTU gtu = new LaneBasedIndividualGTU("" + (++this.carsCreated), this.gtuType, vehicleLength, new Length(1.8, METER), new Speed(200, KM_PER_HOUR), vehicleLength.multiplyBy(0.5), this.simulator, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner( new LaneBasedGTUFollowingTacticalPlanner(gtuFollowingModel, gtu), gtu); gtu.setParameters(parameters); gtu.initWithAnimation(strategicalPlanner, initialPositions, initialSpeed, DefaultCarAnimation.class, |