public class Track
extends java.util.Observable
Modifier and Type | Field and Description |
---|---|
protected float |
brakeProb
currently configured brake probability for
all vehicles
|
protected float |
delayedAvg
average over all velocities in the
simulation, ignoring the first ten steps
|
protected int |
historyLength
length of the history kept
|
protected float |
lastAvg
average over all velocities in the last
step
|
protected
java.util.concurrent.Semaphore |
listSemaphore
semaphore protecting the vtrlist
|
protected float |
maxVelocity
currently configured max velocity for all
vehicles
|
protected float |
overallAvg
average over all velocities in the
simulation
|
protected long |
steps
counter for executed simulation steps
|
protected float |
sumAvgMemory
sum of all vehicle speeds during the
simulation, used for average calculation
|
protected float |
sumDelAvgMemory
sum of all vehicle speeds during the
simulation ignoring the first ten steps,
used for average calculation
|
protected float |
trackLength
length of the track
|
protected java.util.List<Vehicle>
|
vehicles
list a vehicles on the track
|
protected java.util.List<java.util.List<VehicleTimeRecord>>
|
vtrList
list of resulting time records of the
simulation
|
protected int |
waitTime
current configured wait time between two
simulation steps
|
Constructor and Description |
---|
Track(int numberVehicles,
float trackLength,
float brakeProb,
float maxVelocity,
int waitTime,
int historyLength)
Constructor for a new Track.
|
Modifier and Type | Method and Description |
---|---|
float |
avg_step(int step)
Returns the average velocity of the given
simulation step.
|
protected java.util.List<Vehicle>
|
createVehiclesList(int numberVehicles)
Utility function to add vehicles to the
Track.
|
float |
getDelayedAvg()
Getter for delayedAvg
|
int |
getHistoryLength()
Getter for historyLength
|
float |
getLastAvg()
Getter for lastAvg
|
java.util.concurrent.Semaphore
|
getListSemaphore()
Getter for listSemaphore
|
float |
getOverallAvg()
Getter for overallAvg
|
long |
getSteps()
Getter for steps
|
float |
getTrackLength()
Getter for trackLength
|
java.util.List<Vehicle>
|
getVehicles()
Getter for vehicles
|
java.util.List<java.util.List<VehicleTimeRecord>>
|
getVtrList()
Getter for vtrList
|
void |
setBrakeProb(float brakeProb)
Update the brake probability of all
vehicles.
|
void |
setMaxVelocity(float maxVelocity)
Update the maximum velocity of all
vehicles.
|
void |
setWaitTime(int waitTime)
Update the wait time of the simulation.
|
void |
timeElapse()
Calculates on simulation step ahead and then
waits for the configured wait time.
|
protected void |
update_avg()
Utility function which updates the averages
values with the results from the last simulation
step.
|
protected java.util.List<Vehicle> vehicles
protected java.util.List<java.util.List<VehicleTimeRecord>> vtrList
protected float trackLength
protected float sumAvgMemory
protected float sumDelAvgMemory
protected int historyLength
protected float overallAvg
protected float delayedAvg
protected float lastAvg
protected int waitTime
protected float maxVelocity
protected float brakeProb
protected long steps
protected java.util.concurrent.Semaphore listSemaphore
public Track(int numberVehicles, float trackLength, float brakeProb, float maxVelocity, int waitTime, int historyLength)
numberVehicles
- number of vehicles on the
Track
trackLength
- length of the new TrackbrakeProb
- probability of a vehicle to
suddenly brake without reason
maxVelocity
- maxmimum velocity of the vehicles
waitTime
- time between two simulation steps to
slow down the simulation artificially
historyLength
- length of the history to keep
public java.util.List<java.util.List<VehicleTimeRecord>> getVtrList()
public float getOverallAvg()
public float getLastAvg()
public float getDelayedAvg()
public java.util.List<Vehicle> getVehicles()
public float getTrackLength()
public long getSteps()
public java.util.concurrent.Semaphore getListSemaphore()
public int getHistoryLength()
protected java.util.List<Vehicle> createVehiclesList(int numberVehicles)
numberVehicles
- number of vehicles to addpublic void setWaitTime(int waitTime)
waitTime
- new wait time in mspublic void setBrakeProb(float brakeProb)
brakeProb
- new brake probabilitypublic void setMaxVelocity(float maxVelocity)
maxVelocity
- new maximum velocitypublic void timeElapse()
public float avg_step(int step)
step
- index of the step in the history list
protected void update_avg()