25 #include <boost/random/uniform_int.hpp>
26 #include <boost/random/uniform_real.hpp>
30 #include "../exceptions.h"
31 #include "../population.h"
32 #include "../problem/base.h"
37 namespace pagmo {
namespace algorithm {
49 m_algorithm = algorithm.
clone();
51 pagmo_throw(value_error,
"number of multistarts needs to be larger than zero");
56 ms::ms(
const ms &other):
base(other),m_algorithm(other.m_algorithm->clone()),m_starts(other.m_starts) {}
77 if (m_starts == 0 || NP == 0) {
85 for (
int i=0; i< m_starts; ++i)
88 m_algorithm->evolve(working_pop);
94 pop.set_x(pop.get_worst_idx(),working_pop.
get_individual(working_pop.get_best_idx()).cur_x);
95 pop.set_v(pop.get_worst_idx(),working_pop.
get_individual(working_pop.get_best_idx()).cur_v);
99 std::cout << i <<
". " <<
"\tCurrent iteration best: " << working_pop.
get_individual(working_pop.get_best_idx()).cur_f <<
"\tOverall champion: " << pop.champion().
f << std::endl;
108 return "Multi-start";
117 return m_algorithm->clone();
128 m_algorithm = algo.
clone();
137 std::ostringstream s;
138 s <<
"algorithm: " << m_algorithm->get_name() <<
' ';
139 s <<
"iter:" << m_starts <<
' ';
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base algorithm.
const individual_type & get_individual(const size_type &) const
Get constant reference to individual at position n.
base_ptr clone() const
Clone method.
std::string get_name() const
Algorithm name.
virtual base_ptr clone() const =0
Clone method.
fitness_vector f
Fitness vector.
bool m_screen_output
Indicates to the derived class whether to print stuff on screen.
std::string human_readable_extra() const
Extra human readable algorithm info.
void evolve(population &) const
Evolve implementation.
ms(const base &=de(), int=1)
Constructor.
base_ptr get_algorithm() const
Get a copy of the internal algorithm.
container_type::size_type size_type
Population size type.
void reinit(const size_type &)
Re-initialise individual at position idx.
void set_algorithm(const base &)
Set algorithm.
bool compare_fc(const fitness_vector &, const constraint_vector &, const fitness_vector &, const constraint_vector &) const
Simultaneous fitness-constraint comparison.