diff --git a/example_map/delays_wt1reldelta1/dispatcher.jl b/example_map/delays_wt1reldelta1/dispatcher.jl new file mode 100644 index 0000000000000000000000000000000000000000..591442a79ec21fc699e1bdc501a82e6a06ac6ba2 --- /dev/null +++ b/example_map/delays_wt1reldelta1/dispatcher.jl @@ -0,0 +1,7 @@ +max_waiting_time=t0 +max_relative_detour=1.0 + +dispatcher=(; + cost=:trajectory_length, + rejection_criterion=((:any_relative_detour,max_relative_detour),) + ) diff --git a/example_map/map/map.jl b/example_map/map/map.jl new file mode 100644 index 0000000000000000000000000000000000000000..023c353794707806816ebdf1b9ff156acc7a16ea --- /dev/null +++ b/example_map/map/map.jl @@ -0,0 +1,9 @@ +map_specs=(:star_grid_map,(64,16)) +#t0=readdlm(map_folder*"timescale.txt")[1] + +#map +speed_dict=Dict(1=>3.6) +mymap=RP.get_map(map_specs) +RM=RP.get_route_matrix(map_folder) +using DelimitedFiles +t0=readdlm(map_folder*"timescale.txt")[1] diff --git a/example_map/map/route_matrix b/example_map/map/route_matrix new file mode 100644 index 0000000000000000000000000000000000000000..b590c68ad786897b728e9b4d91160db7eb8d98fa Binary files /dev/null and b/example_map/map/route_matrix differ diff --git a/example_map/map/timescale.txt b/example_map/map/timescale.txt new file mode 100644 index 0000000000000000000000000000000000000000..bcf95bcf36864c90155098a098f4a645351df836 --- /dev/null +++ b/example_map/map/timescale.txt @@ -0,0 +1 @@ +45.339190347724944 diff --git a/sim_functions.jl b/sim_functions.jl new file mode 100644 index 0000000000000000000000000000000000000000..4fce8e85a3ecffb8a9d266ad924897d5c98a4f5f --- /dev/null +++ b/sim_functions.jl @@ -0,0 +1,59 @@ +export data_functions, save_path, getValues +import Pkg +Pkg.activate(".") + +using DataFrames +using DelimitedFiles + + + +# Dict of the functions used for evaluation +# QUESTION Calculate Variance for all of these? +data_type_functions = Dict( + :served_percentage => RP.served_percentage, + :driven_distance => RP.driven_distance, + :requested_distance => RP.requested_distance, + :mean_relative_delay => RP.mean_relative_delay, + # :mean_occupancy => RP.mean_occupancy, #BUG In Reading TUples from a CSV File +) + + + +""" + Converts a given index to a 2D Matrix Index with the given Matrix size +""" +function getValue(index, xmin, xmax, xlen, ymin, ymax, ylen) + xstep = (xmax-xmin)/xlen + ystep = (ymax-ymin)/ylen + + + x = (index%xlen) * xstep + xmin + y = trunc(Int64, index/ylen) * ystep + ymin + return x,y +end + + +""" + Function for Running a RidePooling simulation with the normalized Frequency x +""" +function simulate_rp(paths::Dict, N::Int64, x, y, t0::Float64, specs; served = 10*N, requested=10*N) + + #Make Model + model=RP.get_model(;N_bus=N,ν=x/t0,specs...); + RP.run!(model;requested=requested, served=served) + data = Dict() + data[:frequency] = x + data[:dt_latest_dropoff] = y + for (name, func) in data_type_functions + data[name] = func(model) + end + + # Save the calculated Data + data = DataFrame(data) + + open(paths[:data]*"$index.csv", "w") do io + writedlm(io, Iterators.flatten(([names(data)], eachrow(data))), ';') + end + #Save the model for possible later reference + RP.savemodel(paths[:model]*"$index.model",model;route_matrix=false) +end