Rosetta  2021.16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
protocols::genetic_algorithm::GeneticAlgorithmBase Class Reference

#include <GeneticAlgorithm.hh>

Inheritance diagram for protocols::genetic_algorithm::GeneticAlgorithmBase:
Inheritance graph
[legend]

Public Types

typedef EntityRandomizer::OP EntityRandomizerOP
 
typedef Entity::OP EntityOP
 
typedef Entity::COP EntityCOP
 
typedef Entity::COPs EntityCOPs
 
typedef Entity::CAP EntityCAP
 
typedef Entity::CAPs EntityCAPs
 
typedef utility::vector1
< EntityOP >::iterator 
pop_iter
 
typedef utility::vector1
< EntityOP >::const_iterator 
pop_const_iter
 
typedef utility::vector1
< EntityCOP >::const_iterator 
pop_const_const_iter
 
typedef boost::unordered_map
< EntityElements, EntityOP,
Vec1Hash, EntityElementsEqual
TraitEntityHashMap
 

Public Member Functions

 GeneticAlgorithmBase ()
 
 ~GeneticAlgorithmBase () override
 
virtual EntityOP add_entity (EntityElements const &traits)
 
virtual EntityOP add_entity (EntityOP entity)
 
virtual EntityOP add_parent_entity (EntityElements const &traits)
 
virtual EntityOP add_parent_entity (EntityOP entity)
 
virtual void clear_parents ()
 
virtual void add_parents_from_current_generation ()
 
virtual void propagate_best_from_previous_generation (core::Size size=1, bool unique=true)
 add the best entities from the previous generation More...
 
virtual void fill_with_random_entities (core::Size size=0)
 
virtual void fill_with_perturbations_of_existing_entities (core::Size size=0)
 
virtual void fill_by_crossover (core::Size size=0)
 add entities that are recombinants of fit parents More...
 
virtual void fill_by_mutation (core::Size size=0)
 add entities that are mutants of fit parents More...
 
virtual void evolve_next_generation ()
 progress to the next generation and generate new entities More...
 
virtual bool current_generation_complete ()
 
virtual bool complete ()
 
virtual core::Real best_fitness_from_current_generation () const
 
virtual void set_rand (EntityRandomizerOP r)
 
virtual void set_max_generations (core::Size s)
 
virtual void set_max_pop_size (core::Size s)
 
virtual void set_num_to_propagate (core::Size s)
 
virtual void set_frac_by_recomb (core::Real f)
 
virtual void set_checkpoint_prefix (std::string const &p)
 
virtual void set_checkpoint_write_interval (core::Size i)
 
virtual void set_checkpoint_gzip (bool b)
 
virtual void set_checkpoint_rename (bool b)
 
virtual EntityCAPs best_entities (core::Size num)
 non-const to permit sort More...
 
virtual Entity const & tournament_select (utility::vector1< EntityCOP > const &pvec) const
 pick two random entities from an unordered vector, return the one whose fitness is better More...
 
virtual TraitEntityHashMapentity_cache ()
 
virtual TraitEntityHashMap const & entity_cache () const
 
virtual utility::vector1
< utility::vector1< EntityOP >
> const & 
generations () const
 
virtual EntityCOPs population (core::Size gen_num) const
 true const (read-only) access to entity population: new vector of const pointers More...
 
virtual void print_generation_statistics (std::ostream &os, core::Size gen_num) const
 
virtual void print_population (std::ostream &) const
 
virtual void print_cache (std::ostream &) const
 
std::string entities_checkpoint_filename (std::string suffix="") const
 
virtual bool read_entities_checkpoint (bool overwrite=false)
 for checkpointing fitness cache More...
 
virtual bool write_entities_checkpoint () const
 for checkpointing fitness cache More...
 
virtual std::string generations_checkpoint_filename (std::string suffix="") const
 
virtual bool write_generations_checkpoint () const
 This seems to duplicate the functionality of the Entity's write_checkpoint function... More...
 
virtual bool read_generations_checkpoint ()
 
virtual bool read_checkpoint ()
 
