CPD Results

The following document contains the results of PMD's CPD 6.4.0.

Duplications

File Line
org\opentrafficsim\ahfe\AHFEAnimation.java 100
org\opentrafficsim\ahfe\AHFESimulation.java 89
        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\ahfe\AHFEAnimation.java 403
org\opentrafficsim\ahfe\AHFESimulation.java 384
        return new Rectangle2D.Double(-50, -100, 8050, 150);
    }

    /**
     * The AHFE simulation model.
     */
    static class AHFEModel extends AbstractOTSModel
    {
        /** */
        private static final long serialVersionUID = 20170228L;

        /** The network. */
        private OTSNetwork network;

        /** 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. */
        private Sampler<GtuData> sampler;

        /**
         * @param simulator OTSSimulatorInterface; the simulator
         * @param replication Integer; replication
         * @param anticipationStrategy String; anticipation strategy
         * @param reactionTime Duration; reaction time
         * @param anticipationTime Duration; anticipation time
         * @param truckFraction double; truck fraction
         * @param distanceError double; distance error
         * @param speedError double; speed error
         * @param accelerationError double; acceleration error
         * @param leftFraction double; left demand
         * @param rightDemand Frequency; right demand
         * @param leftDemand Frequency; left fraction, per road
         */
        @SuppressWarnings("checkstyle:parameternumber")
        AHFEModel(final OTSSimulatorInterface simulator, 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(simulator);
            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;
        }

        /** {@inheritDoc} */
        @SuppressWarnings("synthetic-access")
        @Override
        public void constructModel() throws SimRuntimeException
        {
            this.sampler = new RoadSampler(this.simulator);
            this.sampler.registerExtendedDataType(new TimeToCollision());
            try
            {
                InputStream stream = URLResource.getResourceAsStream("/AHFE/Network.xml");
                XmlNetworkLaneParser nlp = new XmlNetworkLaneParser(this.simulator);
                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, new DefaultSwitchableGTUColorer(), this.simulator, getReplication(),
File Line
org\opentrafficsim\ahfe\AHFEAnimation.java 307
org\opentrafficsim\ahfe\AHFESimulation.java 295
                        int reportTimeClick = 60;
                        while (true)
                        {
                            int currentTime = (int) simulator.getSimulatorTime().si;
                            if (currentTime >= lastReportedTime + reportTimeClick)
                            {
                                lastReportedTime = currentTime / reportTimeClick * reportTimeClick;
                                System.out.println("time is " + simulator.getSimulatorTime());
                            }
                            try
                            {
                                simulator.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(simulator.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 " + simulator.getSimulatorTime());
                                    if (ahfeModel.getSampler() != null)
                                    {
                                        ahfeModel.getSampler().writeToFile(finalScenario + ".csv");
                                    }
                                }
                                long t2 = System.currentTimeMillis();
                                System.out.println("Run took " + (t2 - t1) / 1000 + "s.");
                                System.exit(0);
                                break;
                            }
                        }

                    }
                }
                catch (SimRuntimeException | NamingException | RemoteException | OTSDrawingException exception)
File Line
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo.java 193
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java 190
                this.trafCOD = new TrafCOD(controllerName, URLResource.getResource("/TrafCODDemo1/simpleTest.tfc"),
                        trafficLights, sensors, getSimulator(), this.controllerDisplayPanel);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_CONTROLLER_EVALUATING);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_CONTROLLER_WARNING);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_CONFLICT_GROUP_CHANGED);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_STATE_CHANGED);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_VARIABLE_CREATED);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_TRACED_VARIABLE_UPDATED);
                // Subscribe the TrafCOD machine to trace command events that we emit
                addListener(this.trafCOD, TrafficController.TRAFFICCONTROL_SET_TRACING);
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new Object[] {controllerName, "TGX", 8, true});
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new Object[] {controllerName, "XR1", 11, true});
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new Object[] {controllerName, "TD1", 11, true});
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new Object[] {controllerName, "TGX", 11, true});
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new Object[] {controllerName, "TL", 11, true});
                // System.out.println("demo: emitting a SET TRACING event for all variables related to stream 11");
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new Object[] { controllerName, "", 11, true });

                // this.trafCOD.traceVariablesOfStream(TrafficController.NO_STREAM, true);
                // this.trafCOD.traceVariablesOfStream(11, true);
                // this.trafCOD.traceVariable("MRV", 11, true);
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }

        /** {@inheritDoc} */
        @Override
        public final OTSNetwork getNetwork()
        {
            return this.network;
        }

        /**
         * @return trafCOD
         */
        public final TrafCOD getTrafCOD()
        {
            return this.trafCOD;
        }

        /**
         * @return controllerDisplayPanel
         */
        public final JPanel getControllerDisplayPanel()
        {
            return this.controllerDisplayPanel;
        }

        /** {@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 248
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo.java 194
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java 191
                        trafficLights, sensors, this.simulator, this.controllerDisplayPanel);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_CONTROLLER_EVALUATING);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_CONTROLLER_WARNING);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_CONFLICT_GROUP_CHANGED);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_STATE_CHANGED);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_VARIABLE_CREATED);
                this.trafCOD.addListener(this, TrafficController.TRAFFICCONTROL_TRACED_VARIABLE_UPDATED);
                // Subscribe the TrafCOD machine to trace command events that we
                // emit
                addListener(this.trafCOD, TrafficController.TRAFFICCONTROL_SET_TRACING);
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new
                // Object[] {controllerName, "TGX", 8, true});
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new
                // Object[] {controllerName, "XR1", 11, true});
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new
                // Object[] {controllerName, "TD1", 11, true});
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new
                // Object[] {controllerName, "TGX", 11, true});
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new
                // Object[] {controllerName, "TL", 11, true});
                // System.out.println("demo: emitting a SET TRACING event for
                // all variables related to stream 11");
                // fireEvent(TrafficController.TRAFFICCONTROL_SET_TRACING, new
                // Object[] { controllerName, "", 11, true });

                // TrafCODDemo2.this.trafCOD.traceVariablesOfStream(TrafficController.NO_STREAM,
                // true);
                // TrafCODDemo2.this.trafCOD.traceVariablesOfStream(11, true);
                // TrafCODDemo2.this.trafCOD.traceVariable("MRV", 11, true);
            }
            catch (Exception exception)
            {
                exception.printStackTrace();
            }
        }

        /** {@inheritDoc} */
        @Override
        public final OTSNetwork getNetwork()
        {
            return this.network;
        }

        /**
         * @return trafCOD
         */
        public final TrafCOD getTrafCOD()
        {
            return this.trafCOD;
        }

        /**
         * @return controllerDisplayPanel
         */
        public final JPanel getControllerDisplayPanel()
        {
            return this.controllerDisplayPanel;
        }

        /** {@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\ahfe\AHFEAnimation.java 514
org\opentrafficsim\ahfe\AHFESimulation.java 497
                AHFEUtil.createDemand(this.network, new DefaultSwitchableGTUColorer(), this.simulator, 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 LinkData; link data
         * @param startDistance Length; start distance on link
         * @param endDistance Length; 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);
                this.sampler.registerSpaceTimeRegion(new SpaceTimeRegion(
                        new KpiLaneDirection(laneData, KpiGtuDirectionality.DIR_PLUS), start, end, WARMUP, SIMEND));
            }
        }

        /** {@inheritDoc} */
        @Override
        public OTSNetwork getNetwork()
        {
            return this.network;
        }

        /**
         * @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;
        }

        /**
         * @return sampler
         */
        public final Sampler<GtuData> getSampler()
        {
            return this.sampler;
        }

    }

}
File Line
org\opentrafficsim\demo\FundamentalDiagrams.java 296
org\opentrafficsim\demo\StraightModel.java 179
                    | InputParameterException exception)
            {
                exception.printStackTrace();
            }
        }

        /**
         * Set up the block.
         */
        protected final void createBlock()
        {
            this.block.setTrafficLightColor(TrafficLightColor.RED);
        }

        /**
         * Remove the block.
         */
        protected final void removeBlock()
        {
            this.block.setTrafficLightColor(TrafficLightColor.GREEN);
        }

        /**
         * Generate cars at a fixed rate (implemented by re-scheduling this method).
         */
        protected final void generateCar()
        {
            try
            {
                boolean generateTruck = this.stream.nextDouble() > this.carProbability;
                Length vehicleLength = new Length(generateTruck ? 15 : 4, METER);
                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);
                gtu.setParameters(generateTruck ? this.parametersTruck : this.parametersCar);
                gtu.setNoLaneChangeDistance(Length.ZERO);
                gtu.setMaximumAcceleration(Acceleration.createSI(3.0));
                gtu.setMaximumDeceleration(Acceleration.createSI(-8.0));

                // strategical planner
                LaneBasedStrategicalPlanner strategicalPlanner =
                        generateTruck ? this.strategicalPlannerGeneratorTrucks.create(gtu, null, null, null)
                                : this.strategicalPlannerGeneratorCars.create(gtu, null, null, null);

                Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1);
                Length initialPosition = new Length(20, METER);
                initialPositions.add(new DirectedLanePosition(this.lane, initialPosition, GTUDirectionality.DIR_PLUS));
                Speed initialSpeed = new Speed(100.0, KM_PER_HOUR);
                gtu.init(strategicalPlanner, initialPositions, initialSpeed);
                this.simulator.scheduleEventRel(this.headway, this, this, "generateCar", null);
            }
            catch (SimRuntimeException | NetworkException | GTUException | OTSGeometryException exception)
            {
                exception.printStackTrace();
            }
        }
