1 package org.opentrafficsim.draw.graphs;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNull;
5 import static org.junit.Assert.assertTrue;
6 import static org.junit.Assert.fail;
7
8 import java.awt.event.ActionEvent;
9 import java.util.ArrayList;
10 import java.util.HashSet;
11 import java.util.LinkedHashSet;
12 import java.util.List;
13 import java.util.Set;
14
15 import javax.naming.NamingException;
16 import javax.swing.JOptionPane;
17
18 import org.djunits.unit.AccelerationUnit;
19 import org.djunits.unit.TimeUnit;
20 import org.djunits.unit.util.UNITS;
21 import org.djunits.value.vdouble.scalar.Acceleration;
22 import org.djunits.value.vdouble.scalar.Direction;
23 import org.djunits.value.vdouble.scalar.Duration;
24 import org.djunits.value.vdouble.scalar.Length;
25 import org.djunits.value.vdouble.scalar.Speed;
26 import org.djunits.value.vdouble.scalar.Time;
27 import org.djutils.immutablecollections.ImmutableArrayList;
28 import org.jfree.data.DomainOrder;
29 import org.junit.Test;
30 import org.mockito.ArgumentMatchers;
31 import org.mockito.Mockito;
32 import org.mockito.invocation.InvocationOnMock;
33 import org.mockito.stubbing.Answer;
34 import org.opentrafficsim.core.dsol.OTSModelInterface;
35 import org.opentrafficsim.core.dsol.OTSReplication;
36 import org.opentrafficsim.core.dsol.OTSSimulator;
37 import org.opentrafficsim.core.dsol.OTSSimulatorInterface;
38 import org.opentrafficsim.core.geometry.OTSGeometryException;
39 import org.opentrafficsim.core.geometry.OTSPoint3D;
40 import org.opentrafficsim.core.gtu.GTUDirectionality;
41 import org.opentrafficsim.core.gtu.GTUException;
42 import org.opentrafficsim.core.gtu.GTUType;
43 import org.opentrafficsim.core.network.NetworkException;
44 import org.opentrafficsim.draw.graphs.GraphPath.Section;
45 import org.opentrafficsim.draw.graphs.road.GraphLaneUtil;
46 import org.opentrafficsim.kpi.interfaces.LaneDataInterface;
47 import org.opentrafficsim.kpi.sampling.KpiLaneDirection;
48 import org.opentrafficsim.kpi.sampling.SamplerData;
49 import org.opentrafficsim.road.gtu.lane.LaneBasedIndividualGTU;
50 import org.opentrafficsim.road.gtu.lane.tactical.LaneBasedCFLCTacticalPlanner;
51 import org.opentrafficsim.road.gtu.lane.tactical.following.FixedAccelerationModel;
52 import org.opentrafficsim.road.gtu.lane.tactical.following.GTUFollowingModelOld;
53 import org.opentrafficsim.road.gtu.lane.tactical.following.SequentialFixedAccelerationModel;
54 import org.opentrafficsim.road.gtu.lane.tactical.lanechangemobil.Egoistic;
55 import org.opentrafficsim.road.gtu.lane.tactical.lanechangemobil.LaneChangeModel;
56 import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlanner;
57 import org.opentrafficsim.road.gtu.strategical.route.LaneBasedStrategicalRoutePlanner;
58 import org.opentrafficsim.road.network.OTSRoadNetwork;
59 import org.opentrafficsim.road.network.factory.LaneFactory;
60 import org.opentrafficsim.road.network.lane.DirectedLanePosition;
61 import org.opentrafficsim.road.network.lane.Lane;
62 import org.opentrafficsim.road.network.lane.LaneDirection;
63 import org.opentrafficsim.road.network.lane.LaneType;
64 import org.opentrafficsim.road.network.lane.OTSRoadNode;
65 import org.opentrafficsim.road.network.sampling.RoadSampler;
66
67 import nl.tudelft.simulation.dsol.SimRuntimeException;
68 import nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEvent;
69 import nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEventInterface;
70 import nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit;
71
72
73
74
75
76
77
78
79
80
81
82 public class ContourPlotTest implements UNITS
83 {
84
85
86 @SuppressWarnings("unchecked")
87 GraphPath<KpiLaneDirection> mockedPath = Mockito.mock(GraphPath.class);
88
89 Section<KpiLaneDirection> section0 = Mockito.mock(Section.class);
90
91 Section<KpiLaneDirection> section1 = Mockito.mock(Section.class);
92
93 KpiLaneDirection direction0 = Mockito.mock(KpiLaneDirection.class);
94
95 KpiLaneDirection direction1 = Mockito.mock(KpiLaneDirection.class);
96
97 LaneDataInterface mockedLane0 = Mockito.mock(LaneDataInterface.class);
98
99 LaneDataInterface mockedLane1 = Mockito.mock(LaneDataInterface.class);
100
101 SamplerData mockedSamplerData = Mockito.mock(SamplerData.class);
102
103 OTSSimulatorInterface mockedSimulator = Mockito.mock(OTSSimulatorInterface.class);
104
105 SimEventInterface<SimTimeDoubleUnit> lastScheduledEvent = null;
106
107
108
109
110
111
112
113
114 private GraphPath<KpiLaneDirection> dummyPath(final OTSSimulatorInterface simulator, final OTSRoadNetwork network)
115 throws Exception
116 {
117 LaneType laneType = network.getLaneType(LaneType.DEFAULTS.TWO_WAY_LANE);
118 OTSRoadNode b = new OTSRoadNode(network, "B", new OTSPoint3D(12345, 0, 0), Direction.ZERO);
119 ArrayList<Lane> result = new ArrayList<Lane>();
120 Lane[] lanes = LaneFactory.makeMultiLane(network, "AtoB",
121 new OTSRoadNode(network, "A", new OTSPoint3D(1234, 0, 0), Direction.ZERO), b, null, 1, laneType,
122 new Speed(100, KM_PER_HOUR), simulator);
123 result.add(lanes[0]);
124
125 lanes = LaneFactory.makeMultiLane(network, "BtoC", b,
126 new OTSRoadNode(network, "C", new OTSPoint3D(99999, 0, 0), Direction.ZERO), null, 1, laneType,
127 new Speed(100, KM_PER_HOUR), null);
128 return GraphLaneUtil.createPath("AtoB", new LaneDirection(lanes[0], GTUDirectionality.DIR_PLUS));
129 }
130
131
132
133
134
135
136 public final void setUp() throws SimRuntimeException, NamingException
137 {
138 Mockito.when(this.mockedPath.getTotalLength()).thenReturn(Length.valueOf("2000m"));
139 Mockito.when(this.mockedPath.getNumberOfSeries()).thenReturn(2);
140 Mockito.when(this.mockedPath.get(0)).thenReturn(this.section0);
141 Mockito.when(this.mockedPath.get(1)).thenReturn(this.section1);
142 Mockito.when(this.mockedPath.getStartDistance(this.section0)).thenReturn(Length.ZERO);
143 Mockito.when(this.mockedPath.getStartDistance(this.section1)).thenReturn(Length.valueOf("1234m"));
144 Mockito.when(this.mockedPath.getSpeedLimit()).thenReturn(Speed.valueOf("100 km/h"));
145 List<Section<KpiLaneDirection>> sectionList = new ArrayList<>();
146 sectionList.add(this.section0);
147 sectionList.add(this.section1);
148 Mockito.when(this.mockedLane0.getLength()).thenReturn(Length.valueOf("1234m"));
149 Mockito.when(this.mockedLane1.getLength()).thenReturn(Length.valueOf("766m"));
150 Mockito.when(this.direction0.getLaneData()).thenReturn(this.mockedLane0);
151 Mockito.when(this.direction1.getLaneData()).thenReturn(this.mockedLane1);
152 Set<KpiLaneDirection> set0 = new HashSet<>();
153 set0.add(this.direction0);
154 Mockito.when(this.section0.iterator()).thenReturn(set0.iterator());
155 Set<KpiLaneDirection> set1 = new HashSet<>();
156 set1.add(this.direction1);
157 Mockito.when(this.section0.iterator()).thenReturn(set0.iterator());
158 Mockito.when(this.section1.iterator()).thenReturn(set1.iterator());
159 Mockito.when(this.mockedPath.getSections()).thenReturn(new ImmutableArrayList<>(sectionList));
160 Mockito.when(this.section0.getLength()).thenReturn(Length.valueOf("2000m"));
161 Mockito.when(this.section1.getLength()).thenReturn(Length.valueOf("766m"));
162 Mockito.when(this.mockedSimulator.scheduleEventAbs(ArgumentMatchers.any(Time.class), ArgumentMatchers.any(),
163 ArgumentMatchers.any(), ArgumentMatchers.anyString(), ArgumentMatchers.isNull()))
164 .thenAnswer(new Answer<SimEventInterface<SimTimeDoubleUnit>>()
165 {
166 @Override
167 public SimEventInterface<SimTimeDoubleUnit> answer(final InvocationOnMock invocation) throws Throwable
168 {
169 ContourPlotTest.this.lastScheduledEvent = new SimEvent.TimeDoubleUnit(invocation.getArgument(0),
170 invocation.getArgument(1), invocation.getArgument(2), "update", null);
171 return ContourPlotTest.this.lastScheduledEvent;
172 }
173 });
174 Mockito.when(this.mockedSimulator.getSimulatorTime()).thenReturn(Time.ZERO);
175 OTSModelInterface model = Mockito.mock(OTSModelInterface.class);
176 OTSReplication replication =
177 OTSReplication.create("test", Time.ZERO, Duration.ZERO, Duration.instantiateSI(3600.0), model);
178 Mockito.when(this.mockedSimulator.getReplication()).thenReturn(replication);
179 }
180
181
182
183
184
185 @Test
186 public final void accelerationContourTest() throws Exception
187 {
188 setUp();
189 ContourDataSource<?> dataPool = new ContourDataSource<>(this.mockedSamplerData, this.mockedPath);
190 ContourPlotAcceleration acp = new ContourPlotAcceleration("acceleration", this.mockedSimulator, dataPool);
191 assertEquals("SeriesKey should be \"acceleration\"", "acceleration", acp.getSeriesKey(0));
192 standardContourTests(this.mockedSimulator, acp, this.mockedPath, Double.NaN, 0);
193 }
194
195
196
197
198
199 @Test
200 public final void densityContourTest() throws Exception
201 {
202 setUp();
203 OTSSimulatorInterface simulator = this.mockedSimulator;
204 OTSRoadNetwork network = new OTSRoadNetwork("density contour test network", true, simulator);
205 GraphPath<KpiLaneDirection> path = dummyPath(simulator, network);
206 RoadSampler sampler = new RoadSampler(network);
207 ContourDataSource<?> dataPool = new ContourDataSource<>(sampler.getSamplerData(), path);
208 ContourPlotDensity dcp = new ContourPlotDensity("density", simulator, dataPool);
209 assertTrue("newly created DensityContourPlot should not be null", null != dcp);
210 assertEquals("SeriesKey should be \"density\"", "density", dcp.getSeriesKey(0));
211 GTUType gtuType = network.getGtuType(GTUType.DEFAULTS.CAR);
212 standardContourTests(simulator, dcp, path, Double.NaN, Double.NaN);
213 }
214
215
216
217
218
219 @Test
220 public final void flowContourTest() throws Exception
221 {
222 setUp();
223 OTSSimulatorInterface simulator = this.mockedSimulator;
224 OTSRoadNetwork network = new OTSRoadNetwork("flow contour test network", true, simulator);
225 GraphPath<KpiLaneDirection> path = dummyPath(simulator, network);
226 RoadSampler sampler = new RoadSampler(network);
227 ContourDataSource<?> dataPool = new ContourDataSource<>(sampler.getSamplerData(), path);
228 ContourPlotFlow fcp = new ContourPlotFlow("flow", simulator, dataPool);
229 assertTrue("newly created DensityContourPlot should not be null", null != fcp);
230 assertEquals("SeriesKey should be \"flow\"", "flow", fcp.getSeriesKey(0));
231 GTUType gtuType = network.getGtuType(GTUType.DEFAULTS.CAR);
232 standardContourTests(simulator, fcp, path, Double.NaN, Double.NaN);
233 }
234
235
236
237
238
239 @Test
240 public final void speedContourTest() throws Exception
241 {
242 setUp();
243 OTSSimulatorInterface simulator = this.mockedSimulator;
244 OTSRoadNetwork network = new OTSRoadNetwork("flow contour test network", true, simulator);
245 GraphPath<KpiLaneDirection> path = dummyPath(simulator, network);
246 RoadSampler sampler = new RoadSampler(network);
247 ContourDataSource<?> dataPool = new ContourDataSource<>(sampler.getSamplerData(), path);
248 ContourPlotSpeed scp = new ContourPlotSpeed("speed", simulator, dataPool);
249 assertTrue("newly created DensityContourPlot should not be null", null != scp);
250 assertEquals("SeriesKey should be \"speed\"", "speed", scp.getSeriesKey(0));
251 GTUType gtuType = network.getGtuType(GTUType.DEFAULTS.CAR);
252 standardContourTests(simulator, scp, path, Double.NaN, 50);
253 }
254
255
256
257
258
259
260
261
262
263 static void printMatrix(final AbstractContourPlot<?> cp, final int fromX, final int toX, final int fromY, final int toY)
264 {
265 System.out.println("Contour plot data:");
266 int maxItem = cp.getItemCount(0);
267 for (int y = fromY; y <= toY; y++)
268 {
269 System.out.print(String.format("y=%3d ", y));
270 for (int x = fromX; x <= toX; x++)
271 {
272
273 int item;
274 for (item = 0; item < maxItem; item++)
275 {
276 if (cp.getXValue(0, item) == x && cp.getYValue(0, item) == y)
277 {
278 break;
279 }
280 }
281 if (item < maxItem)
282 {
283 System.out.print(String.format("%10.6f", cp.getZValue(0, item)));
284 }
285 else
286 {
287 System.out.print(" -------- ");
288 }
289 }
290 System.out.println("");
291 }
292 System.out.print("");
293 }
294
295
296
297
298
299
300
301
302
303
304
305
306 public static void standardContourTests(final OTSSimulatorInterface simulator, final AbstractContourPlot<?> cp,
307 final GraphPath<?> path, final double expectedZValue, final double expectedZValueWithTraffic) throws Exception
308 {
309 assertEquals("seriesCount should be 1", 1, cp.getSeriesCount());
310 assertEquals("domainOrder should be ASCENDING", DomainOrder.ASCENDING, cp.getDomainOrder());
311 assertEquals("indexOf always returns 0", 0, cp.indexOf(0));
312 assertEquals("indexOf always returns 0", 0, cp.indexOf("abc"));
313 assertNull("getGroup always returns null", cp.getGroup());
314 int xBins = cp.getDataPool().timeAxis.getBinCount();
315 int yBins = cp.getDataPool().spaceAxis.getBinCount();
316 int expectedXBins = (int) Math.ceil(((AbstractPlot.DEFAULT_INITIAL_UPPER_TIME_BOUND).getSI())
317 / ContourDataSource.DEFAULT_TIME_GRANULARITIES[ContourDataSource.DEFAULT_TIME_GRANULARITY_INDEX]
318 + (cp.getDataPool().timeAxis.isInterpolate() ? 1 : 0));
319 assertEquals("Initial xBins should be " + expectedXBins, expectedXBins, xBins);
320 int expectedYBins = (int) Math.ceil(path.getTotalLength().getSI()
321 / ContourDataSource.DEFAULT_SPACE_GRANULARITIES[ContourDataSource.DEFAULT_SPACE_GRANULARITY_INDEX]
322 + (cp.getDataPool().timeAxis.isInterpolate() ? 1 : 0));
323 assertEquals("yBins should be " + expectedYBins, expectedYBins, yBins);
324 int bins = cp.getItemCount(0);
325 assertEquals("Total bin count is product of xBins * yBins", xBins * yBins, bins);
326 String initialUpperTimeBoundString = AbstractPlot.DEFAULT_INITIAL_UPPER_TIME_BOUND.toString();
327
328 for (double timeGranularity : ContourDataSource.DEFAULT_TIME_GRANULARITIES)
329 {
330 cp.actionPerformed(new ActionEvent(timeGranularity, 0, "setTimeGranularity"));
331
332 for (double distanceGranularity : ContourDataSource.DEFAULT_SPACE_GRANULARITIES)
333 {
334 cp.actionPerformed(new ActionEvent(distanceGranularity, 0, "setSpaceGranularity"));
335 cp.notifyPlotChange();
336 expectedXBins = (int) Math.ceil((AbstractPlot.DEFAULT_INITIAL_UPPER_TIME_BOUND.getSI()) / timeGranularity)
337 + (cp.getDataPool().timeAxis.isInterpolate() ? 1 : 0);
338 xBins = cp.getDataPool().timeAxis.getBinCount();
339 assertEquals("Modified xBins should be " + expectedXBins, expectedXBins, xBins);
340 expectedYBins = (int) Math.ceil(path.get(0).getLength().getSI() / distanceGranularity)
341 + (cp.getDataPool().spaceAxis.isInterpolate() ? 1 : 0);
342 yBins = cp.getDataPool().spaceAxis.getBinCount();
343
344
345
346 assertEquals("Modified yBins should be " + expectedYBins, expectedYBins, yBins);
347 bins = cp.getItemCount(0);
348 assertEquals("Total bin count is product of xBins * yBins", xBins * yBins, bins);
349 for (int item = 0; item < bins; item++)
350 {
351 double x = cp.getXValue(0, item);
352
353 assertTrue("X should be >= -granularity / 2", x >= -timeGranularity / 2);
354 assertTrue("X should be <= " + initialUpperTimeBoundString,
355 x <= AbstractPlot.DEFAULT_INITIAL_UPPER_TIME_BOUND.getSI());
356 Number alternateX = cp.getX(0, item);
357 assertEquals("getXValue and getX should return things that have the same value", x,
358 alternateX.doubleValue(), 0.000001);
359 double y = cp.getYValue(0, item);
360 Number alternateY = cp.getY(0, item);
361 assertEquals("getYValue and getY should return things that have the same value", y,
362 alternateY.doubleValue(), 0.000001);
363 double z = cp.getZValue(0, item);
364 if (Double.isNaN(expectedZValue))
365 {
366 assertTrue("Z value should be NaN", Double.isNaN(z));
367 }
368 else
369 {
370 assertEquals("Z value should be " + expectedZValue, expectedZValue, z, 0.0001);
371 }
372 Number alternateZ = cp.getZ(0, item);
373 if (Double.isNaN(expectedZValue))
374 {
375 assertTrue("Alternate Z value should be NaN", Double.isNaN(alternateZ.doubleValue()));
376 }
377 else
378 {
379 assertEquals("Alternate Z value should be " + expectedZValue, expectedZValue, alternateZ.doubleValue(),
380 0.0000);
381 }
382 }
383 try
384 {
385 cp.getXValue(0, -1);
386 fail("Should have thrown an Exception");
387 }
388 catch (RuntimeException e)
389 {
390
391 }
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419 }
420 }
421
422 try
423 {
424 cp.actionPerformed(new ActionEvent(cp, 0, "blabla"));
425 fail("Should have thrown an Exception");
426 }
427 catch (RuntimeException e)
428 {
429
430 }
431 try
432 {
433 cp.actionPerformed(new ActionEvent(cp, 0, "setDistanceGranularity -1"));
434 fail("Should have thrown an Exception");
435 }
436 catch (RuntimeException e)
437 {
438
439 }
440 try
441 {
442 cp.actionPerformed(new ActionEvent(cp, 0, "setDistanceGranularity abc"));
443 fail("Should have thrown an Exception");
444 }
445 catch (RuntimeException e)
446 {
447
448 }
449 try
450 {
451 cp.actionPerformed(new ActionEvent(cp, 0, "setDistanceGranularitIE 10"));
452 fail("Should have thrown an Exception");
453 }
454 catch (RuntimeException e)
455 {
456
457 }
458
459 final double useTimeGranularity = 30;
460 cp.actionPerformed(new ActionEvent(useTimeGranularity, 0, "setTimeGranularity"));
461 final double useDistanceGranularity =
462 ContourDataSource.DEFAULT_SPACE_GRANULARITIES[ContourDataSource.DEFAULT_SPACE_GRANULARITIES.length - 1];
463 cp.actionPerformed(new ActionEvent(useDistanceGranularity, 0, "setSpaceGranularity"));
464 cp.notifyPlotChange();
465 bins = cp.getItemCount(0);
466 Time initialTime = new Time(0, TimeUnit.BASE_SECOND);
467 Length initialPosition = new Length(100, METER);
468 Speed initialSpeed = new Speed(50, KM_PER_HOUR);
469
470 SequentialFixedAccelerationModel gtuFollowingModel =
471 new SequentialFixedAccelerationModel(simulator, new Acceleration(2.0, AccelerationUnit.METER_PER_SECOND_2));
472
473 gtuFollowingModel
474 .addStep(new FixedAccelerationModel(new Acceleration(0, METER_PER_SECOND_2), new Duration(60, SECOND)));
475
476 gtuFollowingModel
477 .addStep(new FixedAccelerationModel(new Acceleration(0, METER_PER_SECOND_2), new Duration(600, SECOND)));
478
479 gtuFollowingModel
480 .addStep(new FixedAccelerationModel(new Acceleration(0, METER_PER_SECOND_2), new Duration(300, SECOND)));
481 LaneChangeModel laneChangeModel = new Egoistic();
482
483
484 for (int item = 0; item < bins; item++)
485 {
486 double x = cp.getXValue(0, item);
487
488
489 assertTrue("X should be >= -timeGranularity / 2", x >= -cp.getTimeGranularity() / 2);
490 assertTrue("X should be <= " + initialUpperTimeBoundString, x <= AbstractPlot.DEFAULT_INITIAL_UPPER_TIME_BOUND.si);
491 Number alternateX = cp.getX(0, item);
492 assertEquals("getXValue and getX should return things that have the same value", x, alternateX.doubleValue(),
493 0.000001);
494 double y = cp.getYValue(0, item);
495 Number alternateY = cp.getY(0, item);
496 assertEquals("getYValue and getY should return things that have the same value", y, alternateY.doubleValue(),
497 0.000001);
498 double z = cp.getZValue(0, item);
499 if (Double.isNaN(expectedZValue))
500 {
501 assertTrue("Z value should be NaN (got " + z + ")", Double.isNaN(z));
502 }
503 else
504 {
505 assertEquals("Z value should be " + expectedZValue, expectedZValue, z, 0.0001);
506 }
507 Number alternateZ = cp.getZ(0, item);
508 if (Double.isNaN(expectedZValue))
509 {
510 assertTrue("Alternate Z value should be NaN", Double.isNaN(alternateZ.doubleValue()));
511 }
512 else
513 {
514 assertEquals("Alternate Z value should be " + expectedZValue, expectedZValue, alternateZ.doubleValue(), 0.0000);
515 }
516 }
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756 }
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777 private static LaneBasedIndividualGTU makeReferenceCar(final String id, final GTUType gtuType, final Lane lane,
778 final Length initialPosition, final Speed initialSpeed, final OTSSimulatorInterface simulator,
779 final GTUFollowingModelOld gtuFollowingModel, final LaneChangeModel laneChangeModel, final OTSRoadNetwork network)
780 throws NamingException, NetworkException, SimRuntimeException, GTUException, OTSGeometryException
781 {
782 Length length = new Length(5.0, METER);
783 Length width = new Length(2.0, METER);
784 Set<DirectedLanePosition> initialLongitudinalPositions = new LinkedHashSet<>(1);
785 initialLongitudinalPositions.add(new DirectedLanePosition(lane, initialPosition, GTUDirectionality.DIR_PLUS));
786 Speed maxSpeed = new Speed(120, KM_PER_HOUR);
787 LaneBasedIndividualGTU gtu =
788 new LaneBasedIndividualGTU(id, gtuType, length, width, maxSpeed, length.times(0.5), simulator, network);
789 LaneBasedStrategicalPlanner strategicalPlanner = new LaneBasedStrategicalRoutePlanner(
790 new LaneBasedCFLCTacticalPlanner(gtuFollowingModel, laneChangeModel, gtu), gtu);
791 gtu.init(strategicalPlanner, initialLongitudinalPositions, initialSpeed);
792
793 return gtu;
794 }
795
796
797
798
799
800
801 public static void main(final String[] args) throws Exception
802 {
803 ContourPlotTesttourPlotTest.html#ContourPlotTest">ContourPlotTest cpt = new ContourPlotTest();
804 System.out.println("Click the OK button");
805 JOptionPane.showMessageDialog(null, "ContourPlot", "Start experiment", JOptionPane.INFORMATION_MESSAGE);
806 System.out.println("Running ...");
807 cpt.densityContourTest();
808 System.out.println("Finished");
809 }
810
811 }