void rename_checkpoint_files () const
 allows the prevention of accidental reuse of checkpoint files More...
 
virtual EntityCOP entity_template () const
 
virtual void set_entity_template (EntityCOP entity)
 
virtual EntityOP new_entity ()
 
core::Size current_generation () const
 
core::Size max_generations () const
 
core::Size max_population_size () const
 
core::Size number_to_propagate () const
 
core::Real fraction_by_recombination () const
 
pop_iter current_generation_begin ()
 
pop_iter current_generation_end ()
 
pop_const_iter current_generation_begin () const
 
pop_const_iter current_generation_end () const
 
EntityOP curr_gen_entity (core::Size index)
 retreive a particular entity for the current generation More...
 

Protected Member Functions

core::Size checkpoint_write_interval () const
 

Private Attributes

utility::vector1
< utility::vector1< EntityOP > > 
generations_
 
utility::vector1< EntityCOPparent_entities_
 
TraitEntityHashMap entity_cache_
 
TraitEntityHashMap curr_gen_entities_
 
EntityRandomizerOP entity_randomizer_
 
EntityCOP entity_template_
 
core::Size current_generation_
 
core::Size max_generations_
 
core::Size max_population_size_
 
core::Size number_to_propagate_
 
core::Real fraction_by_recombination_
 
std::string checkpoint_prefix_
 
core::Size checkpoint_write_interval_
 
bool checkpoint_gzip_
 
bool checkpoint_rename_
 

Member Typedef Documentation

Constructor & Destructor Documentation

protocols::genetic_algorithm::GeneticAlgorithmBase::GeneticAlgorithmBase ( )
protocols::genetic_algorithm::GeneticAlgorithmBase::~GeneticAlgorithmBase ( )
override

Member Function Documentation

Entity::OP protocols::genetic_algorithm::GeneticAlgorithmBase::add_entity ( EntityElements const &  traits)
virtual
Entity::OP protocols::genetic_algorithm::GeneticAlgorithmBase::add_entity ( EntityOP  entity)
virtual
Entity::OP protocols::genetic_algorithm::GeneticAlgorithmBase::add_parent_entity ( EntityElements const &  traits)
virtual
Entity::OP protocols::genetic_algorithm::GeneticAlgorithmBase::add_parent_entity ( EntityOP  entity)
virtual

References entity_cache_, and parent_entities_.

void protocols::genetic_algorithm::GeneticAlgorithmBase::add_parents_from_current_generation ( )
virtual
Entity::CAPs protocols::genetic_algorithm::GeneticAlgorithmBase::best_entities ( core::Size  num)
virtual

non-const to permit sort

returns variable number of best (const) entities via vector of pointers to them

References current_generation_, core::sequence::end, and generations_.

core::Real protocols::genetic_algorithm::GeneticAlgorithmBase::best_fitness_from_current_generation ( ) const
virtual
core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::checkpoint_write_interval ( ) const
protected
void protocols::genetic_algorithm::GeneticAlgorithmBase::clear_parents ( )
virtual

References parent_entities_.

bool protocols::genetic_algorithm::GeneticAlgorithmBase::complete ( )
virtual
GeneticAlgorithmBase::EntityOP protocols::genetic_algorithm::GeneticAlgorithmBase::curr_gen_entity ( core::Size  index)

retreive a particular entity for the current generation

References current_generation_, and generations_.

core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::current_generation ( ) const
inline

References current_generation_.

GeneticAlgorithmBase::pop_iter protocols::genetic_algorithm::GeneticAlgorithmBase::current_generation_begin ( )
GeneticAlgorithmBase::pop_const_iter protocols::genetic_algorithm::GeneticAlgorithmBase::current_generation_begin ( ) const
bool protocols::genetic_algorithm::GeneticAlgorithmBase::current_generation_complete ( )
virtual

References current_generation_, and generations_.

Referenced by complete().