File Line
org\opentrafficsim\demo\CircularLaneSwing.java 97
org\opentrafficsim\demo\StraightSwing.java 97
                CircularLaneSwing app = new CircularLaneSwing("Circular Lane", animationPanel, otsModel);
                app.setExitOnClose(exitOnClose);
            }
            else
            {
                if (exitOnClose)
                {
                    System.exit(0);
                }
            }
        }
        catch (SimRuntimeException | NamingException | RemoteException | OTSDrawingException exception)
        {
            exception.printStackTrace();
        }
    }

    /**
     * Add the statistics tabs.
     * @param simulator OTSSimulatorInterface; the simulator on which sampling can be scheduled
     */
    protected final void addStatisticsTabs(final OTSSimulatorInterface simulator)
    {
        GraphPath<KpiLaneDirection> path;
        try
        {
            path = GraphLaneUtil.createPath("Lane", new LaneDirection(getModel().getPath().get(0), GTUDirectionality.DIR_PLUS));
        }
        catch (NetworkException exception)
        {
            throw new RuntimeException("Could not create a path as a lane has no set speed limit.", exception);
        }

        RoadSampler sampler = new RoadSampler(simulator);
        ContourDataSource<?> dataPool = new ContourDataSource<>(sampler, path);
        TablePanel charts = new TablePanel(3, 2);
        AbstractPlot plot = null;

        plot = new TrajectoryPlot("TrajectoryPlot", Duration.createSI(10.0), simulator, sampler, path);
        charts.setCell(plot.getContentPane(), 0, 0);

        plot = new ContourPlotDensity("DensityPlot", simulator, dataPool);
        charts.setCell(plot.getContentPane(), 1, 0);

        plot = new ContourPlotSpeed("SpeedPlot", simulator, dataPool);
        charts.setCell(plot.getContentPane(), 2, 0);

        plot = new ContourPlotFlow("FlowPlot", simulator, dataPool);
        charts.setCell(plot.getContentPane(), 1, 1);

        plot = new ContourPlotAcceleration("AccelerationPlot", simulator, dataPool);
        charts.setCell(plot.getContentPane(), 2, 1);

        getAnimationPanel().getTabbedPane().addTab(getAnimationPanel().getTabbedPane().getTabCount(), "statistics ", charts);
    }

}
File Line
org\opentrafficsim\demo\CircularLaneSwing.java 97
org\opentrafficsim\demo\SequentialLanes.java 135
org\opentrafficsim\demo\StraightSwing.java 97
                CircularLaneSwing app = new CircularLaneSwing("Circular Lane", animationPanel, otsModel);
                app.setExitOnClose(exitOnClose);
            }
            else
            {
                if (exitOnClose)
                {
                    System.exit(0);
                }
            }
        }
        catch (SimRuntimeException | NamingException | RemoteException | OTSDrawingException exception)
        {
            exception.printStackTrace();
        }
    }

    /**
     * Add the statistics tabs.
     * @param simulator OTSSimulatorInterface; the simulator on which sampling can be scheduled
     */
    protected final void addStatisticsTabs(final OTSSimulatorInterface simulator)
    {
        GraphPath<KpiLaneDirection> path;
        try
        {
            path = GraphLaneUtil.createPath("Lane", new LaneDirection(getModel().getPath().get(0), GTUDirectionality.DIR_PLUS));
        }
        catch (NetworkException exception)
        {
            throw new RuntimeException("Could not create a path as a lane has no set speed limit.", exception);
        }

        RoadSampler sampler = new RoadSampler(simulator);
        ContourDataSource<?> dataPool = new ContourDataSource<>(sampler, path);
        TablePanel charts = new TablePanel(3, 2);
        AbstractPlot plot = null;

        plot = new TrajectoryPlot("TrajectoryPlot", Duration.createSI(10.0), simulator, sampler, path);
        charts.setCell(plot.getContentPane(), 0, 0);

        plot = new ContourPlotDensity("DensityPlot", simulator, dataPool);
        charts.setCell(plot.getContentPane(), 1, 0);

        plot = new ContourPlotSpeed("SpeedPlot", simulator, dataPool);
        charts.setCell(plot.getContentPane(), 2, 0);

        plot = new ContourPlotFlow("FlowPlot", simulator, dataPool);
        charts.setCell(plot.getContentPane(), 1, 1);

        plot = new ContourPlotAcceleration("AccelerationPlot", simulator, dataPool);
        charts.setCell(plot.getContentPane(), 2, 1);

        getAnimationPanel().getTabbedPane().addTab(getAnimationPanel().getTabbedPane().getTabCount(), "statistics ", charts);
    }
