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_
 

Detailed Description

Definition at line 46 of file GeneticAlgorithm.hh.

Member Typedef Documentation

Definition at line 54 of file GeneticAlgorithm.hh.

Definition at line 55 of file GeneticAlgorithm.hh.

Definition at line 52 of file GeneticAlgorithm.hh.

Definition at line 53 of file GeneticAlgorithm.hh.

Definition at line 51 of file GeneticAlgorithm.hh.

Definition at line 50 of file GeneticAlgorithm.hh.

Definition at line 49 of file GeneticAlgorithm.hh.

Definition at line 58 of file GeneticAlgorithm.hh.

Definition at line 57 of file GeneticAlgorithm.hh.

Definition at line 56 of file GeneticAlgorithm.hh.

Definition at line 59 of file GeneticAlgorithm.hh.

Constructor & Destructor Documentation

protocols::genetic_algorithm::GeneticAlgorithm::GeneticAlgorithm ( )

Definition at line 48 of file GeneticAlgorithm.cc.

protocols::genetic_algorithm::GeneticAlgorithm::~GeneticAlgorithm ( )
virtual

Definition at line 64 of file GeneticAlgorithm.cc.

References checkpoint_rename_, and rename_checkpoint_files().

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

Definition at line 94 of file GeneticAlgorithm.cc.

References current_generation_, entity_cache_, and generations_.

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

Definition at line 114 of file GeneticAlgorithm.cc.

References entity_cache_, new_entity(), and parent_entities_.

Entity::OP protocols::genetic_algorithm::GeneticAlgorithm::add_parent_entity ( EntityOP  entity)
virtual

Definition at line 133 of file GeneticAlgorithm.cc.

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

Definition at line 321 of file GeneticAlgorithm.cc.

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

core::Real protocols::genetic_algorithm::GeneticAlgorithm::best_fitness_from_current_generation ( ) const
virtual

Definition at line 183 of file GeneticAlgorithm.cc.

References current_generation_, and generations_.

void protocols::genetic_algorithm::GeneticAlgorithm::clear_parents ( )
virtual

Definition at line 147 of file GeneticAlgorithm.cc.

References parent_entities_.

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

Definition at line 83 of file GeneticAlgorithm.hh.

References current_generation_.

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

Definition at line 292 of file GeneticAlgorithm.cc.

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

Definition at line 347 of file GeneticAlgorithm.cc.

References entity_cache_.

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

Definition at line 350 of file GeneticAlgorithm.cc.

References entity_cache_.

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

Definition at line 629 of file GeneticAlgorithm.cc.

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

Definition at line 275 of file GeneticAlgorithm.cc.

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

Definition at line 353 of file GeneticAlgorithm.cc.

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

Definition at line 84 of file GeneticAlgorithm.hh.

References max_generations_.

Entity::OP protocols::genetic_algorithm::GeneticAlgorithm::new_entity ( )
virtual

Definition at line 634 of file GeneticAlgorithm.cc.

References entity_template_.

Referenced by add_entity(), add_parent_entity(), and read_entities_checkpoint().

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

Definition at line 357 of file GeneticAlgorithm.cc.

References generations_.

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

Definition at line 439 of file GeneticAlgorithm.cc.

References core::sequence::end, and entity_cache_.

Referenced by write_entities_checkpoint().

void protocols::genetic_algorithm::GeneticAlgorithm::print_generation_statistics ( std::ostream &  os,
core::Size  gen_num 
) const
virtual

Definition at line 363 of file GeneticAlgorithm.cc.

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

void protocols::genetic_algorithm::GeneticAlgorithm::print_population ( std::ostream &  os) const
virtual

Definition at line 428 of file GeneticAlgorithm.cc.

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

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

Definition at line 164 of file GeneticAlgorithm.cc.

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

Definition at line 614 of file GeneticAlgorithm.cc.

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

Definition at line 91 of file GeneticAlgorithm.hh.

References protocols::match::upstream::b, and checkpoint_gzip_.

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

Definition at line 89 of file GeneticAlgorithm.hh.

References checkpoint_prefix_.

virtual void protocols::genetic_algorithm::GeneticAlgorithm::set_checkpoint_rename ( bool  b)
inlinevirtual

Definition at line 92 of file GeneticAlgorithm.hh.

References protocols::match::upstream::b, and checkpoint_rename_.

virtual void protocols::genetic_algorithm::GeneticAlgorithm::set_checkpoint_write_interval ( core::Size  i)
inlinevirtual

Definition at line 90 of file GeneticAlgorithm.hh.

References checkpoint_write_interval_.

void protocols::genetic_algorithm::GeneticAlgorithm::set_entity_template ( EntityCOP  entity)
virtual

Definition at line 630 of file GeneticAlgorithm.cc.

References entity_template_.

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

Definition at line 88 of file GeneticAlgorithm.hh.

References fraction_by_recombination_.

void protocols::genetic_algorithm::GeneticAlgorithm::set_func ( FitnessFunctionOP  f)
virtual

Definition at line 309 of file GeneticAlgorithm.cc.

References fitness_function_.

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

Definition at line 313 of file GeneticAlgorithm.cc.

References generations_, and max_generations_.

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

Definition at line 86 of file GeneticAlgorithm.hh.

References max_population_size_.

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

Definition at line 87 of file GeneticAlgorithm.hh.

References number_to_propagate_.

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

Definition at line 310 of file GeneticAlgorithm.cc.

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

Definition at line 336 of file GeneticAlgorithm.cc.

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

for checkpointing fitness cache

Definition at line 490 of file GeneticAlgorithm.cc.

References checkpoint_prefix_, entities_checkpoint_filename(), protocols::abinitio::filename(), and print_cache().

Referenced by evaluate_fitnesses().

bool protocols::genetic_algorithm::GeneticAlgorithm::write_generations_checkpoint ( ) const
virtual

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

Definition at line 527 of file GeneticAlgorithm.cc.

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

Definition at line 137 of file GeneticAlgorithm.hh.

Referenced by set_checkpoint_rename(), and ~GeneticAlgorithm().

core::Size protocols::genetic_algorithm::GeneticAlgorithm::checkpoint_write_interval_
private

Definition at line 135 of file GeneticAlgorithm.hh.

Referenced by evaluate_fitnesses(), and set_checkpoint_write_interval().

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

Definition at line 128 of file GeneticAlgorithm.hh.

Referenced by entity_template(), new_entity(), and set_entity_template().

FitnessFunctionOP protocols::genetic_algorithm::GeneticAlgorithm::fitness_function_
private

Definition at line 126 of file GeneticAlgorithm.hh.

Referenced by evaluate_fitnesses(), and set_func().

core::Real protocols::genetic_algorithm::GeneticAlgorithm::fraction_by_recombination_
private

Definition at line 133 of file GeneticAlgorithm.hh.

Referenced by evolve_next_generation(), and set_frac_by_recomb().

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

Definition at line 132 of file GeneticAlgorithm.hh.

Referenced by evolve_next_generation(), and set_num_to_propagate().

utility::vector1< EntityCOP > protocols::genetic_algorithm::GeneticAlgorithm::parent_entities_
private

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