GeneticAlgorithmBase::pop_iter protocols::genetic_algorithm::GeneticAlgorithmBase::current_generation_end ( )
GeneticAlgorithmBase::pop_const_iter protocols::genetic_algorithm::GeneticAlgorithmBase::current_generation_end ( ) const
std::string protocols::genetic_algorithm::GeneticAlgorithmBase::entities_checkpoint_filename ( std::string  suffix = "") const
GeneticAlgorithmBase::TraitEntityHashMap & protocols::genetic_algorithm::GeneticAlgorithmBase::entity_cache ( )
virtual

References entity_cache_.

GeneticAlgorithmBase::TraitEntityHashMap const & protocols::genetic_algorithm::GeneticAlgorithmBase::entity_cache ( ) const
virtual

References entity_cache_.

EntityCOP protocols::genetic_algorithm::GeneticAlgorithmBase::entity_template ( ) const
virtual

References entity_template_.

void protocols::genetic_algorithm::GeneticAlgorithmBase::evolve_next_generation ( )
virtual

progress to the next generation and generate new entities

This method performs the following steps:

  1. If parent entities were not already specified, sets the parents to the current generation
  2. Increments the generation counter
  3. Copies the best scoring entities from the previous generation to the new one
  4. Generates new entities by crossover and/or mutation
  5. Clears the parent entities now that they have been used

References add_parents_from_current_generation(), curr_gen_entities_, current_generation_, fill_by_crossover(), fill_by_mutation(), fraction_by_recombination_, generations_, max_population_size_, number_to_propagate_, parent_entities_, and propagate_best_from_previous_generation().

void protocols::genetic_algorithm::GeneticAlgorithmBase::fill_by_crossover ( core::Size  size = 0)
virtual
void protocols::genetic_algorithm::GeneticAlgorithmBase::fill_by_mutation ( core::Size  size = 0)
virtual
void protocols::genetic_algorithm::GeneticAlgorithmBase::fill_with_perturbations_of_existing_entities ( core::Size  size = 0)
virtual
void protocols::genetic_algorithm::GeneticAlgorithmBase::fill_with_random_entities ( core::Size  size = 0)
virtual
core::Real protocols::genetic_algorithm::GeneticAlgorithmBase::fraction_by_recombination ( ) const
inline
utility::vector1< utility::vector1< EntityOP > > const & protocols::genetic_algorithm::GeneticAlgorithmBase::generations ( ) const
virtual

References generations_.

std::string protocols::genetic_algorithm::GeneticAlgorithmBase::generations_checkpoint_filename ( std::string  suffix = "") const
virtual
core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::max_generations ( ) const
inline

References max_generations_.

core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::max_population_size ( ) const
inline

References max_population_size_.

Entity::OP protocols::genetic_algorithm::GeneticAlgorithmBase::new_entity ( )
virtual
core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::number_to_propagate ( ) const
inline

References number_to_propagate_.

Entity::COPs protocols::genetic_algorithm::GeneticAlgorithmBase::population ( core::Size  gen_num) const
virtual

true const (read-only) access to entity population: new vector of const pointers

true const (read-only) access to entity population

References generations_.

void protocols::genetic_algorithm::GeneticAlgorithmBase::print_cache ( std::ostream &  os) const
virtual

References entity_cache_.

Referenced by write_entities_checkpoint().

void protocols::genetic_algorithm::GeneticAlgorithmBase::print_generation_statistics ( std::ostream &  os,
core::Size  gen_num 
) const
virtual
void protocols::genetic_algorithm::GeneticAlgorithmBase::print_population ( std::ostream &  os) const
virtual
void protocols::genetic_algorithm::GeneticAlgorithmBase::propagate_best_from_previous_generation ( core::Size  size = 1,
bool  unique = true 
)
virtual

add the best entities from the previous generation

References add_entity(), current_generation_, and generations_.

Referenced by evolve_next_generation().

bool protocols::genetic_algorithm::GeneticAlgorithmBase::read_checkpoint ( )
virtual
bool protocols::genetic_algorithm::GeneticAlgorithmBase::read_entities_checkpoint ( bool  overwrite = false)
virtual
bool protocols::genetic_algorithm::GeneticAlgorithmBase::read_generations_checkpoint ( )
virtual
void protocols::genetic_algorithm::GeneticAlgorithmBase::rename_checkpoint_files ( ) const

