Commit 49032929 authored by David Speck's avatar David Speck

started to optimize nbs controller

parent 6d8539d9
......@@ -715,7 +715,7 @@ fast_downward_plugin(
symple/sym_variables
symple/symple_search
symple/transition_relation
symple/open_list
symple/open_lists/open_list
symple/closed_list
symple/sym_astar
symple/expansion_controller/expansion_controller
......@@ -727,7 +727,8 @@ fast_downward_plugin(
# symple/heuristics/evmdd_encoder
symple/heuristics/potential_symbolic_heuristic
symple/heuristics/model_counter
symple/potential_open_list
symple/open_lists/potential_open_list
# symple/open_lists/nbs_open_list
symple/sdac_plan_manager
Meddly/operations_extension/userOperations
Meddly/operations_extension/evplus
......
......@@ -31,6 +31,78 @@ void USER_OPS::initializeUserOperations() {
USER_OPS::initializeCopy();
}
float USER_OPS::min_value(const MEDDLY::dd_edge &edge) {
float result = 0;
edge.getEdgeValue(result);
return result;
}
MEDDLY::dd_edge USER_OPS::logic_not(const MEDDLY::dd_edge &edge) {
MEDDLY::dd_edge result(edge.getForest());
MEDDLY::dd_edge constant(edge.getForest());
constant.set(-1, 1.0f);
MEDDLY::apply(USER_OPS::MINUS, constant, edge, result);
return result;
}
MEDDLY::dd_edge USER_OPS::min_states(const MEDDLY::dd_edge &edge,
bool with_costs) {
MEDDLY::dd_edge result(edge.getForest());
float min_value;
edge.getEdgeValue(min_value);
MEDDLY::dd_edge constant(edge.getForest());
constant.set(-1, min_value);
MEDDLY::apply(USER_OPS::EQUALS, edge, constant, result);
result = USER_OPS::logic_not(result);
constant.set(-1, INFTY);
MEDDLY::apply(USER_OPS::MULTIPLY, result, constant, result);
if (with_costs) {
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, result, edge, result);
}
return result;
}
MEDDLY::dd_edge USER_OPS::less_than(const MEDDLY::dd_edge &edge, float value,
bool with_costs) {
MEDDLY::dd_edge result(edge.getForest());
MEDDLY::dd_edge constant(edge.getForest());
constant.set(-1, value);
MEDDLY::apply(USER_OPS::LESSTHAN, edge, constant, result);
result = logic_not(result);
constant.set(-1, INFTY);
MEDDLY::apply(USER_OPS::MULTIPLY, result, constant, result);
if (with_costs) {
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, result, edge, result);
}
return result;
}
MEDDLY::dd_edge USER_OPS::less_equal(const MEDDLY::dd_edge &edge, float value,
bool with_costs) {
MEDDLY::dd_edge result(edge.getForest());
MEDDLY::dd_edge constant(edge.getForest());
constant.set(-1, value);
MEDDLY::apply(USER_OPS::LESSEQUALS, edge, constant, result);
result = logic_not(result);
constant.set(-1, INFTY);
MEDDLY::apply(USER_OPS::MULTIPLY, result, constant, result);
if (with_costs) {
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, result, edge, result);
}
return result;
}
MEDDLY::dd_edge USER_OPS::remove_costs(const MEDDLY::dd_edge &edge) {
MEDDLY::dd_edge result(edge.getForest());
MEDDLY::apply(USER_OPS::MINUS, edge, edge, result);
return result;
}
template <typename T>
std::string to_string_with_precision(const T a_value, const int n = 20) {
std::ostringstream out;
......
......@@ -28,6 +28,22 @@ extern const float INFTY;
namespace USER_OPS {
void initializeUserOperations();
float min_value(const MEDDLY::dd_edge &edge);
MEDDLY::dd_edge logic_not(const MEDDLY::dd_edge &edge);
MEDDLY::dd_edge min_states(const MEDDLY::dd_edge &edge,
bool with_costs = false);
MEDDLY::dd_edge less_than(const MEDDLY::dd_edge &edge, float value,
bool with_costs = false);
MEDDLY::dd_edge less_equal(const MEDDLY::dd_edge &edge, float value,
bool with_costs = false);
MEDDLY::dd_edge remove_costs(const MEDDLY::dd_edge &edge);
void to_dot(const MEDDLY::dd_edge &edge, std::string file_name);
} // namespace USER_OPS
......
#include "astar_controller.h"
#include "../sym_astar.h"
#include "../sym_variables.h"
#include "../symple_search.h"
#include "astar_controller.h"
namespace symple
{
namespace symple {
AStarController::AStarController(std::shared_ptr<SymVariables> sym_vars,
std::shared_ptr<SymAstar> fwd_astar,
std::shared_ptr<SymAstar> bwd_astar)
......@@ -12,12 +11,9 @@ AStarController::AStarController(std::shared_ptr<SymVariables> sym_vars,
SearchStatus AStarController::expansion_step(
const std::vector<TransitionRelation> &merged_trs,
const SympleParams &params) const
{
if (fwd_astar->open_list_empty() || bwd_astar->open_list_empty())
{
if (fwd_astar->has_collision() || bwd_astar->has_collision())
{
const SympleParams &params) {
if (fwd_astar->open_list_empty() || bwd_astar->open_list_empty()) {
if (fwd_astar->has_collision() || bwd_astar->has_collision()) {
return SearchStatus::SOLVED;
}
return SearchStatus::FAILED;
......@@ -27,13 +23,10 @@ SearchStatus AStarController::expansion_step(
bool opt_sol = false;
Dir step_dir = next_step_dir(params);
std::cout << step_dir << ": " << std::flush;
if (step_dir == Dir::FWD)
{
if (step_dir == Dir::FWD) {
opt_sol = fwd_astar->step(merged_trs);
std::cout << " [" << fwd_astar->last_step_time() << "s] ";
}
else if (step_dir == Dir::BWD)
{
} else if (step_dir == Dir::BWD) {
opt_sol = bwd_astar->step(merged_trs);
std::cout << " [" << bwd_astar->last_step_time() << "s] ";
}
......@@ -44,17 +37,14 @@ SearchStatus AStarController::expansion_step(
return opt_sol ? SearchStatus::SOLVED : SearchStatus::IN_PROGRESS;
}
Dir AStarController::next_step_dir(const SympleParams &params) const
{
if (params.search_dir != Dir::BID)
{
Dir AStarController::next_step_dir(const SympleParams &params) const {
if (params.search_dir != Dir::BID) {
return params.search_dir;
}
if (fwd_astar->last_step_time() <= bwd_astar->last_step_time())
{
if (fwd_astar->last_step_time() <= bwd_astar->last_step_time()) {
return Dir::FWD;
}
return Dir::BWD;
}
} // namespace symple
\ No newline at end of file
} // namespace symple
#ifndef SYMPLE_EXPANDSION_CONTROLLER_ASTAR_CONTROLLER_H
#define SYMPLE_EXPANDSION_CONTROLLER_ASTAR_CONTROLLER_H
#include "expansion_controller.h"
#include <memory>
#include "expansion_controller.h"
namespace symple {
class SymAstar;
......@@ -10,18 +10,18 @@ class SymVariables;
class TransitionRelation;
class AStarController : public ExpansionController {
public:
public:
AStarController(std::shared_ptr<SymVariables> sym_vars,
std::shared_ptr<SymAstar> fwd_astar,
std::shared_ptr<SymAstar> bwd_astar);
virtual SearchStatus
expansion_step(const std::vector<TransitionRelation> &merged_trs,
const SympleParams &params) const override;
virtual SearchStatus expansion_step(
const std::vector<TransitionRelation> &merged_trs,
const SympleParams &params) override;
protected:
protected:
Dir next_step_dir(const SympleParams &params) const;
};
} // namespace symple
} // namespace symple
#endif
\ No newline at end of file
#endif
#ifndef SYMPLE_EXPANDSION_CONTROLLER_EXPANDSION_CONTROLLER_H
#define SYMPLE_EXPANDSION_CONTROLLER_EXPANDSION_CONTROLLER_H
#include "../symple_search.h"
#include <memory>
#include "../symple_search.h"
namespace symple {
class SymAstar;
......@@ -10,20 +10,20 @@ class SymVariables;
class TransitionRelation;
class ExpansionController {
public:
public:
ExpansionController(std::shared_ptr<SymVariables> sym_vars,
std::shared_ptr<SymAstar> fwd_astar,
std::shared_ptr<SymAstar> bwd_astar);
virtual SearchStatus
expansion_step(const std::vector<TransitionRelation> &merged_trs,
const SympleParams &params) const = 0;
virtual SearchStatus expansion_step(
const std::vector<TransitionRelation> &merged_trs,
const SympleParams &params) = 0;
protected:
protected:
std::shared_ptr<SymVariables> sym_vars;
std::shared_ptr<SymAstar> fwd_astar;
std::shared_ptr<SymAstar> bwd_astar;
};
} // namespace symple
} // namespace symple
#endif
\ No newline at end of file
#endif
#include "nbs_controller.h"
#include "../Meddly/operations_extension/userOperations.h"
#include "../open_list.h"
#include "../open_lists/open_list.h"
#include "../open_lists/potential_open_list.h"
#include "../sym_astar.h"
#include "../sym_variables.h"
#include "../symple_search.h"
namespace symple
{
namespace symple {
NbsController::NbsController(std::shared_ptr<SymVariables> sym_vars,
std::shared_ptr<SymAstar> fwd_astar,
std::shared_ptr<SymAstar> bwd_astar)
: ExpansionController(sym_vars, fwd_astar, bwd_astar) {}
: ExpansionController(sym_vars, fwd_astar, bwd_astar),
solution_lower_bound(0) {
fwd_open =
std::dynamic_pointer_cast<PotentialOpenList>(fwd_astar->get_open());
bwd_open =
std::dynamic_pointer_cast<PotentialOpenList>(bwd_astar->get_open());
}
SearchStatus
NbsController::expansion_step(const std::vector<TransitionRelation> &merged_trs,
const SympleParams & /*params*/) const
{
if (fwd_astar->open_list_empty() || bwd_astar->open_list_empty())
{
if (fwd_astar->has_collision() || bwd_astar->has_collision())
{
SearchStatus NbsController::expansion_step(
const std::vector<TransitionRelation>& merged_trs,
const SympleParams& /*params*/) {
if (fwd_astar->collision_cost() <= solution_lower_bound) {
return SearchStatus::SOLVED;
}
if (fwd_astar->open_list_empty() || bwd_astar->open_list_empty()) {
if (fwd_astar->has_collision() || bwd_astar->has_collision()) {
return SearchStatus::SOLVED;
}
return SearchStatus::FAILED;
}
MEDDLY::dd_edge expand_fwd = sym_vars->get_constant_edge(0);
MEDDLY::dd_edge expand_bwd = sym_vars->get_constant_edge(0);
std::tie(expand_fwd, expand_bwd) = selecting_best_pairs();
// USER_OPS::to_dot(expand_fwd, "expand_fwd.dot");
// USER_OPS::to_dot(expand_bwd, "expand_bwd.dot");
// Image
std::cout << "NBS: " << std::flush;
bool opt_sol = false;
auto best_pairs = most_promising_pairs();
auto best_fwd_pairs = sym_vars->min_abstract_all(best_pairs, true);
MEDDLY::apply(USER_OPS::EVPLUS, fwd_astar->get_open()->g_values(),
best_fwd_pairs, best_fwd_pairs);
opt_sol = fwd_astar->step(merged_trs, best_fwd_pairs);
std::cout << " [" << fwd_astar->last_step_time() << "s] ";
if (!opt_sol)
{
fwd_astar->get_open()->remove_states(best_fwd_pairs);
auto best_bwd_pairs = sym_vars->min_abstract_all(best_pairs, false);
best_bwd_pairs = sym_vars->rename_all(best_bwd_pairs, true);
MEDDLY::apply(USER_OPS::EVPLUS, bwd_astar->get_open()->g_values(),
best_bwd_pairs, best_bwd_pairs);
opt_sol = bwd_astar->step(merged_trs, best_bwd_pairs);
std::cout << " [" << bwd_astar->last_step_time() << "s] ";
if (!opt_sol)
{
bwd_astar->get_open()->remove_states(best_bwd_pairs);
std::cout << "NBS:\n - " << std::flush;
bool opt_sol = fwd_astar->step(merged_trs, expand_fwd);
std::cout << " [" << fwd_astar->last_step_time() << "s]\n - ";
if (fwd_astar->collision_cost() <= solution_lower_bound) {
return SearchStatus::SOLVED;
}
if (!opt_sol) {
fwd_astar->get_open()->remove_states(expand_fwd);
opt_sol = bwd_astar->step(merged_trs, expand_bwd);
std::cout << " [" << bwd_astar->last_step_time() << "s]\n => ";
if (fwd_astar->collision_cost() <= solution_lower_bound) {
return SearchStatus::SOLVED;
}
if (!opt_sol) {
bwd_astar->get_open()->remove_states(expand_bwd);
}
}
std::cout << "Overall: "
......@@ -56,37 +60,82 @@ NbsController::expansion_step(const std::vector<TransitionRelation> &merged_trs,
return opt_sol ? SearchStatus::SOLVED : SearchStatus::IN_PROGRESS;
}
MEDDLY::dd_edge NbsController::most_promising_pairs() const
{
MEDDLY::dd_edge result = sym_vars->get_constant_edge(0);
std::pair<MEDDLY::dd_edge, MEDDLY::dd_edge>
NbsController::selecting_best_pairs() {
// TODO: Refactor!
PotentialOpenList fwd_waiting(fwd_open->g_values(), sym_vars, nullptr,
fwd_open->get_potenital_heuristic());
PotentialOpenList bwd_waiting(bwd_open->g_values(), sym_vars, nullptr,
bwd_open->get_potenital_heuristic());
PotentialOpenList fwd_ready(sym_vars->get_constant_edge(INFTY), sym_vars,
nullptr, fwd_open->get_potenital_heuristic());
PotentialOpenList bwd_ready(sym_vars->get_constant_edge(INFTY), sym_vars,
nullptr, bwd_open->get_potenital_heuristic());
// Max of f-values of both directions
auto fwd_f_values = fwd_astar->get_open()->f_values();
auto bwd_f_values = bwd_astar->get_open()->f_values();
bwd_f_values = sym_vars->rename_all(bwd_f_values); // => pairs of states
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, fwd_f_values, bwd_f_values, result);
std::pair<MEDDLY::dd_edge, MEDDLY::dd_edge> result;
// Max with added g-values
auto g_values_added = sym_vars->get_constant_edge(0);
auto fwd_g_values = fwd_astar->get_open()->g_values();
auto bwd_g_values = bwd_astar->get_open()->g_values();
bwd_g_values = sym_vars->rename_all(bwd_g_values); // => pairs of states
// min(f) < Sol_lb (NBS paper: line 2)
// TODO: can we expand here all smaller than Sol_lb???
if (USER_OPS::min_value(fwd_waiting.f_values()) < solution_lower_bound) {
auto best_nodes = USER_OPS::min_states(fwd_waiting.f_values(), false);
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, best_nodes, fwd_waiting.g_values(),
best_nodes);
fwd_ready.insert(best_nodes);
fwd_waiting.remove_states(best_nodes);
}
if (USER_OPS::min_value(bwd_waiting.f_values()) < solution_lower_bound) {
auto best_nodes = USER_OPS::min_states(bwd_waiting.f_values(), false);
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, best_nodes, fwd_waiting.g_values(),
best_nodes);
bwd_ready.insert(best_nodes);
bwd_waiting.remove_states(best_nodes);
}
MEDDLY::apply(USER_OPS::EVPLUS, fwd_g_values, bwd_g_values, g_values_added);
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, result, g_values_added, result);
while (true) {
// min(ready) + min(ready) < Sol_lb (NBS paper: line 8)
if (USER_OPS::min_value(fwd_ready.g_values()) +
USER_OPS::min_value(bwd_ready.g_values()) <=
solution_lower_bound) {
result = std::pair<MEDDLY::dd_edge, MEDDLY::dd_edge>(
fwd_ready.g_values(), bwd_ready.g_values());
fwd_waiting.remove_states(fwd_ready.g_values());
bwd_waiting.remove_states(bwd_ready.g_values());
// USER_OPS::to_dot(fwd_ready.g_values(), "fwd.dot");
// USER_OPS::to_dot(bwd_ready.g_values(), "bwd.dot");
break;
}
// Get min pairs
float min_value = 0;
result.getEdgeValue(min_value);
auto min_states = sym_vars->get_constant_edge(0);
MEDDLY::apply(USER_OPS::EQUALS, sym_vars->get_constant_edge(min_value),
result, min_states);
MEDDLY::apply(USER_OPS::MINUS, sym_vars->get_constant_edge(1), min_states,
min_states);
MEDDLY::apply(USER_OPS::MULTIPLY, sym_vars->get_constant_edge(std::numeric_limits<float>::infinity()),
min_states, result);
bool path_found = false;
// f-values are smaller than Sol_lb (NBS paper: line 10)
if (USER_OPS::min_value(fwd_waiting.f_values()) <= solution_lower_bound) {
auto best_nodes = USER_OPS::min_states(fwd_waiting.f_values());
best_nodes = USER_OPS::remove_costs(best_nodes);
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, best_nodes,
fwd_waiting.g_values(), best_nodes);
fwd_ready.insert(best_nodes);
fwd_waiting.remove_states(best_nodes);
path_found = true;
}
if (USER_OPS::min_value(bwd_waiting.f_values()) <= solution_lower_bound) {
auto best_nodes = USER_OPS::min_states(bwd_waiting.f_values());
best_nodes = USER_OPS::remove_costs(best_nodes);
MEDDLY::apply(USER_OPS::INTERSECTIONMAX, best_nodes,
bwd_waiting.g_values(), best_nodes);
bwd_ready.insert(best_nodes);
bwd_waiting.remove_states(best_nodes);
path_found = true;
}
if (!path_found) {
solution_lower_bound =
std::min(USER_OPS::min_value(fwd_waiting.f_values()),
USER_OPS::min_value(bwd_waiting.f_values()));
solution_lower_bound = std::min(
solution_lower_bound, USER_OPS::min_value(fwd_ready.g_values()) +
USER_OPS::min_value(bwd_ready.g_values()));
}
}
return result;
}
} // namespace symple
\ No newline at end of file
} // namespace symple
#ifndef SYMPLE_EXPANDSION_CONTROLLER_NBS_CONTROLLER_H
#define SYMPLE_EXPANDSION_CONTROLLER_NBS_CONTROLLER_H
#include "expansion_controller.h"
#include <memory>
#include "expansion_controller.h"
namespace symple
{
namespace symple {
class SymAstar;
class SymVariables;
class TransitionRelation;
class PotentialOpenList;
class NbsController : public ExpansionController
{
public:
class NbsController : public ExpansionController {
public:
NbsController(std::shared_ptr<SymVariables> sym_vars,
std::shared_ptr<SymAstar> fwd_astar,
std::shared_ptr<SymAstar> bwd_astar);
virtual SearchStatus
expansion_step(const std::vector<TransitionRelation> &merged_trs,
const SympleParams &params) const override;
virtual SearchStatus expansion_step(
const std::vector<TransitionRelation> &merged_trs,
const SympleParams &params) override;
protected:
MEDDLY::dd_edge most_promising_pairs() const;
protected:
std::shared_ptr<PotentialOpenList> fwd_open;
std::shared_ptr<PotentialOpenList> bwd_open;
std::pair<MEDDLY::dd_edge, MEDDLY::dd_edge> selecting_best_pairs();
float solution_lower_bound;
};
} // namespace symple
} // namespace symple
#endif
\ No newline at end of file
#endif
#include "open_list.h"
#include "../Meddly/operations_extension/userOperations.h"
#include "heuristics/bidirectional_potential.h"
#include "sym_variables.h"
#include <limits>
#include "../../Meddly/operations_extension/userOperations.h"
#include "../heuristics/bidirectional_potential.h"
#include "../sym_variables.h"
namespace symple
{
namespace symple {
OpenList::OpenList(const MEDDLY::dd_edge &start,
std::shared_ptr<SymVariables> sym_vars,
std::shared_ptr<SymAstar> other_dir)
: sym_vars(sym_vars), other_dir(other_dir), open(start) {}
std::shared_ptr<SymVariables> sym_vars)
: sym_vars(sym_vars), open(start) {}
bool OpenList::empty() { return open == sym_vars->get_constant_edge(INFTY); }
void OpenList::insert(const MEDDLY::dd_edge &in)
{
void OpenList::insert(const MEDDLY::dd_edge &in) {
MEDDLY::apply(USER_OPS::UNIONMIN, open, in, open);
}
MEDDLY::dd_edge OpenList::get_most_promising() const
{
float min_cost;
open.getEdgeValue(min_cost);
MEDDLY::dd_edge res = sym_vars->get_constant_edge(min_cost);
MEDDLY::apply(USER_OPS::EQUALS, open, res, res);
// Set costs for results
MEDDLY::apply(USER_OPS::MINUS, sym_vars->get_constant_edge(1), res, res);
MEDDLY::apply(USER_OPS::MULTIPLY, sym_vars->get_constant_edge(std::numeric_limits<float>::infinity()),
res, res);
MEDDLY::apply(USER_OPS::EVPLUS, res, sym_vars->get_constant_edge(min_cost),
res);
return res;
MEDDLY::dd_edge OpenList::get_most_promising() const {
auto result = USER_OPS::min_states(open, true);
return result;
}
void OpenList::remove_states(const MEDDLY::dd_edge states)
{
void OpenList::remove_states(const MEDDLY::dd_edge states) {
// Remove states from open
MEDDLY::dd_edge not_states = sym_vars->get_constant_edge(0);
MEDDLY::apply(USER_OPS::PARTIALCOMPLEMENT, states, not_states);
......@@ -44,25 +29,17 @@ void OpenList::remove_states(const MEDDLY::dd_edge states)
}
// TODO(speckd): create a min-extract operation
MEDDLY::dd_edge OpenList::extract_most_promising()
{
MEDDLY::dd_edge OpenList::extract_most_promising() {
auto res = get_most_promising();
remove_states(res);
return res;
}
MEDDLY::dd_edge OpenList::f_values() const
{
return open;
}
MEDDLY::dd_edge OpenList::f_values() const { return open; }
MEDDLY::dd_edge OpenList::g_values() const
{
return open;
}
MEDDLY::dd_edge OpenList::g_values() const { return open; }
float OpenList::min_g_value() const
{
float OpenList::min_g_value() const {
float result = -1;
open.getEdgeValue(result);
return result;
......@@ -70,13 +47,10 @@ float OpenList::min_g_value() const
float OpenList::min_f_value() const { return min_g_value(); }
MEDDLY::dd_edge OpenList::get_heuristic() const
{
MEDDLY::dd_edge OpenList::get_heuristic() const {
return sym_vars->get_constant_edge(0);
}
void OpenList::update_heuristic() {}
MEDDLY::dd_edge OpenList::get_open_list() const { return open; }
} // namespace symple
} // namespace symple
......@@ -9,9 +9,9 @@ class SymVariables;
class SymAstar;
class OpenList {
public:
OpenList(const MEDDLY::dd_edge &start, std::shared_ptr<SymVariables> sym_vars,
std::shared_ptr<SymAstar> other_dir);
public:
OpenList(const MEDDLY::dd_edge &start,
std::shared_ptr<SymVariables> sym_vars);
virtual void insert(const MEDDLY::dd_edge &in);
virtual MEDDLY::dd_edge extract_most_promising();
virtual MEDDLY::dd_edge get_most_promising() const;
......@@ -23,13 +23,11 @@ public:
virtual MEDDLY::dd_edge g_values() const;
bool empty();
virtual MEDDLY::dd_edge get_heuristic() const;
virtual void update_heuristic();
protected:
protected:
std::shared_ptr<SymVariables> sym_vars;
std::shared_ptr<SymAstar> other_dir;
MEDDLY::dd_edge open;
};
} // namespace symple
} // namespace symple
#endif
#include "potential_open_list.h"
#include "../Meddly/operations_extension/userOperations.h"
#include "../abstract_task.h"
#include "../potentials/potential_heuristic.h"
#include "../potentials/potential_max_heuristic.h"
#include "closed_list.h"
#include "heuristics/potential_symbolic_heuristic.h"
#include "sym_astar.h"
#include "sym_variables.h"
#include <limits>
#include "../../Meddly/operations_extension/userOperations.h"
#include "../../abstract_task.h"
#include "../../potentials/potential_heuristic.h"
#include "../../potentials/potential_max_heuristic.h"
#include "../closed_list.h"
#include "../heuristics/potential_symbolic_heuristic.h"
#include "../sym_astar.h"
#include "../sym_variables.h"
namespace symple
{
namespace symple {
PotentialOpenList::PotentialOpenList(const MEDDLY::dd_edge &start,
std::shared_ptr<SymVariables> sym_vars,
std::shared_ptr<SymAstar> other_dir,
std::shared_ptr<AbstractTask> task,
std::shared_ptr<Heuristic> pot_heuristic)
: OpenList(start, sym_vars, other_dir), task(task),
potenial_heuristic(nullptr), required_heursistic_update(false)
{
: OpenList(start, sym_vars), potenial_heuristic(nullptr) {
potenial_heuristic =
std::dynamic_pointer_cast<PotentialSymbolicHeuristic>(pot_heuristic);
if (potenial_heuristic)
{
if (potenial_heuristic) {
potenial_heuristic->init(sym_vars);
}
else
{
} else {
std::cerr << "Symple only supports blind or symbolic potential heuristic!"
<< std::endl;
utils::exit_with(utils::ExitCode::SEARCH_INPUT_ERROR);
}
}
MEDDLY::dd_edge PotentialOpenList::get_most_promising() const
{
if (required_heursistic_update)
{
required_heursistic_update = false;
potenial_heuristic->update_other_dir_heuristic(
other_dir->get_open()->get_open_list());
}