File Line
org\opentrafficsim\demo\FundamentalDiagrams.java 269
org\opentrafficsim\demo\StraightModel.java 153
                new SinkSensor(sinkLane, new Length(10.0, METER), this.simulator);

                this.carProbability = (double) getInputParameter("generic.carProbability");
                this.parametersCar = InputParameterHelper.getParametersCar(getInputParameterMap());
                this.parametersTruck = InputParameterHelper.getParametersTruck(getInputParameterMap());

                this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(
                        new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory()));
                this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(
                        new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory()));

                // 1500 [veh / hour] == 2.4s headway
                this.headway = new Duration(3600.0 / 1500.0, SECOND);

                // Schedule creation of the first car (this will re-schedule itself one headway later, etc.).
                this.simulator.scheduleEventAbs(Time.ZERO, this, this, "generateCar", null);

                this.block = new SimpleTrafficLight(this.lane.getId() + "_TL", this.lane,
                        new Length(new Length(4000.0, LengthUnit.METER)), this.simulator);
                this.block.setTrafficLightColor(TrafficLightColor.GREEN);

                // 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);
            }
            catch (SimRuntimeException | NetworkException | GTUException | OTSGeometryException | ParameterException
File Line
org\opentrafficsim\demo\FundamentalDiagrams.java 316
org\opentrafficsim\demo\SequentialLanes.java 369
org\opentrafficsim\demo\StraightModel.java 199
        }

        /**
         * Generate cars at a fixed rate (implemented by re-scheduling this method).
         */
        protected final void generateCar()
        {
            try
            {
                boolean generateTruck = this.stream.nextDouble() > this.carProbability;
                Length vehicleLength = new Length(generateTruck ? 15 : 4, METER);
                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);
                gtu.setParameters(generateTruck ? this.parametersTruck : this.parametersCar);
                gtu.setNoLaneChangeDistance(Length.ZERO);
                gtu.setMaximumAcceleration(Acceleration.createSI(3.0));
                gtu.setMaximumDeceleration(Acceleration.createSI(-8.0));

                // strategical planner
                LaneBasedStrategicalPlanner strategicalPlanner =
                        generateTruck ? this.strategicalPlannerGeneratorTrucks.create(gtu, null, null, null)
                                : this.strategicalPlannerGeneratorCars.create(gtu, null, null, null);

                Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1);
                Length initialPosition = new Length(20, METER);
                initialPositions.add(new DirectedLanePosition(this.lane, initialPosition, GTUDirectionality.DIR_PLUS));
