Skip to content

Commit 308049b

Browse files
authored
Release/pr 0.5.0 (#20)
* extended documentation based on review. * renamed jps_gridmap_expansion_policy to jps_expansion_policy_base
1 parent d8ad8d8 commit 308049b

14 files changed

Lines changed: 970 additions & 936 deletions

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ Warthog is an optimised C++ library for pathfinding search.
44
Warthog-JPS is an extension to Warthog with JPS support.
55
See [warthog-core](https://github.com/ShortestPathLab/warthog-core) for more details on Warthog setup.
66

7+
@article{Harabor_Grastien_2014,
8+
title={Improving Jump Point Search},
9+
volume={24},
10+
url={https://ojs.aaai.org/index.php/ICAPS/article/view/13633},
11+
DOI={10.1609/icaps.v24i1.13633},
12+
number={1},
13+
journal={Proceedings of the International Conference on Automated Planning and Scheduling},
14+
author={Harabor, Daniel and Grastien, Alban},
15+
year={2014},
16+
pages={128-135}
17+
}
18+
719
# Using JPS
820

921
## Compile
@@ -17,8 +29,29 @@ cmake --build build
1729
./build/warthog-jps --alg jps --scen example.scen
1830
```
1931

32+
The example scenario `example.scen` is not a part of this repo.
33+
Get benchmark from places like MovingAI or pathfinding.ai found in the resource section.
34+
2035
JPS requires `warthog-core` repo to compile, and by default will fetch the repo.
2136

37+
## JPS Variants
38+
39+
JPS comes with several variants.
40+
All variants use block-based symmetry breaking for finding jump-point locations,
41+
making them at least JPS (B).
42+
These jump points are found in namespace `jps::jump`, while `jps::search` uses provided `jps::jump` locators
43+
to produce successors used in warthog-core.
44+
45+
The algorithms provided to `--alg` parameter, along with their `jps::search` and `jps::jump` classes presented
46+
in the table below:
47+
48+
| `--alg` | `jps::search` | `jps::jump` |
49+
|------------------------------------------------------------------------------|
50+
| `jps` | `jps_expansion_policy<>` | `jump_point_online` |
51+
| `jpsP` or `jps2` | `jps_prune_expansion_policy<>` | `jump_point_online` |
52+
| `jps+` | `jps_expansion_policy` | `jump_point_offline<>` |
53+
| `jpsP+` or `jps2+` | `jps_prune_expansion_policy<>` | `jump_point_offline<>` |
54+
2255
## Use in project
2356

2457
If elements of warthog is used in a project, follow guides from `warthog-core` to set up the project structure.

apps/jps.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ help(std::ostream& out)
6868
<< "Invoking the program this way solves all instances in [scen "
6969
"file] with algorithm [alg]\n"
7070
<< "Currently recognised values for [alg]:\n"
71-
<< "\tjps, jpsP, jpsP32, jps+, jpsP+\n";
71+
<< "\tjps, jpsP or jps2, jps+, jpsP+ or jps2+\n";
7272
// << ""
7373
// << "The following are valid parameters for GENERATING instances:\n"
7474
// << "\t --gen [map file (required)]\n"
@@ -246,25 +246,19 @@ main(int argc, char** argv)
246246
return run_jps<jps_expansion_policy<jump_point>>(
247247
scenmgr, mapfile, alg);
248248
}
249-
else if(alg == "jpsP")
249+
else if(alg == "jpsP" || alg == "jps2")
250250
{
251251
using jump_point = jps::jump::jump_point_online;
252252
return run_jps<jps_prune_expansion_policy<jump_point>>(
253253
scenmgr, mapfile, alg);
254254
}
255-
else if(alg == "jpsP32")
256-
{
257-
using jump_point = jps::jump::jump_point_online;
258-
return run_jps<jps_prune_expansion_policy<jump_point, 32, 64>>(
259-
scenmgr, mapfile, alg);
260-
}
261255
else if(alg == "jps+")
262256
{
263257
using jump_point = jps::jump::jump_point_offline<>;
264258
return run_jps<jps_expansion_policy<jump_point>>(
265259
scenmgr, mapfile, alg);
266260
}
267-
else if(alg == "jpsP+")
261+
else if(alg == "jpsP+" || alg == "jps2+")
268262
{
269263
using jump_point = jps::jump::jump_point_offline<>;
270264
return run_jps<jps_prune_expansion_policy<jump_point>>(

include/jps/domain/rotate_gridmap.h

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
#ifndef WARTHOG_DOMAIN_ROTATE_GRIDMAP_H
22
#define WARTHOG_DOMAIN_ROTATE_GRIDMAP_H
33

4-
// domain::gridmap.h
54
//
6-
// A uniform cost domain::gridmap implementation. The map is stored in
7-
// a compact matrix form. Nodes are represented as single bit quantities.
5+
// jps/domain/rotate_gridmap.h
6+
//
7+
// An extended domain of gridmap that uses 2 gridmaps, one rotated
8+
// for use in JPS block-based jump-point location.
9+
//
10+
// Class rotate_gridmap is the main implementation.
11+
// It supports pointing to a user-supplied gridmap and rotated gridmap,
12+
// or just a user provided gridmap, which it would generate and own the
13+
// rotated gridmap.
14+
//
15+
// Small copyable storage of these maps are provided in utility structs:
16+
// gridmap_rotate_ptr, gridmap_rotate_ptr_convs: 2 pointers to gridmap,
17+
// accessing the grid would require 2-level of indirects (gridmap->data[i])
18+
// gridmap_rotate_table, gridmap_rotate_table_convs: 2 gridmap::bitarray,
19+
// accessing the grid is only a single redirect
20+
// Use of these datatypes do not copy the tables themselves, and are quite
21+
// compact. The non _convs variants should be 2-pointer sized (16-bytes). The
22+
// _convs variants are supplied with width and height, allowing for x/y and
23+
// grid_id and rgrid_id conversions between the two grid (24-bytes).
24+
//
25+
// @author Ryan Hechenberger
26+
// @created 2025-11-20
827
//
928

1029
#include <array>
@@ -385,7 +404,8 @@ struct gridmap_rotate_ptr : std::array<domain::gridmap*, 2>
385404
}
386405
operator bool() const noexcept { return (*this)[0]; }
387406
};
388-
/// @brief a copy-by-value class pointing to grid/rgrid with conversions
407+
/// @brief a copy-by-value class pointing to grid/rgrid with id conversions
408+
/// functions
389409
struct gridmap_rotate_ptr_convs : gridmap_rotate_ptr,
390410
rgridmap_point_conversions
391411
{
@@ -429,7 +449,8 @@ struct gridmap_rotate_table : std::array<domain::gridmap::bitarray, 2>
429449
}
430450
operator bool() const noexcept { return (*this)[0].data(); }
431451
};
432-
/// @brief a copy-by-value class for fast access to grid/rgrid with conversions
452+
/// @brief a copy-by-value class for fast access to grid/rgrid with id
453+
/// conversions functions
433454
struct gridmap_rotate_table_convs : gridmap_rotate_table,
434455
rgridmap_point_conversions
435456
{
@@ -462,6 +483,14 @@ struct gridmap_rotate_table_convs : gridmap_rotate_table,
462483
}
463484
};
464485

486+
/// The main rotate gridmap class.
487+
/// Stores a pointer to a gridmap and rotated gridmap.
488+
/// The rotated gridmap memory may be created and owned by this class, or
489+
/// provided and controlled by the user.
490+
///
491+
/// Supports static_cast operations for all gridmap_rotate_(ptr|table)(_conv)?.
492+
/// They will act as valid small pointer classes (16-24 bytes) with various
493+
/// levels if indirection to the grid data.
465494
class rotate_gridmap : public rgridmap_point_conversions
466495
{
467496
private:
@@ -589,6 +618,12 @@ class rotate_gridmap : public rgridmap_point_conversions
589618
return gridmap_rotate_table_convs(
590619
*this, static_cast<rgridmap_point_conversions>(*this));
591620
}
621+
622+
size_t
623+
mem() const noexcept
624+
{
625+
return rmap_obj != nullptr ? rmap_obj->mem() : 0;
626+
}
592627
};
593628

594629
} // namespace warthog::grid

include/jps/forward.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
#ifndef JPS_FORWARD_H
22
#define JPS_FORWARD_H
33

4-
#include <vector>
4+
//
5+
// jps/forward.h
6+
//
7+
// Global namespace types include.
8+
//
9+
// @author Ryan Hechenberger
10+
// @created 2025-11-20
11+
//
12+
513
#include <warthog/constants.h>
614
#include <warthog/defines.h>
715
#include <warthog/domain/grid.h>
@@ -10,17 +18,14 @@
1018
namespace jps
1119
{
1220

13-
using namespace warthog::grid;
21+
using namespace ::warthog::grid;
1422
using ::warthog::pad_id;
1523
// using jps_id = grid_id;
1624
struct rmap_id_tag
1725
{ };
1826
using rgrid_id = warthog::identity_base<rmap_id_tag, grid_id::id_type>;
1927
using warthog::cost_t;
2028

21-
using vec_jps_id = std::vector<grid_id>;
22-
using vec_jps_cost = std::vector<cost_t>;
23-
2429
} // namespace jps
2530

2631
#include <jps/jump/jump.h>

0 commit comments

Comments
 (0)