The following document contains the results of PMD's CPD 5.3.5.
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 404 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 416 |
public RoadSimulationModel(final ArrayList<AbstractProperty<?>> properties, final GTUColorer gtuColorer) { this.properties = properties; this.gtuColorer = gtuColorer; } /** * @param index int; the rank number of the path * @return List<Lane>; the set of lanes for the specified index */ public List<Lane> getPath(final int index) { return this.paths.get(index); } /** {@inheritDoc} */ @Override public void constructModel(final SimulatorInterface<Abs<TimeUnit>, Rel<TimeUnit>, OTSSimTimeDouble> theSimulator) throws SimRuntimeException, RemoteException { final int laneCount = 2; for (int laneIndex = 0; laneIndex < laneCount; laneIndex++) { this.paths.add(new ArrayList<Lane>()); } this.simulator = (OTSDEVSSimulatorInterface) theSimulator; double radius = 6000 / 2 / Math.PI; double headway = 40; double headwayVariability = 0; try { // Get car-following model name String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); AbstractProperty<?> 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 Iterator<AbstractProperty<List<AbstractProperty<?>>>> iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); if (ap instanceof CompoundProperty) { CompoundProperty cp = (CompoundProperty) ap; System.out.println("Checking compound property " + cp); 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"); } // Get remaining properties iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); if (ap instanceof SelectionProperty) { SelectionProperty sp = (SelectionProperty) ap; if ("TacticalPlanner".equals(sp.getKey())) { String tacticalPlannerName = sp.getValue(); if ("MOBIL".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(new LaneBasedCFLCTacticalPlannerFactory( this.carFollowingModelCars, this.laneChangeModel)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(new LaneBasedCFLCTacticalPlannerFactory( this.carFollowingModelTrucks, this.laneChangeModel)); } else if ("Verbraeck".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingLaneChangeTacticalPlannerFactory(this.carFollowingModelCars)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingLaneChangeTacticalPlannerFactory(this.carFollowingModelTrucks)); } else if ("Verbraeck0".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingChange0TacticalPlannerFactory(this.carFollowingModelCars)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingChange0TacticalPlannerFactory(this.carFollowingModelTrucks)); } else if ("LMRS".equals(tacticalPlannerName)) { // provide default parameters with the car-following model BehavioralCharacteristics defaultBehavioralCFCharacteristics = new BehavioralCharacteristics(); defaultBehavioralCFCharacteristics.setDefaultParameters(AbstractIDM.class); this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(new LMRSFactory(IDMPlus.class, defaultBehavioralCFCharacteristics)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(new LMRSFactory(IDMPlus.class, defaultBehavioralCFCharacteristics)); } 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; if (ap.getKey().equals("TrafficComposition")) { this.carProbability = pdp.getValue()[0]; } } else if (ap instanceof IntegerProperty) { IntegerProperty ip = (IntegerProperty) ap; if ("TrackLength".equals(ip.getKey())) { radius = ip.getValue() / 2 / Math.PI; } } else if (ap instanceof ContinuousProperty) { ContinuousProperty cp = (ContinuousProperty) ap; if (cp.getKey().equals("MeanDensity")) { headway = 1000 / cp.getValue(); } if (cp.getKey().equals("DensityVariability")) { headwayVariability = cp.getValue(); } } else if (ap instanceof CompoundProperty) { if (ap.getKey().equals("OutputGraphs")) { continue; // Output settings are handled elsewhere } } } GTUType gtuType = new GTUType("car"); Set<GTUType> compatibility = new HashSet<GTUType>(); compatibility.add(gtuType); LaneType laneType = new LaneType("CarLane", compatibility); OTSNode start = new OTSNode("Start", new OTSPoint3D(radius, 0, 0)); OTSNode halfway = new OTSNode("Halfway", new OTSPoint3D(-radius, 0, 0)); OTSPoint3D[] coordsHalf1 = new OTSPoint3D[127]; for (int i = 0; i < coordsHalf1.length; i++) { double angle = Math.PI * (1 + i) / (1 + coordsHalf1.length); coordsHalf1[i] = new OTSPoint3D(radius * Math.cos(angle), radius * Math.sin(angle), 0); } Lane[] lanes1 = LaneFactory.makeMultiLane("FirstHalf", start, halfway, coordsHalf1, laneCount, laneType, this.speedLimit, this.simulator, LongitudinalDirectionality.DIR_PLUS); OTSPoint3D[] coordsHalf2 = new OTSPoint3D[127]; for (int i = 0; i < coordsHalf2.length; i++) { double angle = Math.PI + Math.PI * (1 + i) / (1 + coordsHalf2.length); coordsHalf2[i] = new OTSPoint3D(radius * Math.cos(angle), radius * Math.sin(angle), 0); } Lane[] lanes2 = LaneFactory.makeMultiLane("SecondHalf", halfway, start, coordsHalf2, laneCount, laneType, this.speedLimit, this.simulator, LongitudinalDirectionality.DIR_PLUS); for (int laneIndex = 0; laneIndex < laneCount; laneIndex++) { this.paths.get(laneIndex).add(lanes1[laneIndex]); this.paths.get(laneIndex).add(lanes2[laneIndex]); } // Put the (not very evenly spaced) cars on the track double variability = (headway - 20) * headwayVariability; System.out.println("headway is " + headway + " variability limit is " + variability); Random random = new Random(12345); for (int laneIndex = 0; laneIndex < laneCount; laneIndex++) { double lane1Length = lanes1[laneIndex].getLength().getSI(); double trackLength = lane1Length + lanes2[laneIndex].getLength().getSI(); for (double pos = 0; pos <= trackLength - headway - variability;) { Lane lane = pos >= lane1Length ? lanes2[laneIndex] : lanes1[laneIndex]; // Actual headway is uniformly distributed around headway double laneRelativePos = pos > lane1Length ? pos - lane1Length : pos; double actualHeadway = headway + (random.nextDouble() * 2 - 1) * variability; // System.out.println(lane + ", len=" + lane.getLength() + ", pos=" + laneRelativePos); generateCar(new Length(laneRelativePos, METER), lane, gtuType); pos += actualHeadway; } } // Schedule regular updates of the graph this.simulator.scheduleEventAbs(new DoubleScalar.Abs<TimeUnit>(9.999, SECOND), this, this, "drawGraphs", null); } catch (SimRuntimeException | NamingException | NetworkException | GTUException | 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(); } // Re schedule this method try { this.simulator.scheduleEventAbs(new Time(this.simulator.getSimulatorTime().get().getSI() + 10, SECOND), this, this, "drawGraphs", null); } catch (SimRuntimeException exception) { exception.printStackTrace(); } } /** * Generate cars at a fixed rate (implemented by re-scheduling this method). * @param initialPosition Length; the initial position of the new cars * @param lane Lane; the lane on which the new cars are placed * @param gtuType GTUType<String>; the type of the new cars * @throws NamingException on ??? * @throws SimRuntimeException cannot happen * @throws NetworkException on network inconsistency * @throws GTUException when something goes wrong during construction of the car * @throws OTSGeometryException when the initial position is outside the center line of the lane */ protected final void generateCar(final Length initialPosition, final Lane lane, final GTUType gtuType) throws NamingException, NetworkException, SimRuntimeException, GTUException, OTSGeometryException { // GTU itself boolean generateTruck = this.randomGenerator.nextDouble() > this.carProbability; Length vehicleLength = new Length(generateTruck ? 15 : 4, METER); LaneBasedIndividualGTU gtu = new LaneBasedIndividualGTU("" + (++this.carsCreated), gtuType, vehicleLength, new Length(1.8, METER), new Speed( 200, KM_PER_HOUR), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 412 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 434 |
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<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> theSimulator) throws SimRuntimeException, RemoteException { this.simulator = (OTSDEVSSimulatorInterface) theSimulator; OTSNode from = new OTSNode("From", new OTSPoint3D(getMinimumDistance().getSI(), 0, 0)); OTSNode to = new OTSNode("To", new OTSPoint3D(getMaximumDistance().getSI(), 0, 0)); OTSNode end = new OTSNode("End", new OTSPoint3D(getMaximumDistance().getSI() + 50.0, 0, 0)); try { Set<GTUType> compatibility = new HashSet<>(); compatibility.add(this.gtuType); LaneType laneType = new LaneType("CarLane", compatibility); this.lane = LaneFactory.makeLane("Lane", from, to, null, laneType, this.speedLimit, this.simulator, LongitudinalDirectionality.DIR_PLUS); this.path.add(this.lane); CrossSectionLink endLink = LaneFactory.makeLink("endLink", to, end, null, LongitudinalDirectionality.DIR_PLUS); // 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, LongitudinalDirectionality.DIR_PLUS, this.speedLimit, new OvertakingConditions.None()); Sensor sensor = new SinkSensor(sinkLane, new Length(10.0, METER), this.simulator); sinkLane.addSensor(sensor, GTUType.ALL); String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); AbstractProperty<?> 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"); } Iterator<AbstractProperty<List<AbstractProperty<?>>>> iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); 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\CircularRoad.java | 466 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 478 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 398 |
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"); } // Get remaining properties iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); if (ap instanceof SelectionProperty) { SelectionProperty sp = (SelectionProperty) ap; if ("TacticalPlanner".equals(sp.getKey())) { String tacticalPlannerName = sp.getValue(); if ("MOBIL".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(new LaneBasedCFLCTacticalPlannerFactory( this.carFollowingModelCars, this.laneChangeModel)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(new LaneBasedCFLCTacticalPlannerFactory( this.carFollowingModelTrucks, this.laneChangeModel)); } else if ("Verbraeck".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingLaneChangeTacticalPlannerFactory(this.carFollowingModelCars)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingLaneChangeTacticalPlannerFactory(this.carFollowingModelTrucks)); } else if ("Verbraeck0".equals(tacticalPlannerName)) { this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingChange0TacticalPlannerFactory(this.carFollowingModelCars)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory( new LaneBasedGTUFollowingChange0TacticalPlannerFactory(this.carFollowingModelTrucks)); } else if ("LMRS".equals(tacticalPlannerName)) { // provide default parameters with the car-following model BehavioralCharacteristics defaultBehavioralCFCharacteristics = new BehavioralCharacteristics(); defaultBehavioralCFCharacteristics.setDefaultParameters(AbstractIDM.class); this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(new LMRSFactory(IDMPlus.class, defaultBehavioralCFCharacteristics)); this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(new LMRSFactory(IDMPlus.class, defaultBehavioralCFCharacteristics)); } 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\CircularRoad.java | 207 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 214 |
this.model = new RoadSimulationModel(getSavedUserModifiedProperties(), colorer); return this.model; } /** * @return the saved user properties for a next run */ private ArrayList<AbstractProperty<?>> getSavedUserModifiedProperties() { return this.savedUserModifiedProperties; } /** {@inheritDoc} */ @Override protected final Rectangle2D.Double makeAnimationRectangle() { return new Rectangle2D.Double(-350, -350, 700, 700); } /** {@inheritDoc} */ @Override protected final JPanel makeCharts() throws OTSSimulationException, PropertyException { // Make the tab with the plots AbstractProperty<?> output = new CompoundProperty("", "", "", this.properties, false, 0).findByKey("OutputGraphs"); if (null == output) { throw new Error("Cannot find output properties"); } ArrayList<BooleanProperty> graphs = new ArrayList<BooleanProperty>(); if (output instanceof CompoundProperty) { CompoundProperty outputProperties = (CompoundProperty) output; for (AbstractProperty<?> 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; int pos = graphName.indexOf(' ') + 1; String laneNumberText = graphName.substring(pos, pos + 1); int lane = Integer.parseInt(laneNumberText) - 1; if (graphName.contains("Trajectories")) { TrajectoryPlot tp = new TrajectoryPlot(graphName, new Duration(0.5, SECOND), this.model.getPath(lane)); tp.setTitle("Trajectory Graph"); tp.setExtendedState(Frame.MAXIMIZED_BOTH); graph = tp; container = tp.getContentPane(); } else { ContourPlot cp; if (graphName.contains("Density")) { cp = new DensityContourPlot(graphName, this.model.getPath(lane)); cp.setTitle("Density Contour Graph"); } else if (graphName.contains("Speed")) { cp = new SpeedContourPlot(graphName, this.model.getPath(lane)); cp.setTitle("Speed Contour Graph"); } else if (graphName.contains("Flow")) { cp = new FlowContourPlot(graphName, this.model.getPath(lane)); cp.setTitle("Flow Contour Graph"); } else if (graphName.contains("Acceleration")) { cp = new AccelerationContourPlot(graphName, this.model.getPath(lane)); 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); } return charts; } /** {@inheritDoc} */ @Override public final String shortName() { return "Circular Road simulation"; } /** {@inheritDoc} */ @Override public final String description() { return "<html><h1>Circular Road simulation</h1>" + "Vehicles are unequally distributed over a two lane ring road.<br>" + "When simulation starts, all vehicles begin driving, some lane changes will occurr and some " + "shockwaves should develop.<br>" + "Trajectories and contourplots are generated during the simulation for both lanes.</html>"; } } /** * Simulate traffic on a circular, two-lane road. * <p> * Copyright (c) 2013-2016 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: 2016-08-28 22:46:23 +0200 (Sun, 28 Aug 2016) $, @version $Revision: 2191 $, by $Author: averbraeck $, * initial version 1 nov. 2014 <br> * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> */ class RoadSimulationModel implements OTSModelInterface, UNITS |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 312 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 303 |
exception.printStackTrace(); } // create SinkLane for (AbstractProperty<?> p : this.properties) { 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(new DoubleScalar.Abs<>(0.0, SECOND), this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator .scheduleEventAbs(new DoubleScalar.Abs<>(300, SECOND), this, this, "createBlock", null); // Remove the block at t = 7 minutes this.simulator .scheduleEventAbs(new DoubleScalar.Abs<>(420, SECOND), this, this, "removeBlock", null); // Schedule regular updates of the graph for (int t = 1; t <= 1800; t++) { this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(t - 0.001, SECOND), this, this, |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 110 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 115 |
public CircularRoad() throws PropertyException { this.properties.add(new SelectionProperty("LaneChanging", "Lane changing", "<html>The lane change strategies vary in politeness.<br>" + "Two types are implemented:<ul><li>Egoistic (looks only at personal gain).</li>" + "<li>Altruistic (assigns effect on new and current follower the same weight as " + "the personal gain).</html>", new String[] {"Egoistic", "Altruistic"}, 0, false, 500)); 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", "Verbraeck", "Verbraeck0", "LMRS", "Toledo"}, 0, false, 600)); this.properties.add(new IntegerProperty("TrackLength", "Track length", "Circumference of the track", 2000, 500, 6000, "Track length %dm", false, 10)); this.properties.add(new ContinuousProperty("MeanDensity", "Mean density", "Number of vehicles per km", 40.0, 5.0, 45.0, "Density %.1f veh/km", false, 11)); this.properties.add(new ContinuousProperty("DensityVariability", "Density variability", "Variability of the number of vehicles per km", 0.0, 0.0, 1.0, "%.1f", false, 12)); ArrayList<AbstractProperty<?>> outputProperties = new ArrayList<AbstractProperty<?>>(); for (int lane = 1; lane <= 2; lane++) { String laneId = String.format("Lane %d ", lane); outputProperties.add(new BooleanProperty(laneId + "Density", laneId + " Density", laneId + "Density contour plot", true, false, 0)); outputProperties.add(new BooleanProperty(laneId + "Flow", laneId + " Flow", laneId + "Flow contour plot", true, false, 1)); outputProperties.add(new BooleanProperty(laneId + "Speed", laneId + " Speed", laneId + "Speed contour plot", true, false, 2)); outputProperties.add(new BooleanProperty(laneId + "Acceleration", laneId + " Acceleration", laneId + "Acceleration contour plot", true, false, 3)); outputProperties.add(new BooleanProperty(laneId + "Trajectories", laneId + " Trajectories", laneId + "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 public void run() { try { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 322 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 331 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 311 |
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(new DoubleScalar.Abs<>(0.0, SECOND), this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator .scheduleEventAbs(new DoubleScalar.Abs<>(300, SECOND), this, this, "createBlock", null); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 193 |
org\opentrafficsim\demo\carFollowing\Straight.java | 188 |
this.model = new SequentialModel(this.savedUserModifiedProperties, colorer); 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 JPanel makeCharts() throws OTSSimulationException, PropertyException { // Make the tab with the plots AbstractProperty<?> 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 (AbstractProperty<?> 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\FundamentalDiagrams.java | 276 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 268 |
public FundamentalDiagramPlotsModel(final ArrayList<AbstractProperty<?>> properties, final GTUColorer gtuColorer) { this.properties = properties; this.gtuColorer = gtuColorer; } /** {@inheritDoc} */ @Override public final void constructModel( final SimulatorInterface<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> theSimulator) throws SimRuntimeException, RemoteException { this.simulator = (OTSDEVSSimulatorInterface) theSimulator; OTSNode from = new OTSNode("From", new OTSPoint3D(getMinimumDistance().getSI(), 0, 0)); OTSNode to = new OTSNode("To", new OTSPoint3D(getMaximumDistance().getSI(), 0, 0)); OTSNode end = new OTSNode("End", new OTSPoint3D(getMaximumDistance().getSI() + 50.0, 0, 0)); Set<GTUType> compatibility = new HashSet<>(); compatibility.add(this.gtuType); LaneType laneType = new LaneType("CarLane", compatibility); try { this.lane = LaneFactory.makeLane("Lane", from, to, null, laneType, this.speedLimit, this.simulator, LongitudinalDirectionality.DIR_PLUS); CrossSectionLink endLink = LaneFactory.makeLink("endLink", to, end, null, LongitudinalDirectionality.DIR_PLUS); // 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, LongitudinalDirectionality.DIR_PLUS, this.speedLimit, new OvertakingConditions.None()); Sensor sensor = new SinkSensor(sinkLane, new Length(10.0, METER), this.simulator); sinkLane.addSensor(sensor, GTUType.ALL); } catch (NamingException | NetworkException | OTSGeometryException exception) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 141 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 158 |
Straight straight = new Straight(); ArrayList<AbstractProperty<?>> 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(new Time(0.0, SECOND), new Duration(0.0, SECOND), 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 Rectangle2D.Double makeAnimationRectangle() { return new Rectangle2D.Double(1500, -100, 2000, 200); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 204 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 216 |
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 JPanel makeCharts() throws OTSSimulationException, PropertyException { // Make the tab with the plots AbstractProperty<?> 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 (AbstractProperty<?> 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 | 519 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 540 |
} 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(new DoubleScalar.Abs<>(0.0, SECOND), this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(300, SECOND), this, this, "createBlock", null); // Remove the block at t = 7 minutes this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(420, SECOND), this, this, "removeBlock", null); // Schedule regular updates of the graphs for (int t = 1; t <= 1800; t++) { this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(t - 0.001, 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)); BehavioralCharacteristics behavioralCharacteristics = DefaultsFactory.getDefaultBehavioralCharacteristics(); this.block = new LaneBasedIndividualGTU("999999", this.gtuType, new Length(4, METER), new Length(1.8, METER), Speed.ZERO, |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 199 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 216 |
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 JPanel makeCharts() throws OTSSimulationException, PropertyException { // Make the tab with the plots AbstractProperty<?> 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 (AbstractProperty<?> 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\CircularRoad.java | 167 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 173 |
CircularRoad circularRoad = new CircularRoad(); ArrayList<AbstractProperty<?>> propertyList = circularRoad.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)); circularRoad.buildAnimator(new Time(0.0, SECOND), new Duration(0.0, SECOND), new Duration(3600.0, SECOND), propertyList, null, true); } catch (SimRuntimeException | NamingException | OTSSimulationException | PropertyException exception) { exception.printStackTrace(); } } }); } /** {@inheritDoc} */ @Override protected final OTSModelInterface makeModel(final GTUColorer colorer) { this.model = new RoadSimulationModel(getSavedUserModifiedProperties(), colorer); |
File | Line |
---|---|
org\opentrafficsim\demo\lanechange\LaneChangeGraph.java | 498 |
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\carFollowing\SequentialLanes.java | 521 |
org\opentrafficsim\demo\carFollowing\Straight.java | 481 |
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 | 410 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 419 |
initialPositions.add(new DirectedLanePosition(this.getLane(), initialPosition, GTUDirectionality.DIR_PLUS)); BehavioralCharacteristics behavioralCharacteristics = DefaultsFactory.getDefaultBehavioralCharacteristics(); // LaneBasedBehavioralCharacteristics drivingCharacteristics = // new LaneBasedBehavioralCharacteristics(this.carFollowingModelCars, this.laneChangeModel); this.block = new LaneBasedIndividualGTU("999999", this.gtuType, new Length(4, METER), new Length(1.8, METER), new Speed(0.0, KM_PER_HOUR), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner(behavioralCharacteristics, new LaneBasedGTUFollowingTacticalPlanner(this.carFollowingModelCars, this.block), this.block); this.block.init(strategicalPlanner, initialPositions, new Speed(0.0, KM_PER_HOUR)); } 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\SequentialLanes.java | 521 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 503 |
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 | 610 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 429 |
initialPositions.add(new DirectedLanePosition(this.lane, 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"); } BehavioralCharacteristics behavioralCharacteristics = DefaultsFactory.getDefaultBehavioralCharacteristics(); LaneBasedIndividualGTU gtu = new LaneBasedIndividualGTU("" + (++this.carsCreated), this.gtuType, vehicleLength, new Length(1.8, METER), new Speed(200, KM_PER_HOUR), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner(behavioralCharacteristics, new LaneBasedGTUFollowingTacticalPlanner( gtuFollowingModel, gtu), gtu); gtu.init(strategicalPlanner, initialPositions, initialSpeed); this.simulator.scheduleEventRel(this.headway, this, this, "generateCar", null); } catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException exception) { exception.printStackTrace(); } } /** {@inheritDoc} */ @Override public final SimulatorInterface<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> getSimulator() throws RemoteException { return this.simulator; } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 726 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 739 |
200, KM_PER_HOUR), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); // strategical planner LaneBasedStrategicalPlanner strategicalPlanner; if (!generateTruck) { strategicalPlanner = this.strategicalPlannerGeneratorCars.create(gtu); } else { strategicalPlanner = this.strategicalPlannerGeneratorTrucks.create(gtu); } // init Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1); initialPositions.add(new DirectedLanePosition(lane, initialPosition, GTUDirectionality.DIR_PLUS)); Speed initialSpeed = new Speed(0, KM_PER_HOUR); gtu.init(strategicalPlanner, initialPositions, initialSpeed); } /** {@inheritDoc} */ @Override public SimulatorInterface<Abs<TimeUnit>, Rel<TimeUnit>, OTSSimTimeDouble> getSimulator() throws RemoteException { return this.simulator; } /** * @return plots */ public final ArrayList<LaneBasedGTUSampler> getPlots() { return this.plots; } /** * @return minimumDistance */ public final Length getMinimumDistance() { return this.minimumDistance; } /** * Stop simulation and throw an Error. * @param theSimulator OTSDEVSSimulatorInterface; the simulator * @param errorMessage String; the error message */ public void stopSimulator(final OTSDEVSSimulatorInterface theSimulator, final String errorMessage) { System.out.println("Error: " + errorMessage); try { if (theSimulator.isRunning()) { theSimulator.stop(); } } catch (SimRuntimeException exception) { exception.printStackTrace(); } throw new Error(errorMessage); } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 110 |
org\opentrafficsim\demo\carFollowing\Straight.java | 105 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 122 |
public SequentialLanes() throws PropertyException { ArrayList<AbstractProperty<?>> 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() { @Override public void run() { try { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 108 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 112 |
org\opentrafficsim\demo\carFollowing\Straight.java | 107 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 124 |
ArrayList<AbstractProperty<?>> 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 public void run() { try { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 143 |
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 168 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 174 |
ArrayList<AbstractProperty<?>> 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\OpenStreetMap.java | 108 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 147 |
org\opentrafficsim\demo\carFollowing\Straight.java | 142 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 159 |
ArrayList<AbstractProperty<?>> localProperties = osm.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\FundamentalDiagrams.java | 450 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 458 |
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"); } BehavioralCharacteristics behavioralCharacteristics = DefaultsFactory.getDefaultBehavioralCharacteristics(); // 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), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner(behavioralCharacteristics, new LaneBasedGTUFollowingTacticalPlanner(gtuFollowingModel, gtu), gtu); gtu.init(strategicalPlanner, initialPositions, initialSpeed); this.simulator.scheduleEventRel(this.headway, this, this, "generateCar", null); } catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException exception) { exception.printStackTrace(); } } /** * */ protected final void drawGraphs() { // Notify the Fundamental Diagram plots that the underlying data has changed for (FundamentalDiagram fd : this.fundamentalDiagrams) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 490 |
org\opentrafficsim\demo\carFollowing\Straight.java | 449 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 471 |
String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); AbstractProperty<?> 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"); } Iterator<AbstractProperty<List<AbstractProperty<?>>>> iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); 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\FundamentalDiagrams.java | 450 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 458 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 628 |
org\opentrafficsim\demo\carFollowing\Straight.java | 610 |
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"); } BehavioralCharacteristics behavioralCharacteristics = DefaultsFactory.getDefaultBehavioralCharacteristics(); // 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), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner(behavioralCharacteristics, new LaneBasedGTUFollowingTacticalPlanner(gtuFollowingModel, gtu), gtu); gtu.init(strategicalPlanner, initialPositions, initialSpeed); this.simulator.scheduleEventRel(this.headway, this, this, "generateCar", null); } catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException exception) { exception.printStackTrace(); } } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 533 |
org\opentrafficsim\demo\carFollowing\Straight.java | 493 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 395 |
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 | 450 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 458 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 628 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 429 |
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"); } BehavioralCharacteristics behavioralCharacteristics = DefaultsFactory.getDefaultBehavioralCharacteristics(); // 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), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner(behavioralCharacteristics, new LaneBasedGTUFollowingTacticalPlanner(gtuFollowingModel, gtu), gtu); gtu.init(strategicalPlanner, initialPositions, initialSpeed); this.simulator.scheduleEventRel(this.headway, this, this, "generateCar", null); } catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException exception) { exception.printStackTrace(); } } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 236 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 243 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 230 |
org\opentrafficsim\demo\carFollowing\Straight.java | 226 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 243 |
ArrayList<BooleanProperty> graphs = new ArrayList<BooleanProperty>(); if (output instanceof CompoundProperty) { CompoundProperty outputProperties = (CompoundProperty) output; for (AbstractProperty<?> 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 | 466 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 478 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 536 |
org\opentrafficsim\demo\carFollowing\Straight.java | 495 |
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\lanechange\LaneChangeGraph.java | 569 |
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\StraightPerception.java | 515 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 395 |
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 | 85 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 86 |
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\CircularLane.java | 398 |
org\opentrafficsim\demo\carFollowing\Straight.java | 462 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 484 |
throw new SimRuntimeException("\"Car following model\" property has wrong type"); } Iterator<AbstractProperty<List<AbstractProperty<?>>>> iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); // 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 |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 441 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 524 |
org\opentrafficsim\demo\carFollowing\Straight.java | 484 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 506 |
} } 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\CircularRoad.java | 433 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 445 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 366 |
try { // Get car-following model name String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); AbstractProperty<?> 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 Iterator<AbstractProperty<List<AbstractProperty<?>>>> iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); if (ap instanceof CompoundProperty) { |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 433 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 445 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 488 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 366 |
try { // Get car-following model name String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); AbstractProperty<?> 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 Iterator<AbstractProperty<List<AbstractProperty<?>>>> iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); if (ap instanceof CompoundProperty) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 437 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 449 |
org\opentrafficsim\demo\carFollowing\Straight.java | 449 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 471 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 370 |
String carFollowingModelName = null; CompoundProperty propertyContainer = new CompoundProperty("", "", "", this.properties, false, 0); AbstractProperty<?> 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 Iterator<AbstractProperty<List<AbstractProperty<?>>>> iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); if (ap instanceof CompoundProperty) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 466 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 478 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 517 |
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\CircularRoad.java | 347 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 353 |
class RoadSimulationModel implements OTSModelInterface, UNITS { /** */ private static final long serialVersionUID = 20141121L; /** The simulator. */ private OTSDEVSSimulatorInterface simulator; /** The network. */ private OTSNetwork network = new OTSNetwork("network"); /** Number of cars created. */ private int carsCreated = 0; /** The car following model, e.g. IDM Plus for cars. */ private GTUFollowingModelOld carFollowingModelCars; /** The car following model, e.g. IDM Plus for trucks. */ private GTUFollowingModelOld carFollowingModelTrucks; /** The probability that the next generated GTU is a passenger car. */ private double carProbability; /** The lane change model. */ private AbstractLaneChangeModel laneChangeModel; /** Minimum distance. */ private Length minimumDistance = new Length(0, METER); /** The speed limit. */ private Speed speedLimit = new Speed(100, KM_PER_HOUR); /** The plots. */ private ArrayList<LaneBasedGTUSampler> plots = new ArrayList<LaneBasedGTUSampler>(); /** User settable properties. */ private ArrayList<AbstractProperty<?>> properties = null; /** The sequence of Lanes that all vehicles will follow. */ private ArrayList<List<Lane>> paths = new ArrayList<List<Lane>>(); /** The random number generator used to decide what kind of GTU to generate. */ private Random randomGenerator = new Random(12345); /** The GTUColorer for the generated vehicles. */ private final GTUColorer gtuColorer; /** Strategical planner generator for cars. */ private LaneBasedStrategicalPlannerFactory<LaneBasedStrategicalPlanner> strategicalPlannerGeneratorCars = null; /** Strategical planner generator for cars. */ private LaneBasedStrategicalPlannerFactory<LaneBasedStrategicalPlanner> strategicalPlannerGeneratorTrucks = null; |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularRoad.java | 469 |
org\opentrafficsim\demo\carFollowing\CircularRoadIMB.java | 481 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 539 |
org\opentrafficsim\demo\carFollowing\Straight.java | 498 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 401 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 555 |
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 | 379 |
org\opentrafficsim\demo\carFollowing\Straight.java | 536 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 557 |
this.simulator .scheduleEventAbs(new DoubleScalar.Abs<>(0.0, SECOND), this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator .scheduleEventAbs(new DoubleScalar.Abs<>(300, SECOND), this, this, "createBlock", null); // Remove the block at t = 7 minutes this.simulator .scheduleEventAbs(new DoubleScalar.Abs<>(420, SECOND), this, this, "removeBlock", null); // Schedule regular updates of the graph for (int t = 1; t <= 1800; t++) { this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(t - 0.001, SECOND), this, this, "drawGraphs", null); } } catch (SimRuntimeException exception) |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 410 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 398 |
initialPositions.add(new DirectedLanePosition(this.getLane(), initialPosition, GTUDirectionality.DIR_PLUS)); BehavioralCharacteristics behavioralCharacteristics = DefaultsFactory.getDefaultBehavioralCharacteristics(); // LaneBasedBehavioralCharacteristics drivingCharacteristics = // new LaneBasedBehavioralCharacteristics(this.carFollowingModelCars, this.laneChangeModel); this.block = new LaneBasedIndividualGTU("999999", this.gtuType, new Length(4, METER), new Length(1.8, METER), new Speed(0.0, KM_PER_HOUR), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner(behavioralCharacteristics, new LaneBasedGTUFollowingTacticalPlanner(this.carFollowingModelCars, this.block), this.block); this.block.init(strategicalPlanner, initialPositions, new Speed(0.0, KM_PER_HOUR)); } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 280 |
org\opentrafficsim\demo\carFollowing\Straight.java | 420 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 442 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 272 |
} /** {@inheritDoc} */ @Override public final void constructModel( final SimulatorInterface<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> theSimulator) throws SimRuntimeException, RemoteException { this.simulator = (OTSDEVSSimulatorInterface) theSimulator; OTSNode from = new OTSNode("From", new OTSPoint3D(getMinimumDistance().getSI(), 0, 0)); OTSNode to = new OTSNode("To", new OTSPoint3D(getMaximumDistance().getSI(), 0, 0)); OTSNode end = new OTSNode("End", new OTSPoint3D(getMaximumDistance().getSI() + 50.0, 0, 0)); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\Straight.java | 536 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 557 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 367 |
this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(0.0, SECOND), this, this, "generateCar", null); // Create a block at t = 5 minutes this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(300, SECOND), this, this, "createBlock", null); // Remove the block at t = 7 minutes this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(420, SECOND), this, this, "removeBlock", null); // Schedule regular updates of the graphs for (int t = 1; t <= 1800; t++) { this.simulator.scheduleEventAbs(new DoubleScalar.Abs<>(t - 0.001, SECOND), this, this, "drawGraphs", |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagrams.java | 299 |
org\opentrafficsim\demo\carFollowing\Straight.java | 440 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 462 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 291 |
LongitudinalDirectionality.DIR_PLUS); CrossSectionLink endLink = LaneFactory.makeLink("endLink", to, end, null, LongitudinalDirectionality.DIR_PLUS); // 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, LongitudinalDirectionality.DIR_PLUS, this.speedLimit, new OvertakingConditions.None()); Sensor sensor = new SinkSensor(sinkLane, new Length(10.0, METER), this.simulator); sinkLane.addSensor(sensor, GTUType.ALL); |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 419 |
org\opentrafficsim\demo\carFollowing\Trajectories.java | 398 |
initialPositions.add(new DirectedLanePosition(this.lanes.get(this.lanes.size() - 1), initialPosition, GTUDirectionality.DIR_PLUS)); BehavioralCharacteristics behavioralCharacteristics = DefaultsFactory.getDefaultBehavioralCharacteristics(); this.block = new LaneBasedIndividualGTU("999999", this.gtuType, new Length(4, METER), new Length(1.8, METER), new Speed(0.0, KM_PER_HOUR), this.simulator, DefaultCarAnimation.class, this.gtuColorer, this.network); LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner(behavioralCharacteristics, new LaneBasedGTUFollowingTacticalPlanner(this.carFollowingModelCars, this.block), this.block); this.block.init(strategicalPlanner, initialPositions, new Speed(0.0, KM_PER_HOUR)); } |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 398 |
org\opentrafficsim\demo\carFollowing\SequentialLanes.java | 503 |
throw new SimRuntimeException("\"Car following model\" property has wrong type"); } Iterator<AbstractProperty<List<AbstractProperty<?>>>> iterator = new CompoundProperty("", "", "", this.properties, false, 0).iterator(); while (iterator.hasNext()) { AbstractProperty<?> ap = iterator.next(); // 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; |
File | Line |
---|---|
org\opentrafficsim\demo\carFollowing\CircularLane.java | 450 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 395 |
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 | 422 |
org\opentrafficsim\demo\carFollowing\FundamentalDiagramsLane.java | 429 |
org\opentrafficsim\demo\carFollowing\Straight.java | 582 |
this.block.init(strategicalPlanner, initialPositions, new Speed(0.0, KM_PER_HOUR)); } 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\Straight.java | 626 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 663 |
this.simulator.scheduleEventRel(this.headway, this, this, "generateCar", null); } catch (SimRuntimeException | NamingException | NetworkException | GTUException | OTSGeometryException exception) { exception.printStackTrace(); } } /** {@inheritDoc} */ @Override public final SimulatorInterface<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> getSimulator() throws RemoteException { return this.simulator; } /** * @return contourPlots */ public final ArrayList<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\Straight.java | 286 |
org\opentrafficsim\demo\carFollowing\StraightPerception.java | 303 |
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); } return 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-2016 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: 2016-08-04 17:07:01 +0200 (Thu, 04 Aug 2016) $, @version $Revision: 2124 $, by $Author: wjschakel $, * 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\StraightPerception.java | 520 |
org\opentrafficsim\demo\carFollowing\XMLNetworks.java | 555 |
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")) { |