public void CheckIntegrity()
        {
            CellBasedSim sim = new CellBasedSim(TestUtils.RandomSeed);

            sim.GenerateNew(24, 10, 10, 500, 3000, 0.1f, TestUtils.RandomSeed);

            sim.DoStepReference();

            bool result = sim.CheckIntegrity();

            Assert.IsTrue(result);
        }
        public void CarMovementReference()
        {
            CellBasedSim sim = new CellBasedSim(TestUtils.RandomSeed);

            sim.Flags = SimulationFlags.NoSpawn;
            sim.GenerateNew(10, 2, 1, 1, 1, float.PositiveInfinity, TestUtils.RandomSeed);

            Car carPrev = sim.Current.Cars[0];

            Assert.AreEqual(0, sim.Current.CellsToCar[carPrev.Position].CarIndex);

            sim.DoStepReference();
            sim.DoStepReference();

            Car carNext = sim.Current.Cars[0];

            Assert.AreEqual(sim.Current.Cells[carPrev.Position].T1, carNext.Position);
            Assert.AreEqual(1f, carNext.Speed);

            Assert.AreEqual(0, sim.Current.CellsToCar[carNext.Position].CarIndex);
        }
Beispiel #3
0
        public static CellBasedSim CreateCellBasedSim(IBenchmarkTrace trace, int distance,
                                                      int junctionsX, int junctionsY, int carCount, int maxCarCount, float generatorProbability)
        {
            PrintBenchmarkInfoIfNeeded <CellBasedSim>(trace, distance,
                                                      junctionsX, junctionsY, carCount, maxCarCount, generatorProbability);

            CellBasedSim sim = new CellBasedSim(RandomSeed);

            sim.GenerateNew(distance, junctionsX, junctionsY, carCount, maxCarCount, generatorProbability, RandomSeed);

            for (int i = 0; i < WarmupStepCount; i++)
            {
                sim.DoStepReference();
            }

            return(sim);
        }
        public void CarSpawnReference()
        {
            CellBasedSim sim = new CellBasedSim(TestUtils.RandomSeed);

            sim.GenerateNew(10, 1, 1, 0, 1, 0, TestUtils.RandomSeed);

            Car carPrev = sim.Current.Cars[0];

            Assert.AreEqual(Cell.None, carPrev.Position);

            sim.DoStepReference();

            Car carNext = sim.Current.Cars[0];

            Assert.AreNotEqual(Cell.None, carNext.Position);
            Assert.AreEqual(0f, carNext.Speed);

            Assert.AreEqual(0, sim.Current.CellsToCar[carNext.Position].CarIndex);
        }
        public void CarTerminationReference()
        {
            CellBasedSim sim = new CellBasedSim(TestUtils.RandomSeed);

            sim.Flags = SimulationFlags.NoSpawn;
            sim.GenerateNew(10, 1, 1, 1, 1, float.PositiveInfinity, TestUtils.RandomSeed);

            Car carPrev = sim.Current.Cars[0];

            Assert.AreNotEqual(Cell.None, carPrev.Position);

            for (int i = 0; i < 20; i++)
            {
                sim.DoStepReference();
            }

            Car carNext = sim.Current.Cars[0];

            Assert.AreEqual(Cell.None, carNext.Position);
        }
        public void OneStepReference()
        {
            CellBasedSim sim = new CellBasedSim(TestUtils.RandomSeed);

            sim.GenerateNew(24, 10, 10, 500, 3000, 0.1f, TestUtils.RandomSeed);

            sim.DoStepReference();

            Assert.AreEqual(SimulationType.CellBased, sim.CurrentType);
            Assert.IsTrue(sim.IsReady);
            Assert.AreEqual(1, sim.CurrentStep);

            Assert.AreEqual(3000, sim.Current.Cars.Length);
            Assert.AreEqual(3000, sim.Current.CarsUi.Length);
            Assert.AreEqual(15460, sim.Current.Cells.Length);
            Assert.AreEqual(15460, sim.Current.CellsToCar.Length);
            Assert.AreEqual(15460, sim.Current.CellsUi.Length);
            Assert.AreEqual(140, sim.Current.Generators.Length);
            Assert.AreEqual(100, sim.Current.Junctions.Length);

            Assert.IsFalse(string.IsNullOrWhiteSpace(sim.ToString()));
        }