Skip to content

Commit

Permalink
Merge pull request #21 from sisl/develop
Browse files Browse the repository at this point in the history
Merged develop with main. Integrating changes from Kyle and work already accomplished in master.
  • Loading branch information
dylan-asmar authored Jul 14, 2023
2 parents 467a5b5 + 944d227 commit 5baec89
Show file tree
Hide file tree
Showing 43 changed files with 5,414 additions and 1,377 deletions.
33 changes: 15 additions & 18 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
name = "TaskGraphs"
uuid = "6635cb54-791c-11e9-2805-8512ad3937f9"
authors = ["kylebrown <[email protected]>"]
version = "0.1.0"
authors = ["kylebrown <[email protected]> and collaborators"]
version = "0.2.0"

[deps]
Arpack_jll = "68821587-b530-5797-8361-c406ea357684"
CRCBS = "edef75b8-3ac4-11e9-0392-bf149c536ee3"
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
GraphUtils = "5d4bc1c0-0fb7-11e9-3252-b1aa07358cab"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
NBInclude = "0db19996-df87-5ea3-a455-e3a50d440464"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Arpack_jll = "68821587-b530-5797-8361-c406ea357684"
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
NBInclude = "0db19996-df87-5ea3-a455-e3a50d440464"
Plots= "91a5bcdd-55d7-5caf-9e0b-520d859cae80"


