Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
548fd17
create stream_listener
heavenfall Aug 6, 2025
0af8334
added listener functionality
heavenfall Aug 6, 2025
1524765
trace for grid
heavenfall Aug 7, 2025
e6c0f88
trace for grid
heavenfall Aug 7, 2025
f81c8ad
rename listener to observer
heavenfall Sep 5, 2025
d439de1
rename src observers
heavenfall Sep 5, 2025
8232fdd
listener renamed to observer
heavenfall Sep 11, 2025
0c755f7
added first part of log
heavenfall Sep 11, 2025
7660b0d
log in debug phase
heavenfall Sep 12, 2025
7a3fb87
global logger works with uds
heavenfall Sep 18, 2025
8dd72e4
update time to local time
heavenfall Sep 18, 2025
7eb6f45
update log interface
heavenfall Sep 30, 2025
798de27
ported to new logger
heavenfall Oct 1, 2025
47bf302
added logger comments
heavenfall Oct 3, 2025
ecfc59d
update posthoc trace with comments and trace rendering; added support…
heavenfall Oct 3, 2025
10bdd85
added expanded verbose message
heavenfall Oct 3, 2025
904dfb2
missing commit
heavenfall Oct 3, 2025
141532f
removed accidental file from git
heavenfall Oct 5, 2025
885ac31
auto clang-format action
github-actions[bot] Oct 17, 2025
26b88d9
added CONTRIB file
heavenfall Mar 5, 2026
4ed865d
update trace src filenames
heavenfall Mar 6, 2026
29c643a
observer documentation and overhaul, posthoc_trace updated
heavenfall Mar 8, 2026
6f2a957
pull changes from jps in presenting output
heavenfall Mar 10, 2026
2af67c6
revert dominated check
heavenfall Mar 12, 2026
29fc066
updated logging description at high level
heavenfall Mar 12, 2026
a131c6c
auto clang-format action
github-actions[bot] Mar 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ set_property(GLOBAL PROPERTY WARTHOG_warthog-core ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

option(WARTHOG_POSTHOC "Compile trace support generation for posthoc" OFF)
option(WARTHOG_INT128 "Enable support for __int128 on gcc and clang" OFF)
option(WARTHOG_BMI "Enable support cpu BMI for WARTHOG_INTRIN_HAS(BMI)" OFF)
option(WARTHOG_BMI2 "Enable support cpu BMI2 for WARTHOG_INTRIN_HAS(BMI2), use for Zen 3+" OFF)
option(WARTHOG_INTRIN_ALL "Enable march=native and support x86 intrinsics if able (based on system), supersedes all manual instruction sets" OFF)

find_package(Threads REQUIRED)

include(cmake/warthog.cmake)

add_library(warthog_compile INTERFACE)
Expand All @@ -30,7 +33,7 @@ target_include_directories(warthog_core PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(warthog_core PUBLIC warthog::compile)
target_link_libraries(warthog_core PUBLIC warthog::compile Threads::Threads)
include(cmake/headers.cmake)

add_executable(warthog_app)
Expand Down
18 changes: 18 additions & 0 deletions CONTRIB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Contributors to the Warthog Pathfinding Library
===============================================

Maintainers
-----------

Daniel Harabor @dharabor <Daniel.Harabor@monash.edu>
Ryan Hechenberger @heavenfall <Ryan.Hechenberger@monash.edu>

Contributors
------------

Arthur Maheo
Shizhe Zhao
Saman Ahmadi
Mark Carlson <Mark.Carlson@monash.edu>
Thomas Nobes <thomas.nobes@monash.edu>
Massimo Bono
2 changes: 1 addition & 1 deletion apps/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ warthog::util::cfg::parse_args(
std::string
warthog::util::cfg::get_param_value(std::string param_name)
{
std::string ret("");
std::string ret;
std::map<std::string, std::vector<std::string>>::iterator it
= params_.find(param_name);
if(it != params_.end())
Expand Down
2 changes: 1 addition & 1 deletion apps/cfg.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef WARTHOG_APP_CFG_H
#define WARTHOG_APP_CFG_H

#include "getopt.h"
#include <getopt.h>

#include <cstdint>
#include <iostream>
Expand Down
133 changes: 95 additions & 38 deletions apps/warthog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <warthog/util/pqueue.h>
#include <warthog/util/scenario_manager.h>
#include <warthog/util/timer.h>
#ifdef WARTHOG_POSTHOC
#include <warthog/io/grid_trace.h>
#endif

#include "cfg.h"
#include <getopt.h>
Expand All @@ -30,6 +33,7 @@
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <memory>
#include <sstream>
#include <unordered_map>
Expand All @@ -44,6 +48,16 @@ int checkopt = 0;
int verbose = 0;
// display program help on startup
int print_help = 0;
// run only this query, or -1 for all
int filter_id = -1;
#ifdef WARTHOG_POSTHOC
// write trace to file, empty string to disable
std::string trace_file;
using listener_grid = ::warthog::io::grid_trace;
using listener_type = std::tuple<listener_grid>;
#else
using listener_type = std::tuple<>;
#endif

void
help(std::ostream& out)
Expand All @@ -66,6 +80,11 @@ help(std::ostream& out)
"values in the scen file)\n"
<< "\t--verbose (optional; prints debugging info when compiled "
"with debug symbols)\n"
<< "\t--filter [id] (optional; run only query [id])\n"
#ifdef WARTHOG_POSTHOC
<< "\t--trace [.trace.yaml file] (optional; write posthoc trace for "
"first query to [file])\n"
#endif
<< "Invoking the program this way solves all instances in [scen "
"file] with algorithm [alg]\n"
<< "Currently recognised values for [alg]:\n"
Expand Down Expand Up @@ -104,21 +123,49 @@ check_optimality(
return true;
}

#ifdef WARTHOG_POSTHOC
#define WARTHOG_POSTHOC_DO(f) f
#else
#define WARTHOG_POSTHOC_DO(f)
#endif

template<typename Search>
int
run_experiments(
Search& algo, std::string alg_name,
warthog::util::scenario_manager& scenmgr, bool verbose, bool checkopt,
std::ostream& out)
{
WARTHOG_GINFO_FMT("start search with algorithm {}", alg_name);
warthog::search::search_parameters par;
warthog::search::solution sol;
auto* expander = algo.get_expander();
if(expander == nullptr) return 1;

out << "id\talg\texpanded\tgenerated\treopen\tsurplus\theapops"
<< "\tnanos\tplen\tpcost\tscost\tmap\n";
for(unsigned int i = 0; i < scenmgr.num_experiments(); i++)
for(uint32_t i = filter_id >= 0 ? static_cast<uint32_t>(filter_id) : 0,
ie = filter_id >= 0
? i + 1
: static_cast<uint32_t>(scenmgr.num_experiments());
i < ie; i++)
{
#ifdef WARTHOG_POSTHOC
std::optional<std::ofstream>
trace_stream; // open and pass to trace if used
if constexpr(std::same_as<
listener_type,
std::remove_cvref_t<decltype(algo.get_listeners())>>)
{
if(i == filter_id && !trace_file.empty())
{
listener_grid& l
= std::get<listener_grid>(algo.get_listeners());
trace_stream.emplace(trace_file);
l.open(*trace_stream);
}
}
#endif
warthog::util::experiment* exp = scenmgr.get_experiment(i);

warthog::pack_id startid
Expand All @@ -130,21 +177,40 @@ run_experiments(

algo.get_path(&pi, &par, &sol);

#ifdef WARTHOG_POSTHOC
if constexpr(std::same_as<
listener_type,
std::remove_cvref_t<decltype(algo.get_listeners())>>)
{
if(trace_stream.has_value())
{
// close
std::get<listener_grid>(algo.get_listeners()).close();
}
}
#endif

out << i << "\t" << alg_name << "\t" << sol.met_.nodes_expanded_
<< "\t" << sol.met_.nodes_generated_ << "\t"
<< sol.met_.nodes_reopen_ << "\t" << sol.met_.nodes_surplus_
<< "\t" << sol.met_.heap_ops_ << "\t"
<< sol.met_.time_elapsed_nano_.count() << "\t"
<< (sol.path_.size() - 1) << "\t" << sol.sum_of_edge_costs_ << "\t"
<< exp->distance() << "\t" << scenmgr.last_file_loaded()
<< std::endl;
<< (!sol.path_.empty() ? sol.path_.size() - 1 : 0) << "\t"
<< sol.sum_of_edge_costs_ << "\t" << exp->distance() << "\t"
<< scenmgr.last_file_loaded() << std::endl;

if(checkopt)
{
if(!check_optimality(sol, exp)) return 4;
if(!check_optimality(sol, exp))
{
WARTHOG_GCRIT("search error: failed suboptimal 4");
return 4;
}
}
}

WARTHOG_GINFO_FMT(
"search complete; total memory: {}", algo.mem() + scenmgr.mem());
return 0;
}

Expand All @@ -158,17 +224,12 @@ run_astar(
warthog::heuristic::octile_heuristic heuristic(map.width(), map.height());
warthog::util::pqueue_min open;

warthog::search::unidirectional_search astar(&heuristic, &expander, &open);
warthog::search::unidirectional_search astar(
&heuristic, &expander, &open, listener_type(WARTHOG_POSTHOC_DO(&map)));

int ret = run_experiments(
astar, alg_name, scenmgr, verbose, checkopt, std::cout);
if(ret != 0)
{
std::cerr << "run_experiments error code " << ret << std::endl;
return ret;
}
std::cerr << "done. total memory: " << astar.mem() + scenmgr.mem() << "\n";
return 0;
return ret;
}

int
Expand All @@ -182,17 +243,12 @@ run_astar4c(
map.width(), map.height());
warthog::util::pqueue_min open;

warthog::search::unidirectional_search astar(&heuristic, &expander, &open);
warthog::search::unidirectional_search astar(
&heuristic, &expander, &open, listener_type(WARTHOG_POSTHOC_DO(&map)));

int ret = run_experiments(
astar, alg_name, scenmgr, verbose, checkopt, std::cout);
if(ret != 0)
{
std::cerr << "run_experiments error code " << ret << std::endl;
return ret;
}
std::cerr << "done. total memory: " << astar.mem() + scenmgr.mem() << "\n";
return 0;
return ret;
}

int
Expand All @@ -205,17 +261,12 @@ run_dijkstra(
warthog::heuristic::zero_heuristic heuristic;
warthog::util::pqueue_min open;

warthog::search::unidirectional_search astar(&heuristic, &expander, &open);
warthog::search::unidirectional_search astar(
&heuristic, &expander, &open, listener_type(WARTHOG_POSTHOC_DO(&map)));

int ret = run_experiments(
astar, alg_name, scenmgr, verbose, checkopt, std::cout);
if(ret != 0)
{
std::cerr << "run_experiments error code " << ret << std::endl;
return ret;
}
std::cerr << "done. total memory: " << astar.mem() + scenmgr.mem() << "\n";
return 0;
return ret;
}

int
Expand All @@ -242,13 +293,7 @@ run_wgm_astar(

int ret = run_experiments(
astar, alg_name, scenmgr, verbose, checkopt, std::cout);
if(ret != 0)
{
std::cerr << "run_experiments error code " << ret << std::endl;
return ret;
}
std::cerr << "done. total memory: " << astar.mem() + scenmgr.mem() << "\n";
return 0;
return ret;
}

} // namespace
Expand All @@ -258,13 +303,17 @@ main(int argc, char** argv)
{
// parse arguments
warthog::util::param valid_args[]
= {{"alg", required_argument, 0, 1},
= {{"alg", required_argument, 0, 0},
{"scen", required_argument, 0, 0},
{"map", required_argument, 0, 1},
{"map", required_argument, 0, 0},
// {"gen", required_argument, 0, 3},
{"help", no_argument, &print_help, 1},
{"checkopt", no_argument, &checkopt, 1},
{"verbose", no_argument, &verbose, 1},
{"filter", required_argument, &filter_id, 1},
#ifdef WARTHOG_POSTHOC
{"trace", required_argument, 0, 0},
#endif
{"costs", required_argument, 0, 1},
{0, 0, 0, 0}};

Expand All @@ -283,6 +332,14 @@ main(int argc, char** argv)
std::string mapfile = cfg.get_param_value("map");
std::string costfile = cfg.get_param_value("costs");

if(filter_id == 1)
{
filter_id = std::stoi(cfg.get_param_value("filter"));
}
#ifdef WARTHOG_POSTHOC
trace_file = cfg.get_param_value("trace");
#endif

// if(gen != "")
// {
// warthog::util::scenario_manager sm;
Expand Down
1 change: 1 addition & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define WARTHOG_VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@
#define WARTHOG_VERSION_REVISON @CMAKE_PROJECT_VERSION_PATCH@

#cmakedefine WARTHOG_POSTHOC
#cmakedefine WARTHOG_INT128
#cmakedefine WARTHOG_INTRIN_ALL
#cmakedefine WARTHOG_BMI
Expand Down
2 changes: 1 addition & 1 deletion cmake/headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include/warthog/heuristic/octile_heuristic.h
include/warthog/heuristic/zero_heuristic.h

include/warthog/io/grid.h
include/warthog/io/log.h

include/warthog/memory/arraylist.h
include/warthog/memory/bittable.h
Expand Down Expand Up @@ -56,7 +57,6 @@ include/warthog/util/file_utils.h
include/warthog/util/gm_parser.h
include/warthog/util/helpers.h
include/warthog/util/intrin.h
include/warthog/util/log.h
include/warthog/util/macros.h
include/warthog/util/pqueue.h
include/warthog/util/scenario_manager.h
Expand Down
Loading