1 #if !defined(_SIMPLE_LOCAL_SEARCH_HH_)
2 #define _SIMPLE_LOCAL_SEARCH_HH_
19 template <
class Input,
class Output,
class State,
typename CFtype =
int>
30 void Print(std::ostream& os = std::cout)
const;
31 void ReadParameters(std::istream& is = std::cin, std::ostream& os = std::cout);
53 template <
class Input,
class Output,
class State,
typename CFtype>
58 :
AbstractLocalSearch<Input, Output, State, CFtype>(in, e_sm, e_om, name,
"Simple Local Search Solver"), p_searchengine(nullptr)
61 template <
class Input,
class Output,
class State,
typename CFtype>
64 os <<
"Simple Local Search Solver: " << this->name <<
" parameters" << std::endl;
65 os <<
"SearchEngine: " << std::endl;
66 if (this->p_searchengine)
67 this->p_searchengine->ReadParameters(is, os);
70 template <
class Input,
class Output,
class State,
typename CFtype>
73 os <<
"Simple Local Search Solver: " << this->name << std::endl;
74 if (this->p_searchengine)
75 this->p_searchengine->Print(os);
77 os <<
"<no searchengine attached>" << std::endl;
87 template <
class Input,
class Output,
class State,
typename CFtype>
89 { this->p_searchengine = &r; }
92 template <
class Input,
class Output,
class State,
typename CFtype>
97 throw std::logic_error(
"SearchEngine not set in object " + this->name);
98 this->current_state_cost = p_searchengine->Go(*this->p_current_state);
100 *this->p_best_state = *this->p_current_state;
101 this->best_state_cost = this->current_state_cost;
104 template <
class Input,
class Output,
class State,
typename CFtype>
107 p_searchengine->Interrupt();
112 #endif // _SIMPLE_LOCAL_SEARCH_HH_
void SetSearchEngine(SearchEngine< Input, State, CFtype > &r)
void Print(std::ostream &os=std::cout) const
void ReadParameters(std::istream &is=std::cin, std::ostream &os=std::cout)
SimpleLocalSearch(const Input &in, StateManager< Input, State, CFtype > &e_sm, OutputManager< Input, Output, State, CFtype > &e_om, std::string name)
SearchEngine< Input, State, CFtype > SearchEngineType
This component is responsible for all operations on the state which are independent of the neighborho...
SearchEngineType * p_searchengine