Example #1
0
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		public VehicleSet(Vehicle[] vehicles)
		{
			Vehicles = vehicles;

			foreach (var vehicle in Vehicles)
				Bind(nameof(vehicle.IsTunnelClosed), nameof(ForwardIsTunnelClosed));

			LeftOHV.AddEffects<Vehicle.DriveLeftEffect>(vehicles.Where(vehicle => vehicle.Kind == VehicleKind.OverheightVehicle));
			LeftHV.AddEffects<Vehicle.DriveLeftEffect>(vehicles.Where(vehicle => vehicle.Kind == VehicleKind.HighVehicle));
			SlowTraffic.AddEffects<Vehicle.SlowTrafficEffect>(vehicles);

			for (var i = 0; i < Vehicles.Length; ++i)
			{
				for (var j = i + 1; j < Vehicles.Length; ++j)
				{
					AddSensorConstraint(Vehicles[i], Vehicles[j], Model.PreControlPosition);
					AddSensorConstraint(Vehicles[i], Vehicles[j], Model.MainControlPosition);
					AddSensorConstraint(Vehicles[i], Vehicles[j], Model.EndControlPosition);
				}
			}
		}
Example #2
0
		/// <summary>
		///   Adds a state constraint ensuring that no two vehicles pass the same sensor on the same lane at the same time.
		/// </summary>
		private void AddSensorConstraint(Vehicle vehicle1, Vehicle vehicle2, int position)
		{
			AddStateConstraint(() => !vehicle1.IsAtPosition(position) || !vehicle2.IsAtPosition(position) || vehicle1.Lane != vehicle2.Lane);
		}