Getting Started
Installation
To install CRCBS.jl, start up Julia and type the following code-snipped into the REPL.
julia> ] # enter package mode by typing "]"
(@v1.4) pkg> add https://github.com/kylejbrown17/CRCBS.jl.git
Example
To construct and solve a predefined multi agent path finding (MAPF) problem:
julia> using CRCBS
julia> solver = CBSSolver() # initialize a solver
CBSSolver{AStar{Float64}, Float64} low_level_planner: AStar{Float64} logger: SolverLogger{Float64}
julia> prob = init_mapf_1() # initialize the problem
MAPF{CRCBS.CBSEnv.LowLevelEnv{FullCostModel{typeof(sum), Float64, TravelTime}, PerfectHeuristic{CRCBS.var"#129#130"{Dict{Int64, Vector{Int64}}}}, GridFactoryEnvironment{MetaGraphs.MetaGraph{Int64, Float64}}, DiscreteConstraintTable}, CRCBS.CBSEnv.State, CRCBS.CBSEnv.State}(CRCBS.CBSEnv.LowLevelEnv{FullCostModel{typeof(sum), Float64, TravelTime}, PerfectHeuristic{CRCBS.var"#129#130"{Dict{Int64, Vector{Int64}}}}, GridFactoryEnvironment{MetaGraphs.MetaGraph{Int64, Float64}}, DiscreteConstraintTable} graph: GridFactoryEnvironment{MetaGraphs.MetaGraph{Int64, Float64}} goal: CRCBS.CBSEnv.State agent_idx: Int64 -1 constraints: DiscreteConstraintTable cost_model: FullCostModel{typeof(sum), Float64, TravelTime} heuristic: PerfectHeuristic{CRCBS.var"#129#130"{Dict{Int64, Vector{Int64}}}} , CRCBS.CBSEnv.State[CRCBS.CBSEnv.State(1, 0), CRCBS.CBSEnv.State(4, 0)], CRCBS.CBSEnv.State[CRCBS.CBSEnv.State(13, 0), CRCBS.CBSEnv.State(16, 0)])
julia> solution, cost = solve!(solver,prob) # solve it
(LowLevelSolution: T: 0 1 2 3 1: [1 5 9 13 ] 2: [4 8 12 16 ] , 6.0)
julia> optimal_status(solver) # check if the problem was solved optimally
true
If you want to build your own MAPF problem from scratch:
# copied from CRCBS/scripts/mapf_demo.jl
using CRCBS
## set up the environment
vtx_grid = initialize_dense_vtx_grid(4,4) # 4 x 4 grid world
# 1 2 3 4
# 5 6 7 8
# 9 10 11 12
# 13 14 15 16
env = construct_factory_env_from_vtx_grid(vtx_grid)
## Define the initial conditions of the robots
starts = [1,4]
goals = [13,16]
cost_model = FullCostModel(maximum,TravelTime())
prob = init_mapf_problem(env,starts,goals,cost_model)
## define solver
solver = CBSSolver() # PIBTPlanner()
# solve the problem
solution, cost = solve!(solver,prob)
# check if the problem was solved to optimality
@show feasible_status(solver)
@show optimal_status(solver)