EasyLocalpp  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
solver.hh
Go to the documentation of this file.
1 #if !defined(_SOLVER_HH_)
2 #define _SOLVER_HH_
3 
4 #include <tuple>
5 
9 
10 namespace EasyLocal {
11 
12  namespace Core {
13 
14  template <class Input, class Output, typename CFtype = int>
15  struct SolverResult
16  {
17  SolverResult(const Output& output, const CostStructure<CFtype>& cost, double running_time) : output(output), cost(cost), running_time(running_time) {}
18  Output output;
20  double running_time;
21  };
22 
28  template <class Input, class Output, typename CFtype = int>
29  class Solver
30  {
31  public:
33  const std::string name;
34 
41 
48  virtual SolverResult<Input, Output, CFtype> Resolve(const Output& initial_solution) throw (ParameterNotSet, IncorrectParameterValue) = 0;
49 
51  virtual ~Solver() {}
52 
54  static std::vector<Solver<Input, Output, CFtype>*> solvers;
55 
56  protected:
57 
62  Solver(const Input& in, std::string name);
63 
65  const Input& in;
66 
67  };
68 
69  /*************************************************************************
70  * Implementation
71  *************************************************************************/
72 
73  template <class Input, class Output, typename CFtype>
74  std::vector<Solver<Input, Output, CFtype>*> Solver<Input, Output, CFtype>::solvers;
75 
76  template <class Input, class Output, typename CFtype>
77  Solver<Input, Output, CFtype>::Solver(const Input& i, std::string e_name)
78  : name(e_name), in(i)
79  {
80  solvers.push_back(this);
81  }
82  }
83 }
84 
85 #endif // _SOLVER_HH_
CostStructure< CFtype > cost
Definition: solver.hh:19
static std::vector< Solver< Input, Output, CFtype > * > solvers
Definition: solver.hh:54
virtual SolverResult< Input, Output, CFtype > Solve()=0
virtual SolverResult< Input, Output, CFtype > Resolve(const Output &initial_solution)=0
SolverResult(const Output &output, const CostStructure< CFtype > &cost, double running_time)
Definition: solver.hh:17
const std::string name
Definition: solver.hh:33
Solver(const Input &in, std::string name)
Definition: solver.hh:77
const Input & in
Definition: solver.hh:65