Skip to content

Commit

Permalink
use smaller epsilon value for rounding operator-counting heuristics
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianPommerening committed Jul 3, 2024
1 parent 92060af commit a97ae21
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/search/lp/cplex_solver_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> &coefficients) {
objective_indices.clear();
objective_indices.resize(coefficients.size());
Expand Down
1 change: 1 addition & 0 deletions src/search/lp/cplex_solver_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class CplexSolverInterface : public SolverInterface {
virtual void add_temporary_constraints(const named_vector::NamedVector<LPConstraint> &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<double> &coefficients) override;
virtual void set_objective_coefficient(int index, double coefficient) override;
virtual void set_constraint_lower_bound(int index, double bound) override;
Expand Down
4 changes: 4 additions & 0 deletions src/search/lp/lp_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> &coefficients) {
pimpl->set_objective_coefficients(coefficients);
}
Expand Down
1 change: 1 addition & 0 deletions src/search/lp/lp_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class LPSolver {
void add_temporary_constraints(const named_vector::NamedVector<LPConstraint> &constraints);
void clear_temporary_constraints();
double get_infinity() const;
double get_epsilon() const;

void set_objective_coefficients(const std::vector<double> &coefficients);
void set_objective_coefficient(int index, double coefficient);
Expand Down
1 change: 1 addition & 0 deletions src/search/lp/solver_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class SolverInterface {
virtual void add_temporary_constraints(const named_vector::NamedVector<LPConstraint> &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<double> &coefficients) = 0;
virtual void set_objective_coefficient(int index, double coefficient) = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/search/lp/soplex_solver_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> &coefficients) {
int num_cols = coefficients.size();
for (int i = 0; i < num_cols; ++i) {
Expand Down
1 change: 1 addition & 0 deletions src/search/lp/soplex_solver_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SoPlexSolverInterface : public SolverInterface {
virtual void add_temporary_constraints(const named_vector::NamedVector<LPConstraint> &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<double> &coefficients) override;
virtual void set_objective_coefficient(int index, double coefficient) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(ceil(objective_value - epsilon));
} else {
result = DEAD_END;
Expand Down

0 comments on commit a97ae21

Please sign in to comment.