Mentions légales du service

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • rouzaudc/aevol
  • aevol/aevol
  • tgrohens/aevol
  • mfoley/aevol
  • jluisell/aevol
  • jluisell/aevol-eukaryotes
  • rouzaudc/aevol-asyncgarbage
  • elie.dumont/aevol
8 results
Show changes
Showing
with 396 additions and 857 deletions
......@@ -65,8 +65,7 @@ namespace aevol {
class IndividualFactory
{
class IndividualFactory {
public :
// ==========================================================================
// Constructors
......
......@@ -135,7 +135,7 @@ void Individual_X11::display_cdss(X11Window * win)
else canvas_width = win->width();
int16_t canvas_height = win->height();
int16_t canvas_size = Utils::min(canvas_width, canvas_width);
int16_t canvas_size = Utils::min(canvas_width, canvas_height);
int16_t diam = round(canvas_size * log((double)genome_length) / 16);
// Prevent diameter from getting greater than 2/3 of the window size
......
......@@ -36,6 +36,7 @@ FuzzyFactory.h \
Gaussian.h \
GeneticUnit.h \
GridCell.h \
GzHelpers.h \
HybridFuzzy.h \
Individual.h \
IndividualFactory.h \
......@@ -51,7 +52,7 @@ Duplication.h \
Deletion.h \
Translocation.h \
Inversion.h \
HT.h \
HorizontalTransfer.h \
InsertionHT.h \
ReplacementHT.h \
Observable.h \
......
......@@ -61,8 +61,7 @@ namespace aevol {
// =================================================================
// Constructors
// =================================================================
OutputManager::OutputManager(ExpManager * exp_m)
{
OutputManager::OutputManager(ExpManager * exp_m) {
exp_m_ = exp_m;
stats_ = nullptr;
tree_ = nullptr;
......@@ -71,14 +70,13 @@ OutputManager::OutputManager(ExpManager * exp_m)
record_tree_ = false;
make_dumps_ = false;
dump_step_ = 0;
logs_ = new Logging();
logs_ = new Logging();
}
// =================================================================
// Destructors
// =================================================================
OutputManager::~OutputManager()
{
OutputManager::~OutputManager() {
delete stats_;
delete tree_;
delete dump_;
......@@ -92,8 +90,7 @@ void OutputManager::InitStats() {
stats_ = new Stats(exp_m_);
}
void OutputManager::WriteSetupFile(gzFile setup_file) const
{
void OutputManager::WriteSetupFile(gzFile setup_file) const {
// Write the backup steps
gzwrite(setup_file, &backup_step_, sizeof(backup_step_));
gzwrite(setup_file, &big_backup_step_, sizeof(big_backup_step_));
......@@ -125,15 +122,13 @@ void OutputManager::CopyStats(const std::string& outdir, int64_t time) const {
stats_->MoveTmpFiles(outdir);
}
void OutputManager::load(gzFile setup_file, bool verbose, bool to_be_run)
{
void OutputManager::load(gzFile setup_file, bool verbose, bool to_be_run) {
// Write the backup steps
gzread(setup_file, &backup_step_, sizeof(backup_step_));
gzread(setup_file, &big_backup_step_, sizeof(big_backup_step_));
// Stats
if (to_be_run)
{
if (to_be_run) {
delete stats_;
stats_ = new Stats(exp_m_, AeTime::time());
}
......@@ -143,8 +138,7 @@ void OutputManager::load(gzFile setup_file, bool verbose, bool to_be_run)
int8_t record_tree;
gzread(setup_file, &record_tree, sizeof(record_tree));
record_tree_ = record_tree;
if (record_tree_)
{
if (record_tree_) {
int32_t tmp_tree_step;
gzread(setup_file, &tmp_tree_step, sizeof(tmp_tree_step));
......@@ -156,22 +150,19 @@ void OutputManager::load(gzFile setup_file, bool verbose, bool to_be_run)
gzread(setup_file, &make_dumps, sizeof(make_dumps));
make_dumps_ = make_dumps;
gzread(setup_file, &dump_step_, sizeof(dump_step_));
if(make_dumps_ == true)
{
if(make_dumps_) {
dump_ = new Dump(exp_m_);
}
// Logs
int8_t logs;
gzread(setup_file, &logs, sizeof(logs));
if (to_be_run)
{
if (to_be_run) {
logs_->load(logs, AeTime::time());
}
}
void OutputManager::write_current_generation_outputs() const
{
void OutputManager::write_current_generation_outputs() const {
// Write stats
stats_->write_current_generation_statistics();
......
......@@ -93,6 +93,9 @@ static const int8_t STRAIN_NAME_LOGIN_SIZE = 10;
#ifndef LOGIN_NAME_MAX
#define LOGIN_NAME_MAX 256
#endif
const char kTabChar = 0x09;
// =================================================================
// Constructors
// =================================================================
......@@ -278,7 +281,9 @@ ParamLoader::ParamLoader(const char* file_name)
_list_eval_step.insert(_nb_indiv_age);
_env_switch_probability = 0.1;
#endif
#endif
first_regul_ = true;
// Read parameter file
param_file_name_ = strdup(file_name);
......@@ -1351,6 +1356,16 @@ void ParamLoader::interpret_line(ParameterLine * line, int32_t cur_line)
param_file_name_, cur_line, _env_gaussians_list.size() );
exit( EXIT_FAILURE );
}
} else if (strcmp(line->words[0], "REGUL_FIRST") == 0)
{
if (strncmp(line->words[1], "true", 4) == 0)
{
first_regul_ = true;
}
else if (strncmp(line->words[1], "false", 5) == 0)
{
first_regul_ = false;
}
}
#endif
......@@ -1509,6 +1524,7 @@ void ParamLoader::load(ExpManager * exp_m, bool verbose,
exp_s->init_binding_matrix(_random_binding_matrix,_binding_zeros_percentage,prng_);
#endif
exp_s->set_first_regul(first_regul_);
if (FuzzyFactory::fuzzyFactory == NULL)
FuzzyFactory::fuzzyFactory = new FuzzyFactory(exp_s);
......@@ -1922,18 +1938,17 @@ void ParamLoader::load(ExpManager * exp_m, bool verbose,
\param line original line in char*
\param line_is_interpretable boolean with about the possible intrepretation of the line
*/
void ParamLoader::format_line(ParameterLine * formated_line, char* line, bool* line_is_interpretable)
{
void ParamLoader::format_line(ParameterLine * formated_line, char* line,
bool* line_is_interpretable) {
int16_t i = 0;
int16_t j;
// Parse line
while (line[i] != '\n' && line[i] != '\0' && line[i] != '\r')
{
while (line[i] != '\n' && line[i] != '\0' && line[i] != '\r') {
j = 0;
// Flush white spaces and tabs
while (line[i] == ' ' || line[i] == 0x09) i++; // 0x09 is the ASCII code for TAB
while (line[i] == ' ' || line[i] == kTabChar) i++;
// Check comments
if (line[i] == '#') break;
......@@ -1942,14 +1957,13 @@ void ParamLoader::format_line(ParameterLine * formated_line, char* line, bool* l
*line_is_interpretable = true;
// Parse word
while (line[i] != ' ' && line[i] != '\n' && line[i] != '\0' && line[i] != '\r')
{
while (line[i] != ' ' && line[i] != kTabChar && line[i] != '\n' &&
line[i] != '\0' && line[i] != '\r') {
formated_line->words[formated_line->nb_words][j++] = line[i++];
}
// Add '\0' at end of word if it's not empty (line ending with space or tab)
if (j != 0)
{
if (j != 0) {
formated_line->words[formated_line->nb_words++][j] = '\0';
}
}
......
......@@ -313,6 +313,8 @@ class ParamLoader {
std::vector<std::list<int8_t>> _env_signals_list;
std::vector<Protein_R*> _signals_models;
#endif
bool first_regul_;
};
} // namespace aevol
......
......@@ -504,11 +504,10 @@ void Selection::compute_local_prob_reprod() {
}
}
Individual* Selection::do_replication(Individual* parent, int32_t index,
int16_t x, int16_t y) {
Individual* Selection::do_replication(Individual* parent, int32_t index) {
//Individual* new_indiv = NULL;
// ===========================================================================
// 1) Copy parent
// Copy parent
// ===========================================================================
#ifdef __NO_X
#ifndef __REGUL
......@@ -530,9 +529,6 @@ Individual* Selection::do_replication(Individual* parent, int32_t index,
notifyObservers(NEW_INDIV, msg);
}
// Set the new individual's location on the grid
exp_m_->world()->PlaceIndiv(new_indiv, x, y);
// Perform transfer, rearrangements and mutations
if (not new_indiv->allow_plasmids()) {
const GeneticUnit* chromosome = &new_indiv->genetic_unit_list().front();
......@@ -556,6 +552,16 @@ Individual* Selection::do_replication(Individual* parent, int32_t index,
}
}
return new_indiv;
}
Individual* Selection::do_replication(Individual* parent, int32_t index,
int16_t x, int16_t y) {
Individual* new_indiv = do_replication(parent, index);
// Set the new individual's location on the grid
exp_m_->world()->PlaceIndiv(new_indiv, x, y);
// Evaluate new individual
new_indiv->Evaluate();
......
......@@ -108,17 +108,12 @@ class Selection : public Observable
void save(gzFile& backup_file) const;
void load(gzFile& exp_setup_file, gzFile& backup_file, bool verbose);
Individual* do_replication(Individual* parent, int32_t index = -1);
Individual* do_replication(Individual* parent,
int32_t index,
int16_t x = -1,
int16_t y = -1);
int16_t x,
int16_t y);
#ifdef __TBB
Individual* do_replication_tbb(Individual* parent,
int32_t index,
int16_t x = -1,
int16_t y = -1);
#endif
// =================================================================
// Public Attributes
// =================================================================
......
......@@ -39,7 +39,7 @@
// =================================================================
#include "StatRecord.h"
#include "ExpManager.h"
#include "AeTime.h"
#include "ExpSetup.h"
#include "Individual.h"
#include "GeneticUnit.h"
......@@ -72,16 +72,7 @@ namespace aevol {
// =================================================================
// Constructors
// =================================================================
StatRecord::StatRecord(ExpManager * exp_m)
{
exp_m_ = exp_m;
initialize_data();
}
StatRecord::StatRecord(const StatRecord &model)
{
exp_m_ = model.exp_m_;
StatRecord::StatRecord(const StatRecord &model) {
pop_size_ = model.pop_size_;
metabolic_error_ = model.metabolic_error_;
......@@ -141,13 +132,11 @@ StatRecord::StatRecord(const StatRecord &model)
#endif
}
StatRecord::StatRecord(ExpManager* exp_m,
StatRecord::StatRecord(ExpSetup* exp_s,
Individual* indiv,
ReplicationReport* replic_report,
chrom_or_gen_unit chrom_or_gu,
bool compute_non_coding)
{
exp_m_ = exp_m;
initialize_data();
bool compute_non_coding) {
record_type_ = INDIV;
// ---------------
......@@ -216,16 +205,10 @@ StatRecord::StatRecord(ExpManager* exp_m,
#endif
// TODO : These conditions are not well managed!!!
if (indiv->nb_genetic_units() == 1)
{ // One single Genetic Unit
if (indiv->nb_genetic_units() == 1) {
// -------------------------------------------------
// Compute statistical data for the given individual
// -------------------------------------------------
ReplicationReport* replic_report = nullptr;
if (exp_m_->tree() != nullptr)
replic_report = exp_m_->tree()->report_by_index(AeTime::time(),
indiv->id());
if (compute_non_coding)
indiv->compute_non_coding();
......@@ -242,8 +225,7 @@ StatRecord::StatRecord(ExpManager* exp_m,
fitness_ = indiv->fitness();
// Secretion stats
if (exp_m_->with_secretion())
{
if (exp_s->with_secretion()) {
secretion_error_ = indiv->dist_to_target_by_feature(SECRETION);
secretion_fitness_ = indiv->fitness_by_feature(SECRETION);
compound_amount_ = indiv->grid_cell()->compound_amount();
......@@ -325,11 +307,6 @@ StatRecord::StatRecord(ExpManager* exp_m,
// -------------------------------------------------
// Compute statistical data for the given individual
// -------------------------------------------------
ReplicationReport* replic_report = nullptr;
if (exp_m_->tree() != nullptr)
replic_report = exp_m_->tree()->report_by_index(AeTime::time(),
indiv->id());
// Metabolic error stats
metabolic_error_ = (double) indiv->dist_to_target_by_feature(METABOLISM);
metabolic_fitness_ = (double) indiv->fitness_by_feature(METABOLISM);
......@@ -339,8 +316,7 @@ StatRecord::StatRecord(ExpManager* exp_m,
fitness_ = indiv->fitness();
// Secretion stats
if (exp_m_->with_secretion())
{
if (exp_s->with_secretion()) {
secretion_error_ = (double) indiv->dist_to_target_by_feature(SECRETION);
secretion_fitness_ = (double) indiv->fitness_by_feature(SECRETION);
compound_amount_ = (double) indiv->grid_cell()->compound_amount();
......@@ -425,11 +401,6 @@ StatRecord::StatRecord(ExpManager* exp_m,
// -------------------------------------------------
// Compute statistical data for the given individual
// -------------------------------------------------
ReplicationReport* replic_report = nullptr;
if (exp_m_->tree() != nullptr)
replic_report = exp_m_->tree()->report_by_index(AeTime::time(),
indiv->id());
// Metabolic error stats
metabolic_error_ = (double) gen_unit.dist_to_target_by_feature(METABOLISM);
metabolic_fitness_ = (double) gen_unit.fitness_by_feature(METABOLISM);
......@@ -439,8 +410,7 @@ StatRecord::StatRecord(ExpManager* exp_m,
fitness_ = indiv->fitness();
// Secretion stats
if (exp_m_->with_secretion())
{
if (exp_s->with_secretion()) {
secretion_error_ = (double) gen_unit.dist_to_target_by_feature(SECRETION);
secretion_fitness_ = (double) gen_unit.fitness_by_feature(SECRETION);
compound_amount_ = (double) indiv->grid_cell()->compound_amount();
......@@ -512,28 +482,26 @@ StatRecord::StatRecord(ExpManager* exp_m,
}
// Calculate average statistics for all the recorded values
StatRecord::StatRecord(ExpManager * exp_m,
const list<Individual *> indivs,
chrom_or_gen_unit chrom_or_gu)
{
exp_m_ = exp_m;
initialize_data();
StatRecord::StatRecord(ExpSetup* exp_s,
std::list<std::pair<Individual*,
ReplicationReport*>> annotated_indivs,
chrom_or_gen_unit chrom_or_gu) {
record_type_ = POP;
// ---------------
// Simulation data
// ---------------
pop_size_ = (double) indivs.size();
pop_size_ = static_cast<int32_t>(annotated_indivs.size());
// ------------------------------------------------------------------
// Compute statistical data for the each individual in the population
// ------------------------------------------------------------------
for (const auto& indiv: indivs)
{
StatRecord * indiv_stat_record = new StatRecord(exp_m_, indiv, chrom_or_gu, false);
this->add(indiv_stat_record, indiv->id());
delete indiv_stat_record;
for (const auto& annotated_indiv : annotated_indivs) {
StatRecord indiv_stat_record(exp_s,
annotated_indiv.first,
annotated_indiv.second,
chrom_or_gu, false);
this->add(&indiv_stat_record, annotated_indiv.first->id());
}
......@@ -544,28 +512,27 @@ StatRecord::StatRecord(ExpManager * exp_m,
}
// Calculate standard deviation for all the recorded values
StatRecord::StatRecord(ExpManager * exp_m,
const list<Individual *> indivs,
const StatRecord * means,
chrom_or_gen_unit chrom_or_gu)
{
exp_m_ = exp_m;
initialize_data();
StatRecord::StatRecord(ExpSetup* exp_s,
std::list<std::pair<Individual*,
ReplicationReport*>> annotated_indivs,
const StatRecord * means,
chrom_or_gen_unit chrom_or_gu) {
record_type_ = STDEVS;
// ---------------
// Simulation data
// ---------------
pop_size_ = indivs.size();
pop_size_ = static_cast<int32_t>(annotated_indivs.size());
// ------------------------------------------------------------------
// Compute statistical data for the each individual in the population
// ------------------------------------------------------------------
for (const auto& indiv : indivs) {
StatRecord * indiv_stat_record = new StatRecord(exp_m_, indiv, chrom_or_gu, false);
this->substract_power(means, indiv_stat_record, 2);
delete indiv_stat_record;
for (const auto& annotated_indiv : annotated_indivs) {
StatRecord indiv_stat_record(exp_s,
annotated_indiv.first,
annotated_indiv.second,
chrom_or_gu, false);
this->substract_power(means, &indiv_stat_record, 2);
}
// ---------------------------------------------------------------------------------
......@@ -575,30 +542,28 @@ StatRecord::StatRecord(ExpManager * exp_m,
}
// Calculate skewness for all the recorded values
StatRecord::StatRecord(ExpManager * exp_m,
const list<Individual *> indivs,
const StatRecord * means,
const StatRecord * stdevs,
chrom_or_gen_unit chrom_or_gu)
{
exp_m_ = exp_m;
initialize_data();
StatRecord::StatRecord(ExpSetup* exp_s,
std::list<std::pair<Individual*,
ReplicationReport*>> annotated_indivs,
const StatRecord* means,
const StatRecord* stdevs,
chrom_or_gen_unit chrom_or_gu) {
record_type_ = SKEWNESS;
// ---------------
// Simulation data
// ---------------
pop_size_ = (double) indivs.size();
pop_size_ = static_cast<int32_t>(annotated_indivs.size());
// ------------------------------------------------------------------
// Compute statistical data for the each individual in the population
// ------------------------------------------------------------------
for (const auto& indiv : indivs)
{
StatRecord * indiv_stat_record = new StatRecord(exp_m_, indiv, chrom_or_gu, false);
this->substract_power(means, indiv_stat_record, 3);
delete indiv_stat_record;
for (const auto& annotated_indiv : annotated_indivs) {
StatRecord indiv_stat_record(exp_s,
annotated_indiv.first,
annotated_indiv.second,
chrom_or_gu, false);
this->substract_power(means, &indiv_stat_record, 3);
}
this->divide(-pop_size_);
......@@ -616,238 +581,103 @@ StatRecord::~StatRecord()
// =================================================================
// Public Methods
// =================================================================
void StatRecord::initialize_data()
{
pop_size_ = 0.0;
metabolic_error_ = 0.0;
metabolic_fitness_ = 0.0;
parent_metabolic_error_ = 0.0;
secretion_error_ = 0.0;
parent_secretion_error_ = 0.0;
secretion_fitness_ = 0.0;
compound_amount_ = 0.0;
fitness_ = 0.0;
amount_of_dna_ = 0.0;
nb_coding_rnas_ = 0.0;
nb_non_coding_rnas_ = 0.0;
av_size_coding_rnas_ = 0.0;
av_size_non_coding_rnas_ = 0.0;
nb_functional_genes_ = 0.0;
nb_non_functional_genes_ = 0.0;
av_size_functional_gene_ = 0.0;
av_size_non_functional_gene_ = 0.0;
nb_mut_ = 0.0;
nb_rear_ = 0.0;
nb_switch_ = 0.0;
nb_indels_ = 0.0;
nb_dupl_ = 0.0;
nb_del_ = 0.0;
nb_trans_ = 0.0;
nb_inv_ = 0.0;
dupl_rate_ = 0.0;
del_rate_ = 0.0;
trans_rate_ = 0.0;
inv_rate_ = 0.0;
mean_align_score_ = 0.0;
nb_bases_in_0_CDS_ = 0.0;
nb_bases_in_0_functional_CDS_ = 0.0;
nb_bases_in_0_non_functional_CDS_ = 0.0;
nb_bases_in_0_RNA_ = 0.0;
nb_bases_in_0_coding_RNA_ = 0.0;
nb_bases_in_0_non_coding_RNA_ = 0.0;
nb_bases_non_essential_ = 0.0;
nb_bases_non_essential_including_nf_genes_ = 0.0;
#ifdef __REGUL
nb_influences_ = 0.0;
nb_enhancing_influences_ = 0.0;
nb_operating_influences_ = 0.0;
av_value_influences_ = 0.0;
av_value_enhancing_influences_ = 0.0;
av_value_operating_influences_ = 0.0;
#endif
}
void StatRecord::write_to_file(FILE* stat_file, stats_type stat_type_to_print) const
{
if (record_type_ == INDIV)
if (stat_type_to_print == FITNESS_STATS)
{
if (stat_type_to_print == FITNESS_STATS)
{
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %e %" PRId32 " %e %e %e %e %e %e %e",
AeTime::time(),
pop_size_,
fitness_,
amount_of_dna_,
metabolic_error_,
parent_metabolic_error_,
metabolic_fitness_,
secretion_error_,
parent_secretion_error_,
secretion_fitness_,
compound_amount_);
#ifdef __REGUL
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %e %" PRId32 " %e %e %e %e %e %e %e",
AeTime::time(),
pop_size_,
fitness_,
amount_of_dna_,
metabolic_error_,
parent_metabolic_error_,
metabolic_fitness_,
secretion_error_,
parent_secretion_error_,
secretion_fitness_,
compound_amount_);
#ifdef __REGUL
fprintf(stat_file,
" %" PRId32 " %" PRId32 " %" PRId32 " %f %f %f",
nb_influences_,
nb_enhancing_influences_,
nb_operating_influences_,
av_value_influences_,
av_value_enhancing_influences_,
av_value_operating_influences_);
#endif
}
if (stat_type_to_print == MUTATION_STATS)
{
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 "",
AeTime::time(),
nb_mut_,
nb_rear_,
nb_switch_,
nb_indels_,
nb_dupl_,
nb_del_,
nb_trans_,
nb_inv_);
}
if (stat_type_to_print == GENES_STATS)
{
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %" PRId32 " %f %f %" PRId32 " %" PRId32 " %f %f ",
AeTime::time(),
nb_coding_rnas_,
nb_non_coding_rnas_,
av_size_coding_rnas_,
av_size_non_coding_rnas_,
nb_functional_genes_,
nb_non_functional_genes_,
av_size_functional_gene_,
av_size_non_functional_gene_);
}
if (stat_type_to_print == BP_STATS)
{
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 "",
AeTime::time(),
nb_bases_in_0_CDS_,
nb_bases_in_0_functional_CDS_,
nb_bases_in_0_non_functional_CDS_,
nb_bases_in_0_RNA_,
nb_bases_in_0_coding_RNA_,
nb_bases_in_0_non_coding_RNA_,
nb_bases_non_essential_,
nb_bases_non_essential_including_nf_genes_);
}
if (stat_type_to_print == REAR_STATS)
{
fprintf(stat_file,
"%" PRId64 " %e %e %e %e %f",
AeTime::time(),
dupl_rate_,
del_rate_,
trans_rate_,
inv_rate_,
mean_align_score_);
}
" %" PRId32 " %" PRId32 " %" PRId32 " %f %f %f",
nb_influences_,
nb_enhancing_influences_,
nb_operating_influences_,
av_value_influences_,
av_value_enhancing_influences_,
av_value_operating_influences_);
#endif
}
else // if record_type_ == POP
if (stat_type_to_print == MUTATION_STATS)
{
if (stat_type_to_print == FITNESS_STATS)
{
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %e %" PRId32 " %e %e %e %e %e %e %e",
AeTime::time(),
pop_size_,
fitness_,
amount_of_dna_,
metabolic_error_,
parent_metabolic_error_,
metabolic_fitness_,
secretion_error_,
parent_secretion_error_,
secretion_fitness_,
compound_amount_);
#ifdef __REGUL
fprintf(stat_file,
" %" PRId32 " %" PRId32 " %" PRId32 " %f %f %f",
nb_influences_,
nb_enhancing_influences_,
nb_operating_influences_,
av_value_influences_,
av_value_enhancing_influences_,
av_value_operating_influences_);
#endif
}
if (stat_type_to_print == MUTATION_STATS)
{
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32
" %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 "",
AeTime::time(),
nb_mut_,
nb_rear_,
nb_switch_,
nb_indels_,
nb_dupl_,
nb_del_,
nb_trans_,
nb_inv_);
}
if (stat_type_to_print == GENES_STATS)
{
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 "",
AeTime::time(),
nb_mut_,
nb_rear_,
nb_switch_,
nb_indels_,
nb_dupl_,
nb_del_,
nb_trans_,
nb_inv_);
}
if (stat_type_to_print == GENES_STATS)
{
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %" PRId32 " %f %f %" PRId32 " %" PRId32 " %f %f ",
AeTime::time(),
nb_coding_rnas_,
nb_non_coding_rnas_,
av_size_coding_rnas_,
av_size_non_coding_rnas_,
nb_functional_genes_,
nb_non_functional_genes_,
av_size_functional_gene_,
av_size_non_functional_gene_);
}
if (stat_type_to_print == BP_STATS) {
if (record_type_ == INDIV) {
fprintf(stat_file,
"%" PRId64 " %" PRId32 " %" PRId32 " %f %f %" PRId32 " %" PRId32
" %f %f",
AeTime::time(),
nb_coding_rnas_,
nb_non_coding_rnas_,
av_size_coding_rnas_,
av_size_non_coding_rnas_,
nb_functional_genes_,
nb_non_functional_genes_,
av_size_functional_gene_,
av_size_non_functional_gene_);
}
if (stat_type_to_print == BP_STATS)
{
// TO DO (if needed) : base-pair stats for all individuals, not just for the best one.
//
// fprintf(stat_file, "%" PRId64 " %f %f %f %f %f %f %f %f",
// AeTime::time(),
// nb_bases_in_0_CDS_,
// nb_bases_in_0_functional_CDS_,
// nb_bases_in_0_non_functional_CDS_,
// nb_bases_in_0_RNA_,
// nb_bases_in_0_coding_RNA_,
// nb_bases_in_0_non_coding_RNA_,
// nb_bases_non_essential_,
// nb_bases_non_essential_including_nf_genes_);
"%" PRId64 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 " %" PRId32 "",
AeTime::time(),
nb_bases_in_0_CDS_,
nb_bases_in_0_functional_CDS_,
nb_bases_in_0_non_functional_CDS_,
nb_bases_in_0_RNA_,
nb_bases_in_0_coding_RNA_,
nb_bases_in_0_non_coding_RNA_,
nb_bases_non_essential_,
nb_bases_non_essential_including_nf_genes_);
}
if (stat_type_to_print == REAR_STATS)
else // if record_type_ == POP
{
fprintf(stat_file,
"%" PRId64 " %e %e %e %e %f",
AeTime::time(),
dupl_rate_,
del_rate_,
trans_rate_,
inv_rate_,
mean_align_score_);
// TO DO (if needed) : base-pair stats for all individuals, not just for the best one.
//
// fprintf(stat_file, "%" PRId64 " %f %f %f %f %f %f %f %f",
// AeTime::time(),
// nb_bases_in_0_CDS_,
// nb_bases_in_0_functional_CDS_,
// nb_bases_in_0_non_functional_CDS_,
// nb_bases_in_0_RNA_,
// nb_bases_in_0_coding_RNA_,
// nb_bases_in_0_non_coding_RNA_,
// nb_bases_non_essential_,
// nb_bases_non_essential_including_nf_genes_);
}
}
if (stat_type_to_print == REAR_STATS)
{
fprintf(stat_file,
"%" PRId64 " %e %e %e %e %f",
AeTime::time(),
dupl_rate_,
del_rate_,
trans_rate_,
inv_rate_,
mean_align_score_);
}
fprintf(stat_file, "\n");
}
......@@ -917,8 +747,7 @@ void StatRecord::divide(double divisor)
}
void StatRecord::divide_record(StatRecord const * to_divide, double power)
{
void StatRecord::divide_record(const StatRecord* to_divide, double power) {
// NB : pop_size is a "global" value and must not be divided.
if (to_divide->fitness_ != 0) { fitness_ /= pow(to_divide->fitness_, power); }
......
......@@ -38,6 +38,8 @@
#include <cassert>
#include <list>
#include "ReplicationReport.h"
#include "ExpSetup.h"
......@@ -56,6 +58,7 @@ class ExpManager;
class Stats;
class Individual;
class ae_population;
class ReplicationReport;
enum indiv_or_pop
{
......@@ -107,24 +110,27 @@ class StatRecord
// Constructors
// =================================================================
StatRecord() = delete;
StatRecord(ExpManager * exp_m);
StatRecord(const StatRecord &model);
StatRecord(ExpManager * exp_m,
Individual * indiv,
chrom_or_gen_unit chrom_or_gu = CHROM,
bool compute_non_coding = true);
StatRecord(ExpManager * exp_m,
const std::list<Individual *> indivs,
chrom_or_gen_unit chrom_or_gu = CHROM);
StatRecord(ExpManager * exp_m,
const std::list<Individual *> indivs,
const StatRecord * means,
chrom_or_gen_unit chrom_or_gu = CHROM);
StatRecord(ExpManager * exp_m,
const std::list<Individual *> indivs,
const StatRecord * means,
const StatRecord * stdevs,
chrom_or_gen_unit chrom_or_gu = CHROM);
StatRecord(ExpSetup* exp_s,
Individual * indiv,
ReplicationReport* replic_report,
chrom_or_gen_unit chrom_or_gu = CHROM,
bool compute_non_coding = true);
StatRecord(ExpSetup* exp_s,
std::list<std::pair<Individual*,
ReplicationReport*>> annotated_indivs,
chrom_or_gen_unit chrom_or_gu = CHROM);
StatRecord(ExpSetup* exp_s,
std::list<std::pair<Individual*,
ReplicationReport*>> annotated_indivs,
const StatRecord * means,
chrom_or_gen_unit chrom_or_gu = CHROM);
StatRecord(ExpSetup* exp_s,
std::list<std::pair<Individual*,
ReplicationReport*>> annotated_indivs,
const StatRecord * means,
const StatRecord* stdevs,
chrom_or_gen_unit chrom_or_gu = CHROM);
// =================================================================
// Destructors
......@@ -163,68 +169,71 @@ class StatRecord
// =================================================================
// Protected Attributes
// =================================================================
ExpManager * exp_m_;
// NB : All the attributes are doubles because they will be used to
// compute averages over the population.
indiv_or_pop record_type_;
int32_t pop_size_;
double fitness_;
double metabolic_error_;
double parent_metabolic_error_;
double metabolic_fitness_;
double secretion_error_;
double parent_secretion_error_;
double secretion_fitness_;
double compound_amount_;
int32_t amount_of_dna_;
int32_t nb_coding_rnas_;
int32_t nb_non_coding_rnas_;
double av_size_coding_rnas_; // NOT including promoter but including terminator
double av_size_non_coding_rnas_; // NOT including promoter but including terminator
int32_t nb_functional_genes_;
int32_t nb_non_functional_genes_;
double av_size_functional_gene_; // NOT including START and STOP codons
double av_size_non_functional_gene_; // NOT including START and STOP codons
int32_t nb_mut_;
int32_t nb_rear_;
int32_t nb_switch_;
int32_t nb_indels_;
int32_t nb_dupl_;
int32_t nb_del_;
int32_t nb_trans_;
int32_t nb_inv_;
double dupl_rate_;
double del_rate_;
double trans_rate_;
double inv_rate_;
double mean_align_score_;
int32_t nb_bases_in_0_CDS_;
int32_t nb_bases_in_0_functional_CDS_;
int32_t nb_bases_in_0_non_functional_CDS_;
int32_t nb_bases_in_0_RNA_;
int32_t nb_bases_in_0_coding_RNA_;
int32_t nb_bases_in_0_non_coding_RNA_;
int32_t nb_bases_non_essential_;
int32_t nb_bases_non_essential_including_nf_genes_;
int32_t pop_size_ = 0.0;
double fitness_ = 0.0;
double metabolic_error_ = 0.0;
double parent_metabolic_error_ = 0.0;
double metabolic_fitness_ = 0.0;
double secretion_error_ = 0.0;
double parent_secretion_error_ = 0.0;
double secretion_fitness_ = 0.0;
double compound_amount_ = 0.0;
int32_t amount_of_dna_ = 0.0;
int32_t nb_coding_rnas_ = 0.0;
int32_t nb_non_coding_rnas_ = 0.0;
// NOT including promoter but including terminator
double av_size_coding_rnas_ = 0.0;
double av_size_non_coding_rnas_ = 0.0;
int32_t nb_functional_genes_ = 0.0;
int32_t nb_non_functional_genes_ = 0.0;
// NOT including START and STOP codons
double av_size_functional_gene_ = 0.0;
double av_size_non_functional_gene_ = 0.0;
int32_t nb_mut_ = 0.0;
int32_t nb_rear_ = 0.0;
int32_t nb_switch_ = 0.0;
int32_t nb_indels_ = 0.0;
int32_t nb_dupl_ = 0.0;
int32_t nb_del_ = 0.0;
int32_t nb_trans_ = 0.0;
int32_t nb_inv_ = 0.0;
double dupl_rate_ = 0.0;
double del_rate_ = 0.0;
double trans_rate_ = 0.0;
double inv_rate_ = 0.0;
double mean_align_score_ = 0.0;
int32_t nb_bases_in_0_CDS_ = 0.0;
int32_t nb_bases_in_0_functional_CDS_ = 0.0;
int32_t nb_bases_in_0_non_functional_CDS_ = 0.0;
int32_t nb_bases_in_0_RNA_ = 0.0;
int32_t nb_bases_in_0_coding_RNA_ = 0.0;
int32_t nb_bases_in_0_non_coding_RNA_ = 0.0;
int32_t nb_bases_non_essential_ = 0.0;
int32_t nb_bases_non_essential_including_nf_genes_ = 0.0;
#ifdef __REGUL
int32_t nb_influences_;
int32_t nb_enhancing_influences_;
int32_t nb_operating_influences_;
double av_value_influences_;
double av_value_enhancing_influences_;
double av_value_operating_influences_;
int32_t nb_influences_ = 0.0;
int32_t nb_enhancing_influences_ = 0.0;
int32_t nb_operating_influences_ = 0.0;
double av_value_influences_ = 0.0;
double av_value_enhancing_influences_ = 0.0;
double av_value_operating_influences_ = 0.0;
double nb_TF_;
double nb_pure_TF_;
#endif
......
......@@ -82,12 +82,12 @@ Stats::Stats(ExpManager * exp_m,
write_headers();
}
/*!
Create a stat manager to append existing stats
/**
* Create a stat manager to append to existing stats
*/
Stats::Stats(ExpManager * exp_m,
int64_t time,
bool best_indiv_only,
bool best_indiv_only/* = false */,
const char * prefix /* = "stat" */,
bool addition_old_stats /* = true */,
bool delete_old_stats /* = true */) {
......@@ -476,6 +476,12 @@ void Stats::write_headers(bool ancstats_stats /* = false */)
void Stats::write_current_generation_statistics()
{
StatRecord** stat_records;
Individual* best_indiv = exp_m_->best_indiv();
ReplicationReport* best_replic_report = exp_m_->tree() ?
exp_m_->tree()->report_by_index(AeTime::time(), best_indiv->id()) :
nullptr;
std::list<std::pair<Individual*, ReplicationReport*>> annotated_indivs =
exp_m_->indivs_annotated();
for (int8_t chrom_or_GU = 0 ; chrom_or_GU < NB_CHROM_OR_GU ; chrom_or_GU++)
{
......@@ -484,18 +490,21 @@ void Stats::write_current_generation_statistics()
stat_records = new StatRecord* [NB_BEST_OR_GLOB];
stat_records[BEST] = new StatRecord(exp_m_,
exp_m_->best_indiv(),
// WARNING: stat_record initialization order matters: SKEW computation
// relies on SDEV being computed
stat_records[BEST] = new StatRecord(exp_m_->exp_s(),
best_indiv,
best_replic_report,
(chrom_or_gen_unit) chrom_or_GU);
stat_records[GLOB] = new StatRecord(exp_m_,
exp_m_->indivs(),
stat_records[GLOB] = new StatRecord(exp_m_->exp_s(),
annotated_indivs,
(chrom_or_gen_unit) chrom_or_GU);
stat_records[SDEV] = new StatRecord(exp_m_,
exp_m_->indivs(),
stat_records[SDEV] = new StatRecord(exp_m_->exp_s(),
annotated_indivs,
stat_records[GLOB],
(chrom_or_gen_unit) chrom_or_GU);
stat_records[SKEW] = new StatRecord(exp_m_,
exp_m_->indivs(),
stat_records[SKEW] = new StatRecord(exp_m_->exp_s(),
annotated_indivs,
stat_records[GLOB],
stat_records[SDEV],
(chrom_or_gen_unit) chrom_or_GU);
......@@ -506,7 +515,9 @@ void Stats::write_current_generation_statistics()
{
if (stat_files_names_[chrom_or_GU][best_or_glob][stat_type] != NULL)
{
stat_records[best_or_glob]->write_to_file(stat_files_[chrom_or_GU][best_or_glob][stat_type], (stats_type) stat_type);
stat_records[best_or_glob]->
write_to_file(stat_files_[chrom_or_GU][best_or_glob][stat_type],
(stats_type) stat_type);
}
}
......@@ -517,13 +528,15 @@ void Stats::write_current_generation_statistics()
}
}
void Stats::write_statistics_of_this_indiv(Individual * indiv)
void Stats::write_statistics_of_this_indiv(Individual * indiv,
ReplicationReport* replic_report)
{
StatRecord * stat_record;
for (int8_t chrom_or_GU = 0 ; chrom_or_GU < NB_CHROM_OR_GU ; chrom_or_GU++)
{
stat_record = new StatRecord(exp_m_, indiv, (chrom_or_gen_unit) chrom_or_GU, true);
stat_record = new StatRecord(exp_m_->exp_s(), indiv, replic_report,
(chrom_or_gen_unit) chrom_or_GU, true);
for (int8_t stat_type = 0 ; stat_type < NB_STATS_TYPES ; stat_type++)
{
......@@ -606,11 +619,11 @@ void Stats::set_file_names(const char* prefix,
}
const char* chrom_or_gu_name[NB_CHROM_OR_GU] =
{"", "chromosome_", "plasmids_"};
{"", "_chromosome", "_plasmids"};
const char* best_or_glob_name[NB_BEST_OR_GLOB] =
{"best_", "glob_", "sdev_", "skew_"};
{"_best", "_glob", "_sdev", "_skew"};
const char* stat_type_name[NB_STATS_TYPES] =
{"fitness_", "mutation_", "genes_", "bp_", "rear_"};
{"_fitness" ,"_mutation", "_genes", "_bp", "_rear"};
for (int8_t chrom_or_GU = 0 ; chrom_or_GU < NB_CHROM_OR_GU ; chrom_or_GU++) {
// If plasmids are not allowed, don't issue "chromosome" and
......@@ -720,9 +733,6 @@ void Stats::CreateTmpFiles(int64_t time) {
}
// Copy stats until time (included)
if (fgets(line, 500, old_file) == NULL) {
// TODO check for error
}
while ((int64_t)atol(line) <= time && !feof(old_file)) {
fputs(line, new_file);
if (fgets(line, 500, old_file)) {
......
......@@ -50,6 +50,7 @@
#include <stdlib.h>
#include <assert.h>
#include "Individual.h"
#include "ReplicationReport.h"
namespace aevol {
......@@ -65,84 +66,84 @@ class ExpManager;
class Stats
{
public :
// =================================================================
// Constructors
// =================================================================
Stats() = delete;
Stats(const Stats &) = delete;
Stats(ExpManager * exp_m,
bool best_indiv_only = false,
const char* prefix = "stat",
bool with_plasmids = false,
bool compute_phen_contrib_by_GU = false);
Stats(ExpManager * exp_m,
int64_t time,
bool best_indiv_only = false,
const char * prefix = "stat",
bool addition_old_stats = true,
bool delete_old_stats = true);
// =================================================================
// Destructors
// =================================================================
virtual ~Stats();
// =================================================================
// Accessors: getters
// =================================================================
// =================================================================
// Accessors: setters
// =================================================================
inline void set_exp_m(ExpManager * exp_m);
// =================================================================
// Public Methods
// =================================================================
void write_current_generation_statistics();
void write_statistics_of_this_indiv(Individual * indiv);
void flush();
void write_headers(bool ancstats_stats = false);
void CreateTmpFiles(int64_t time);
void MoveTmpFiles(const std::string& destdir);
void PromoteTmpFiles();
class Stats {
public :
// =================================================================
// Constructors
// =================================================================
Stats() = delete;
Stats(const Stats&) = delete;
Stats(ExpManager* exp_m,
bool best_indiv_only = false,
const char* prefix = "stat",
bool with_plasmids = false,
bool compute_phen_contrib_by_GU = false);
Stats(ExpManager* exp_m,
int64_t time,
bool best_indiv_only = false,
const char * prefix = "stat",
bool addition_old_stats = true,
bool delete_old_stats = true);
// =================================================================
// Destructors
// =================================================================
virtual ~Stats();
// =================================================================
// Accessors: getters
// =================================================================
// =================================================================
// Accessors: setters
// =================================================================
inline void set_exp_m(ExpManager * exp_m);
// =================================================================
// Public Methods
// =================================================================
void write_current_generation_statistics();
void write_statistics_of_this_indiv(Individual* indiv,
ReplicationReport* replic_report);
void flush();
void write_headers(bool ancstats_stats = false);
void CreateTmpFiles(int64_t time);
void MoveTmpFiles(const std::string& destdir);
void PromoteTmpFiles();
protected :
// =================================================================
// Protected Methods
// =================================================================
void init_data();
void set_file_names(const char* prefix,
bool one_lambda_indiv_only,
bool with_plasmids = false,
bool compute_phen_contrib_by_GU = false);
void open_files();
inline void write_header(FILE* file_name, const char* header);
inline void write_header(FILE* file_name, const char* header, int8_t key);
// =================================================================
// Protected Attributes
// =================================================================
ExpManager * exp_m_;
// 3D tables of stat files (FILE*) and their names (char*)
// Dimensions are given by:
// * genetic unit (ALL_GU, CHROM or PLASMIDS)
// * BEST or GLOB
// * stat type (FITNESS_STATS, MUTATION_STATS, GENES_STATS, BP_STATS or REAR_STATS)
// Files that are not wanted MUST have their name set to NULL.
// The files themselves are also NULL because we don't fopen() them.
FILE**** stat_files_;
char**** stat_files_names_;
// =================================================================
// Protected Methods
// =================================================================
void init_data();
void set_file_names(const char* prefix,
bool one_lambda_indiv_only,
bool with_plasmids = false,
bool compute_phen_contrib_by_GU = false);
void open_files();
inline void write_header(FILE* file_name, const char* header);
inline void write_header(FILE* file_name, const char* header, int8_t key);
// =================================================================
// Protected Attributes
// =================================================================
ExpManager * exp_m_;
// 3D tables of stat files (FILE*) and their names (char*)
// Dimensions are given by:
// * genetic unit (ALL_GU, CHROM or PLASMIDS)
// * BEST or GLOB
// * stat type (FITNESS_STATS, MUTATION_STATS, GENES_STATS, BP_STATS or REAR_STATS)
// Files that are not wanted MUST have their name set to NULL.
// The files themselves are also NULL because we don't fopen() them.
FILE**** stat_files_;
char**** stat_files_names_;
};
......
......@@ -179,13 +179,21 @@ void Tree::write_to_tree_file(gzFile tree_file) {
}
}
/**
* This method is called whenever an observed object calls notifyObservers
*
* \param o the observable that has called notifyObservers
* \param e type of event triggered
* \param arg array containing a pointer to the new indiv and its parent
*/
void Tree::update(Observable& o, ObservableEvent e, void* arg) {
switch (e) {
case NEW_INDIV : {
// Initialize the replication report corresponding to the new individual
auto indivs = reinterpret_cast<Individual**>(arg);
report_by_index(AeTime::time(), indivs[0]->id())->
init(indivs[0], indivs[1]);
Individual* new_indiv = indivs[0];
Individual* parent = indivs[1];
report_by_index(AeTime::time(), new_indiv->id())->init(new_indiv, parent);
break;
}
case END_GENERATION :
......
......@@ -80,9 +80,9 @@ class World
std::shared_ptr<JumpingMT> mut_prng() const;
std::shared_ptr<JumpingMT> stoch_prng() const;
std::list<Individual *> indivs() const;
std::list<Individual*> indivs() const;
inline int32_t nb_indivs() const;
inline Individual * best_indiv() const;
inline Individual* best_indiv() const;
int16_t width() const {return width_;};
int16_t height() const {return height_;};
inline int32_t partial_mix_nb_permutations() const;
......
......@@ -37,7 +37,6 @@
#include "DnaReplicationReport.h"
#include "Dump.h"
#include "ExpManager.h"
#include "ExpManager_X11.h"
#include "ExpSetup.h"
#include "ParameterLine.h"
#include "Fuzzy.h"
......@@ -47,7 +46,6 @@
#include "Habitat.h"
#include "IndividualFactory.h"
#include "Individual.h"
#include "Individual_X11.h"
#include "Metrics.h"
#include "JumpingMT.h"
#include "JumpPoly.h"
......@@ -80,6 +78,11 @@
#include "Tree.h"
#include "VisAVis.h"
#include "World.h"
#include "X11Window.h"
#ifdef __X11
#include "ExpManager_X11.h"
#include "Individual_X11.h"
#include "X11Window.h"
#endif
#endif // AEVOL_AEVOL_H_
......@@ -91,6 +91,7 @@ class Habitat_R : public virtual Habitat
// ==========================================================================
virtual const PhenotypicTarget& phenotypic_target() const {
Utils::ExitWithDevMsg("You should not call a phenotypic target without age id in RAevol", __FILE__, __LINE__);
return *(new PhenotypicTarget()); // suppress warning
}
const PhenotypicTarget_R& phenotypic_target( int8_t age ) const {
......
......@@ -264,7 +264,7 @@ void Individual_R::one_step( void )
// fitnesses
//----------------------------------------------------------------------------
update_concentrations();
if (exp_m_->regul_or_not()) update_concentrations();
}
void Individual_R::eval_step( const Habitat_R& habitat, int8_t age ) {
......
if WITH_CPPUNIT
############################################
# Set a few variables #
############################################
AM_CPPFLAGS = $(AEVOLCPPFLAGS) $(CPPUNIT_CFLAGS)
AM_CXXFLAGS = $(AEVOLCXXFLAGS)
AM_LDFLAGS = $(AEVOLLDFLAGS)
AM_CPPFLAGS += -I$(top_srcdir)/src/libaevol
AM_LDFLAGS += -L$(top_srcdir)/src/libaevol
############################################
# Set aevol library to use #
############################################
LDADD = $(top_srcdir)/src/libaevol/libaevol.a
LDADD += $(top_srcdir)/src/libaevol/SFMT-src-1.4/libsfmt.a $(CPPUNIT_LIBS)
############################################
# C99 exact-width integer specific support #
############################################
# __STDC_FORMAT_MACROS allows us to use exact-width integer format specifiers e.g. PRId32 (for printf etc)
# __STDC_CONSTANT_MACROS allows us to define exact-width integer macros with e.g. INT32_C( <value> )
# __STDC_LIMIT_MACROS allows us to use exact-width integer limit macros with e.g. INT32_MAX
AM_CPPFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
############################################
# Set programs to build #
############################################
check_PROGRAMS = run_tests
CLEANFILES = $(check_PROGRAMS)
TESTS = $(check_PROGRAMS)
# The target_CPPFLAGS for each target may look useless, it is here to force automake to create
# prefixed object files so that we don't use an object file built for another set of macrodefinitions
# e.g. We don't want to use an object file created with NO_X when building the X11 lib
run_tests_SOURCES = \
run_tests.cpp \
Test_JumpingMT.h \
Test_JumpingMT.cpp
run_tests_CPPFLAGS = $(AM_CPPFLAGS)
endif
// ****************************************************************************
//
// Aevol - An in silico experimental evolution platform
//
// ****************************************************************************
//
// Copyright: See the AUTHORS file provided with the package or <www.aevol.fr>
// Web: http://www.aevol.fr/
// E-mail: See <http://www.aevol.fr/contact/>
// Original Authors : Guillaume Beslon, Carole Knibbe, David Parsons
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//*****************************************************************************
// =================================================================
// Libraries
// =================================================================
// =================================================================
// Project Files
// =================================================================
#include "Test_JumpingMT.h"
namespace aevol {
// ===========================================================================
// Declare Used Namespaces
// ===========================================================================
//############################################################################
// #
// Class Test_JumpingMT #
// #
//############################################################################
CPPUNIT_TEST_SUITE_REGISTRATION(Test_JumpingMT);
// ===========================================================================
// Static attributes
// ===========================================================================
// ===========================================================================
// Constructors
// ===========================================================================
Test_JumpingMT::Test_JumpingMT(void)
{
}
// ===========================================================================
// Destructors
// ===========================================================================
Test_JumpingMT::~Test_JumpingMT(void)
{
}
// ===========================================================================
// Operators
// ===========================================================================
// ===========================================================================
// Public Methods
// ===========================================================================
void Test_JumpingMT::setUp(void)
{
obj1 = new JumpingMT(56873);
obj2 = new JumpingMT(*obj1);
}
void Test_JumpingMT::tearDown(void)
{
delete obj1;
delete obj2;
}
void Test_JumpingMT::test1(void)
{
for (int i = 0 ; i < 10 ; i++)
{
obj1->random();
obj2->random();
}
CPPUNIT_ASSERT(obj1->random() == obj2->random());
CPPUNIT_ASSERT(obj1->random((int8_t) INT8_MAX) == obj2->random((int8_t) INT8_MAX));
CPPUNIT_ASSERT(obj1->random((int16_t) INT16_MAX) == obj2->random((int16_t) INT16_MAX));
CPPUNIT_ASSERT(obj1->random((int32_t) INT32_MAX) == obj2->random((int32_t) INT32_MAX));
CPPUNIT_ASSERT(obj1->random((int64_t) INT64_MAX) == obj2->random((int64_t) INT64_MAX));
CPPUNIT_ASSERT(obj1->binomial_random(435, 0.5) == obj2->binomial_random(435, 0.5));
CPPUNIT_ASSERT(obj1->gaussian_random() == obj2->gaussian_random());
}
void Test_JumpingMT::test2(void)
{
CPPUNIT_ASSERT(true);
}
// ===========================================================================
// Protected Methods
// ===========================================================================
// ===========================================================================
// Non inline accessors
// ===========================================================================
} // namespace aevol
// ****************************************************************************
//
// Aevol - An in silico experimental evolution platform
//
// ****************************************************************************
//
// Copyright: See the AUTHORS file provided with the package or <www.aevol.fr>
// Web: http://www.aevol.fr/
// E-mail: See <http://www.aevol.fr/contact/>
// Original Authors : Guillaume Beslon, Carole Knibbe, David Parsons
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//*****************************************************************************
#ifndef TEST_AE_JUMPING_MT
#define TEST_AE_JUMPING_MT
// =================================================================
// Libraries
// =================================================================
#include <cstdio>
#include <cstdlib>
#include <cppunit/TestCase.h>
#include <cppunit/extensions/HelperMacros.h>
// =================================================================
// Project Files
// =================================================================
#include "JumpingMT.h"
namespace aevol {
// ===========================================================================
// Declare Used Namespaces
// ===========================================================================
using namespace CppUnit;
using namespace std;
class Test_JumpingMT : public TestFixture
{
CPPUNIT_TEST_SUITE(Test_JumpingMT);
CPPUNIT_TEST(test1);
CPPUNIT_TEST(test2);
CPPUNIT_TEST_SUITE_END();
public :
// =======================================================================
// Enums
// =======================================================================
// =======================================================================
// Constructors
// =======================================================================
Test_JumpingMT(void);
// =======================================================================
// Destructors
// =======================================================================
virtual ~Test_JumpingMT(void);
// =======================================================================
// Accessors: getters
// =======================================================================
// =======================================================================
// Accessors: setters
// =======================================================================
// =======================================================================
// Operators
// =======================================================================
// =======================================================================
// Public Methods
// =======================================================================
void setUp(void);
void tearDown(void);
void test1(void);
void test2(void);
// =======================================================================
// Public Attributes
// =======================================================================
protected :
// =======================================================================
// Forbidden Constructors
// =======================================================================
/*Test_JumpingMT(void)
{
printf("%s:%d: error: call to forbidden constructor.\n", __FILE__, __LINE__);
exit(EXIT_FAILURE);
};
Test_JumpingMT(const Test_JumpingMT &model)
{
printf("%s:%d: error: call to forbidden constructor.\n", __FILE__, __LINE__);
exit(EXIT_FAILURE);
};*/
// =======================================================================
// Protected Methods
// =======================================================================
// =======================================================================
// Protected Attributes
// =======================================================================
JumpingMT* obj1;
JumpingMT* obj2;
};
// ===========================================================================
// Getters' definitions
// ===========================================================================
// ===========================================================================
// Setters' definitions
// ===========================================================================
// ===========================================================================
// Inline Operators' definitions
// ===========================================================================
// ===========================================================================
// Inline functions' definition
// ===========================================================================
} // namespace aevol
#endif // TEST_AE_JUMPING_MT