File Line
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java 192
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java 218
                                TrafficLight tl = new SimpleTrafficLight(String.format("TL%02d", stream), lane,
                                        lane.getLength().minus(stopLineMargin), this.simulator);
                                trafficLights.add(tl);

                                try
                                {
                                    new TrafficLightAnimation(tl, this.simulator);
                                }
                                catch (RemoteException | NamingException exception)
                                {
                                    throw new NetworkException(exception);
                                }

                                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, this.simulator, 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, this.simulator, Compatible.EVERYTHING));
                            }
File Line
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo.java 94
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java 94
            TrafCODDemo app = new TrafCODDemo("TrafCOD demo simple crossing", animationPanel, trafcodModel);
            app.setExitOnClose(exitOnClose);
        }
        catch (SimRuntimeException | NamingException | RemoteException | OTSDrawingException exception)
        {
            exception.printStackTrace();
        }
    }

    /**
     * Add tab with trafCOD status.
     */
    protected void addTabs()
    {
        JScrollPane scrollPane = new JScrollPane(getModel().getControllerDisplayPanel());
        JPanel wrapper = new JPanel(new BorderLayout());
        wrapper.add(scrollPane);
        getAnimationPanel().getTabbedPane().addTab(getAnimationPanel().getTabbedPane().getTabCount() - 1,
                getModel().getTrafCOD().getId(), wrapper);
    }

    /**
     * The simulation model.
     */
    static class TrafCODModel extends AbstractOTSModel implements EventListenerInterface
    {
        /** */
        private static final long serialVersionUID = 20161020L;

        /** the model. */
        private OTSNetwork network;

        /** The TrafCOD controller. */
        private TrafCOD trafCOD;

        /** TrafCOD controller display. */
        private JPanel controllerDisplayPanel = new JPanel(new BorderLayout());

        /**
         * @param simulator OTSSimulatorInterface; the simulator for this model
         */
        TrafCODModel(final OTSSimulatorInterface simulator)
        {
            super(simulator);
        }

        /** {@inheritDoc} */
        @Override
        public void constructModel() throws SimRuntimeException
        {
            try
            {
                URL url = URLResource.getResource("/TrafCODDemo1/TrafCODDemo1.xml");
File Line
org\opentrafficsim\demo\CircularLaneModel.java 227
org\opentrafficsim\demo\CircularRoadModel.java 245
                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);
        gtu.setParameters(generateTruck ? this.parametersTruck : this.parametersCar);
        gtu.setNoLaneChangeDistance(Length.ZERO);
        gtu.setMaximumAcceleration(Acceleration.createSI(3.0));
        gtu.setMaximumDeceleration(Acceleration.createSI(-8.0));

        // strategical planner
        LaneBasedStrategicalPlanner strategicalPlanner;
        Route route = null;
        if (!generateTruck)
        {
            strategicalPlanner = this.strategicalPlannerGeneratorCars.create(gtu, route, null, null);
        }
        else
        {
            strategicalPlanner = this.strategicalPlannerGeneratorTrucks.create(gtu, route, null, null);
        }

        // init
        Set<DirectedLanePosition> initialPositions = new LinkedHashSet<>(1);
        initialPositions.add(new DirectedLanePosition(lane, initialPosition, GTUDirectionality.DIR_PLUS));
        Speed initialSpeed = new Speed(0, KM_PER_HOUR);
File Line
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java 102
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo.java 94
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java 94
            DemoTrafcodAndTurbo app = new DemoTrafcodAndTurbo("TrafCOD Turbo demo", animationPanel, junctionModel);
            app.setExitOnClose(exitOnClose);
        }
        catch (SimRuntimeException | NamingException | RemoteException | OTSDrawingException exception)
        {
            exception.printStackTrace();
        }
    }

    /**
     * Add tab with trafCOD status.
     */
    protected void addTabs()
    {
        JScrollPane scrollPane = new JScrollPane(getModel().getControllerDisplayPanel());
        JPanel wrapper = new JPanel(new BorderLayout());
        wrapper.add(scrollPane);
        getAnimationPanel().getTabbedPane().addTab(getAnimationPanel().getTabbedPane().getTabCount() - 1,
                getModel().getTrafCOD().getId(), wrapper);
    }

    /**
     * The simulation model.
     */
    static class TrafCODModel extends AbstractOTSModel implements EventListenerInterface
    {
        /** */
        private static final long serialVersionUID = 20161020L;

        /** The network. */
        private OTSNetwork network;

        /** The TrafCOD controller. */
        private TrafCOD trafCOD;

        /** TrafCOD controller display. */
        private JPanel controllerDisplayPanel = new JPanel(new BorderLayout());

        /**
         * @param simulator OTSSimulatorInterface; the simulator for this model
         */
        TrafCODModel(final OTSSimulatorInterface simulator)
        {
            super(simulator);
        }

        /** {@inheritDoc} */
        @Override
        public void constructModel() throws SimRuntimeException
        {
            try
            {
                URL url = URLResource.getResource("/conflictAndControl/TurboRoundaboutAndSignal.xml");
File Line
org\opentrafficsim\demo\conflictAndControl\DemoTrafcodAndTurbo.java 163
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java 148
                        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) this.simulator,
                // 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\FundamentalDiagrams.java 246
org\opentrafficsim\demo\StraightModel.java 129
        FundamentalDiagramPlotsModel(final OTSSimulatorInterface simulator)
        {
            super(simulator);
            InputParameterHelper.makeInputParameterMapCarTruck(this.inputParameterMap, 1.0);
        }

        /** {@inheritDoc} */
        @Override
        public final void constructModel() throws SimRuntimeException
        {
            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\conflict\TJunctionDemo.java 166
org\opentrafficsim\demo\conflict\TurboRoundaboutDemo.java 186
                    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 OTSNetwork getNetwork()
        {
            return this.network;
        }

    }
}
File Line
org\opentrafficsim\demo\CircularLaneModel.java 222
org\opentrafficsim\demo\FundamentalDiagrams.java 324
org\opentrafficsim\demo\SequentialLanes.java 377
org\opentrafficsim\demo\StraightModel.java 207
    {
        // GTU itself
        boolean generateTruck = this.stream.nextDouble() > this.carProbability;
        Length vehicleLength = new Length(generateTruck ? 15 : 4, METER);
        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);
        gtu.setParameters(generateTruck ? this.parametersTruck : this.parametersCar);
        gtu.setNoLaneChangeDistance(Length.ZERO);
        gtu.setMaximumAcceleration(Acceleration.createSI(3.0));
        gtu.setMaximumDeceleration(Acceleration.createSI(-8.0));

        // strategical planner
        LaneBasedStrategicalPlanner strategicalPlanner;
File Line
org\opentrafficsim\demo\CircularLaneModel.java 146
org\opentrafficsim\demo\CircularRoadModel.java 162
            this.carProbability = (double) getInputParameter("generic.carProbability");
            double radius = ((Length) getInputParameter("generic.trackLength")).si / 2 / Math.PI;
            double headway = 1000.0 / (double) getInputParameter("generic.densityMean");
            double headwayVariability = (double) getInputParameter("generic.densityVariability");

            this.parametersCar = InputParameterHelper.getParametersCar(getInputParameterMap());
            this.parametersTruck = InputParameterHelper.getParametersTruck(getInputParameterMap());

            this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(
                    new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory()));
            this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(
                    new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory()));
