Skip to content

Commit

Permalink
Feature astar (#7)
Browse files Browse the repository at this point in the history
* file updater tool with example files

* Ported warthog over, some bugs

* added deduction guide

* added coordinate features, assertion error

* fixed warthog version config file

* fixing id bug

* refactor sn_id_t to pack_id and pad_id

* added submodule include function

* convertion between identity integer types

* added MIT license

* Remove experiment generator from file

* updated timer new std::chrono
  • Loading branch information
heavenfall authored Oct 11, 2024
1 parent b05ae7b commit 0fa6665
Show file tree
Hide file tree
Showing 74 changed files with 8,042 additions and 6 deletions.
8 changes: 5 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@
Language: Cpp
Standard: c++11
BasedOnStyle: GNU
AccessModifierOffset: -2
AccessModifierOffset: -4
PointerAlignment: Left
UseTab: ForIndentation
IndentWidth: 4
TabWidth: 4
Cpp11BracedListStyle: true
AlwaysBreakTemplateDeclarations: Yes
AlwaysBreakAfterReturnType: All
AlignAfterOpenBracket: AlwaysBreak
SpaceInEmptyBlock: true
SpaceBeforeParens: Never
SpaceAfterTemplateKeyword: false
AllowShortBlocksOnASingleLine: Always
AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortFunctionsOnASingleLine: All
AllowShortFunctionsOnASingleLine: Inline
AlignOperands: false
BreakBeforeBraces: Custom
BraceWrapping:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.backup
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.13)

project(Warthog
VERSION 0.1.0
LANGUAGE CXX C)
LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

include(cmake/submodule.cmake)

add_library(warthog_core)
add_library(warthog::core ALIAS warthog_core)
target_include_directories(warthog_core PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
include(cmake/headers.cmake)

add_executable(warthog_app)
add_executable(warthog::warthog ALIAS warthog_app)
set_target_properties(warthog_app PROPERTIES OUTPUT_NAME "warthog")
target_link_libraries(warthog_app PUBLIC warthog::core)

add_subdirectory(src)
add_subdirectory(apps)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Shortest Path Lab @ Monash University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Warthog is an optimised C++ library for pathfinding search. It is developed and maintained by Daniel Harabor and contributors in the Shortest Path Lab. If you are interested in obtaining a copy, please visit the project homepage at:
This is an in-development version for the new Warthog.

Warthog is an optimised C++ library for pathfinding search. It is developed and maintained by Daniel Harabor and
contributors in the Shortest Path Lab. If you are interested in obtaining a copy, please visit the project homepage at:
https://bitbucket.org/dharabor/pathfinding/
8 changes: 8 additions & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.13)

# find_package(Getopt)

configure_file(config.h.in config.h @ONLY)
target_sources(warthog_app PRIVATE warthog.cpp cfg.cpp)
target_sources(warthog_app PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/config.h cfg.h)
target_include_directories(warthog_app PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
94 changes: 94 additions & 0 deletions apps/cfg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include "cfg.h"

warthog::util::cfg::cfg() { }

warthog::util::cfg::~cfg() { }

void
warthog::util::cfg::parse_args(
int argc, char** argv, warthog::util::param params[])
{
parse_args(argc, argv, "", params);
}

void
warthog::util::cfg::parse_args(
int argc, char** argv, const char* options, warthog::util::param params[])
{
int current_opt;
for(int c = getopt_long(argc, argv, options, params, &current_opt);
c != -1; c = getopt_long(argc, argv, options, params, &current_opt))
{
if(c == '?') break;
if(params[current_opt].has_arg == 0)
{
params_[params[current_opt].name].push_back("1");
}
if(!(optarg == 0))
{
params_[params[current_opt].name].push_back(optarg);
for(int index = optind; index < argc && *argv[index] != '-';
index++)
{
params_[params[current_opt].name].push_back(argv[index]);
}
}
}
}

std::string
warthog::util::cfg::get_param_value(std::string param_name)
{
std::string ret("");
std::map<std::string, std::vector<std::string>>::iterator it
= params_.find(param_name);
if(it != params_.end())
{
if((*it).second.size() > 0)
{
ret = (*it).second.front();
(*it).second.erase((*it).second.begin());
}
}
return ret;
}

uint32_t
warthog::util::cfg::get_num_values(std::string param_name)
{
uint32_t ret = 0;
std::map<std::string, std::vector<std::string>>::iterator it
= params_.find(param_name);
if(it != params_.end()) { ret = (uint32_t)(*it).second.size(); }
return ret;
}

void
warthog::util::cfg::print(std::ostream& out)
{
out << "cfg\n";
for(std::map<std::string, std::vector<std::string>>::iterator it
= params_.begin();
it != params_.end(); it++)
{
out << (*it).first << "=";
for(uint32_t i = 0; i < (*it).second.size(); i++)
{
out << (*it).second.at(i);
}
}
}

void
warthog::util::cfg::print_values(const std::string& option, std::ostream& out)
{
std::map<std::string, std::vector<std::string>>::iterator it
= params_.find(option);
if(it != params_.end())
{
for(uint32_t i = 0; i < (*it).second.size(); i++)
{
out << " " << (*it).second.at(i);
}
}
}
62 changes: 62 additions & 0 deletions apps/cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifndef WARTHOG_APP_CFG_H
#define WARTHOG_APP_CFG_H

#include "getopt.h"

#include <cstdint>
#include <iostream>
#include <map>
#include <vector>

// cfg.h
//
// A centralised place for dealing with configuration parameters.
//
// @author: dharabor
// @created: 10/09/2012
//

namespace warthog::util
{

typedef struct option param;

class cfg
{
public:
cfg();
~cfg();

void
parse_args(int argc, char** argv, warthog::util::param params[]);

void
parse_args(
int argc, char** argv, const char* short_opts,
warthog::util::param params[]);

std::string get_param_value(std::string);

uint32_t get_num_values(std::string);

void
print(std::ostream& out);

void
print_values(const std::string&, std::ostream& out);

private:
// no copy
cfg(const cfg& other) { }
cfg&
operator=(const cfg& other)
{
return *this;
}

std::map<std::string, std::vector<std::string>> params_;
};

} // namespace warthog::util

#endif // WARTHOG_APP_CFG_H
8 changes: 8 additions & 0 deletions apps/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef WARTHOG_APP_CONFIG_H

#define WARTHOG_VERSION "@CMAKE_PROJECT_VERSION@"
#define WARTHOG_VERSION_MAJOR @CMAKE_PROJECT_VERSION_MAJOR@
#define WARTHOG_VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@
#define WARTHOG_VERSION_REVISON @CMAKE_PROJECT_VERSION_PATCH@

#endif // WARTHOG_APP_CONFIG_H
Loading

0 comments on commit 0fa6665

Please sign in to comment.