Commit f7bb0341 authored by Sumitra Corraya's avatar Sumitra Corraya

Update aStarBwd.cc

parent d6c90555
......@@ -66,34 +66,37 @@ int AStarBwd::selectAnyState(MEDDLY::dd_edge &targetState) {
Operator *AStarBwd::reconstructPlanStep(MEDDLY::dd_edge &targetState) {
MEDDLY::FILE_output out(stdout);
int costAfter = selectAnyState(targetState);
// targetState.show(out, 3);
//std::random_device rd;
typedef std::chrono::high_resolution_clock myclock;
myclock::time_point beginning = myclock::now();
myclock::duration d = myclock::now() - beginning;
unsigned seed = d.count();
std::mt19937 g(seed);
std::vector<int> vector;
std::vector<int> vector;
for (int op_i = 0; op_i < g_operators.size(); op_i++) {
vector.push_back(op_i);
}
std::shuffle(vector.begin(), vector.end(), g);
for (std::vector<int>::iterator it=vector.begin(); it!=vector.end(); ++it)
{
MEDDLY::dd_edge predecessors(forest);
imageInv(targetState, *g_operators[*it].get_op_evmdd(), predecessors);
/*if (minVal(predecessors) == std::numeric_limits<int>::max())
continue;*/
// predecessors.show(out, 3);
// TODO(speckd): add guard such that it only searches for states with lower
// i
// Not really necessary but if something goes wrong...
MEDDLY::dd_edge successors(forest);
imageInv(targetState, *g_operators[*it].get_op_evmdd(), successors);
for (int c_i = 0; c_i < curClosedList; c_i++) {
MEDDLY::dd_edge tmp(forest);
MEDDLY::apply(INTERSECTIONMAX, predecessors, *closedLists[c_i], tmp);
MEDDLY::apply(MEDDLY::PLUS, tmp, *g_operators[*it].get_SDAC_cost(), tmp);
// Fits!
// std::cout << "Cost after: " << costAfter << ", minval" << minVal(tmp)
// << std::endl;
if (minVal(tmp) == costAfter) {
MEDDLY::apply(INTERSECTIONMAX, successors, *closedLists[c_i], tmp);
// We need to add the cost to target and then check if it fits
MEDDLY::dd_edge costDummy(forest);
MEDDLY::apply(MEDDLY::PLUS, *g_operators[*it].get_SDAC_cost(),
targetState, costDummy);
int cost_tmp = minVal(costDummy);
costDummy.set(-1, cost_tmp);
MEDDLY::apply(MEDDLY::PLUS, tmp, costDummy, costDummy);
// Cost Fits
if (minVal(costDummy) == costAfter) {
// tmp.show(out, 3);
MEDDLY::apply(MINSTATES, tmp, tmp);
// add cost to it
......@@ -101,12 +104,12 @@ Operator *AStarBwd::reconstructPlanStep(MEDDLY::dd_edge &targetState) {
MEDDLY::apply(INTERSECTIONMAX, tmp, *closedLists[c_i], targetState);
// create dummy op with correct cost
Operator *dummy = new Operator(g_operators[*it].get_name(),
costAfter - minVal(targetState));
dummy->set_cost_function(g_operators[*it].get_SDAC_cost_function());
Operator *dummy = new Operator(g_operators[*it].get_name(),
costAfter - minVal(targetState));
dummy->set_cost_function(g_operators[*it].get_SDAC_cost_function());
// targetState.show(out, 3);
// std::cout << "----------------------"
// << std::endl;
// std::cout << "-----------------------" << std::endl;
// std::cout << "\n" << curClosedList << std::endl;
curClosedList = c_i;
return dummy;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment