Skip to content

Commit

Permalink
Fix the block-delays bug
Browse files Browse the repository at this point in the history
  • Loading branch information
snehal-shekatkar committed Nov 6, 2023
1 parent 945faa1 commit 4ef2215
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 7 additions & 7 deletions simulation/initialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ function imposeDelays(FL::Fleet, df::DataFrame)::Nothing
(train, block, delay) = r;
train BLACKLIST && continue;

o = split(block, "-");
if length(o) == 1 || o[1] == o[2] # it's a station
block = replace(o[1], r"[ _]+" => "");
else
# if the block is not a station we have to find to which line it belongs
@warn "Delays on blocks other than stations [$block] is not implemented yet.";
end
#o = split(block, "-");
#if length(o) == 1 || o[1] == o[2] # it's a station
# block = replace(o[1], r"[ _]+" => "");
#else
# # if the block is not a station we have to find to which line it belongs
# @warn "Delays on blocks other than stations [$block] is not implemented yet.";
#end

FL.train[train].delay[block] = delay;

Expand Down
4 changes: 3 additions & 1 deletion simulation/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ function simulation(RN::Network, FL::Fleet, sim_id::Int=0)::Bool

if current_opid == nextopid
nextBlockid = current_opid;
naked_nextBlockid = current_opid;
nextBlock = ST[nextBlockid]; # it's a station
else
nextBlockid = current_opid*"-"*nextopid*"-"*line;
naked_nextBlockid = current_opid*"-"*nextopid; # nextBlockid without line
# some blocks do not exist on the starting op line and we find one that fits
if !haskey(BK, nextBlockid)
print_notifications && @info "\tBlock $nextBlockid not found on train $trainid";
Expand Down Expand Up @@ -204,7 +206,7 @@ function simulation(RN::Network, FL::Fleet, sim_id::Int=0)::Bool
end
end
end
delay_imposed = get(train.delay, nextBlockid,0);
delay_imposed = get(train.delay, naked_nextBlockid,0);

# here we will handle gains
# ....
Expand Down

0 comments on commit 4ef2215

Please sign in to comment.