Skip to content

Commit

Permalink
[issue1134] Rename existing delete-relaxation constraints and add cop…
Browse files Browse the repository at this point in the history
…y for new Rankooh and Rintanen implementation.
  • Loading branch information
remochristen committed Jan 30, 2024
1 parent 9ac0165 commit be4bf16
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/search/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ create_fast_downward_library(
HELP "Plugin containing the code for operator-counting heuristics"
SOURCES
operator_counting/constraint_generator
operator_counting/delete_relaxation_constraints
operator_counting/delete_relaxation_constraints_if
operator_counting/lm_cut_constraints
operator_counting/operator_counting_heuristic
operator_counting/pho_constraints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "delete_relaxation_constraints.h"
#include "delete_relaxation_constraints_if.h"

#include "../task_proxy.h"

Expand All @@ -21,37 +21,37 @@ static void add_lp_variables(int count, LPVariables &variables, vector<int> &ind
}


DeleteRelaxationConstraints::DeleteRelaxationConstraints(const plugins::Options &opts)
DeleteRelaxationConstraintsIF::DeleteRelaxationConstraintsIF(const plugins::Options &opts)
: use_time_vars(opts.get<bool>("use_time_vars")),
use_integer_vars(opts.get<bool>("use_integer_vars")) {
}

int DeleteRelaxationConstraints::get_var_op_used(const OperatorProxy &op) {
int DeleteRelaxationConstraintsIF::get_var_op_used(const OperatorProxy &op) {
return lp_var_id_op_used[op.get_id()];
}

int DeleteRelaxationConstraints::get_var_fact_reached(FactPair f) {
int DeleteRelaxationConstraintsIF::get_var_fact_reached(FactPair f) {
return lp_var_id_fact_reached[f.var][f.value];
}

int DeleteRelaxationConstraints::get_var_first_achiever(
int DeleteRelaxationConstraintsIF::get_var_first_achiever(
const OperatorProxy &op, FactPair f) {
return lp_var_id_first_achiever[op.get_id()][f.var][f.value];
}

int DeleteRelaxationConstraints::get_var_op_time(const OperatorProxy &op) {
int DeleteRelaxationConstraintsIF::get_var_op_time(const OperatorProxy &op) {
return lp_var_id_op_time[op.get_id()];
}

int DeleteRelaxationConstraints::get_var_fact_time(FactPair f) {
int DeleteRelaxationConstraintsIF::get_var_fact_time(FactPair f) {
return lp_var_id_fact_time[f.var][f.value];
}

int DeleteRelaxationConstraints::get_constraint_id(FactPair f) {
int DeleteRelaxationConstraintsIF::get_constraint_id(FactPair f) {
return constraint_ids[f.var][f.value];
}

void DeleteRelaxationConstraints::create_auxiliary_variables(
void DeleteRelaxationConstraintsIF::create_auxiliary_variables(
const TaskProxy &task_proxy, LPVariables &variables) {
OperatorsProxy ops = task_proxy.get_operators();
int num_ops = ops.size();
Expand Down Expand Up @@ -94,7 +94,7 @@ void DeleteRelaxationConstraints::create_auxiliary_variables(
}
}

void DeleteRelaxationConstraints::create_constraints(const TaskProxy &task_proxy,
void DeleteRelaxationConstraintsIF::create_constraints(const TaskProxy &task_proxy,
lp::LinearProgram &lp) {
LPVariables &variables = lp.get_variables();
LPConstraints &constraints = lp.get_constraints();
Expand Down Expand Up @@ -213,15 +213,15 @@ void DeleteRelaxationConstraints::create_constraints(const TaskProxy &task_proxy
}


void DeleteRelaxationConstraints::initialize_constraints(
void DeleteRelaxationConstraintsIF::initialize_constraints(
const shared_ptr<AbstractTask> &task, lp::LinearProgram &lp) {
TaskProxy task_proxy(*task);
create_auxiliary_variables(task_proxy, lp.get_variables());
create_constraints(task_proxy, lp);
}


bool DeleteRelaxationConstraints::update_constraints(
bool DeleteRelaxationConstraintsIF::update_constraints(
const State &state, lp::LPSolver &lp_solver) {
// Unset old bounds.
for (FactPair f : last_state) {
Expand All @@ -236,9 +236,9 @@ bool DeleteRelaxationConstraints::update_constraints(
return false;
}

class DeleteRelaxationConstraintsFeature : public plugins::TypedFeature<ConstraintGenerator, DeleteRelaxationConstraints> {
class DeleteRelaxationConstraintsIFFeature : public plugins::TypedFeature<ConstraintGenerator, DeleteRelaxationConstraintsIF> {
public:
DeleteRelaxationConstraintsFeature() : TypedFeature("delete_relaxation_constraints") {
DeleteRelaxationConstraintsIFFeature() : TypedFeature("delete_relaxation_constraints") {
document_title("Delete relaxation constraints");
document_synopsis(
"Operator-counting constraints based on the delete relaxation. By "
Expand Down Expand Up @@ -282,5 +282,5 @@ class DeleteRelaxationConstraintsFeature : public plugins::TypedFeature<Constrai
}
};

static plugins::FeaturePlugin<DeleteRelaxationConstraintsFeature> _plugin;
static plugins::FeaturePlugin<DeleteRelaxationConstraintsIFFeature> _plugin;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef OPERATOR_COUNTING_DELETE_RELAXATION_CONSTRAINTS_H
#define OPERATOR_COUNTING_DELETE_RELAXATION_CONSTRAINTS_H
#ifndef OPERATOR_COUNTING_DELETE_RELAXATION_CONSTRAINTS_IF_H
#define OPERATOR_COUNTING_DELETE_RELAXATION_CONSTRAINTS_IF_H

#include "constraint_generator.h"

Expand All @@ -20,7 +20,7 @@ namespace operator_counting {
using LPConstraints = named_vector::NamedVector<lp::LPConstraint>;
using LPVariables = named_vector::NamedVector<lp::LPVariable>;

class DeleteRelaxationConstraints : public ConstraintGenerator {
class DeleteRelaxationConstraintsIF : public ConstraintGenerator {
bool use_time_vars;
bool use_integer_vars;

Expand Down Expand Up @@ -63,7 +63,7 @@ class DeleteRelaxationConstraints : public ConstraintGenerator {
const TaskProxy &task_proxy, LPVariables &variables);
void create_constraints(const TaskProxy &task_proxy, lp::LinearProgram &lp);
public:
explicit DeleteRelaxationConstraints(const plugins::Options &opts);
explicit DeleteRelaxationConstraintsIF(const plugins::Options &opts);

virtual void initialize_constraints(
const std::shared_ptr<AbstractTask> &task,
Expand Down
Loading

0 comments on commit be4bf16

Please sign in to comment.