1 #if !defined(_ABSTRACT_LOCAL_SEARCH_HH_)
2 #define _ABSTRACT_LOCAL_SEARCH_HH_
23 template<
class Input,
class Output,
class State,
typename CFtype =
int>
31 std::string
name, std::string description);
38 return [
this](void) ->
int {
46 virtual void Go() = 0;
65 void TerminateSolve();
80 template<class Input, class Output, class State, typename CFtype>
82 OutputManager<Input, Output, State, CFtype>& e_om, std::
string name, std::
string description) :
86 template<
class Input,
class Output,
class State,
typename CFtype>
88 init_trials(
"init_trials",
"Number of states to be tried in the initialization phase", this->
parameters);
90 timeout(
"timeout",
"Solver timeout (if not specified, no timeout)", this->
parameters);
99 template<
class Input,
class Output,
class State,
typename CFtype>
111 template<
class Input,
class Output,
class State,
typename CFtype>
117 template<
class Input,
class Output,
class State,
typename CFtype>
119 auto start = std::chrono::high_resolution_clock::now();
123 SyncRun(std::chrono::milliseconds(static_cast<long long int>(
timeout * 1000.0)));
126 p_out = std::make_shared < Output > (this->
in);
131 std::chrono::duration_cast < std::chrono::duration<double, std::ratio<1>>>(std::chrono::high_resolution_clock::now() - start).count();
136 template<
class Input,
class Output,
class State,
typename CFtype>
139 auto start = std::chrono::high_resolution_clock::now();
146 SyncRun(std::chrono::milliseconds(static_cast<long long int>(
timeout * 1000.0)));
149 p_out = std::make_shared < Output > (this->
in);
154 std::chrono::duration_cast < std::chrono::duration<double, std::ratio<1>>>(std::chrono::high_resolution_clock::now() - start).count();
159 template<
class Input,
class Output,
class State,
typename CFtype>
165 #endif // _ABSTRACT_LOCAL_SEARCH_HH_
int SyncRun(std::chrono::milliseconds timeout, Args...args)
CostStructure< CFtype > current_state_cost
std::shared_ptr< State > p_best_state
virtual std::function< int(void)> MakeFunction()
virtual SolverResult< Input, Output, CFtype > Solve() final
AbstractLocalSearch(const Input &in, StateManager< Input, State, CFtype > &e_sm, OutputManager< Input, Output, State, CFtype > &e_om, std::string name, std::string description)
Constructs an abstract local search solver.
StateManager< Input, State, CFtype > & sm
virtual ~AbstractLocalSearch()
void RegisterParameters()
Parameter< bool > random_initial_state
Parameter< unsigned int > init_trials
virtual SolverResult< Input, Output, CFtype > Resolve(const Output &initial_solution) final
std::shared_ptr< State > p_current_state
Parameter< double > timeout
std::shared_ptr< Output > p_out
OutputManager< Input, Output, State, CFtype > & om
CostStructure< CFtype > best_state_cost
This component is responsible for all operations on the state which are independent of the neighborho...
virtual void FindInitialState()