AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
lp_heuristic.h
1#ifndef PROBFD_HEURISTICS_LP_HEURISTIC_H
2#define PROBFD_HEURISTICS_LP_HEURISTIC_H
3
4#include "probfd/heuristics/task_dependent_heuristic.h"
5
6#include "downward/lp/lp_solver.h"
7
8#include <memory>
9#include <vector>
10
11namespace probfd::heuristics {
12
23template <typename Derived>
24class LPHeuristic : public TaskDependentHeuristic {
25protected:
26 mutable lp::LPSolver lp_solver_;
27
28public:
30 std::shared_ptr<ProbabilisticTask> task,
31 utils::LogProxy log,
32 lp::LPSolverType solver_type)
33 : TaskDependentHeuristic(task, log)
34 , lp_solver_(solver_type)
35 {
36 }
37
38 value_t evaluate(const State& state) const final
39 {
40 assert(!lp_solver_.has_temporary_constraints());
41
42 static_cast<const Derived*>(this)->update_constraints(state);
43
44 lp_solver_.solve();
45
46 value_t result = lp_solver_.has_optimal_solution()
47 ? lp_solver_.get_objective_value()
48 : INFINITE_VALUE;
49
50 lp_solver_.clear_temporary_constraints();
51 static_cast<const Derived*>(this)->reset_constraints(state);
52
53 return result;
54 }
55};
56
57} // namespace probfd::heuristics
58
59#endif
Base class for heuristics based on linear programming.
Definition lp_heuristic.h:24
This namespace contains heuristic implementations.
Definition additive_cartesian_heuristic.h:19
double value_t
Typedef for the state value type.
Definition aliases.h:7