[compat]
CRCBS = "0.1"
Compose = "0.9"
DataFrames= "1.4"
DataFrames = "1.4"
GLPK = "1.1"
GraphUtils= "0.1"
ImageFiltering="0.7"
JuMP="1.0"
Graphs="1.7"
MathOptInterface= "1.8"
Parameters= "0.12"
Random= "1.5"
julia = "1"
Graphs = "1.7"
ImageFiltering = "0.7"
JLLWrappers = "1.2.0"
JuMP = "1.0"
MathOptInterface = "1.8"
Parameters = "0.12"
Random = "1.5"
julia = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{tabular}{l | l l l l l | l l l l l | l l l l l }
& \multicolumn{5}{c}{$M=30$} & \multicolumn{5}{c}{$M=25$} & \multicolumn{5}{c}{$M=20$} \\
$arrival_interval=40$ & 160.0 & 134.0 & \textbf{133.0} & 135.0 & 133.0 & & & & & & & & & & \\
$arrival_interval=30$ & 303.0 & \textbf{165.0} & 182.0 & 182.0 & 211.0 & 144.0 & 138.0 & 135.0 & \textbf{130.0} & 138.0 & & & & & \\
$arrival_interval=20$ & 461.0 & 303.0 & \textbf{257.0} & 265.0 & 361.0 & 270.0 & 204.0 & \textbf{181.0} & 210.0 & 265.0 & 146.0 & \textbf{131.0} & 134.0 & 135.0 & 189.0
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\begin{tabular}{l | l l l l l }
& \multicolumn{5}{c}{} \\
$M=30$,$arrival_interval=40$ & 160.0 & 134.0 & \textbf{133.0} & 135.0 & 133.0 \\
$M=30$,$arrival_interval=30$ & 303.0 & \textbf{165.0} & 182.0 & 182.0 & 211.0 \\
$M=30$,$arrival_interval=20$ & 461.0 & 303.0 & \textbf{257.0} & 265.0 & 361.0 \\
$M=25$,$arrival_interval=40$ & & & & & \\
$M=25$,$arrival_interval=30$ & 144.0 & 138.0 & 135.0 & \textbf{130.0} & 138.0 \\
$M=25$,$arrival_interval=20$ & 270.0 & 204.0 & \textbf{181.0} & 210.0 & 265.0 \\
$M=20$,$arrival_interval=40$ & & & & & \\
$M=20$,$arrival_interval=30$ & & & & & \\
$M=20$,$arrival_interval=20$ & 146.0 & \textbf{131.0} & 134.0 & 135.0 & 189.0
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{tabular}{l | l | l | l }
& \multicolumn{1}{c}{$M=30$} & \multicolumn{1}{c}{$M=25$} & \multicolumn{1}{c}{$M=20$} \\
$arrival_interval=40$ & 0.83 & & \\
$arrival_interval=30$ & 0.54 & 0.9 & \\
$arrival_interval=20$ & 0.56 & 0.67 & 0.9
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{tabular}{l | l l l l l | l l l l l | l l l l l }
& \multicolumn{5}{c}{$M=30$} & \multicolumn{5}{c}{$M=25$} & \multicolumn{5}{c}{$M=20$} \\
$arrival_interval=40$ & 1.08 & 1.03 & \textbf{1.03} & 1.05 & 1.03 & & & & & & & & & & \\
$arrival_interval=30$ & 1.39 & \textbf{1.11} & 1.27 & 1.19 & 1.2 & 1.07 & 1.07 & 1.08 & \textbf{1.03} & 1.05 & & & & & \\
$arrival_interval=20$ & 1.94 & 1.5 & 1.39 & \textbf{1.36} & 1.65 & 1.45 & 1.25 & \textbf{1.17} & 1.3 & 1.44 & 1.15 & \textbf{1.09} & 1.14 & 1.15 & 1.28
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\begin{tabular}{l | l l l l l }
& \multicolumn{5}{c}{} \\
$M=30$,$arrival_interval=40$ & 1.08 & 1.03 & \textbf{1.03} & 1.05 & 1.03 \\
$M=30$,$arrival_interval=30$ & 1.39 & \textbf{1.11} & 1.27 & 1.19 & 1.2 \\
$M=30$,$arrival_interval=20$ & 1.94 & 1.5 & 1.39 & \textbf{1.36} & 1.65 \\
$M=25$,$arrival_interval=40$ & & & & & \\
$M=25$,$arrival_interval=30$ & 1.07 & 1.07 & 1.08 & \textbf{1.03} & 1.05 \\
$M=25$,$arrival_interval=20$ & 1.45 & 1.25 & \textbf{1.17} & 1.3 & 1.44 \\
$M=20$,$arrival_interval=40$ & & & & & \\
$M=20$,$arrival_interval=30$ & & & & & \\
$M=20$,$arrival_interval=20$ & 1.15 & \textbf{1.09} & 1.14 & 1.15 & 1.28
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{tabular}{l | l | l | l }
& \multicolumn{1}{c}{$M=30$} & \multicolumn{1}{c}{$M=25$} & \multicolumn{1}{c}{$M=20$} \\
$arrival_interval=40$ & 0.96 & & \\
$arrival_interval=30$ & 0.8 & 0.97 & \\
$arrival_interval=20$ & 0.7 & 0.81 & 0.95
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{tabular}{l | l l l l l | l l l l l | l l l l l }
& \multicolumn{5}{c}{$M=30$} & \multicolumn{5}{c}{$M=25$} & \multicolumn{5}{c}{$M=20$} \\
$arrival_interval=40$ & \textbf{0.0} & 0.0 & \textbf{0.0} & 0.01 & \textbf{0.0} & & & & & & & & & & \\
$arrival_interval=30$ & \textbf{0.0} & \textbf{0.0} & 0.03 & 0.09 & \textbf{0.0} & \textbf{0.0} & 0.0 & 0.01 & \textbf{0.0} & \textbf{0.0} & & & & & \\
$arrival_interval=20$ & \textbf{0.0} & \textbf{0.0} & 0.0 & 0.05 & 0.0 & \textbf{0.0} & 0.0 & 0.01 & 0.1 & 0.0 & \textbf{0.0} & 0.0 & 0.02 & 0.02 & 0.01
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\begin{tabular}{l | l l l l l }
& \multicolumn{5}{c}{} \\
$M=30$,$arrival_interval=40$ & \textbf{0.0} & 0.0 & \textbf{0.0} & 0.01 & \textbf{0.0} \\
$M=30$,$arrival_interval=30$ & \textbf{0.0} & \textbf{0.0} & 0.03 & 0.09 & \textbf{0.0} \\
$M=30$,$arrival_interval=20$ & \textbf{0.0} & \textbf{0.0} & 0.0 & 0.05 & 0.0 \\
$M=25$,$arrival_interval=40$ & & & & & \\
$M=25$,$arrival_interval=30$ & \textbf{0.0} & 0.0 & 0.01 & \textbf{0.0} & \textbf{0.0} \\
$M=25$,$arrival_interval=20$ & \textbf{0.0} & 0.0 & 0.01 & 0.1 & 0.0 \\
$M=20$,$arrival_interval=40$ & & & & & \\
$M=20$,$arrival_interval=30$ & & & & & \\
$M=20$,$arrival_interval=20$ & \textbf{0.0} & 0.0 & 0.02 & 0.02 & 0.01
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{tabular}{l | l | l | l }
& \multicolumn{1}{c}{$M=30$} & \multicolumn{1}{c}{$M=25$} & \multicolumn{1}{c}{$M=20$} \\
$arrival_interval=40$ & 0.0 & & \\
$arrival_interval=30$ & 0.0 & 0.0 & \\
$arrival_interval=20$ & 0.0 & 0.0 & 0.0
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{tabular}{l | l l l l l | l l l l l | l l l l l }
& \multicolumn{5}{c}{$M=30$} & \multicolumn{5}{c}{$M=25$} & \multicolumn{5}{c}{$M=20$} \\
$arrival_interval=40$ & 38.9 & 40.4 & \textbf{40.6} & 39.9 & 40.6 & & & & & & & & & & \\
$arrival_interval=30$ & 38.9 & \textbf{48.8} & 43.9 & 45.6 & 45.0 & 42.8 & 43.0 & 42.5 & \textbf{44.1} & 43.4 & & & & & \\
$arrival_interval=20$ & 39.1 & 50.4 & 54.6 & \textbf{55.7} & 45.9 & 44.1 & 50.9 & \textbf{54.4} & 49.6 & 44.3 & 45.7 & \textbf{48.2} & 46.5 & 46.2 & 41.4
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\begin{tabular}{l | l l l l l }
& \multicolumn{5}{c}{} \\
$M=30$,$arrival_interval=40$ & 38.9 & 40.4 & \textbf{40.6} & 39.9 & 40.6 \\
$M=30$,$arrival_interval=30$ & 38.9 & \textbf{48.8} & 43.9 & 45.6 & 45.0 \\
$M=30$,$arrival_interval=20$ & 39.1 & 50.4 & 54.6 & \textbf{55.7} & 45.9 \\
$M=25$,$arrival_interval=40$ & & & & & \\
$M=25$,$arrival_interval=30$ & 42.8 & 43.0 & 42.5 & \textbf{44.1} & 43.4 \\
$M=25$,$arrival_interval=20$ & 44.1 & 50.9 & \textbf{54.4} & 49.6 & 44.3 \\
$M=20$,$arrival_interval=40$ & & & & & \\
$M=20$,$arrival_interval=30$ & & & & & \\
$M=20$,$arrival_interval=20$ & 45.7 & \textbf{48.2} & 46.5 & 46.2 & 41.4
\end{tabular}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{tabular}{l | l | l | l }
& \multicolumn{1}{c}{$M=30$} & \multicolumn{1}{c}{$M=25$} & \multicolumn{1}{c}{$M=20$} \\
$arrival_interval=40$ & 0.96 & & \\
$arrival_interval=30$ & 0.8 & 0.97 & \\
$arrival_interval=20$ & 0.7 & 0.81 & 0.95
\end{tabular}
2 changes: 1 addition & 1 deletion src/TaskGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ include("utils.jl")
include("task_assignment_solvers.jl")
include("path_planning.jl")
include("pc_tapf_solvers.jl")
include("milp_formulation.jl")
include("edge_milp_formulation.jl")
include("disturbances.jl")
include("path_planners/pibt_planner.jl")
include("replanning.jl")
Expand Down
124 changes: 73 additions & 51 deletions src/disturbances.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,42 +108,38 @@ end