File Line
org\opentrafficsim\demo\CircularLaneModel.java 159
org\opentrafficsim\demo\CircularRoadModel.java 176
            LaneType laneType = LaneType.TWO_WAY_LANE;
            OTSNode start = new OTSNode(this.network, "Start", new OTSPoint3D(radius, 0, 0));
            OTSNode halfway = new OTSNode(this.network, "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);
            }
File Line
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo.java 67
org\opentrafficsim\demo\trafficcontrol\TrafCODDemo2.java 67
    public TrafCODDemo(final String title, final OTSAnimationPanel panel, final TrafCODModel model) throws OTSDrawingException
    {
        super(model, panel);
    }

    /**
     * Main program.
     * @param args String[]; the command line arguments (not used)
     */
    public static void main(final String[] args)
    {
        demo(true);
    }

    /**
     * Start the demo.
     * @param exitOnClose boolean; when running stand-alone: true; when running as part of a demo: false
     */
    public static void demo(final boolean exitOnClose)
    {
        try
        {
            OTSAnimator simulator = new OTSAnimator();
            final TrafCODModel trafcodModel = new TrafCODModel(simulator);
            simulator.initialize(Time.ZERO, Duration.ZERO, Duration.createSI(3600.0), trafcodModel);
            OTSAnimationPanel animationPanel = new OTSAnimationPanel(trafcodModel.getNetwork().getExtent(),
                    new Dimension(800, 600), simulator, trafcodModel, DEFAULT_COLORER, trafcodModel.getNetwork());
File Line
strategies\LmrsStrategies.java 598
strategies\StrategiesDemo.java 667
                            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\FundamentalDiagrams.java 271
org\opentrafficsim\demo\SequentialLanes.java 326
org\opentrafficsim\demo\StraightModel.java 155
                this.carProbability = (double) getInputParameter("generic.carProbability");
                this.parametersCar = InputParameterHelper.getParametersCar(getInputParameterMap());
                this.parametersTruck = InputParameterHelper.getParametersTruck(getInputParameterMap());

                this.strategicalPlannerGeneratorCars = new LaneBasedStrategicalRoutePlannerFactory(
                        new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory()));
                this.strategicalPlannerGeneratorTrucks = new LaneBasedStrategicalRoutePlannerFactory(
                        new LMRSFactory(new IDMPlusFactory(this.stream), new DefaultLMRSPerceptionFactory()));

                // 1500 [veh / hour] == 2.4s headway
                this.headway = new Duration(3600.0 / 1500.0, SECOND);

                // Schedule creation of the first car (this will re-schedule itself one headway later, etc.).
                this.simulator.scheduleEventAbs(Time.ZERO, this, this, "generateCar", null);
File Line
org\opentrafficsim\demo\FundamentalDiagrams.java 263
org\opentrafficsim\demo\StraightModel.java 146
                        LaneFactory.makeLane(this.network, "Lane", from, to, null, laneType, this.speedLimit, this.simulator);
                CrossSectionLink endLink = LaneFactory.makeLink(this.network, "endLink", to, end, null, this.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);

                this.carProbability = (double) getInputParameter("generic.carProbability");