Skip to content

Commit c0efa76

Browse files
committed
various bug fixes. I believe forest should work now. Speed up in combination with core changes
1 parent 6b20bbe commit c0efa76

File tree

12 files changed

+56
-126
lines changed

12 files changed

+56
-126
lines changed

src/deadend.cc

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bool FSAP::operator< (const FSAP& other) const {
2525
if (is_active != other.is_active)
2626
return is_active;
2727
else
28-
return op->nondet_index > other.op->nondet_index;
28+
return op->nondet_index < other.op->nondet_index;
2929
}
3030

3131
string FSAP::get_name() {
@@ -167,75 +167,3 @@ void update_deadends(vector< DeadendTuple* > &failed_states) {
167167
}
168168

169169

170-
171-
// void DeadendAwareSuccessorGenerator::generate_applicable_ops(const PR2State &_curr, vector<OperatorID> &ops) const {
172-
// if (PR2.deadend.enabled && PR2.deadend.policy) {
173-
174-
// PR2State curr = PR2State(_curr);
175-
176-
// vector<PolicyItem *> reg_items;
177-
// vector<OperatorID> orig_ops;
178-
// map<int, PolicyItem *> fsap_map;
179-
180-
// PR2.generate_orig_applicable_ops(_curr, orig_ops);
181-
// PR2.deadend.policy->generate_entailed_items(curr, reg_items);
182-
183-
// set<int> forbidden;
184-
// for (auto item : reg_items) {
185-
186-
// int index = ((FSAP*)item)->get_index();
187-
188-
// forbidden.insert(index);
189-
190-
// if ((fsap_map.find(index) == fsap_map.end()) ||
191-
// (item->state->size() < fsap_map[index]->state->size()))
192-
// fsap_map[index] = item;
193-
// }
194-
195-
// vector<int> ruled_out;
196-
// for (auto opid : orig_ops) {
197-
// if (0 == forbidden.count(PR2.proxy->get_nondet_index(opid)))
198-
// ops.push_back(opid);
199-
// else if (PR2.deadend.combine)
200-
// ruled_out.push_back(PR2.proxy->get_nondet_index(opid));
201-
// }
202-
203-
// // Add this state as a deadend if we have ruled out everything
204-
// if (!PR2.weaksearch.limit_states && PR2.deadend.record_online &&
205-
// PR2.deadend.combine && (orig_ops.size() > 0) && ops.empty()) {
206-
207-
// // Combind all of the FSAPs
208-
// PR2State *newDE = new PR2State();
209-
// for (unsigned i = 0; i < ruled_out.size(); i++) {
210-
// newDE->combine_with(*(((FSAP*)(fsap_map[ruled_out[i]]))->state));
211-
// }
212-
213-
// // Also rule out all of the unapplicable actions
214-
// for (const auto & op : PR2.proxy->get_operators()) {
215-
// if (0 == forbidden.count(op.nondet_index)) {
216-
// if (op.is_possibly_applicable(*newDE)) {
217-
// assert (!(op.is_possibly_applicable(curr)));
218-
// int conflict_var = op.compute_conflict_var(curr);
219-
// assert (conflict_var != -1);
220-
// assert ((*newDE)[conflict_var] == -1);
221-
// (*newDE)[conflict_var] = curr[conflict_var];
222-
// }
223-
// }
224-
// }
225-
226-
// PR2.deadend.combination_count++;
227-
228-
// vector<DeadendTuple *> failed_states;
229-
// failed_states.push_back(new DeadendTuple(newDE, NULL, NULL));
230-
// update_deadends(failed_states);
231-
// }
232-
233-
// } else {
234-
235-
// PR2.generate_orig_applicable_ops(_curr, ops);
236-
237-
// }
238-
239-
// return;
240-
// }
241-

src/expand.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PR2State * generate_nondet_successors(PR2State * current_state, const PR2Operato
99
PR2OperatorProxy o = PR2.proxy->get_operators()[oid];
1010
successors.push_back(new NondetSuccessor(current_state->progress(o),
1111
(oid == op->get_id()), o.nondet_outcome));
12-
if (o == *op)
12+
if (o.get_id() == op->get_id())
1313
expected = successors.back()->state;
1414
}
1515

src/fd_integration/fsap_penalized_ff_heuristic.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,10 @@ int FSAPPenalizedFFHeuristic::compute_heuristic(const State &state) {
354354
// for (size_t i = 0; i < goal_propositions.size(); ++i)
355355
// mark_preferred_operators(state, goal_propositions[i]);
356356
} else {
357-
if (PR2.logging.deadends)
357+
if (PR2.logging.deadends) {
358358
cout << "\nHeuristic found deadend!" << endl;
359+
PR2State(state).dump_pddl();
360+
}
359361

360362
if (PR2.deadend.record_online) {
361363
PR2.deadend.found_online.push_back(new DeadendTuple(new PR2State(state), NULL, NULL));

src/fd_integration/partial_state.cc

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <iostream>
1010
#include <cassert>
1111

12+
set<int> get_relevant_basic_variables(vector<int> target_axioms);
13+
1214
PR2State & PR2State::operator=(const PR2State &other) {
1315
if (this != &other) {
1416
vars = other.vars;
@@ -81,9 +83,7 @@ PR2State * PR2State::progress(const PR2OperatorProxy &op) {
8183
(*next)[eff.get_fact().get_variable().get_id()] = eff.get_fact().get_value();
8284
}
8385

84-
// PR2 TODO : This is disabled since we cannot handle domains with axioms,
85-
// leaving it in slows us down.
86-
//g_axiom_evaluator->evaluate(*this);
86+
PR2.axioms.axiom_evaluator->evaluate(this->vars);
8787

8888
return next;
8989

@@ -94,8 +94,7 @@ PR2State * PR2State::regress(const PR2OperatorProxy &op, PR2State *context) {
9494
assert(!op.is_axiom());
9595
assert(NULL != context);
9696

97-
// vector<int> relevant_axioms = {};
98-
// set<int> added = {};
97+
vector<int> relevant_axioms;
9998

10099
PR2State * prev = new PR2State(*this);
101100

@@ -126,14 +125,14 @@ PR2State * PR2State::regress(const PR2OperatorProxy &op, PR2State *context) {
126125
}
127126
}
128127

129-
// Remove all of the prevail effects
130-
for (auto pre : op.get_preconditions()) {
131-
int var = pre.get_variable().get_id();
132-
int val = pre.get_value();
133-
if (0 == seen.count(var) && context->triggers(pre)) {
134-
(*prev)[var] = -1;
135-
}
136-
}
128+
// // Remove all of the prevail effects
129+
// for (auto pre : op.get_preconditions()) {
130+
// int var = pre.get_variable().get_id();
131+
// int val = pre.get_value();
132+
// if (0 == seen.count(var) && context->triggers(pre)) {
133+
// (*prev)[var] = -1;
134+
// }
135+
// }
137136

138137
// Assign the values from the context that are mentioned in conditions
139138
for (auto var : *(PR2.general.conditional_mask[op.nondet_index]))
@@ -143,47 +142,20 @@ PR2State * PR2State::regress(const PR2OperatorProxy &op, PR2State *context) {
143142
for (FactProxy pre : op.get_preconditions()) {
144143
//if the precondition is an derived predicate, find relevant variables and undefine
145144
if (pre.get_variable().is_derived()) {
146-
// relevant_axioms.push_back(pre.get_pair().var);
145+
relevant_axioms.push_back(pre.get_pair().var);
147146
//else set to context value
148147
} else {
149148
(*prev)[pre.get_pair().var] = pre.get_pair().value;
150149
}
151150
}
152151

153-
// cout << prev->get_unpacked_values() << endl;
154-
155-
// set<int> potential_untouchables = get_relevant_basic_variables(relevant_axioms);
156-
157-
// set<int> intermediate;
152+
// set<int> required_basics = get_relevant_basic_variables(relevant_axioms);
158153

159-
// std::set_difference(
160-
// potential_untouchables.begin(), potential_untouchables.end(),
161-
// (*prev).untouchables.begin(), (*prev).untouchables.end(),
162-
// inserter(intermediate, intermediate.begin()));
163-
164-
// (*prev).untouchables = intermediate;
165-
166-
// cout << prev->get_unpacked_values() << endl;
167-
168-
// for (int index : (*prev).untouchables)
154+
// for (int index : required_basics)
169155
// {
170156
// int new_index = PR2.proxy->get_variables()[index].get_id();
171157
// (*prev)[new_index] = (*context)[new_index];
172158
// }
173-
174-
// set<int> step1 = {};
175-
// set<int> step2 = {};
176-
177-
// std::set_union(potential_untouchables.begin(), potential_untouchables.end(),
178-
// (*context).untouchables.begin(), (*context).untouchables.end(),
179-
// inserter(step1,step1.begin()));
180-
181-
// std::set_difference(
182-
// step1.begin(), step1.end(),
183-
// added.begin(), added.end(),
184-
// inserter(step2, step2.begin()));
185-
186-
// (*prev).untouchables = step2;
187159

188160
// //Undefine all axioms
189161
// for (int i = 0; i < vars.size(); i++) {
@@ -214,7 +186,7 @@ set<int> get_relevant_basic_variables(vector<int> target_axioms) {
214186
if (op.get_effects()[0].get_fact().get_pair().var == target) {
215187
for (FactProxy pre : op.get_effects()[0].get_conditions()) {
216188
int index = pre.get_variable().get_id();
217-
if (pre.get_variable().get_axiom_layer() != -1) {
189+
if (pre.get_variable().is_derived()) {
218190
if (find(seen.begin(), seen.end(), index) == seen.end()) {
219191
target_axioms.push_back(index);
220192
seen.push_back(index);

src/fd_integration/pr2_proxies.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class PR2OperatorProxy : public OperatorProxy {
5757
return "goal_action";
5858
}
5959
string name = get_name();
60-
std::regex target("_detdup_[0-9]*");
60+
std::regex target("_detdup_[0-9]*|_DETDUP_[0-9]*");
6161
string name2 = std::regex_replace(name, target, "");
6262
return name2;
6363
}

src/fd_integration/pr2_search_algorithm.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ unique_ptr<SearchAlgorithm> PR2Search::get_search_engine() {
6767
numeric_limits<int>::max(),
6868
PR2.time.limit - PR2.time.time_taken(),
6969
"PR2 Search",
70-
utils::Verbosity::SILENT,
70+
utils::Verbosity::DEBUG,
7171
weak_task,
7272
new DeadendAwareSuccessorGenerator());
7373

@@ -172,7 +172,8 @@ void DeadendAwareSuccessorGenerator::generate_applicable_ops(const PR2State &_cu
172172
}
173173

174174
// Also rule out all of the unapplicable actions
175-
for (const auto & op : PR2.proxy->get_operators()) {
175+
for (int i = 0; i < PR2.proxy->get_operators().size(); i++) {
176+
PR2OperatorProxy op = PR2.proxy->get_operators()[i];
176177
if (0 == forbidden.count(op.nondet_index)) {
177178
if (op.is_possibly_applicable(*newDE)) {
178179
assert (!(op.is_possibly_applicable(curr)));

src/fond_search.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ bool case5_new_path(PR2SearchStatus * SS) {
368368
if (PR2.logging.fond_search)
369369
cout << "\nFONDSEARCH(" << PR2.logging.id() << "): Handled by Case-5 (computing new path)" << endl;
370370

371+
372+
for (auto opid: SS->sim->engine.get()->get_plan()) {
373+
cout << PR2.proxy->get_operators()[opid.get_index()].get_name() << endl;
374+
}
375+
371376
// Update the statistics, as we just patched up the
372377
// policy a little bit.
373378
SS->num_fixed_states++;
@@ -541,6 +546,10 @@ void PR2SearchNode::poison() {
541546
if (0 == previous_nodes.size())
542547
poison_recurse();
543548

549+
if (!poisoned) {
550+
poisoned = true;
551+
}
552+
544553
assert(poisoned);
545554
}
546555

@@ -814,8 +823,7 @@ void PR2SearchStatus::pop_next_node () {
814823
previous_node = current_node->previous_nodes[0];
815824
prev_to_curr_outcome = current_node->previous_node_outcomes[0];
816825
int prev_op_ind = PR2.general.nondet_mapping[previous_step->op.nondet_index][prev_to_curr_outcome];
817-
PR2OperatorProxy prev_op_proxy = PR2.proxy->get_operators()[prev_op_ind];
818-
previous_op = &prev_op_proxy;
826+
previous_op = new PR2OperatorProxy(PR2.proxy->get_operators()[prev_op_ind]);
819827
}
820828
}
821829

src/partial_state_graph.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@ void PSGraph::full_marking() {
215215
// Identify all of the solsteps that aren't marked strong cyclic
216216
set< SolutionStep * > unmarked;
217217
for (auto s : steps)
218-
if (!(s->is_sc))
218+
if (!(s->is_sc)) {
219219
unmarked.insert(s);
220+
}
220221

221222
// For any that possibly veer off course, flag them as not strong cyclic
222223
set< SolutionStep * > not_sc;

src/policy.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "solution.h"
44

55
int PolicyItem::generality() {
6-
if (-1 != _generality) {
6+
if (_generality != -1) {
77
_generality = 0;
88
for (unsigned i = 0; i < PR2.general.num_vars; i++) {
99
if (-1 == value(i)) {

src/pr2.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ bool PR2Wrapper::run_pr2() {
5656
// We also create a deadend heuristic computer
5757
PR2.deadend.reachability_heuristic = PR2.proxy->new_deadend_heuristic();
5858

59+
PR2.axioms.axiom_evaluator = new AxiomEvaluator((TaskProxy) *PR2.proxy);
60+
5961
/**********************
6062
* Handle Time Limits *
6163
**********************/
@@ -240,6 +242,9 @@ bool PR2Wrapper::run_pr2() {
240242

241243
cout << endl;
242244

245+
if (PR2.solution.best->is_strong_cyclic())
246+
cout << "Strong cyclic solution found." << endl;
247+
243248
return PR2.solution.best->is_strong_cyclic();
244249
}
245250

0 commit comments

Comments
 (0)