export handle_disturbance!

function remove_vtxs(sched,remove_set::Set{A}) where {A<:AbstractID}
remove_vtxs(sched,Set{Int}(get_vtx(sched,id) for id in remove_set))
end
# function remove_vtxs(sched,remove_set::Set{A}) where {A<:AbstractID}
# remove_vtxs(sched,Set{Int}(get_vtx(sched,id) for id in remove_set))
# end
function remove_vtxs!(sched,remove_set)
new_sched = sched
rem_nodes!(new_sched,remove_set)
set_leaf_operation_vtxs!(new_sched)
process_schedule!(new_sched)
new_sched
end
function remove_vtxs(sched,remove_set)
# Construct new graph
# new_sched = sched
# rem_nodes!(new_sched,remove_set)
# set_leaf_operation_vtxs!(new_sched)
# process_schedule!(new_sched)

new_sched = OperatingSchedule()
keep_vtxs = setdiff(Set{Int}(collect(vertices(sched))), remove_set)
# add all non-deleted nodes to new project schedule
for v in keep_vtxs
# node_id = get_vtx_id(sched,v)
# node = get_node_from_id(sched, node_id)
# path_spec = get_path_spec(sched,v)
# add_to_schedule!(new_sched,path_spec,node,node_id)
add_to_schedule!(new_sched,get_node(sched,v))
end
# add all edges between nodes that still exist
for e in edges(get_graph(sched))
add_edge!(new_sched, get_vtx_id(sched, e.src), get_vtx_id(sched, e.dst))
end
set_leaf_operation_vtxs!(new_sched)
process_schedule!(new_sched)
# @assert sanity_check(new_sched)
new_sched
end
# function remove_vtxs(sched,remove_set)
# # Construct new graph
# # new_sched = sched
# # rem_nodes!(new_sched,remove_set)
# # set_leaf_operation_vtxs!(new_sched)
# # process_schedule!(new_sched)

# new_sched = OperatingSchedule()
# keep_vtxs = setdiff(Set{Int}(collect(vertices(sched))), remove_set)
# # add all non-deleted nodes to new project schedule
# for v in keep_vtxs
# add_node!(new_sched,get_node(sched,v))
# end
# # add all edges between nodes that still exist
# for e in edges(get_graph(sched))
# add_edge!(new_sched, get_vtx_id(sched, e.src), get_vtx_id(sched, e.dst))
# end
# set_leaf_operation_vtxs!(new_sched)
# process_schedule!(new_sched)
# # @assert sanity_check(new_sched)
# new_sched
# end

