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

#include <GeneticAlgorithm.hh>

Inheritance diagram for protocols::genetic_algorithm::GeneticAlgorithm:
Inheritance graph
[legend]
Collaboration diagram for protocols::genetic_algorithm::GeneticAlgorithm:
Collaboration graph
[legend]

Public Types

typedef FitnessFunction::OP FitnessFunctionOP
 
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

 GeneticAlgorithm ()
 
virtual ~GeneticAlgorithm ()
 
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_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 evaluate_fitnesses ()
 
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_func (FitnessFunctionOP f)
 
virtual void set_rand (EntityRandomizerOP r)
 
virtual core::Size current_generation () const
 
virtual core::Size max_generations () const
 
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
 
virtual 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 ()
 
virtual 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 ()
 

Private Attributes

utility::vector1
< utility::vector1< EntityOP > > 
generations_
 
utility::vector1< EntityCOPparent_entities_
 
TraitEntityHashMap entity_cache_
 
FitnessFunctionOP fitness_function_
 
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::GeneticAlgorithm::GeneticAlgorithm ( )
protocols::genetic_algorithm::GeneticAlgorithm::~GeneticAlgorithm ( )
virtual

Member Function Documentation

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

References entity_cache_, and parent_entities_.

void protocols::genetic_algorithm::GeneticAlgorithm::add_parents_from_current_generation ( )
virtual
Entity::CAPs protocols::genetic_algorithm::GeneticAlgorithm::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::GeneticAlgorithm::best_fitness_from_current_generation ( ) const
virtual
void protocols::genetic_algorithm::GeneticAlgorithm::clear_parents ( )
virtual

References parent_entities_.

bool protocols::genetic_algorithm::GeneticAlgorithm::complete ( )
virtual
virtual core::Size protocols::genetic_algorithm::GeneticAlgorithm::current_generation ( ) const
inlinevirtual

References current_generation_.

bool protocols::genetic_algorithm::GeneticAlgorithm::current_generation_complete ( )
virtual

References current_generation_, and generations_.

Referenced by complete().

std::string protocols::genetic_algorithm::GeneticAlgorithm::entities_checkpoint_filename ( std::string  suffix = "") const
virtual
GeneticAlgorithm::TraitEntityHashMap & protocols::genetic_algorithm::GeneticAlgorithm::entity_cache ( )
virtual

References entity_cache_.

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

References entity_cache_.

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

References entity_template_.

void protocols::genetic_algorithm::GeneticAlgorithm::evaluate_fitnesses ( )
virtual
void protocols::genetic_algorithm::GeneticAlgorithm::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(), 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::GeneticAlgorithm::fill_by_crossover ( core::Size  size = 0)
virtual
void protocols::genetic_algorithm::GeneticAlgorithm::fill_by_mutation ( core::Size  size = 0)
virtual
void protocols::genetic_algorithm::GeneticAlgorithm::fill_with_random_entities ( core::Size  size = 0)
virtual
utility::vector1< utility::vector1< EntityOP > > const & protocols::genetic_algorithm::GeneticAlgorithm::generations ( ) const
virtual

References generations_.

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

References max_generations_.

Entity::OP protocols::genetic_algorithm::GeneticAlgorithm::new_entity ( )
virtual
Entity::COPs protocols::genetic_algorithm::GeneticAlgorithm::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::GeneticAlgorithm::print_cache ( std::ostream &  os) const
virtual
void protocols::genetic_algorithm::GeneticAlgorithm::print_generation_statistics ( std::ostream &  os,
core::Size  gen_num 
) const
virtual
void protocols::genetic_algorithm::GeneticAlgorithm::print_population ( std::ostream &  os) const
virtual
void protocols::genetic_algorithm::GeneticAlgorithm::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::GeneticAlgorithm::read_checkpoint ( )
virtual
bool protocols::genetic_algorithm::GeneticAlgorithm::read_entities_checkpoint ( bool  overwrite = false)
virtual
bool protocols::genetic_algorithm::GeneticAlgorithm::read_generations_checkpoint ( )
virtual
void protocols::genetic_algorithm::GeneticAlgorithm::rename_checkpoint_files ( ) const
virtual

allows the prevention of accidental reuse of checkpoint files

References checkpoint_prefix_, entities_checkpoint_filename(), protocols::swa::rna::file_exists(), and generations_checkpoint_filename().

Referenced by ~GeneticAlgorithm().

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

References checkpoint_prefix_.

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

References entity_template_.

virtual void protocols::genetic_algorithm::GeneticAlgorithm::set_frac_by_recomb ( core::Real  f)
inlinevirtual
void protocols::genetic_algorithm::GeneticAlgorithm::set_func ( FitnessFunctionOP  f)
virtual

References fitness_function_.

void protocols::genetic_algorithm::GeneticAlgorithm::set_max_generations ( core::Size  s)
virtual

References generations_, and max_generations_.

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

References max_population_size_.

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

References number_to_propagate_.

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

References entity_randomizer_.

Entity const & protocols::genetic_algorithm::GeneticAlgorithm::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::GeneticAlgorithm::write_entities_checkpoint ( ) const
virtual
bool protocols::genetic_algorithm::GeneticAlgorithm::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 evaluate_fitnesses().

Member Data Documentation

bool protocols::genetic_algorithm::GeneticAlgorithm::checkpoint_gzip_
private
std::string protocols::genetic_algorithm::GeneticAlgorithm::checkpoint_prefix_
private
bool protocols::genetic_algorithm::GeneticAlgorithm::checkpoint_rename_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithm::checkpoint_write_interval_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithm::current_generation_
private
TraitEntityHashMap protocols::genetic_algorithm::GeneticAlgorithm::entity_cache_
private
EntityRandomizerOP protocols::genetic_algorithm::GeneticAlgorithm::entity_randomizer_
private
EntityCOP protocols::genetic_algorithm::GeneticAlgorithm::entity_template_
private
FitnessFunctionOP protocols::genetic_algorithm::GeneticAlgorithm::fitness_function_
private

Referenced by evaluate_fitnesses(), and set_func().

core::Real protocols::genetic_algorithm::GeneticAlgorithm::fraction_by_recombination_
private
utility::vector1< utility::vector1< EntityOP > > protocols::genetic_algorithm::GeneticAlgorithm::generations_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithm::max_generations_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithm::max_population_size_
private
core::Size protocols::genetic_algorithm::GeneticAlgorithm::number_to_propagate_
private
utility::vector1< EntityCOP > protocols::genetic_algorithm::GeneticAlgorithm::parent_entities_
private

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