From a97ae213ead9db055894782c33312eed978a4411 Mon Sep 17 00:00:00 2001 From: Florian Pommerening Date: Wed, 3 Jul 2024 18:52:48 +0200 Subject: [PATCH] use smaller epsilon value for rounding operator-counting heuristics --- src/search/lp/cplex_solver_interface.cc | 6 ++++++ src/search/lp/cplex_solver_interface.h | 1 + src/search/lp/lp_solver.cc | 4 ++++ src/search/lp/lp_solver.h | 1 + src/search/lp/solver_interface.h | 1 + src/search/lp/soplex_solver_interface.cc | 4 ++++ src/search/lp/soplex_solver_interface.h | 1 + src/search/operator_counting/operator_counting_heuristic.cc | 2 +- 8 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/search/lp/cplex_solver_interface.cc b/src/search/lp/cplex_solver_interface.cc index d6e3eb9617..6f34216568 100644 --- a/src/search/lp/cplex_solver_interface.cc +++ b/src/search/lp/cplex_solver_interface.cc @@ -419,6 +419,12 @@ double CplexSolverInterface::get_infinity() const { return CPX_INFBOUND; } +double CplexSolverInterface::get_epsilon() const { + double epsilon; + CPX_CALL(CPXgetdblparam, env, CPX_PARAM_EPOPT, &epsilon); + return epsilon; +} + void CplexSolverInterface::set_objective_coefficients(const vector &coefficients) { objective_indices.clear(); objective_indices.resize(coefficients.size()); diff --git a/src/search/lp/cplex_solver_interface.h b/src/search/lp/cplex_solver_interface.h index 5ba35cd532..de248acb10 100644 --- a/src/search/lp/cplex_solver_interface.h +++ b/src/search/lp/cplex_solver_interface.h @@ -209,6 +209,7 @@ class CplexSolverInterface : public SolverInterface { virtual void add_temporary_constraints(const named_vector::NamedVector &constraints) override; virtual void clear_temporary_constraints() override; virtual double get_infinity() const override; + virtual double get_epsilon() const override; virtual void set_objective_coefficients(const std::vector &coefficients) override; virtual void set_objective_coefficient(int index, double coefficient) override; virtual void set_constraint_lower_bound(int index, double bound) override; diff --git a/src/search/lp/lp_solver.cc b/src/search/lp/lp_solver.cc index 9f34d3d520..9c423d1a59 100644 --- a/src/search/lp/lp_solver.cc +++ b/src/search/lp/lp_solver.cc @@ -159,6 +159,10 @@ double LPSolver::get_infinity() const { return pimpl->get_infinity(); } +double LPSolver::get_epsilon() const { + return pimpl->get_epsilon(); +} + void LPSolver::set_objective_coefficients(const vector &coefficients) { pimpl->set_objective_coefficients(coefficients); } diff --git a/src/search/lp/lp_solver.h b/src/search/lp/lp_solver.h index a9bdff8c0a..1d48c26560 100644 --- a/src/search/lp/lp_solver.h +++ b/src/search/lp/lp_solver.h @@ -104,6 +104,7 @@ class LPSolver { void add_temporary_constraints(const named_vector::NamedVector &constraints); void clear_temporary_constraints(); double get_infinity() const; + double get_epsilon() const; void set_objective_coefficients(const std::vector &coefficients); void set_objective_coefficient(int index, double coefficient); diff --git a/src/search/lp/solver_interface.h b/src/search/lp/solver_interface.h index c9be11cf3d..0eea5598c5 100644 --- a/src/search/lp/solver_interface.h +++ b/src/search/lp/solver_interface.h @@ -21,6 +21,7 @@ class SolverInterface { virtual void add_temporary_constraints(const named_vector::NamedVector &constraints) = 0; virtual void clear_temporary_constraints() = 0; virtual double get_infinity() const = 0; + virtual double get_epsilon() const = 0; virtual void set_objective_coefficients(const std::vector &coefficients) = 0; virtual void set_objective_coefficient(int index, double coefficient) = 0; diff --git a/src/search/lp/soplex_solver_interface.cc b/src/search/lp/soplex_solver_interface.cc index 02c7cdb228..8b0b4ca680 100644 --- a/src/search/lp/soplex_solver_interface.cc +++ b/src/search/lp/soplex_solver_interface.cc @@ -85,6 +85,10 @@ double SoPlexSolverInterface::get_infinity() const { return infinity; } +double SoPlexSolverInterface::get_epsilon() const { + return soplex.realParam(SoPlex::OPTTOL); +} + void SoPlexSolverInterface::set_objective_coefficients(const vector &coefficients) { int num_cols = coefficients.size(); for (int i = 0; i < num_cols; ++i) { diff --git a/src/search/lp/soplex_solver_interface.h b/src/search/lp/soplex_solver_interface.h index 50bc3fb75f..1bd778847b 100644 --- a/src/search/lp/soplex_solver_interface.h +++ b/src/search/lp/soplex_solver_interface.h @@ -34,6 +34,7 @@ class SoPlexSolverInterface : public SolverInterface { virtual void add_temporary_constraints(const named_vector::NamedVector &constraints) override; virtual void clear_temporary_constraints() override; virtual double get_infinity() const override; + virtual double get_epsilon() const override; virtual void set_objective_coefficients(const std::vector &coefficients) override; virtual void set_objective_coefficient(int index, double coefficient) override; diff --git a/src/search/operator_counting/operator_counting_heuristic.cc b/src/search/operator_counting/operator_counting_heuristic.cc index a844b377bb..138bacc0c0 100644 --- a/src/search/operator_counting/operator_counting_heuristic.cc +++ b/src/search/operator_counting/operator_counting_heuristic.cc @@ -50,8 +50,8 @@ int OperatorCountingHeuristic::compute_heuristic(const State &ancestor_state) { int result; lp_solver.solve(); if (lp_solver.has_optimal_solution()) { - double epsilon = 0.01; double objective_value = lp_solver.get_objective_value(); + double epsilon = lp_solver.get_epsilon(); result = static_cast(ceil(objective_value - epsilon)); } else { result = DEAD_END;