PaGMO
1.1.5
|
Evolutionary Neuro-Controller for the MIT Spheres (perception-action defined in the absolute frame) More...
#include <spheres.h>
Public Member Functions | |
spheres (int n_evaluations=10, int n_hidden=10, double ode_prec=1E-6, unsigned int seed=0, bool symmetric=false, double sim_time=50.0, const std::vector< double > &sides=std::vector< double >(3, 0.5)) | |
Constructor. More... | |
spheres (const spheres &) | |
Copy Constructor. More... | |
~spheres () | |
Destructor. More... | |
std::vector< std::vector< double > > | post_evaluate (const decision_vector &x, int N=25000, unsigned int seed=0) const |
Post evaluation of the neural controller. More... | |
std::vector< std::vector< double > > | simulate (const decision_vector &x, const std::vector< double > &ic, int N) const |
Performs one "detailed" simulation. More... | |
std::string | get_name () const |
Get problem's name. More... | |
base_ptr | clone () const |
Clone method. | |
std::vector< double > | get_nn_weights (decision_vector x) const |
Gets the weights of the neural network. | |
Public Member Functions inherited from pagmo::problem::base_stochastic | |
base_stochastic (int, unsigned int=0u) | |
Constructor from global dimension and random seed. More... | |
base_stochastic (int, int, int, int, int, const double &, unsigned int) | |
Constructor from global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More... | |
base_stochastic (int, int, int, int, int, const std::vector< double > &, unsigned int) | |
Constructor from global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance vector. More... | |
unsigned int | get_seed () const |
Gets the pseudo random generator seed. More... | |
void | set_seed (unsigned int) const |
Sets the pseudo random generator seed. More... | |
Public Member Functions inherited from pagmo::problem::base | |
base (int, int=0, int=1, int=0, int=0, const double &=0) | |
Constructor from global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More... | |
base (int, int, int, int, int, const std::vector< double > &) | |
Constructor from global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More... | |
base (const double &, const double &, int, int=0, int=1, int=0, int=0, const double &=0) | |
Constructor from values for lower and upper bounds, global dimension, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More... | |
base (const decision_vector &, const decision_vector &, int=0, int=1, int=0, int=0, const double &=0) | |
Constructor from upper/lower bounds, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More... | |
template<std::size_t N> | |
base (const double(&v1)[N], const double(&v2)[N], int ni=0, int nf=1, int nc=0, int nic=0, const double &c_tol=0) | |
Constructor from raw arrays, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More... | |
template<class Iterator1 , class Iterator2 > | |
base (Iterator1 start1, Iterator1 end1, Iterator2 start2, Iterator2 end2, int ni=0, int nf=1, int nc=0, int nic=0, const double &c_tol=0) | |
Constructor from iterators, integer dimension, fitness dimension, global constraints dimension, inequality constraints dimension and constraints tolerance. More... | |
virtual | ~base () |
Trivial destructor. More... | |
std::string | human_readable () const |
Return human readable representation of the problem. More... | |
bool | operator== (const base &) const |
Equality operator. More... | |
bool | operator!= (const base &) const |
Inequality operator. More... | |
bool | is_compatible (const base &) const |
Compatibility operator. More... | |
bool | compare_x (const decision_vector &, const decision_vector &) const |
Compare decision vectors. More... | |
bool | verify_x (const decision_vector &) const |
Verify compatibility of decision vector x with problem. More... | |
bool | compare_fc (const fitness_vector &, const constraint_vector &, const fitness_vector &, const constraint_vector &) const |
Simultaneous fitness-constraint comparison. More... | |
virtual void | pre_evolution (population &) const |
Pre-evolution hook. More... | |
virtual void | post_evolution (population &) const |
Post-evolution hook. More... | |
virtual void | set_sparsity (int &lenG, std::vector< int > &iGfun, std::vector< int > &jGvar) const |
Sets the sparsity pattern of the gradient. More... | |
const decision_vector & | get_lb () const |
Lower bounds getter. More... | |
const decision_vector & | get_ub () const |
Upper bounds getter. More... | |
void | set_bounds (const decision_vector &, const decision_vector &) |
Bounds setter from pagmo::decision_vector. More... | |
template<class Iterator1 , class Iterator2 > | |
void | set_bounds (Iterator1 start1, Iterator1 end1, Iterator2 start2, Iterator2 end2) |
Bounds setter from iterators. More... | |
template<std::size_t N> | |
void | set_bounds (const double(&v1)[N], const double(&v2)[N]) |
Bounds setter from raw arrays. More... | |
void | set_bounds (const double &, const double &) |
Set bounds to specified values. More... | |
void | set_bounds (int, const double &, const double &) |
Set bounds to specified values. More... | |
void | set_lb (const decision_vector &) |
Set lower bounds from pagmo::decision_vector. More... | |
void | set_lb (int, const double &) |
Set specific lower bound to value. More... | |
void | set_lb (const double &) |
Set all lower bounds to value. More... | |
template<class Iterator > | |
void | set_lb (Iterator start, Iterator end) |
Lower bounds setter from iterators. More... | |
template<std::size_t N> | |
void | set_lb (const double(&v)[N]) |
Lower bounds setter from raw array. More... | |
void | set_ub (const decision_vector &) |
Set upper bounds from pagmo::decision_vector. More... | |
void | set_ub (int, const double &) |
Set specific upper bound to value. More... | |
void | set_ub (const double &) |
Set all upper bounds to value. More... | |
template<class Iterator > | |
void | set_ub (Iterator start, Iterator end) |
Upper bounds setter from iterators. More... | |
template<std::size_t N> | |
void | set_ub (const double(&v)[N]) |
Upper bounds setter from raw array. More... | |
unsigned int | get_fevals () const |
Return number of function evaluations. More... | |
unsigned int | get_cevals () const |
Return number of constraints function evaluations. More... | |
size_type | get_dimension () const |
Return global dimension. More... | |
size_type | get_i_dimension () const |
Return integer dimension. More... | |
f_size_type | get_f_dimension () const |
Return fitness dimension. More... | |
c_size_type | get_c_dimension () const |
Return global constraints dimension. More... | |
c_size_type | get_ic_dimension () const |
Return inequality constraints dimension. More... | |
const std::vector< double > & | get_c_tol () const |
Return constraints tolerance. More... | |
double | get_diameter () const |
Get the diameter of the problem. More... | |
constraint_vector | compute_constraints (const decision_vector &) const |
Compute constraints and return constraint vector. More... | |
void | compute_constraints (constraint_vector &, const decision_vector &) const |
Compute constraints and write them into contraint vector. More... | |
bool | compare_constraints (const constraint_vector &, const constraint_vector &) const |
Compare constraint vectors. More... | |
bool | test_constraint (const constraint_vector &, const c_size_type &) const |
Test i-th constraint of c (using tolerance information). More... | |
bool | feasibility_x (const decision_vector &) const |
Test feasibility of decision vector. More... | |
bool | feasibility_c (const constraint_vector &) const |
Test feasibility of constraint vector. More... | |
fitness_vector | objfun (const decision_vector &) const |
Return fitness of pagmo::decision_vector. More... | |
void | objfun (fitness_vector &, const decision_vector &) const |
Write fitness of pagmo::decision_vector into pagmo::fitness_vector. More... | |
bool | compare_fitness (const fitness_vector &, const fitness_vector &) const |
Compare fitness vectors. More... | |
void | reset_caches () const |
Reset internal caches. More... | |
const std::vector< constraint_vector > & | get_best_c (void) const |
Get the best known constraint vector. More... | |
const std::vector< decision_vector > & | get_best_x (void) const |
Get the best known decision vector. More... | |
const std::vector< fitness_vector > & | get_best_f (void) const |
Get the best known fitness vector. More... | |
void | set_best_x (const std::vector< decision_vector > &) |
Sets the best known decision vectors. More... | |
Protected Member Functions | |
void | objfun_impl (fitness_vector &, const decision_vector &) const |
Objective function implementation. More... | |
std::string | human_readable_extra () const |
Extra human readable info for the problem. More... | |
Protected Member Functions inherited from pagmo::problem::base | |
virtual bool | equality_operator_extra (const base &) const |
Extra requirements for equality. More... | |
virtual bool | compare_fc_impl (const fitness_vector &, const constraint_vector &, const fitness_vector &, const constraint_vector &) const |
Implementation of simultaneous fitness-constraint comparison. More... | |
void | estimate_sparsity (const decision_vector &, int &lenG, std::vector< int > &iGfun, std::vector< int > &jGvar) const |
Heuristics to estimate the sparsity pattern of the problem. More... | |
void | estimate_sparsity (int &lenG, std::vector< int > &iGfun, std::vector< int > &jGvar) const |
Heuristics to estimate the sparsity pattern of the problem. More... | |
virtual void | compute_constraints_impl (constraint_vector &, const decision_vector &) const |
Implementation of constraint computation. More... | |
virtual bool | compare_constraints_impl (const constraint_vector &, const constraint_vector &) const |
Implementation of constraint vector comparison. More... | |
virtual bool | compare_fitness_impl (const fitness_vector &, const fitness_vector &) const |
Implementation of fitness vectors comparison. More... | |
Friends | |
class | boost::serialization::access |
Additional Inherited Members | |
Public Types inherited from pagmo::problem::base | |
typedef decision_vector::size_type | size_type |
Problem's size type: the same as pagmo::decision_vector's size type. | |
typedef fitness_vector::size_type | f_size_type |
Fitness' size type: the same as pagmo::fitness_vector's size type. | |
typedef constraint_vector::size_type | c_size_type |
Constraints' size type: the same as pagmo::constraint_vector's size type. | |
Static Public Attributes inherited from pagmo::problem::base | |
static const std::size_t | cache_capacity = 5 |
Capacity of the internal caches. | |
Protected Attributes inherited from pagmo::problem::base_stochastic | |
rng_double | m_drng |
Random number generator for double-precision floating point values. | |
rng_uint32 | m_urng |
Random number generator for unsigned integer values. | |
unsigned int | m_seed |
Seed of the random number generator. | |
Evolutionary Neuro-Controller for the MIT Spheres (perception-action defined in the absolute frame)
This problem (a stochastic optimization problem) aims at 'evolving' an artificial neural network able to steer the positions of three satellites representing the SPHERES MIT test-bed on-board of the ISS. It requies GSL libraries and thus it is compiled only if that option is activated when compiling pagmo.
The objective function is the average over multiple runs of the following fitness
rewarding neurocontrollers that drive the spheres towards a triangular configuration in space with final zero absolute velocity. L1<L2<L3 are the three sides of the trianlgular formation desired and the three actual interspheres distances at the end of one simulation.
NOTE: the dynamical model of the spheres is here that of point masses. As a consequence, each sphere perception and action (sensing and actuating) must be defined with respect to a reference frame that is known by all spheres (a star-tracker would give this information). This seemingly small detail brings to an important bias in learning (i.e. the final triangle is always achieved with the same absolute orientation!!!). In pagmo::problem::spheres_q such a bias is removed by defining perception and action in the sphere's body frame.
pagmo::problem::spheres::spheres | ( | int | n_evaluations = 10 , |
int | n_hidden = 10 , |
||
double | ode_prec = 1E-6 , |
||
unsigned int | seed = 0 , |
||
bool | symmetric = false , |
||
double | sim_time = 50.0 , |
||
const std::vector< double > & | sides = std::vector<double>(3,0.5) |
||
) |
Constructor.
Initializes the Sphere simulator, the neural net and everything else!!!
[in] | n_evaluations | Number of initial conditions each neural network fitness is evaluated upon |
[in] | n_hidden | number of hidden neurons in the neural net |
[in] | ode_prec | precision requested to adapt the ode-solver step size |
[in] | seed | seed used to produce all random initial conditions |
[in] | symmetric | a boolean value that, if true, indicates that the neural network does not distinguish among permutations of its input values due to sphere ID exchange. |
[in] | sim_time | Time after wich the fitness is evaluated in the simualtion |
[in] | sides | The three sides of the trianglular formation to acquire and maintain |
Definition at line 47 of file spheres.cpp.
pagmo::problem::spheres::spheres | ( | const spheres & | other | ) |
Copy Constructor.
Necessary to properly handle the gsl variables (pointers!!!)
Definition at line 65 of file spheres.cpp.
pagmo::problem::spheres::~spheres | ( | ) |
Destructor.
Necessary to properly clear memory allocated by gsl routines
Definition at line 77 of file spheres.cpp.
|
virtual |
Get problem's name.
Default implementation will return the problem's mangled C++ name.
Reimplemented from pagmo::problem::base.
Definition at line 380 of file spheres.cpp.
|
protectedvirtual |
Extra human readable info for the problem.
Will return a formatted string containing the values vector, the weights vectors and the max weight.
Reimplemented from pagmo::problem::base.
Definition at line 389 of file spheres.cpp.
|
protectedvirtual |
Objective function implementation.
Takes a pagmo::decision_vector x as input and writes its pagmo::fitness_vector to f. This function is not to be called directly, it is invoked by objfun() after a series of safety checks is performed on x and f.
[out] | f | fitness vector into which x's fitness will be written. |
[in] | x | decision vector whose fitness will be calculated. |
Implements pagmo::problem::base.
Definition at line 230 of file spheres.cpp.
std::vector< std::vector< double > > pagmo::problem::spheres::post_evaluate | ( | const decision_vector & | x, |
int | N = 25000 , |
||
unsigned int | seed = 0 |
||
) | const |
Post evaluation of the neural controller.
It tests a given neural controller over a large set of initial conditions (different from those the controller's fitness was actually evaluated upon during evolution)
[in] | x | chromosome encoding the neural network |
[in] | N | number of initial conditions we want it to be tested against |
[in] | seed | seed used to produce all random initial conditions |
Definition at line 268 of file spheres.cpp.
std::vector< std::vector< double > > pagmo::problem::spheres::simulate | ( | const decision_vector & | x, |
const std::vector< double > & | ic, | ||
int | N | ||
) | const |
Performs one "detailed" simulation.
One single run of the ode solver is made, maintaining the states along the simulation ....)
[in] | x | chromosome encoding the neural network |
[in] | ic | initial condition for the simulation |
[in] | N | number of points to retain along the simulation (plus the ic, of course) |
Definition at line 343 of file spheres.cpp.