"""
get_delivery_task_vtxs(sched::OperatingSchedule,o::ObjectID)
Expand Down Expand Up @@ -243,22 +239,21 @@ function handle_disturbance!(solver,prob,env::SearchEnv,d::DroppedObject,t,
# Add GO->GO edges for affected robot(s), as if they were never assigned
stitch_disjoint_node_sets!(sched,incoming,outgoing,env_state)
# remove old nodes
new_sched = remove_vtxs(sched,vtxs)
# new_sched = remove_vtxs!(sched,vtxs)
remove_vtxs!(sched,vtxs)
# add new CleanUpBot task nodes
x = get_location_ids(object_position(env_state,o))
replace_in_schedule!(new_sched,OBJECT_AT(o,x),o)
set_t0!(new_sched,o,t)
replace_in_schedule!(sched,OBJECT_AT(o,x),o)
set_t0!(sched,o,t)
add_headless_delivery_task!(
new_sched,get_problem_spec(env,:CleanUpBot),o,op.id,CleanUpBot;
sched,get_problem_spec(env,:CleanUpBot),o,op.id,CleanUpBot;
t0=t
)
process_schedule!(new_sched)
process_schedule!(sched)
construct_search_env(
solver,
new_sched,
sched,
env,
initialize_planning_cache(new_sched)
initialize_planning_cache(sched)
)
end

Expand Down Expand Up @@ -299,12 +294,12 @@ function add_headless_cleanup_task!(
)

robot_id = CleanUpBotID(-1)
action_id = get_unique_action_id()
action_id = get_unique_id(ActionID)
add_to_sched!(sched, spec, CLEAN_UP(robot_id, d.vtxs), action_id)
set_t0!(sched,action_id,t0)

prev_action_id = action_id
action_id = get_unique_action_id()
action_id = get_unique_id(ActionID)
add_to_sched!(sched, spec, CUB_GO(robot_id, d.vtxs[1], return_vtx), action_id)
set_t0!(sched,action_id,t0)
add_edge!(sched, prev_action_id, action_id)
Expand All @@ -319,25 +314,31 @@ function remove_robot!(env::SearchEnv,id::BotID,t::Int)
to_remove = Set{AbstractID}(id)
v = get_vtx(sched,id)
for vp in edges(bfs_tree(G,v))
node_id = get_vtx_id(sched,vp)
if isa(node_id,ActionID)
node = get_node_from_id(sched,node_id)
if isa(node,BOT_GO)
push!(to_remove,node_id)
node = get_node(sched,vp)
# n_id = get_vtx_id(sched,vp)
# if isa(n_id,ActionID)
if matches_template(AbstractRobotAction,node)
# node = get_node_from_id(sched,n_id)
# if isa(node,BOT_GO)
if matches_template(BOT_GO,node)
# push!(to_remove,n_id)
push!(to_remove,node_id(node))
else
new_node = replace_robot_id(node,-1)
replace_in_schedule!(sched,get_problem_spec(env),new_node,node_id)
# new_node = replace_robot_id(node,-1)
replace_in_schedule!(sched,get_problem_spec(env),new_node,n_id)
new_node = replace_robot_id(node.node,-1)
replace_in_schedule!(sched,get_problem_spec(env),new_node,node_id(node))
end
end
end
for node_id in to_remove
delete_node!(sched,node_id)
for n_id in to_remove
delete_node!(sched,n_id)
end
# Verify that the robot is no longer in schedule
for v in vertices(G)
node_id = get_vtx_id(sched,v)
if isa(node_id,ActionID)
node = get_node_from_id(sched,node_id)
n_id = get_vtx_id(sched,v)
if isa(n_id,ActionID)
node = get_node_from_id(sched,n_id)
@assert !(get_id(id) in get_valid_robot_ids(node)) "Robot id $(string(id)) should be wiped from schedule, but is present in $(string(node))"
end
end
Expand All @@ -346,3 +347,24 @@ function remove_robot!(env::SearchEnv,id::BotID,t::Int)
# set assignment ids to -1 with replace_robot_id()
# if in the middle of CARRY, another robot needs to get the object
end

# Simulation

# select_action(robot,env_state,t) = get_a(get_path_node(robot.path,Int(round(t))))

function step_simulation!(env_state,robots,base_station;
dt::Float64=1.0,
)
actions = []
for robot in robots
# robots receive instructions from base station
# robots observe environment
# robots communicate to base station
# robots choose actions
# push!(actions,)
end

# environment steps forward

# base station updates global map
end
Loading

0 comments on commit 5baec89

Please sign in to comment.