OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Individual Class Reference

#include <Individual.h>

Public Types

typedef std::vector< double > genes_t
 representation of genes
 
typedef std::vector< std::string > names_t
 gene names
 
typedef std::vector< double > objectives_t
 objectives array
 
typedef std::vector< std::pair< double, double > > bounds_t
 bounds on design variables
 
typedef Expressions::Named_t constraints_t
 constraints
 

Public Member Functions

 Individual ()
 
 Individual (bounds_t gene_bounds, names_t names, constraints_t constraints)
 create a new individual and initialize with random genes
 
 Individual (std::shared_ptr< Individual > individual)
 copy another individual
 
void writeState (std::ostream &os) const
 write this individual's state to a stream, replaces boost::serialization
 
void readState (std::istream &is)
 read this individual's state from a stream, replaces boost::serialization
 
double new_gene (std::size_t gene_idx)
 
bool viable ()
 test if individual within bounds and constraints
 

Public Attributes

genes_t genes_m
 genes of an individual
 
objectives_t objectives_m
 values of objectives of an individual
 
unsigned int id_m = 0
 id
 

Private Member Functions

bool checkBounds ()
 check bounds
 
bool checkConstraints ()
 check if all constraints on design variables are checked
 

Private Attributes

bounds_t bounds_m
 bounds on each gene
 
names_t names_m
 gene names
 
constraints_t constraints_m
 constraints that depend only on design variables
 

Detailed Description

Definition at line 42 of file Individual.h.

Member Typedef Documentation

◆ bounds_t

typedef std::vector< std::pair<double, double> > Individual::bounds_t

bounds on design variables

Definition at line 52 of file Individual.h.

◆ constraints_t

constraints

Definition at line 54 of file Individual.h.

◆ genes_t

typedef std::vector<double> Individual::genes_t

representation of genes

Definition at line 46 of file Individual.h.

◆ names_t

typedef std::vector<std::string> Individual::names_t

gene names

Definition at line 48 of file Individual.h.

◆ objectives_t

typedef std::vector<double> Individual::objectives_t

objectives array

Definition at line 50 of file Individual.h.

Constructor & Destructor Documentation

◆ Individual() [1/3]

Individual::Individual ( )
inline

Definition at line 56 of file Individual.h.

◆ Individual() [2/3]

Individual::Individual ( bounds_t  gene_bounds,
names_t  names,
constraints_t  constraints 
)
inline

create a new individual and initialize with random genes

Definition at line 60 of file Individual.h.

References bounds_m, checkConstraints(), genes_m, names_m, new_gene(), and objectives_m.

Here is the call graph for this function:

◆ Individual() [3/3]

Individual::Individual ( std::shared_ptr< Individual >  individual)
inline

copy another individual

Definition at line 89 of file Individual.h.

References bounds_m, constraints_m, genes_m, id_m, names_m, and objectives_m.

Member Function Documentation

◆ checkBounds()

bool Individual::checkBounds ( )
inlineprivate

check bounds

Definition at line 142 of file Individual.h.

References bounds_m, genes_m, max(), and min().

Referenced by viable().

Here is the call graph for this function:

◆ checkConstraints()

bool Individual::checkConstraints ( )
inlineprivate

check if all constraints on design variables are checked

Definition at line 156 of file Individual.h.

References constraints_m, Expression::evaluate(), genes_m, Expression::getReqVars(), and names_m.

Referenced by Individual(), and viable().

Here is the call graph for this function:

◆ new_gene()

double Individual::new_gene ( std::size_t  gene_idx)
inline

initialize the gene with index gene_idx with a new random value contained in the specified gene boundaries

Definition at line 121 of file Individual.h.

References bounds_m, genes_m, max(), and min().

Referenced by Individual().

Here is the call graph for this function:

◆ readState()

void Individual::readState ( std::istream &  is)
inline

read this individual's state from a stream, replaces boost::serialization

Definition at line 109 of file Individual.h.

References genes_m, id_m, and objectives_m.

◆ viable()

bool Individual::viable ( )
inline

test if individual within bounds and constraints

Definition at line 129 of file Individual.h.

References checkBounds(), and checkConstraints().

Here is the call graph for this function:

◆ writeState()

void Individual::writeState ( std::ostream &  os) const
inline

write this individual's state to a stream, replaces boost::serialization

Definition at line 99 of file Individual.h.

References genes_m, id_m, and objectives_m.

Member Data Documentation

◆ bounds_m

bounds_t Individual::bounds_m
private

bounds on each gene

Definition at line 186 of file Individual.h.

Referenced by checkBounds(), Individual(), Individual(), and new_gene().

◆ constraints_m

constraints_t Individual::constraints_m
private

constraints that depend only on design variables

Definition at line 190 of file Individual.h.

Referenced by checkConstraints(), and Individual().

◆ genes_m

genes_t Individual::genes_m

genes of an individual

Definition at line 134 of file Individual.h.

Referenced by checkBounds(), checkConstraints(), Individual(), Individual(), new_gene(), readState(), and writeState().

◆ id_m

unsigned int Individual::id_m = 0

id

Definition at line 138 of file Individual.h.

Referenced by Individual(), readState(), and writeState().

◆ names_m

names_t Individual::names_m
private

gene names

Definition at line 188 of file Individual.h.

Referenced by checkConstraints(), Individual(), and Individual().

◆ objectives_m

objectives_t Individual::objectives_m

values of objectives of an individual

Definition at line 136 of file Individual.h.

Referenced by Individual(), Individual(), readState(), and writeState().


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