25#ifndef __INDIVIDUAL_H__
26#define __INDIVIDUAL_H__
36#include "boost/smart_ptr.hpp"
49 typedef std::vector< std::pair<double, double> >
bounds_t;
68 std::cerr <<
"Individual::Individual(): names not equal length to bounds, shouldn't happen exiting" <<
std::endl;
74 for (
size_t i=0; i <
bounds_m.size(); i++) {
79 if (allSatisfied ==
true)
break;
92 id_m = individual->id_m;
96 template<
class Archive>
109 genes_m[gene_idx] = rand() / (RAND_MAX + 1.0) * delta +
min;
127 for (
size_t i=0; i <
bounds_m.size(); i++) {
131 bool is_valid = (value >=
min && value<=
max);
132 if (is_valid ==
false) {
143 std::set<std::string> req_vars = constraint->
getReqVars();
146 for (std::string req_var : req_vars) {
150 std::cerr <<
"Individual::checkConstraints(): " << req_var <<
" is not a design variable" <<
std::endl;
153 size_t gene_idx = std::distance(
names_m.begin(),it);
154 double value =
genes_m[gene_idx];
155 variable_dictionary.insert(std::pair<std::string, double>(req_var, value));
158 constraint->
evaluate(variable_dictionary);
160 double evaluation = boost::get<0>(result);
161 bool is_valid = boost::get<1>(result);
163 if (is_valid==
false || evaluation==0) {
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
std::map< std::string, double > variableDictionary_t
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
const T * find(const T table[], const std::string &name)
Look up name.
boost::tuple< double, bool > Result_t
Expressions::Result_t evaluate(variableDictionary_t vars)
evaluate an expression given a value dictionary of free variables
std::set< std::string > getReqVars() const
void serialize(Archive &ar, const unsigned int)
serialization of structure
std::vector< std::string > names_t
gene names
genes_t genes_m
genes of an individual
names_t names_m
gene names
objectives_t objectives_m
values of objectives of an individual
bool checkBounds()
check bounds
std::vector< std::pair< double, double > > bounds_t
bounds on design variables
bool viable()
test if individual within bounds and constraints
double new_gene(size_t gene_idx)
Individual(bounds_t gene_bounds, names_t names, constraints_t constraints)
create a new individual and initialize with random genes
bounds_t bounds_m
bounds on each gene
constraints_t constraints_m
constraints that depend only on design variables
Individual(boost::shared_ptr< Individual > individual)
copy another individual
std::vector< double > genes_t
representation of genes
bool checkConstraints()
check if all constraints on design variables are checked
std::vector< double > objectives_t
objectives array
Expressions::Named_t constraints_t
constraints