Skip to content

Commit

Permalink
Change test if axiom sets default value to assert that it does not (a…
Browse files Browse the repository at this point in the history
…xioms.cc).
  • Loading branch information
salome-eriksson committed Jul 15, 2024
1 parent 2068ea6 commit 262e2b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/search/axioms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,28 @@ AxiomEvaluator::AxiomEvaluator(const TaskProxy &task_proxy) {
axiom_literals.emplace_back(var.get_domain_size());

// Initialize rules
// Since we are skipping some axioms, we cannot access them through
// their id position directly.
vector<int> axiom_id_to_position(axioms.size(), -1);
for (OperatorProxy axiom : axioms) {
assert(axiom.get_effects().size() == 1);
EffectProxy cond_effect = axiom.get_effects()[0];
FactPair effect = cond_effect.get_fact().get_pair();
int num_conditions = cond_effect.get_conditions().size();
// Ignore axioms which set the variable to its default value.
if (effect.value != variables[effect.var].get_default_axiom_value()) {
AxiomLiteral *eff_literal = &axiom_literals[effect.var][effect.value];
axiom_id_to_position[axiom.get_id()] = rules.size();
rules.emplace_back(

// We don't allow axioms that set the variable to its default value.
assert(effect.value != variables[effect.var].get_default_axiom_value());
AxiomLiteral *eff_literal = &axiom_literals[effect.var][effect.value];
rules.emplace_back(
num_conditions, effect.var, effect.value, eff_literal);
}
}

// Cross-reference rules and literals
for (OperatorProxy axiom : axioms) {
// Ignore axioms which set the variable to its default value.
int position = axiom_id_to_position[axiom.get_id()];
if (position != -1) {
EffectProxy effect = axiom.get_effects()[0];
for (FactProxy condition : effect.get_conditions()) {
int var_id = condition.get_variable().get_id();
int val = condition.get_value();
AxiomRule *rule = &rules[position];
axiom_literals[var_id][val].condition_of.push_back(rule);
}
int id = axiom.get_id();
EffectProxy effect = axiom.get_effects()[0];
for (FactProxy condition : effect.get_conditions()) {
int var_id = condition.get_variable().get_id();
int val = condition.get_value();
AxiomRule *rule = &rules[id];
axiom_literals[var_id][val].condition_of.push_back(rule);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/search/tasks/default_value_axioms_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class Options;
that together represent ¬v <- ¬c_1 ^ ... ^ ¬c_n.
Notes:
- Technically, this transformation is illegal since it adds axioms which set
derived variables to their default value. Do not use it for search; the
axiom evaluator expects that all axioms set variables to their non-default
values (checked with an assertion).
- We assume that derived variables are binary.
- THE TRANSFORMATION CAN BE SLOW! The rule ¬v <- ¬c_1 ^ ... ^ ¬c_n must
be split up into axioms whose conditions are simple conjunctions. Since
Expand Down

0 comments on commit 262e2b2

Please sign in to comment.