allows the prevention of accidental reuse of checkpoint files

References checkpoint_prefix_, entities_checkpoint_filename(), and generations_checkpoint_filename().

Referenced by ~GeneticAlgorithmBase().

virtual void protocols::genetic_algorithm::GeneticAlgorithmBase::set_checkpoint_gzip ( bool  b)
inlinevirtual
virtual void protocols::genetic_algorithm::GeneticAlgorithmBase::set_checkpoint_prefix ( std::string const &  p)
inlinevirtual

References checkpoint_prefix_.

virtual void protocols::genetic_algorithm::GeneticAlgorithmBase::set_checkpoint_rename ( bool  b)
inlinevirtual
virtual void protocols::genetic_algorithm::GeneticAlgorithmBase::set_checkpoint_write_interval ( core::Size  i)
inlinevirtual
void protocols::genetic_algorithm::GeneticAlgorithmBase::set_entity_template ( EntityCOP  entity)
virtual

References entity_template_.

virtual void protocols::genetic_algorithm::GeneticAlgorithmBase::set_frac_by_recomb ( core::Real  f)
inlinevirtual
void protocols::genetic_algorithm::GeneticAlgorithmBase::set_max_generations ( core::Size  s)
virtual

References generations_, and max_generations_.

virtual void protocols::genetic_algorithm::GeneticAlgorithmBase::set_max_pop_size ( core::Size  s)
inlinevirtual

References max_population_size_.

virtual void protocols::genetic_algorithm::GeneticAlgorithmBase::set_num_to_propagate ( core::Size  s)
inlinevirtual

References number_to_propagate_.

void protocols::genetic_algorithm::GeneticAlgorithmBase::set_rand ( EntityRandomizerOP  r)
virtual

References entity_randomizer_.

Entity const & protocols::genetic_algorithm::GeneticAlgorithmBase::tournament_select ( utility::vector1< EntityCOP > const &  pvec) const
virtual

pick two random entities from an unordered vector, return the one whose fitness is better

References protocols::genetic_algorithm::Entity::fitness().

Referenced by fill_by_crossover(), and fill_by_mutation().

bool protocols::genetic_algorithm::GeneticAlgorithmBase::write_entities_checkpoint ( ) const
virtual
bool protocols::genetic_algorithm::GeneticAlgorithmBase::write_generations_checkpoint ( ) const
virtual

This seems to duplicate the functionality of the Entity's write_checkpoint function...

References checkpoint_prefix_, protocols::abinitio::filename(), generations_, and generations_checkpoint_filename().

Referenced by protocols::genetic_algorithm::GeneticAlgorithm::evaluate_fitnesses().

Member Data Documentation

bool protocols::genetic_algorithm::GeneticAlgorithmBase::checkpoint_gzip_
private
std::string protocols::genetic_algorithm::GeneticAlgorithmBase::checkpoint_prefix_
private
bool protocols::genetic_algorithm::GeneticAlgorithmBase::checkpoint_rename_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::checkpoint_write_interval_
private
TraitEntityHashMap protocols::genetic_algorithm::GeneticAlgorithmBase::curr_gen_entities_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::current_generation_
private
TraitEntityHashMap protocols::genetic_algorithm::GeneticAlgorithmBase::entity_cache_
private
EntityRandomizerOP protocols::genetic_algorithm::GeneticAlgorithmBase::entity_randomizer_
private
EntityCOP protocols::genetic_algorithm::GeneticAlgorithmBase::entity_template_
private
core::Real protocols::genetic_algorithm::GeneticAlgorithmBase::fraction_by_recombination_
private
utility::vector1< utility::vector1< EntityOP > > protocols::genetic_algorithm::GeneticAlgorithmBase::generations_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::max_generations_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::max_population_size_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithmBase::number_to_propagate_
private
utility::vector1< EntityCOP > protocols::genetic_algorithm::GeneticAlgorithmBase::parent_entities_
private

The documentation for this class was generated from the following files: