16 private int previousSpeed;
20 internal int PreviousSpeed {
get {
return previousSpeed; } }
25 private int currentSpeed;
29 internal int CurrentSpeed {
get {
return currentSpeed; } }
38 internal int NewSpeed {
get {
return newSpeed; } }
47 public int Length {
get {
return length; } }
52 private Cell firstCell;
57 internal bool IsStillInTopology {
get {
return outside < length; } }
62 private int outside = 0;
66 public int Outside {
get {
return outside; } }
77 private bool isRecordedBySensor =
false;
83 internal bool IsRecordedBySensor
87 bool toReturn = isRecordedBySensor;
88 if (!isRecordedBySensor)
89 isRecordedBySensor =
true;
103 this.firstCell = firstCell;
104 this.previousSpeed = this.currentSpeed = speed;
105 parameters = transitionFunctionParameters;
115 internal Cell PerformTransition(Random random)
117 ComputeNewSpeed(random);
118 return SetToNextCells();
126 private void ComputeNewSpeed(Random random)
130 newSpeed = currentSpeed;
140 Gap gap = ComputeGap();
141 if (gap.Length ==
int.MaxValue ||
142 (gap.Length + gap.FollowingCarAcceleration) > newSpeed)
163 if (gap.FollowingCarAcceleration > 0)
164 newSpeed = (int)Math.Round((gap.Length + gap.FollowingCarAcceleration) /
167 newSpeed = (int)Math.Round((gap.Length + gap.FollowingCarAcceleration) /
171 Debug.Assert(newSpeed <= gap.Length,
"Speed larger than gap");
179 private Gap ComputeGap()
183 foreach (
Cell cell
in cellWalker.GetNext())
185 if (cell.Car != null)
187 return new Gap(cellWalker.CellsWalked,
188 cell.Car.CurrentSpeed - cell.Car.PreviousSpeed);
191 return new Gap(
int.MaxValue);
199 private Cell SetToNextCells()
203 foreach (
Cell cell
in walker.GetNext())
210 firstCell = walker.LastCell ?? firstCell;
223 internal void PrepareForNextSimulationStep()
226 previousSpeed = currentSpeed;
227 currentSpeed = newSpeed;
232 foreach (
Cell cell
in walker.GetNext())
238 RemoveCarFromCells(walker.LastCell);
245 private void RemoveCarFromCells(
Cell fromCell)
248 foreach (
Cell cell
in walker.GetNext())
257 internal void RemoveCarFromCells()
259 RemoveCarFromCells(firstCell);
Struct containing information about gap.
double P7_AccelerationProbability
Acceleration probability.
double P5_LowSpeedDecProbability
Low speed deceleration probability.
Class representing backward walker through cells taken by car.
double P9_DecRateWhenLeadingAcc
Deceleration rate when leading vehicle accelerates.
Class containing parameters of transition function.
Cell FollowingCell
Link to following cell.
Cell walker in backward direction.
double P8_HighSpeedDecProbability
High speed deceleration probability.
Class wrapping a cell walker and applying limit to number of walked cells.
int P6_DecProbabilitySpeedBound
Threshold speed for the p5 and p8.
double P10_DecRateWhenLeadingDec
Deceleration rate when leading vehicle decelerates.
Class wrapping a cell walker and applying limit to number of walked cells but if wrapped cell walker ...
Cell walker in forward direction.
Cell PreviousCell
Link to previous cell.