Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def build(config_name, configure_parameters, build_parameters):
print(f"Building configuration {config_name}.")

build_path = get_build_path(config_name)
generator_cmd = [CMAKE, "-S", get_src_path(), "-B", build_path]
generator_cmd = [CMAKE, "-S", get_src_path(), "-B", build_path, "-DCMAKE_EXPORT_COMPILE_COMMANDS=1"]
if CMAKE_GENERATOR:
generator_cmd += ["-G", CMAKE_GENERATOR]
generator_cmd += configure_parameters
Expand Down
7 changes: 6 additions & 1 deletion driver/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,12 @@ def parse_args():
driver_other.add_argument(
"--cleanup", action="store_true",
help="clean up temporary files (translator output and plan files) and exit")


driver_other.add_argument(
"--profile", choices=["none", "time", "memory"],
default="none",
help="profile the time or memory usage of the search component using valgrind tools")

parser.add_argument(
"planner_args", nargs=argparse.REMAINDER,
help="file names and options passed on to planner components")
Expand Down
10 changes: 10 additions & 0 deletions driver/run_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ def run_search(args):
portfolio_bound=args.portfolio_bound,
single_plan=args.portfolio_single_plan)
plan_manager.delete_existing_plans()
# Add profiling options

profile = []
if "time" == args.profile:
# args.search_options = '--tool=callgrind --dump-instr=yes --collect-jumps=yes --callgrind-out-file=callgrind.out'.split(' ') + args.search_options
profile = "valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes --callgrind-out-file=callgrind.out".split(' ')
elif "memory" == args.profile:
# args.search_options = '--leak-check=full --track-origins=yes --log-file=memory-info.out'.split(' ') + args.search_options
profile = "valgrind --leak-check=full --track-origins=yes --log-file=memory-info.out".split(' ')

if args.portfolio:
assert not args.search_options
Expand All @@ -140,6 +149,7 @@ def run_search(args):
try:
call.check_call(
"search",
profile +
[executable] + args.search_options,
stdin=args.search_input,
time_limit=time_limit,
Expand Down
14 changes: 14 additions & 0 deletions src/search/search_algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "utils/timer.h"

#include "pr2/pr2.h"
#include "pr2/policy.h"
#include "pr2/deadend.h"

#include <cassert>
#include <iostream>
Expand Down Expand Up @@ -151,6 +153,12 @@ void SearchAlgorithm::set_plan(const Plan &p) {
}

void SearchAlgorithm::search() {
if (PR2.deadend.record_online) {
PR2.deadend.found_online.clear();
delete PR2.deadend.online_policy;
PR2.deadend.online_policy = new Policy<PolicyItem>();
}

initialize();
utils::CountdownTimer timer(max_time);
while (status == IN_PROGRESS) {
Expand All @@ -161,6 +169,12 @@ void SearchAlgorithm::search() {
break;
}
}

if (PR2.deadend.record_online &&
!PR2.weaksearch.limit_states &&
PR2.deadend.found_online.size() > 0)
update_deadends(PR2.deadend.found_online);

// TODO: Revise when and which search times are logged.
if (PR2.logging.verbose)
log << "Actual search time: " << timer.get_elapsed_time() << endl;
Expand Down
13 changes: 13 additions & 0 deletions src/search/search_algorithms/lazy_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ void LazySearch::initialize() {
if (PR2.logging.verbose)
log << "Conducting lazy best first search, (real) bound = " << bound << endl;

// Only set up the heuristics on the first go
if (was_initialized)
return;
else
was_initialized = true;

assert(open_list);
set<Evaluator *> evals;
open_list->get_path_dependent_evaluators(evals);
Expand Down Expand Up @@ -214,6 +220,13 @@ SearchStatus LazySearch::step() {
!node.is_dead_end() && (current_g < node.get_g());

if (node.is_new() || reopen) {
if (PR2.weaksearch.limit_states) {
if (state_count > PR2.weaksearch.max_states)
return FAILED;
else
state_count++;
}

if (current_operator_id != OperatorID::no_operator) {
assert(current_predecessor_id != StateID::no_state);
if (!path_dependent_evaluators.empty()) {
Expand Down
3 changes: 3 additions & 0 deletions src/search/search_algorithms/lazy_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class LazySearch : public SearchAlgorithm {
int current_real_g;
EvaluationContext current_eval_context;

int state_count; // Used to limit the search when replanning for a local goal
bool was_initialized;

virtual void initialize() override;
virtual SearchStatus step() override;

Expand Down
7 changes: 0 additions & 7 deletions src/search/state_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ const State &StateRegistry::get_initial_state() {
StateID id = insert_id_or_pop_state();
cached_initial_state = make_unique<State>(lookup_state(id));
}
int x = 1 + 1;
x = 1 + 1;
x = 1 + 1;
x = 1 + 1;
x = 1 + 1;
x = 1 + 1;
x = 1 + 1;
// I think this return is broken
return *cached_initial_state;
}
Expand Down
Loading