25 #ifndef __INDIVIDUAL_H__
26 #define __INDIVIDUAL_H__
47 typedef std::vector< std::pair<double, double> >
bounds_t;
66 std::cerr <<
"Individual::Individual(): names not equal length to bounds, shouldn't happen exiting" <<
std::endl;
72 for (
size_t i=0; i <
bounds_m.size(); i++) {
77 if (allSatisfied ==
true)
break;
90 id_m = individual->id_m;
94 template<
class Archive>
107 genes_m[gene_idx] = rand() / (RAND_MAX + 1.0) * delta +
min;
125 for (
size_t i=0; i <
bounds_m.size(); i++) {
129 bool is_valid = (value >= min && value<=
max);
130 if (is_valid ==
false) {
141 std::set<std::string> req_vars = constraint->
getReqVars();
144 for (std::string req_var : req_vars) {
148 std::cerr <<
"Individual::checkConstraints(): " << req_var <<
" is not a design variable" <<
std::endl;
151 size_t gene_idx = std::distance(
names_m.begin(),
it);
152 double value =
genes_m[gene_idx];
153 variable_dictionary.insert(std::pair<std::string, double>(req_var, value));
156 constraint->
evaluate(variable_dictionary);
158 double evaluation = boost::get<0>(
result);
159 bool is_valid = boost::get<1>(
result);
161 if (is_valid==
false || evaluation==0) {
std::vector< double > genes_t
representation of genes
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
std::vector< double > objectives_t
objectives array
Individual(bounds_t gene_bounds, names_t names, constraints_t constraints)
create a new individual and initialize with random genes
Expressions::Result_t evaluate(variableDictionary_t vars)
evaluate an expression given a value dictionary of free variables
objectives_t objectives_m
values of objectives of an individual
Individual(std::shared_ptr< Individual > individual)
copy another individual
std::vector< std::pair< double, double > > bounds_t
bounds on design variables
std::map< std::string, double > variableDictionary_t
Inform & endl(Inform &inf)
double new_gene(size_t gene_idx)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
bool checkBounds()
check bounds
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
bool viable()
test if individual within bounds and constraints
const T * find(const T table[], const std::string &name)
Look up name.
std::set< std::string > getReqVars() const
void serialize(Archive &ar, const unsigned int)
serialization of structure
names_t names_m
gene names
bounds_t bounds_m
bounds on each gene
constraints_t constraints_m
constraints that depend only on design variables
boost::tuple< double, bool > Result_t
std::vector< std::string > names_t
gene names
genes_t genes_m
genes of an individual
bool checkConstraints()
check if all constraints on design variables are checked
Expressions::Named_t constraints_t
constraints