Remove the Dictionary for the behavior sections
parent
99a07094fc
commit
acf8cd0c3b
221
src/behavior.jl
221
src/behavior.jl
|
@ -13,8 +13,9 @@ function addBreakFreeSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags:
|
||||||
trainIsHalting = drivingCourse[end][:v] == 0.0
|
trainIsHalting = drivingCourse[end][:v] == 0.0
|
||||||
|
|
||||||
if trainIsHalting && !endOfCSReached
|
if trainIsHalting && !endOfCSReached
|
||||||
BS = BehaviorSection("breakFree", drivingCourse[end][:s], drivingCourse[end][:v], drivingCourse[end][:i])
|
drivingMode = "breakFree"
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
|
startingPoint = drivingCourse[end][:i]
|
||||||
|
|
||||||
# traction effort and resisting forces (in N)
|
# traction effort and resisting forces (in N)
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], "accelerating", train, settings.massModel) # currently the tractive effort is calculated like in the accelerating section
|
calculateForces!(drivingCourse[end], CSs, CS[:id], "accelerating", train, settings.massModel) # currently the tractive effort is calculated like in the accelerating section
|
||||||
|
@ -27,28 +28,13 @@ function addBreakFreeSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags:
|
||||||
end
|
end
|
||||||
|
|
||||||
# delete every supportPoint except the first two
|
# delete every supportPoint except the first two
|
||||||
while drivingCourse[end][:i] > drivingCourse[BS[:supportPoints][1]][:i] +1
|
while drivingCourse[end][:i] > startingPoint +1
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
end
|
end
|
||||||
|
|
||||||
# change the accelerating data to break free
|
# change the accelerating data to break free
|
||||||
drivingCourse[end-1][:behavior] = BS[:type]
|
drivingCourse[end-1][:behavior] = drivingMode
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
|
|
||||||
# remove the accelerating section from the CS
|
|
||||||
CS[:t] = CS[:t] - get(CS[:behaviorSections], :accelerating, Dict(:t=>0.0))[:t] # total running time (in s)
|
|
||||||
delete!(CS[:behaviorSections], :accelerating)
|
|
||||||
|
|
||||||
# calculate the accumulated breakFree section information
|
|
||||||
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
|
|
||||||
:s_exit => drivingCourse[end][:s], # last position (in m)
|
|
||||||
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
|
|
||||||
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
|
|
||||||
|
|
||||||
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
|
|
||||||
|
|
||||||
merge!(CS[:behaviorSections], Dict(:breakFree => BS))
|
|
||||||
end # else: return the characteristic section without a breakFree section
|
end # else: return the characteristic section without a breakFree section
|
||||||
|
|
||||||
# determine state flags
|
# determine state flags
|
||||||
|
@ -107,7 +93,7 @@ end #function addClearingSection
|
||||||
## This function calculates the support points of the accelerating section.
|
## This function calculates the support points of the accelerating section.
|
||||||
# Therefore it gets its previous driving course and the characteristic section and returns the characteristic section and driving course including the accelerating section
|
# Therefore it gets its previous driving course and the characteristic section and returns the characteristic section and driving course including the accelerating section
|
||||||
function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, settings::Settings, train::Train, CSs::Vector{Dict})
|
function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::Dict, settings::Settings, train::Train, CSs::Vector{Dict})
|
||||||
#= TODO: instead of CS just give csId?
|
#= TODO: instead of CS just give csId?
|
||||||
-> CS = CSs[csId] =#
|
-> CS = CSs[csId] =#
|
||||||
|
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], "accelerating", train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], "accelerating", train, settings.massModel)
|
||||||
|
@ -129,8 +115,8 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
|
||||||
|
|
||||||
# use the conditions for the accelerating section
|
# use the conditions for the accelerating section
|
||||||
if !targetSpeedReached && !endOfCSReached && tractionSurplus && !brakingStartReached
|
if !targetSpeedReached && !endOfCSReached && tractionSurplus && !brakingStartReached
|
||||||
BS = BehaviorSection("accelerating", drivingCourse[end][:s], drivingCourse[end][:v], drivingCourse[end][:i])
|
drivingMode = "accelerating"
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
|
|
||||||
currentSpeedLimit = getCurrentSpeedLimit(CSs, CS[:id], drivingCourse[end][:s], train.length)
|
currentSpeedLimit = getCurrentSpeedLimit(CSs, CS[:id], drivingCourse[end][:s], train.length)
|
||||||
previousSpeedLimitReached = currentSpeedLimit[:v] != CS[:v_limit] && drivingCourse[end][:v] >= currentSpeedLimit[:v]
|
previousSpeedLimitReached = currentSpeedLimit[:v] != CS[:v_limit] && drivingCourse[end][:v] >= currentSpeedLimit[:v]
|
||||||
|
@ -159,10 +145,9 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
|
||||||
|
|
||||||
# create the next support point
|
# create the next support point
|
||||||
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
|
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
|
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], BS[:type], train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], drivingMode, train, settings.massModel)
|
||||||
|
|
||||||
# conditions for the next while cycle
|
# conditions for the next while cycle
|
||||||
if !ignoreBraking
|
if !ignoreBraking
|
||||||
|
@ -249,7 +234,6 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
|
||||||
end
|
end
|
||||||
# delete last support point for recalculating the last step with reduced step size
|
# delete last support point for recalculating the last step with reduced step size
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
# conditions for the next for cycle
|
# conditions for the next for cycle
|
||||||
brakingStartReached = false
|
brakingStartReached = false
|
||||||
|
@ -264,7 +248,6 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
|
||||||
if drivingCourse[end][:v] > CS[:v_peak]
|
if drivingCourse[end][:v] > CS[:v_peak]
|
||||||
testFlag && println("in CS",CS[:id]," accelerating cycle",cycle," case: v=", drivingCourse[end][:v]," > v_peak=",CS[:v_peak]) # for testing
|
testFlag && println("in CS",CS[:id]," accelerating cycle",cycle," case: v=", drivingCourse[end][:v]," > v_peak=",CS[:v_peak]) # for testing
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
# conditions for the next section
|
# conditions for the next section
|
||||||
brakingStartReached = false
|
brakingStartReached = false
|
||||||
|
@ -273,7 +256,6 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
|
||||||
testFlag && println("in CS",CS[:id]," accelerating cycle",cycle," case: s +s_braking=", drivingCourse[end][:s],",+",s_braking," = ",drivingCourse[end][:s] +s_braking," > s_exit=",CS[:s_exit]) # for testing
|
testFlag && println("in CS",CS[:id]," accelerating cycle",cycle," case: s +s_braking=", drivingCourse[end][:s],",+",s_braking," = ",drivingCourse[end][:s] +s_braking," > s_exit=",CS[:s_exit]) # for testing
|
||||||
if s_braking > 0.0
|
if s_braking > 0.0
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
else
|
else
|
||||||
drivingCourse[end][:s] = CS[:s_exit] # round s down to CS[:s_exit]
|
drivingCourse[end][:s] = CS[:s_exit] # round s down to CS[:s_exit]
|
||||||
|
@ -291,7 +273,6 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
|
||||||
previousSpeedLimitReached = true
|
previousSpeedLimitReached = true
|
||||||
|
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
else
|
else
|
||||||
if drivingCourse[end][:s] + s_braking == CS[:s_exit]
|
if drivingCourse[end][:s] + s_braking == CS[:s_exit]
|
||||||
|
@ -318,19 +299,6 @@ function addAcceleratingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFla
|
||||||
end
|
end
|
||||||
|
|
||||||
end #while
|
end #while
|
||||||
|
|
||||||
if length(BS[:supportPoints]) > 1
|
|
||||||
# calculate the accumulated accelerating section information
|
|
||||||
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
|
|
||||||
:s_exit => drivingCourse[end][:s], # last position (in m)
|
|
||||||
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
|
|
||||||
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
|
|
||||||
|
|
||||||
# 03/10 old: CS[:v_peak] = max(drivingCourse[end][:v], CS[:v_entry]) # setting v_peak to the last support points velocity which is the highest reachable value in this characteristic section or to v_entry in case it is higher when running on a path with high resistances
|
|
||||||
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
|
|
||||||
|
|
||||||
mergeBehaviorSection!(CS[:behaviorSections], BS)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# set state flags
|
# set state flags
|
||||||
|
@ -353,7 +321,7 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
trainIsBrakingDownhill = cruisingType == "downhillBraking"
|
trainIsBrakingDownhill = cruisingType == "downhillBraking"
|
||||||
|
|
||||||
# traction effort and resisting forces (in N)
|
# traction effort and resisting forces (in N)
|
||||||
if !trainIsBrakingDownhill # TODO: or just give BS[:type] instead of "cruising"/"braking"?
|
if !trainIsBrakingDownhill # TODO: or just give drivingMode instead of "cruising"/"braking"?
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], "cruising", train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], "cruising", train, settings.massModel)
|
||||||
else
|
else
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], "braking", train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], "braking", train, settings.massModel)
|
||||||
|
@ -374,17 +342,16 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
tractionDeficit = drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
tractionDeficit = drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
||||||
targetPositionReached = s_cruising == 0.0
|
targetPositionReached = s_cruising == 0.0
|
||||||
resistingForceNegative = drivingCourse[end][:F_R] < 0
|
resistingForceNegative = drivingCourse[end][:F_R] < 0
|
||||||
#println(" vor if speedIsValid=",speedIsValid ," brakingStartReached=", brakingStartReached," tractionDeficit=", tractionDeficit," targetPositionReached=", targetPositionReached)
|
|
||||||
|
|
||||||
if speedIsValid && !brakingStartReached && !tractionDeficit && !targetPositionReached
|
if speedIsValid && !brakingStartReached && !tractionDeficit && !targetPositionReached
|
||||||
# 03/04 old: if drivingCourse[end][:v]>0.0 && drivingCourse[end][:v]<=CS[:v_peak] && !brakingStartReached && drivingCourse[end][:F_T] >= drivingCourse[end][:F_R]
|
# 03/04 old: if drivingCourse[end][:v]>0.0 && drivingCourse[end][:v]<=CS[:v_peak] && !brakingStartReached && drivingCourse[end][:F_T] >= drivingCourse[end][:F_R]
|
||||||
BS = BehaviorSection(cruisingType, drivingCourse[end][:s], drivingCourse[end][:v], drivingCourse[end][:i])
|
drivingMode = cruisingType
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
# TODO: necessary?
|
# TODO: necessary?
|
||||||
s_cruising = min(s_cruising, CS[:s_exit]-BS[:s_entry])
|
targetPosition = min(drivingCourse[end][:s] + s_cruising, CS[:s_exit])
|
||||||
|
# 07/12 old: s_cruising = min(s_cruising, CS[:s_exit]-drivingCourse[end][:s])
|
||||||
|
|
||||||
# traction effort and resisting forces (in N)
|
# traction effort and resisting forces (in N)
|
||||||
#03/25 calculateForces!(drivingCourse[end], CSs, CS[:id], "cruising", train, settings.massModel)
|
|
||||||
if !trainIsBrakingDownhill
|
if !trainIsBrakingDownhill
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], "cruising", train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], "cruising", train, settings.massModel)
|
||||||
else
|
else
|
||||||
|
@ -394,7 +361,7 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
if settings.massModel == :homogeneous_strip && CS[:id] > 1
|
if settings.massModel == :homogeneous_strip && CS[:id] > 1
|
||||||
# conditions for cruising section
|
# conditions for cruising section
|
||||||
trainInPreviousCS = drivingCourse[end][:s] < CS[:s_entry] + train.length
|
trainInPreviousCS = drivingCourse[end][:s] < CS[:s_entry] + train.length
|
||||||
targetPositionReached = drivingCourse[end][:s] >= BS[:s_entry] +s_cruising
|
targetPositionReached = drivingCourse[end][:s] >= targetPosition
|
||||||
resistingForceNegative = drivingCourse[end][:F_R] < 0.0
|
resistingForceNegative = drivingCourse[end][:F_R] < 0.0
|
||||||
# targetSpeedReached = stateFlags[:speedLimitReached] || drivingCourse[end][:v] >= CS[:v_peak]
|
# targetSpeedReached = stateFlags[:speedLimitReached] || drivingCourse[end][:v] >= CS[:v_peak]
|
||||||
# TODO: change? to correctCruisingType = (trainIsClearing || (trainIsBrakingDownhill == drivingCourse[end][:F_R] < 0)) # while clearing tractive or braking force can be used
|
# TODO: change? to correctCruisingType = (trainIsClearing || (trainIsBrakingDownhill == drivingCourse[end][:F_R] < 0)) # while clearing tractive or braking force can be used
|
||||||
|
@ -407,11 +374,9 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
|
|
||||||
for cycle in 1:settings.approxLevel+1 # first cycle with normal step size followed by cycles with reduced step size depending on the level of approximation
|
for cycle in 1:settings.approxLevel+1 # first cycle with normal step size followed by cycles with reduced step size depending on the level of approximation
|
||||||
while trainInPreviousCS && !targetPositionReached && !pointOfInterestReached && !tractionDeficit && (trainIsClearing || (trainIsBrakingDownhill == resistingForceNegative)) # while clearing tractive or braking force can be used
|
while trainInPreviousCS && !targetPositionReached && !pointOfInterestReached && !tractionDeficit && (trainIsClearing || (trainIsBrakingDownhill == resistingForceNegative)) # while clearing tractive or braking force can be used
|
||||||
# 03/09 old: while drivingCourse[end][:s] < CS[:s_entry] + train.length && drivingCourse[end][:s] < BS[:s_entry] +s_cruising && drivingCourse[end][:s] < nextPointOfInterest[1] && drivingCourse[end][:F_T]>=drivingCourse[end][:F_R]
|
|
||||||
# the tractive effort is lower than the resisiting forces and the train has use the highest possible effort to try to stay at v_peak OR the mass model homogeneous strip is used and parts of the train are still in former CS
|
# the tractive effort is lower than the resisiting forces and the train has use the highest possible effort to try to stay at v_peak OR the mass model homogeneous strip is used and parts of the train are still in former CS
|
||||||
#TODO: maybe just consider former CS with different path resistance?
|
#TODO: maybe just consider former CS with different path resistance?
|
||||||
# tractive effort (in N):
|
# tractive effort (in N):
|
||||||
#03/25 drivingCourse[end][:F_T] = min(drivingCourse[end][:F_T], max(0.0, drivingCourse[end][:F_R]))
|
|
||||||
if !trainIsBrakingDownhill
|
if !trainIsBrakingDownhill
|
||||||
drivingCourse[end][:F_T] = min(drivingCourse[end][:F_T], max(0.0, drivingCourse[end][:F_R]))
|
drivingCourse[end][:F_T] = min(drivingCourse[end][:F_T], max(0.0, drivingCourse[end][:F_R]))
|
||||||
else
|
else
|
||||||
|
@ -428,8 +393,7 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
else
|
else
|
||||||
push!(drivingCourse, moveAStep(drivingCourse[end], position, train.length/(10.0^cycle), CS[:id])) # TODO which step size should be used?
|
push!(drivingCourse, moveAStep(drivingCourse[end], position, train.length/(10.0^cycle), CS[:id])) # TODO which step size should be used?
|
||||||
end
|
end
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
|
|
||||||
# traction effort and resisting forces (in N)
|
# traction effort and resisting forces (in N)
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], "default", train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], "default", train, settings.massModel)
|
||||||
|
@ -443,7 +407,7 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
# conditions for the next while cycle
|
# conditions for the next while cycle
|
||||||
pointOfInterestReached = drivingCourse[end][:s] >= nextPointOfInterest[1] # POIs include s_exit as well
|
pointOfInterestReached = drivingCourse[end][:s] >= nextPointOfInterest[1] # POIs include s_exit as well
|
||||||
tractionDeficit = drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
tractionDeficit = drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
||||||
targetPositionReached = drivingCourse[end][:s] >= BS[:s_entry] +s_cruising
|
targetPositionReached = drivingCourse[end][:s] >= targetPosition
|
||||||
trainInPreviousCS = drivingCourse[end][:s] < CS[:s_entry] + train.length
|
trainInPreviousCS = drivingCourse[end][:s] < CS[:s_entry] + train.length
|
||||||
resistingForceNegative = drivingCourse[end][:F_R] < 0.0
|
resistingForceNegative = drivingCourse[end][:F_R] < 0.0
|
||||||
end #while
|
end #while
|
||||||
|
@ -466,14 +430,14 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
currentStepSize = settings.stepSize / 10.0^cycle
|
currentStepSize = settings.stepSize / 10.0^cycle
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif drivingCourse[end][:s] > BS[:s_entry] + s_cruising # TODO also the following? drivingCourse[end][:s] > CSs[CS[:id]][:s_entry] + train.length))
|
elseif drivingCourse[end][:s] > targetPosition # TODO also the following? drivingCourse[end][:s] > CSs[CS[:id]][:s_entry] + train.length))
|
||||||
if settings.stepVariable == :distance
|
if settings.stepVariable == :distance
|
||||||
currentStepSize=BS[:s_entry] + s_cruising-drivingCourse[end-1][:s]
|
currentStepSize = targetPosition - drivingCourse[end-1][:s]
|
||||||
else
|
else
|
||||||
currentStepSize = settings.stepSize / 10.0^cycle
|
currentStepSize = settings.stepSize / 10.0^cycle
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif drivingCourse[end][:s] == BS[:s_entry] + s_cruising # || drivingCourse[end][:s]==CS[:s_exit]
|
elseif drivingCourse[end][:s] == targetPosition # || drivingCourse[end][:s]==CS[:s_exit]
|
||||||
break
|
break
|
||||||
|
|
||||||
elseif drivingCourse[end][:s] >= CS[:s_entry] + train.length
|
elseif drivingCourse[end][:s] >= CS[:s_entry] + train.length
|
||||||
|
@ -491,7 +455,6 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
|
|
||||||
# delete last support point for recalculating the last step with reduced step size
|
# delete last support point for recalculating the last step with reduced step size
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
# conditions for the next for cycle
|
# conditions for the next for cycle
|
||||||
pointOfInterestReached = false
|
pointOfInterestReached = false
|
||||||
|
@ -503,12 +466,11 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
else # if the level of approximation is reached
|
else # if the level of approximation is reached
|
||||||
if drivingCourse[end][:s] > nextPointOfInterest[1]
|
if drivingCourse[end][:s] > nextPointOfInterest[1]
|
||||||
drivingCourse[end][:s] = nextPointOfInterest[1] # round s down to nextPointOfInterest
|
drivingCourse[end][:s] = nextPointOfInterest[1] # round s down to nextPointOfInterest
|
||||||
elseif drivingCourse[end][:s] > BS[:s_entry]+s_cruising
|
elseif drivingCourse[end][:s] > targetPosition
|
||||||
if BS[:type] != "clearing"
|
if drivingMode != "clearing"
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
end
|
end
|
||||||
elseif drivingCourse[end][:s] == BS[:s_entry]+s_cruising
|
elseif drivingCourse[end][:s] == targetPosition
|
||||||
break
|
break
|
||||||
elseif drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
elseif drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
||||||
break
|
break
|
||||||
|
@ -533,15 +495,15 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
end #if
|
end #if
|
||||||
|
|
||||||
# conditions for the next while cycle
|
# conditions for the next while cycle
|
||||||
targetPositionReached = drivingCourse[end][:s] >= BS[:s_entry] +s_cruising
|
targetPositionReached = drivingCourse[end][:s] >= targetPosition
|
||||||
tractionDeficit = drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
tractionDeficit = drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
||||||
resistingForceNegative = drivingCourse[end][:F_R] < 0.0
|
resistingForceNegative = drivingCourse[end][:F_R] < 0.0
|
||||||
|
|
||||||
while !targetPositionReached && !tractionDeficit && (trainIsClearing || (trainIsBrakingDownhill == resistingForceNegative)) # while clearing tractive or braking force can be used
|
while !targetPositionReached && !tractionDeficit && (trainIsClearing || (trainIsBrakingDownhill == resistingForceNegative)) # while clearing tractive or braking force can be used
|
||||||
# 03/09 old: while drivingCourse[end][:s] < BS[:s_entry]+s_cruising && drivingCourse[end][:F_T] >= drivingCourse[end][:F_R]
|
# 03/09 old: while drivingCourse[end][:s] < targetPosition && drivingCourse[end][:F_T] >= drivingCourse[end][:F_R]
|
||||||
nextPointOfInterest = getNextPointOfInterest(CS[:pointsOfInterest], drivingCourse[end][:s])
|
nextPointOfInterest = getNextPointOfInterest(CS[:pointsOfInterest], drivingCourse[end][:s])
|
||||||
if nextPointOfInterest[1] > BS[:s_entry]+s_cruising
|
if nextPointOfInterest[1] > targetPosition
|
||||||
nextPointOfInterest = [BS[:s_entry]+s_cruising, ""]
|
nextPointOfInterest = [targetPosition, ""]
|
||||||
end
|
end
|
||||||
|
|
||||||
# tractive effort (in N):
|
# tractive effort (in N):
|
||||||
|
@ -557,16 +519,15 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
drivingCourse[end][:a] = 0.0 # acceleration (in m/s^2)
|
drivingCourse[end][:a] = 0.0 # acceleration (in m/s^2)
|
||||||
|
|
||||||
# calculate the remaining cruising way
|
# calculate the remaining cruising way
|
||||||
#s_cruisingRemaining=BS[:s_entry] + s_cruising-drivingCourse[end][:s]
|
#s_cruisingRemaining=targetPosition-drivingCourse[end][:s]
|
||||||
s_cruisingRemaining = min(nextPointOfInterest[1] -drivingCourse[end][:s], BS[:s_entry] +s_cruising -drivingCourse[end][:s])
|
s_cruisingRemaining = min(nextPointOfInterest[1] -drivingCourse[end][:s], targetPosition -drivingCourse[end][:s])
|
||||||
|
|
||||||
# create the next support point
|
# create the next support point
|
||||||
push!(drivingCourse, moveAStep(drivingCourse[end], :distance, s_cruisingRemaining, CS[:id]))
|
push!(drivingCourse, moveAStep(drivingCourse[end], :distance, s_cruisingRemaining, CS[:id]))
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
if drivingCourse[end][:s] == nextPointOfInterest[1]
|
if drivingCourse[end][:s] == nextPointOfInterest[1]
|
||||||
drivingCourse[end][:label] = nextPointOfInterest[2]
|
drivingCourse[end][:label] = nextPointOfInterest[2]
|
||||||
end
|
end
|
||||||
push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
|
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], "default", train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], "default", train, settings.massModel)
|
||||||
# calculateForces!(drivingCourse[end], CSs, CS[:id], "cruising", train, settings.massModel)
|
# calculateForces!(drivingCourse[end], CSs, CS[:id], "cruising", train, settings.massModel)
|
||||||
|
@ -577,23 +538,11 @@ function addCruisingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
#end
|
#end
|
||||||
|
|
||||||
# conditions for the next while cycle
|
# conditions for the next while cycle
|
||||||
targetPositionReached = drivingCourse[end][:s] >= BS[:s_entry] +s_cruising
|
targetPositionReached = drivingCourse[end][:s] >= targetPosition
|
||||||
tractionDeficit = drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
tractionDeficit = drivingCourse[end][:F_T] < drivingCourse[end][:F_R]
|
||||||
resistingForceNegative = drivingCourse[end][:F_R] < 0
|
resistingForceNegative = drivingCourse[end][:F_R] < 0
|
||||||
end #while
|
end #while
|
||||||
|
|
||||||
# TODO: realize this better inside the upper loops?
|
|
||||||
|
|
||||||
|
|
||||||
# calculate the accumulated cruising section information
|
|
||||||
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
|
|
||||||
:s_exit => drivingCourse[end][:s], # last position (in m)
|
|
||||||
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
|
|
||||||
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
|
|
||||||
|
|
||||||
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
|
|
||||||
|
|
||||||
mergeBehaviorSection!(CS[:behaviorSections], BS)
|
|
||||||
end # else: return the characteristic section without a cruising section
|
end # else: return the characteristic section without a cruising section
|
||||||
|
|
||||||
# set state flags
|
# set state flags
|
||||||
|
@ -633,8 +582,8 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
|
||||||
|
|
||||||
# use the conditions for the diminishing section
|
# use the conditions for the diminishing section
|
||||||
if tractionDeficit && !targetSpeedReached && !endOfCSReached
|
if tractionDeficit && !targetSpeedReached && !endOfCSReached
|
||||||
BS = BehaviorSection("diminishing", drivingCourse[end][:s], drivingCourse[end][:v], drivingCourse[end][:i])
|
drivingMode = "diminishing"
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
|
|
||||||
while tractionDeficit && !targetSpeedReached && !endOfCSReached && !brakingStartReached
|
while tractionDeficit && !targetSpeedReached && !endOfCSReached && !brakingStartReached
|
||||||
currentStepSize=settings.stepSize # initialize the step size that can be reduced near intersections
|
currentStepSize=settings.stepSize # initialize the step size that can be reduced near intersections
|
||||||
|
@ -649,10 +598,9 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
|
||||||
|
|
||||||
# create the next support point
|
# create the next support point
|
||||||
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
|
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
|
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], BS[:type], train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], drivingMode, train, settings.massModel)
|
||||||
|
|
||||||
# conditions for the next while cycle
|
# conditions for the next while cycle
|
||||||
if !ignoreBraking
|
if !ignoreBraking
|
||||||
|
@ -717,7 +665,6 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
|
||||||
end
|
end
|
||||||
# delete last support point for recalculating the last step with reduced step size
|
# delete last support point for recalculating the last step with reduced step size
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
# conditions for the next for cycle
|
# conditions for the next for cycle
|
||||||
brakingStartReached = false
|
brakingStartReached = false
|
||||||
|
@ -729,7 +676,6 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
|
||||||
else # if the level of approximation is reached
|
else # if the level of approximation is reached
|
||||||
if drivingCourse[end][:v] <= 0.0
|
if drivingCourse[end][:v] <= 0.0
|
||||||
testFlag && println("in CS",CS[:id]," diminishing cycle",cycle," case: v=", drivingCourse[end][:v]," <= 0.0") # for testing
|
testFlag && println("in CS",CS[:id]," diminishing cycle",cycle," case: v=", drivingCourse[end][:v]," <= 0.0") # for testing
|
||||||
# push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
error("ERROR: The train stops during diminishing run in CS",CS[:id]," because the maximum tractive effort is lower than the resistant forces.",
|
error("ERROR: The train stops during diminishing run in CS",CS[:id]," because the maximum tractive effort is lower than the resistant forces.",
|
||||||
" Before the stop the last point has the values s=",drivingCourse[end-1][:s]," m v=",drivingCourse[end-1][:v]," m/s a=",drivingCourse[end-1][:a]," m/s^2",
|
" Before the stop the last point has the values s=",drivingCourse[end-1][:s]," m v=",drivingCourse[end-1][:v]," m/s a=",drivingCourse[end-1][:a]," m/s^2",
|
||||||
" F_T=",drivingCourse[end-1][:F_T]," N R_traction=",drivingCourse[end-1][:R_traction]," N R_wagons=",drivingCourse[end-1][:R_wagons]," N R_path=",drivingCourse[end-1][:R_path]," N.")
|
" F_T=",drivingCourse[end-1][:F_T]," N R_traction=",drivingCourse[end-1][:R_traction]," N R_wagons=",drivingCourse[end-1][:R_wagons]," N R_path=",drivingCourse[end-1][:R_path]," N.")
|
||||||
|
@ -737,7 +683,6 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
|
||||||
elseif s_braking > 0.0 && drivingCourse[end][:s] + s_braking > CS[:s_exit]
|
elseif s_braking > 0.0 && drivingCourse[end][:s] + s_braking > CS[:s_exit]
|
||||||
testFlag && println("in CS",CS[:id]," diminishing cycle",cycle," case: s +s_braking=", drivingCourse[end][:s],"+",s_braking," = ",drivingCourse[end][:s] +s_braking," > s_exit=",CS[:s_exit]) # for testing
|
testFlag && println("in CS",CS[:id]," diminishing cycle",cycle," case: s +s_braking=", drivingCourse[end][:s],"+",s_braking," = ",drivingCourse[end][:s] +s_braking," > s_exit=",CS[:s_exit]) # for testing
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
pointOfInterestReached = false
|
pointOfInterestReached = false
|
||||||
targetSpeedReached = false
|
targetSpeedReached = false
|
||||||
|
@ -773,18 +718,6 @@ function addDiminishingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlag
|
||||||
drivingCourse[end][:label] = nextPointOfInterest[2]
|
drivingCourse[end][:label] = nextPointOfInterest[2]
|
||||||
end
|
end
|
||||||
end #while
|
end #while
|
||||||
|
|
||||||
if length(BS[:supportPoints]) > 1 # TODO: necessary? May it be possible that there is no diminishing because braking has to start?
|
|
||||||
# calculate the accumulated diminishing section information
|
|
||||||
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
|
|
||||||
:s_exit => drivingCourse[end][:s], # last position (in m)
|
|
||||||
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
|
|
||||||
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
|
|
||||||
|
|
||||||
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
|
|
||||||
|
|
||||||
mergeBehaviorSection!(CS[:behaviorSections], BS)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# set state flags
|
# set state flags
|
||||||
|
@ -814,8 +747,8 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
|
|
||||||
# use the conditions for the coasting section
|
# use the conditions for the coasting section
|
||||||
if !targetSpeedReached && !endOfCSReached
|
if !targetSpeedReached && !endOfCSReached
|
||||||
BS = BehaviorSection("coasting", drivingCourse[end][:s], drivingCourse[end][:v], drivingCourse[end][:i])
|
drivingMode = "coasting"
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
|
|
||||||
while !targetSpeedReached && !endOfCSReached && !brakingStartReached
|
while !targetSpeedReached && !endOfCSReached && !brakingStartReached
|
||||||
currentStepSize=settings.stepSize # initialize the step size that can be reduced near intersections
|
currentStepSize=settings.stepSize # initialize the step size that can be reduced near intersections
|
||||||
|
@ -826,15 +759,14 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
while !targetSpeedReached && !brakingStartReached && !pointOfInterestReached
|
while !targetSpeedReached && !brakingStartReached && !pointOfInterestReached
|
||||||
# 03/09 old : while drivingCourse[end][:v] > CS[:v_exit] && drivingCourse[end][:v] <= CS[:v_peak] && !brakingStartReached && drivingCourse[end][:s] < nextPointOfInterest[1]
|
# 03/09 old : while drivingCourse[end][:v] > CS[:v_exit] && drivingCourse[end][:v] <= CS[:v_peak] && !brakingStartReached && drivingCourse[end][:s] < nextPointOfInterest[1]
|
||||||
# traction effort and resisting forces (in N):
|
# traction effort and resisting forces (in N):
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], BS[:type], train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], drivingMode, train, settings.massModel)
|
||||||
|
|
||||||
# acceleration (in m/s^2):
|
# acceleration (in m/s^2):
|
||||||
drivingCourse[end][:a] = acceleration(drivingCourse[end][:F_T], drivingCourse[end][:F_R], train.m_train_full, train.ξ_train)
|
drivingCourse[end][:a] = acceleration(drivingCourse[end][:F_T], drivingCourse[end][:F_R], train.m_train_full, train.ξ_train)
|
||||||
|
|
||||||
# create the next support point
|
# create the next support point
|
||||||
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
|
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
|
|
||||||
# conditions for the next while cycle
|
# conditions for the next while cycle
|
||||||
s_braking = brakingDistance(drivingCourse[end][:v], CS[:v_exit], train.a_braking, settings.approxLevel)
|
s_braking = brakingDistance(drivingCourse[end][:v], CS[:v_exit], train.a_braking, settings.approxLevel)
|
||||||
|
@ -892,7 +824,6 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
end
|
end
|
||||||
# delete last support point for recalculating the last step with reduced step size
|
# delete last support point for recalculating the last step with reduced step size
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
# conditions for the next for cycle
|
# conditions for the next for cycle
|
||||||
brakingStartReached = false
|
brakingStartReached = false
|
||||||
|
@ -909,7 +840,6 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
elseif drivingCourse[end][:s] + s_braking > CS[:s_exit]
|
elseif drivingCourse[end][:s] + s_braking > CS[:s_exit]
|
||||||
# delete last support point because it went to far
|
# delete last support point because it went to far
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
# conditions for the next for cycle
|
# conditions for the next for cycle
|
||||||
# brakingStartReached = true
|
# brakingStartReached = true
|
||||||
|
@ -919,7 +849,6 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
elseif drivingCourse[end][:v] > CS[:v_peak] # if the train gets to fast it has to brake # TODO: if accelereation and coasting functions will be combined this case is different for coasting and also the order of if cases is different
|
elseif drivingCourse[end][:v] > CS[:v_peak] # if the train gets to fast it has to brake # TODO: if accelereation and coasting functions will be combined this case is different for coasting and also the order of if cases is different
|
||||||
# delete last support point because it went to far
|
# delete last support point because it went to far
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
# conditions for the next for cycle
|
# conditions for the next for cycle
|
||||||
brakingStartReached = false
|
brakingStartReached = false
|
||||||
|
@ -941,16 +870,6 @@ function addCoastingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::
|
||||||
end #while
|
end #while
|
||||||
|
|
||||||
stateFlags[:speedLimitReached] = false
|
stateFlags[:speedLimitReached] = false
|
||||||
|
|
||||||
# calculate the accumulated coasting section information
|
|
||||||
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
|
|
||||||
:s_exit => drivingCourse[end][:s], # last position (in m)
|
|
||||||
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
|
|
||||||
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
|
|
||||||
|
|
||||||
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
|
|
||||||
|
|
||||||
merge!(CS[:behaviorSections], Dict(:coasting=>BS))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# set state flags
|
# set state flags
|
||||||
|
@ -973,8 +892,8 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
|
||||||
|
|
||||||
# use the conditions for the braking section
|
# use the conditions for the braking section
|
||||||
if !targetSpeedReached && !endOfCSReached
|
if !targetSpeedReached && !endOfCSReached
|
||||||
BS = BehaviorSection("braking", drivingCourse[end][:s], drivingCourse[end][:v], drivingCourse[end][:i])
|
drivingMode = "braking"
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
|
|
||||||
while !targetSpeedReached && !endOfCSReached
|
while !targetSpeedReached && !endOfCSReached
|
||||||
currentStepSize = settings.stepSize # initialize the step size that can be reduced near intersections
|
currentStepSize = settings.stepSize # initialize the step size that can be reduced near intersections
|
||||||
|
@ -985,7 +904,7 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
|
||||||
while !targetSpeedReached && !endOfCSReached && !pointOfInterestReached
|
while !targetSpeedReached && !endOfCSReached && !pointOfInterestReached
|
||||||
# 03/09 old: while drivingCourse[end][:v] > CS[:v_exit] && !targetSpeedReached && drivingCourse[end][:s] < CS[:s_exit] && drivingCourse[end][:s] < nextPointOfInterest[1]
|
# 03/09 old: while drivingCourse[end][:v] > CS[:v_exit] && !targetSpeedReached && drivingCourse[end][:s] < CS[:s_exit] && drivingCourse[end][:s] < nextPointOfInterest[1]
|
||||||
# traction effort and resisting forces (in N):
|
# traction effort and resisting forces (in N):
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], BS[:type], train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], drivingMode, train, settings.massModel)
|
||||||
|
|
||||||
# acceleration (in m/s^2):
|
# acceleration (in m/s^2):
|
||||||
drivingCourse[end][:a] = train.a_braking
|
drivingCourse[end][:a] = train.a_braking
|
||||||
|
@ -995,14 +914,12 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
|
||||||
# create empty support point and set it for the values of s_exit and v_exit
|
# create empty support point and set it for the values of s_exit and v_exit
|
||||||
push!(drivingCourse, SupportPoint())
|
push!(drivingCourse, SupportPoint())
|
||||||
drivingCourse[end][:i] = drivingCourse[end-1][:i]+1
|
drivingCourse[end][:i] = drivingCourse[end-1][:i]+1
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
recalculateLastBrakingPoint!(drivingCourse, CS[:s_exit], CS[:v_exit])
|
recalculateLastBrakingPoint!(drivingCourse, CS[:s_exit], CS[:v_exit])
|
||||||
else
|
else
|
||||||
# create the next support point
|
# create the next support point
|
||||||
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
|
push!(drivingCourse, moveAStep(drivingCourse[end], settings.stepVariable, currentStepSize, CS[:id]))
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
push!(BS[:supportPoints], drivingCourse[end][:i])
|
|
||||||
end
|
end
|
||||||
#println(drivingCourse[end][:i],". s=",drivingCourse[end][:s]," s_exit=", CS[:s_exit]," v_exit=", CS[:v_exit]," v=",drivingCourse[end][:v])
|
#println(drivingCourse[end][:i],". s=",drivingCourse[end][:s]," s_exit=", CS[:s_exit]," v_exit=", CS[:v_exit]," v=",drivingCourse[end][:v])
|
||||||
|
|
||||||
|
@ -1046,7 +963,6 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
|
||||||
|
|
||||||
# delete last support point for recalculating the last step with reduced step size
|
# delete last support point for recalculating the last step with reduced step size
|
||||||
pop!(drivingCourse)
|
pop!(drivingCourse)
|
||||||
pop!(BS[:supportPoints])
|
|
||||||
|
|
||||||
# conditions for the next for cycle
|
# conditions for the next for cycle
|
||||||
pointOfInterestReached = false
|
pointOfInterestReached = false
|
||||||
|
@ -1098,16 +1014,6 @@ function addBrakingSection!(CS::Dict, drivingCourse::Vector{Dict}, stateFlags::D
|
||||||
end
|
end
|
||||||
|
|
||||||
end #while
|
end #while
|
||||||
|
|
||||||
# calculate the accumulated coasting section information
|
|
||||||
merge!(BS, Dict(:length => drivingCourse[end][:s] - BS[:s_entry], # total length (in m)
|
|
||||||
:s_exit => drivingCourse[end][:s], # last position (in m)
|
|
||||||
:t => drivingCourse[end][:t] - drivingCourse[BS[:supportPoints][1]][:t], # total running time (in s)
|
|
||||||
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
|
|
||||||
|
|
||||||
CS[:t] = CS[:t] + BS[:t] # total running time (in s)
|
|
||||||
|
|
||||||
merge!(CS[:behaviorSections], Dict(:braking=>BS))
|
|
||||||
end # else: return the characteristic section without a braking section
|
end # else: return the characteristic section without a braking section
|
||||||
|
|
||||||
# set state flags
|
# set state flags
|
||||||
|
@ -1127,35 +1033,15 @@ end #function addBrakingSection!
|
||||||
# Therefore it gets its first support point and the characteristic section and returns the characteristic section including the halt if needed.
|
# Therefore it gets its first support point and the characteristic section and returns the characteristic section including the halt if needed.
|
||||||
function addHalt!(CS::Dict, drivingCourse::Vector{Dict}, settings::Settings, train::Train, CSs::Vector{Dict})
|
function addHalt!(CS::Dict, drivingCourse::Vector{Dict}, settings::Settings, train::Train, CSs::Vector{Dict})
|
||||||
if drivingCourse[end][:v] == 0.0
|
if drivingCourse[end][:v] == 0.0
|
||||||
BS = BehaviorSection("standstill", drivingCourse[end][:s], drivingCourse[end][:v], drivingCourse[end][:i])
|
drivingMode = "halt"
|
||||||
merge!(BS, Dict(:length => 0.0, # total length (in m)
|
drivingCourse[end][:behavior] = drivingMode
|
||||||
:t => 0.0, # total running time (in s)
|
|
||||||
:s_exit => drivingCourse[end][:s], # last position (in m)
|
|
||||||
:v_exit => drivingCourse[end][:v])) # exit speed (in m/s)))
|
|
||||||
drivingCourse[end][:behavior] = BS[:type]
|
|
||||||
|
|
||||||
# traction effort and resisting forces (in N)
|
# traction effort and resisting forces (in N)
|
||||||
calculateForces!(drivingCourse[end], CSs, CS[:id], BS[:type], train, settings.massModel)
|
calculateForces!(drivingCourse[end], CSs, CS[:id], drivingMode, train, settings.massModel)
|
||||||
|
|
||||||
merge!(CS[:behaviorSections], Dict(:halt => BS))
|
|
||||||
end # else: return the characteristic section without a halt section section
|
end # else: return the characteristic section without a halt section section
|
||||||
return (CS, drivingCourse)
|
return (CS, drivingCourse)
|
||||||
end #function addHalt!
|
end #function addHalt!
|
||||||
|
|
||||||
function mergeBehaviorSection!(BSs::Dict, BS::Dict)
|
|
||||||
if !haskey(BSs, Symbol(BS[:type]))
|
|
||||||
merge!(BSs, Dict(Symbol(BS[:type]) => BS))
|
|
||||||
else
|
|
||||||
number = "2"
|
|
||||||
while haskey(BSs, Symbol(BS[:type]*number))
|
|
||||||
number = string(parse(Int, number)+1)
|
|
||||||
end
|
|
||||||
merge!(BSs, Dict(Symbol(BS[:type]*number) => BS))
|
|
||||||
# println("INFO: The ",number,". ",BS[:type]," section has been created. ! ! ! ! ! ! ! ! !")
|
|
||||||
end
|
|
||||||
return BSs
|
|
||||||
end #function mergeBehaviorSection!
|
|
||||||
|
|
||||||
function recalculateLastBrakingPoint!(drivingCourse, s_target, v_target)
|
function recalculateLastBrakingPoint!(drivingCourse, s_target, v_target)
|
||||||
currentPoint = drivingCourse[end]
|
currentPoint = drivingCourse[end]
|
||||||
previousPoint = drivingCourse[end-1]
|
previousPoint = drivingCourse[end-1]
|
||||||
|
@ -1188,11 +1074,6 @@ function secureBrakingBehavior!(CSs::Vector{Dict}, a_braking::Real, approxLevel:
|
||||||
CS[:v_entry] = min(CS[:v_limit], v_entryMax)
|
CS[:v_entry] = min(CS[:v_limit], v_entryMax)
|
||||||
CS[:v_peak] = CS[:v_entry]
|
CS[:v_peak] = CS[:v_entry]
|
||||||
|
|
||||||
|
|
||||||
# reset the characteristic section (CS), delete behavior sections (BS) that were used during the preperation for setting v_entry, v_peak and v_exit
|
|
||||||
CS[:behaviorSections] = Dict()
|
|
||||||
CS[:t] = 0.0
|
|
||||||
|
|
||||||
followingCSv_entry = CS[:v_entry]
|
followingCSv_entry = CS[:v_entry]
|
||||||
csId = csId - 1
|
csId = csId - 1
|
||||||
end #while
|
end #while
|
||||||
|
@ -1253,10 +1134,6 @@ function secureAcceleratingBehavior!(CSs::Vector{Dict}, settings::Settings, trai
|
||||||
end #if
|
end #if
|
||||||
|
|
||||||
previousCSv_exit = CS[:v_exit]
|
previousCSv_exit = CS[:v_exit]
|
||||||
|
|
||||||
# reset the characteristic section (CS), delete behavior sections (BS) that were used during the preperation for setting v_entry, v_peak and v_exit
|
|
||||||
CS[:behaviorSections] = Dict()
|
|
||||||
CS[:t] = 0.0
|
|
||||||
end #for
|
end #for
|
||||||
|
|
||||||
return CSs
|
return CSs
|
||||||
|
|
|
@ -639,13 +639,11 @@ end #function CharacteristicSections
|
||||||
## create a characteristic section for a path section. A characteristic section is a part of the moving section. It contains behavior sections.
|
## create a characteristic section for a path section. A characteristic section is a part of the moving section. It contains behavior sections.
|
||||||
function CharacteristicSection(id::Integer, s_entry::Real, section::Dict, v_limit::Real, s_trainLength::Real, MS_poi::Vector{Tuple})
|
function CharacteristicSection(id::Integer, s_entry::Real, section::Dict, v_limit::Real, s_trainLength::Real, MS_poi::Vector{Tuple})
|
||||||
# Create and return a characteristic section dependent on the paths attributes
|
# Create and return a characteristic section dependent on the paths attributes
|
||||||
characteristicSection= Dict(:id => id, # identifier
|
characteristicSection::Dict{Symbol, Any} = Dict(:id => id, # identifier
|
||||||
:s_entry => s_entry, # first position (in m)
|
:s_entry => s_entry, # first position (in m)
|
||||||
:s_exit => section[:s_end], # last position (in m)
|
:s_exit => section[:s_end], # last position (in m)
|
||||||
:length => section[:s_end] -s_entry, # total length (in m)
|
:length => section[:s_end] -s_entry, # total length (in m)
|
||||||
:r_path => section[:f_Rp], # path resistance (in ‰)
|
:r_path => section[:f_Rp], # path resistance (in ‰)
|
||||||
:behaviorSections => Dict(), # list of containing behavior sections
|
|
||||||
:t => 0.0, # total running time (in s)
|
|
||||||
:v_limit => v_limit, # speed limit (in m/s)
|
:v_limit => v_limit, # speed limit (in m/s)
|
||||||
# initializing :v_entry, :v_peak and :v_exit with :v_limit
|
# initializing :v_entry, :v_peak and :v_exit with :v_limit
|
||||||
:v_peak => v_limit, # maximum reachable speed (in m/s)
|
:v_peak => v_limit, # maximum reachable speed (in m/s)
|
||||||
|
@ -673,23 +671,6 @@ function CharacteristicSection(id::Integer, s_entry::Real, section::Dict, v_limi
|
||||||
return characteristicSection
|
return characteristicSection
|
||||||
end #function CharacteristicSection
|
end #function CharacteristicSection
|
||||||
|
|
||||||
"""
|
|
||||||
BehaviorSection() TODO!
|
|
||||||
"""
|
|
||||||
function BehaviorSection(type::String, s_entry::Real, v_entry::Real, startingPoint::Integer)
|
|
||||||
BS= Dict(
|
|
||||||
:type => type, # type of behavior section: "breakFree", "clearing", "accelerating", "cruising", "downhillBraking", "diminishing", "coasting", "braking" or "standstill"
|
|
||||||
:length => 0.0, # total length (in m)
|
|
||||||
:s_entry => s_entry, # first position (in m)
|
|
||||||
:s_exit => 0.0, # last position (in m)
|
|
||||||
:t => 0.0, # total running time (in s)
|
|
||||||
:v_entry => v_entry, # entry speed (in m/s)
|
|
||||||
:v_exit => 0.0, # exit speed (in m/s)
|
|
||||||
:supportPoints => [startingPoint] # list of identifiers of the containing support points starting with the initial point
|
|
||||||
)
|
|
||||||
return BS
|
|
||||||
end #function BehaviorSection
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
a SupportPoint is the smallest element of the driving course. One step of the step approach is between two support points
|
a SupportPoint is the smallest element of the driving course. One step of the step approach is between two support points
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue