Skip to content

Commit

Permalink
Option to disable negative axioms (default: disabled) + style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
speckdavid committed Sep 13, 2023
1 parent 5b1ac05 commit 4978191
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/search/algorithms/segmented_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class SegmentedArrayVector {
: elements_per_array((assert(elements_per_array_ > 0),
elements_per_array_)),
arrays_per_segment(
std::max(SEGMENT_BYTES / (elements_per_array * sizeof(Element)), size_t(1))),
std::max(SEGMENT_BYTES / (elements_per_array * sizeof(Element)), size_t (1))),
elements_per_segment(elements_per_array * arrays_per_segment),
the_size(0) {
}
Expand All @@ -193,7 +193,7 @@ class SegmentedArrayVector {
elements_per_array((assert(elements_per_array_ > 0),
elements_per_array_)),
arrays_per_segment(
std::max(SEGMENT_BYTES / (elements_per_array * sizeof(Element)), size_t(1))),
std::max(SEGMENT_BYTES / (elements_per_array * sizeof(Element)), size_t (1))),
elements_per_segment(elements_per_array * arrays_per_segment),
the_size(0) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/search/cegar/abstraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pair<int, int> Abstraction::refine(
states.push_back(move(v2));

return {
v1_id, v2_id
v1_id, v2_id
};
}

Expand Down
22 changes: 11 additions & 11 deletions src/search/lp/lp_internals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ unique_ptr<OsiSolverInterface> create_lp_solver(LPSolverType solver_type) {
break;
case LPSolverType::CPLEX:
#ifdef COIN_HAS_CPX
{
OsiCpxSolverInterface *cpx_solver = new OsiCpxSolverInterface;
CPXsetintparam(cpx_solver->getEnvironmentPtr(), CPX_PARAM_THREADS, 1);
cpx_solver->passInMessageHandler(new ErrorCatchingCoinMessageHandler);
lp_solver = cpx_solver;
}
{
OsiCpxSolverInterface *cpx_solver = new OsiCpxSolverInterface;
CPXsetintparam(cpx_solver->getEnvironmentPtr(), CPX_PARAM_THREADS, 1);
cpx_solver->passInMessageHandler(new ErrorCatchingCoinMessageHandler);
lp_solver = cpx_solver;
}
#else
missing_symbol = "COIN_HAS_CPX";
#endif
Expand All @@ -127,11 +127,11 @@ unique_ptr<OsiSolverInterface> create_lp_solver(LPSolverType solver_type) {
break;
case LPSolverType::SOPLEX:
#ifdef COIN_HAS_SPX
{
OsiSpxSolverInterface *spx_solver = new OsiSpxSolverInterface;
spx_solver->getSPxOut()->setVerbosity(soplex::SPxOut::ERROR);
lp_solver = spx_solver;
}
{
OsiSpxSolverInterface *spx_solver = new OsiSpxSolverInterface;
spx_solver->getSPxOut()->setVerbosity(soplex::SPxOut::ERROR);
lp_solver = spx_solver;
}
#else
missing_symbol = "COIN_HAS_SPX";
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/search/mutex_group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool MutexGroup::hasPair(int var, int val) const {

ostream &operator<<(ostream &os, const MutexGroup &mg) {
os << (mg.exactly_one ? "[ExactlyOne_" : "[MutexGroup_") <<
(mg.detected_fw ? "fw" : "bw");
(mg.detected_fw ? "fw" : "bw");
for (size_t i = 0; i < mg.facts.size(); ++i) {
os << " " << tasks::g_root_task->get_fact_name(mg.facts[i]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/search/pdbs/pattern_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ class PatternDatabase {
return num_states;
}

std::vector<std::vector<OperatorID>> && extract_wildcard_plan() {
std::vector<std::vector<OperatorID>> &&extract_wildcard_plan() {
return std::move(wildcard_plan);
};
}

/*
Returns the average h-value over all states, where dead-ends are
Expand Down
4 changes: 2 additions & 2 deletions src/search/plan_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void PlanManager::dump_plan(const Plan &plan,
OperatorsProxy operators = task_proxy.get_operators();
for (OperatorID op_id : plan) {
cout << operators[op_id].get_name() << " (" << operators[op_id].get_cost()
<< ")" << endl;
<< ")" << endl;
}
int plan_cost = calculate_plan_cost(plan, task_proxy);
utils::g_log << "Plan length: " << plan.size() << " step(s)." << endl;
Expand All @@ -71,7 +71,7 @@ void PlanManager::save_plan(const Plan &plan, const TaskProxy &task_proxy,
for (OperatorID op_id : plan) {
if (dump_plan) {
cout << operators[op_id].get_name() << " (" << operators[op_id].get_cost()
<< ")" << endl;
<< ")" << endl;
}
outfile << "(" << operators[op_id].get_name() << ")" << endl;
}
Expand Down
3 changes: 2 additions & 1 deletion src/search/task_utils/sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class RandomWalkSampler {
*/
State sample_state(
int init_h,
const DeadEndDetector &is_dead_end = [](const State &) {return false;}) const;
const DeadEndDetector &is_dead_end = [] (const State &) {return false;
}) const;
};
}

Expand Down
7 changes: 4 additions & 3 deletions src/translate/axiom_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, derived_variables):
self.layer = 0


def handle_axioms(operators, axioms, goals, layer_strategy):
def handle_axioms(operators, axioms, goals, layer_strategy, negative_axioms):
clusters = compute_clusters(axioms, goals, operators)
axiom_layers = compute_axiom_layers(clusters, layer_strategy)

Expand All @@ -62,8 +62,9 @@ def handle_axioms(operators, axioms, goals, layer_strategy):
# the future. Similarly, it would be a good idea to remove the notion of
# axiom layers and derived variable default values from the output.
# (All derived variables should be binary and default to false.)
with timers.timing("Computing negative axioms"):
compute_negative_axioms(clusters)
if negative_axioms:
with timers.timing("Computing negative axioms"):
compute_negative_axioms(clusters)

axioms = get_axioms(clusters)
if DEBUG:
Expand Down
4 changes: 4 additions & 0 deletions src/translate/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def parse_args():
help="How to assign layers to derived variables. 'min' attempts to put as "
"many variables into the same layer as possible, while 'max' puts each variable "
"into its own layer unless it is part of a cycle.")
argparser.add_argument(
"--add-negative-axioms", action="store_true",
help="add negative axioms. This setting introduced axioms that can help "
"to be more informative.")
return argparser.parse_args()


Expand Down
3 changes: 2 additions & 1 deletion src/translate/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ def translate_task(strips_to_sas, ranges, translation_key,
actions, axioms, metric, implied_facts):
with timers.timing("Processing axioms", block=True):
axioms, axiom_layer_dict = axiom_rules.handle_axioms(actions, axioms, goals,
options.layer_strategy)
options.layer_strategy,
options.add_negative_axioms)

if options.dump_task:
# Remove init facts that don't occur in strips_to_sas: they're constant.
Expand Down

0 comments on commit 4978191

Please sign in to comment.