Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 98e1baab authored by David Parsons's avatar David Parsons
Browse files

Fix remaining read/writes of time as 32bit integers

parent 9936e90c
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,7 @@ int main(int argc, char* argv[])
// 1) Initialize command-line option variables with default values
char* param_file_name = NULL;
bool verbose = false;
int32_t num_gener = -1;
int64_t num_gener = -1;
// 2) Define allowed options
const char * options_list = "hf:g:V";
......@@ -140,7 +140,7 @@ int main(int argc, char* argv[])
// If it doesn't, print help and exit
FILE* lg_file = fopen(LAST_GENER_FNAME, "r");
if (lg_file != NULL) {
if (fscanf(lg_file, "%" PRId32 "\n", &num_gener) == EOF) {
if (fscanf(lg_file, "%" PRId64 "\n", &num_gener) == EOF) {
Utils::ExitWithUsrMsg(
std::string("failed to read last generation from file ") +
LAST_GENER_FNAME);
......@@ -183,9 +183,9 @@ int main(int argc, char* argv[])
{
// If a tree is available, assign the replication reports to the individuals
#ifdef __REGUL
sprintf(tree_file_name,"tree/tree_%06" PRId32 ".rae", num_gener);
sprintf(tree_file_name,"tree/tree_%06" PRId64 ".rae", num_gener);
#else
sprintf(tree_file_name,"tree/tree_%06" PRId32 ".ae", num_gener);
sprintf(tree_file_name,"tree/tree_%06" PRId64 ".ae", num_gener);
#endif
tree = new Tree(exp_manager, tree_file_name);
......@@ -698,9 +698,9 @@ int main(int argc, char* argv[])
printf("Save the modified replication reports into tree...\t");
#ifdef __REGUL
sprintf(tree_file_name,"tree/tree_%06" PRId32 ".rae", num_gener);
sprintf(tree_file_name,"tree/tree_%06" PRId64 ".rae", num_gener);
#else
sprintf(tree_file_name,"tree/tree_%06" PRId32 ".ae", num_gener);
sprintf(tree_file_name,"tree/tree_%06" PRId64 ".ae", num_gener);
#endif
gzFile tree_file = gzopen(tree_file_name, "w");
tree->write_to_tree_file(tree_file);
......
......@@ -66,7 +66,7 @@ void print_help(char* prog_path);
int main(int argc, char* argv[])
{
// 1) Initialize command-line option variables with default values
int32_t num_gener = -1;
int64_t num_gener = -1;
int32_t generalseed = -1;
int32_t selseed = -1;
int32_t mutseed = -1;
......@@ -192,27 +192,22 @@ int main(int argc, char* argv[])
output_dir = new char[255];
sprintf(output_dir, "%s", "output");
}
if (num_gener == -1)
{
if (num_gener == -1) {
// Set num_gener to the content of the LAST_GENER file if it exists.
// If it doesn't, print help and exit
char lg_filename[300];
sprintf(lg_filename, "%s/%s", input_dir, LAST_GENER_FNAME);
FILE* lg_file = fopen(lg_filename, "r");
if (lg_file != NULL)
{
if (fscanf(lg_file, "%" PRId32 "\n", &num_gener) == EOF)
{
printf("ERROR: failed to read last generation from file %s\n",lg_filename);
if (lg_file != NULL) {
if (fscanf(lg_file, "%" PRId64 "\n", &num_gener) == EOF) {
printf("ERROR: failed to read last generation from file %s\n",
lg_filename);
exit(EXIT_FAILURE);
}
fclose(lg_file);
}
else
{
printf("aevol_propagate: no generation number provided.\n");
print_help(argv[0]);
exit(EXIT_FAILURE);
else {
Utils::ExitWithUsrMsg("You must provide a generation number");
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -56,7 +56,7 @@ void analyse_gu(GeneticUnit* gen_unit, int32_t gen_unit_number,
int main( int argc, char* argv[] )
int main(int argc, char* argv[])
{
// Initialize command-line option variables with default values
char* pop_file_name = NULL;
......@@ -81,33 +81,33 @@ int main( int argc, char* argv[] )
// Get actual values of the command-line options
int option;
while ( ( option = getopt_long(argc, argv, options_list, long_options_list, NULL) ) != -1 )
while ((option = getopt_long(argc, argv, options_list, long_options_list, NULL)) != -1)
{
switch ( option )
switch (option)
{
case 'h' :
{
print_help(argv[0]);
exit( EXIT_SUCCESS );
exit(EXIT_SUCCESS);
}
case 'V' :
{
Utils::PrintAevolVersion();
exit( EXIT_SUCCESS );
exit(EXIT_SUCCESS);
}
case 'r':
num_gener = atol( optarg );
num_gener = atol(optarg);
break;
case 't' :
triangles_file_name = new char[strlen(optarg) + 1];
sprintf( triangles_file_name, "%s", optarg );
sprintf(triangles_file_name, "%s", optarg);
break;
case 's' :
sequence_file_name = new char[strlen(optarg) + 1];
sprintf( sequence_file_name, "%s", optarg );
sprintf(sequence_file_name, "%s", optarg);
break;
case 'g' :
gu = atoi( optarg );
gu = atoi(optarg);
break;
case 'b' :
best_only = true;
......@@ -120,7 +120,7 @@ int main( int argc, char* argv[] )
num_gener = OutputManager::get_last_gener();
}
if ( triangles_file_name == NULL && sequence_file_name == NULL ) {
if (triangles_file_name == NULL && sequence_file_name == NULL) {
Utils::ExitWithDevMsg("Use option -s or -t (-h for more info)",
__FILE__, __LINE__);
}
......@@ -129,7 +129,7 @@ int main( int argc, char* argv[] )
FILE* triangles_file = NULL;
FILE* sequence_file = NULL;
if ( triangles_file_name != NULL )
if (triangles_file_name != NULL)
{
triangles_file = fopen(triangles_file_name,"w");
......@@ -153,7 +153,7 @@ int main( int argc, char* argv[] )
fprintf(triangles_file, "\n");
fprintf(triangles_file, "id c_or_p strand pos len lpos sequence m w h c f prom_pos rna_len basal_level\n");
}
if ( sequence_file_name != NULL )
if (sequence_file_name != NULL)
{
sequence_file = fopen(sequence_file_name,"w");
}
......@@ -203,15 +203,15 @@ inline void analyse_indiv(Individual* indiv, FILE* triangles_file,
FILE* sequence_file, int16_t gu,
const PhenotypicTarget & phenotypicTarget)
{
if ( gu == -1 ) // We want to treat all genetic units
if (gu == -1) // We want to treat all genetic units
{
int32_t gen_unit_number = 0;
for (auto& gen_unit: indiv->get_genetic_unit_list_nonconst()) {
if ( triangles_file != NULL )
if (triangles_file != NULL)
{
analyse_gu(&gen_unit, gen_unit_number, triangles_file, phenotypicTarget); // We call the triangle parser for each GU successively
}
if ( sequence_file != NULL )
if (sequence_file != NULL)
{
const char* dna = gen_unit.get_dna()->get_data();
int32_t length = gen_unit.get_dna()->get_length();
......@@ -224,11 +224,11 @@ inline void analyse_indiv(Individual* indiv, FILE* triangles_file,
else // User specified a genetic unit
{
GeneticUnit* gen_unit = &indiv->get_genetic_unit_nonconst(gu);
if ( triangles_file != NULL )
if (triangles_file != NULL)
{
analyse_gu(gen_unit, gu, triangles_file, phenotypicTarget); // We call the triangle parser
}
if ( sequence_file != NULL )
if (sequence_file != NULL)
{
const char* dna = gen_unit->get_dna()->get_data();
int32_t length = gen_unit->get_dna()->get_length();
......@@ -237,11 +237,11 @@ inline void analyse_indiv(Individual* indiv, FILE* triangles_file,
}
// We go to next line in each file
if ( triangles_file != NULL )
if (triangles_file != NULL)
{
fprintf(triangles_file,"\n");
}
if ( sequence_file != NULL )
if (sequence_file != NULL)
{
fprintf(sequence_file,"\n");
}
......
......@@ -384,7 +384,7 @@ int main(int argc, char** argv)
mut->get_generic_description_string( mut_descr_string );
fprintf( output, "%"PRId32 " %"PRId32 " %s %"PRId32 " %.15f %"PRId32 " %"PRId32 " %"PRId32 " \n",\
fprintf( output, "%"PRId64 " %"PRId32 " %s %"PRId32 " %.15f %"PRId32 " %"PRId32 " %"PRId32 " \n",\
get_time(), genetic_unit_number, \
mut_descr_string, unitlen_before, \
impact_on_metabolic_error, nb_genes_at_breakpoints, nb_genes_in_segment, nb_genes_in_replaced_segment );
......
......@@ -146,7 +146,7 @@ int main(int argc, char** argv)
// If it doesn't, print help and exit
FILE* lg_file = fopen(LAST_GENER_FNAME, "r");
if (lg_file != NULL) {
if (fscanf(lg_file, "%" PRId32 "\n", &t_end) == EOF) {
if (fscanf(lg_file, "%" PRId64, &t_end) == EOF) {
printf("ERROR: failed to read last generation from file %s\n",
LAST_GENER_FNAME);
exit(EXIT_FAILURE);
......
This diff is collapsed.
......@@ -65,7 +65,7 @@ void print_help(char* prog_path);
// =====================================================================
int main( int argc, char* argv[] )
int main(int argc, char* argv[])
{
// ----------------------------------------
// command-line option parsing
......@@ -73,7 +73,7 @@ int main( int argc, char* argv[] )
int32_t nb_children = 1000;
int32_t wanted_rank = -1;
int32_t wanted_index = -1;
int32_t num_gener = 0;
int64_t num_gener = 0;
const char * options_list = "hVg:n:r:i:";
static struct option long_options_list[] = {
......@@ -96,22 +96,22 @@ int main( int argc, char* argv[] )
case 'h' :
{
print_help(argv[0]);
exit( EXIT_SUCCESS );
exit(EXIT_SUCCESS);
}
case 'V' :
{
Utils::PrintAevolVersion();
exit( EXIT_SUCCESS );
exit(EXIT_SUCCESS);
}
case 'g' :
{
if ( strcmp( optarg, "" ) == 0 )
if (strcmp(optarg, "") == 0)
{
printf( "%s: error: Option -g or --gener : missing argument.\n", argv[0] );
exit( EXIT_FAILURE );
printf("%s: error: Option -g or --gener : missing argument.\n", argv[0]);
exit(EXIT_FAILURE);
}
num_gener = atol( optarg );
num_gener = atol(optarg);
break;
}
case 'n' :
......@@ -120,8 +120,8 @@ int main( int argc, char* argv[] )
case 'r' :
if (index_already_set)
{
fprintf( stderr, "%s: error: Options -r and -i are incompatible. Please choose one of them only.\n", argv[0] );
exit( EXIT_FAILURE );
fprintf(stderr, "%s: error: Options -r and -i are incompatible. Please choose one of them only.\n", argv[0]);
exit(EXIT_FAILURE);
}
wanted_rank = atol(optarg);
rank_already_set = true;
......@@ -129,9 +129,9 @@ int main( int argc, char* argv[] )
case 'i' :
if (rank_already_set)
{
fprintf( stderr, "%s: error: Options -r and -i are incompatible. Please choose one of them only.\n", argv[0] );
fprintf( stderr, " Use %s --help for more information.\n", argv[0] );
exit( EXIT_FAILURE );
fprintf(stderr, "%s: error: Options -r and -i are incompatible. Please choose one of them only.\n", argv[0]);
fprintf(stderr, " Use %s --help for more information.\n", argv[0]);
exit(EXIT_FAILURE);
}
wanted_index = atol(optarg);
index_already_set = true;
......@@ -148,7 +148,7 @@ int main( int argc, char* argv[] )
ae_exp_manager* exp_manager = new ae_exp_manager();
exp_manager->load(num_gener, true, false);
if ( (wanted_rank == -1) && (wanted_index == -1) )
if ((wanted_rank == -1) && (wanted_index == -1))
{
wanted_rank = exp_manager->get_nb_indivs(); // the best one has rank N
}
......@@ -190,41 +190,44 @@ int main( int argc, char* argv[] )
// ----------------------
char directory_name[64];
sprintf( directory_name, "analysis-generation%06" PRId32, num_gener );
sprintf(directory_name, "analysis-generation%06" PRId64, num_gener);
// Check whether the directory already exists and is writable
if ( access( directory_name, F_OK ) == 0 )
if (access(directory_name, F_OK) == 0)
{
if ( access( directory_name, X_OK | W_OK) != 0 )
if (access(directory_name, X_OK | W_OK) != 0)
{
fprintf(stderr, "Error: cannot enter or write in directory %s.\n", directory_name);
exit( EXIT_FAILURE );
exit(EXIT_FAILURE);
}
}
else
{
// Create the directory with permissions : rwx r-x r-x
if ( mkdir( directory_name, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0 )
if (mkdir(directory_name, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0)
{
fprintf(stderr, "Error: cannot create directory %s.\n", directory_name);
exit( EXIT_FAILURE );
exit(EXIT_FAILURE);
}
}
char filename[256];
snprintf( filename, 255, "%s/robustness-allindivs-g%06" PRId32 ".out", directory_name, num_gener );
FILE * outputfile_wholepop = fopen( filename, "w" );
snprintf( filename, 255, "%s/robustness-allindivs-g%06" PRId64 ".out", directory_name, num_gener);
FILE * outputfile_wholepop = fopen(filename, "w");
snprintf( filename, 255, "%s/robustness-singleindiv-details-g%06" PRId32 "-i%" PRId32 "-r%" PRId32 ".out", directory_name, num_gener, wanted_index, wanted_rank );
FILE * outputfile_details = fopen( filename, "w" );
snprintf(filename, 255,
"%s/robustness-singleindiv-details-g%06" PRId64
"-i%" PRId32 "-r%" PRId32 ".out",
directory_name, num_gener, wanted_index, wanted_rank);
FILE * outputfile_details = fopen(filename, "w");
// Write headers
fprintf(outputfile_wholepop, "# ######################################################################\n" );
fprintf(outputfile_wholepop, "# Robustness data of individuals at generation %" PRId32 "\n",num_gener );
fprintf(outputfile_wholepop, "# ######################################################################\n" );
fprintf(outputfile_wholepop, "# ######################################################################\n");
fprintf(outputfile_wholepop, "# Robustness data of individuals at generation %" PRId64 "\n",num_gener);
fprintf(outputfile_wholepop, "# ######################################################################\n");
fprintf(outputfile_wholepop, "# 1. Rank\n");
fprintf(outputfile_wholepop, "# 2. Index\n");
fprintf(outputfile_wholepop, "# 3. Fitness\n");
......@@ -242,12 +245,12 @@ int main( int argc, char* argv[] )
fprintf(outputfile_wholepop, "# 15. Genome size variance of offsprings\n");
fprintf(outputfile_wholepop, "# 16. Functional gene number mean of offsprings\n");
fprintf(outputfile_wholepop, "# 17. Functional gene number variance of offsprings\n");
fprintf(outputfile_wholepop, "# ######################################################################\n" );
fprintf(outputfile_wholepop, "# ######################################################################\n");
fprintf(outputfile_details, "# #######################################################################################################\n" );
fprintf(outputfile_details, "# Offspring details of individual with rank %" PRId32 " and index %" PRId32 " at generation %" PRId32 " \n", \
wanted_rank, wanted_index, num_gener );
fprintf(outputfile_details, "# #######################################################################################################\n" );
fprintf(outputfile_details, "# #######################################################################################################\n");
fprintf(outputfile_details, "# Offspring details of individual with rank %" PRId32 " and index %" PRId32 " at generation %" PRId64 " \n", \
wanted_rank, wanted_index, num_gener);
fprintf(outputfile_details, "# #######################################################################################################\n");
fprintf(outputfile_details, "# 1. Fitness\n");
fprintf(outputfile_details, "# 2. Metabolic error\n");
fprintf(outputfile_details, "# 3. Genome size\n");
......@@ -255,7 +258,7 @@ int main( int argc, char* argv[] )
fprintf(outputfile_details, "# 5. Number of coding bases\n");
fprintf(outputfile_details, "# 6. Number of transcribed but not translated bases\n");
fprintf(outputfile_details, "# 7. Number of non transcribed bases\n");
fprintf(outputfile_details, "# #######################################################################################################\n" );
fprintf(outputfile_details, "# #######################################################################################################\n");
......@@ -312,14 +315,14 @@ int main( int argc, char* argv[] )
offsprings_statistics[3],
offsprings_statistics[4],
offsprings_statistics[5]
);
);
}
}
fclose( outputfile_wholepop );
fclose( outputfile_details );
fclose(outputfile_wholepop);
fclose(outputfile_details);
delete exp_manager;
......@@ -337,54 +340,54 @@ void print_help(char* prog_path)
{
// Get the program file-name in prog_name (strip prog_path of the path)
char* prog_name; // No new, it will point to somewhere inside prog_path
if ( ( prog_name = strrchr( prog_path, '/' )) ) prog_name++;
if ((prog_name = strrchr(prog_path, '/'))) prog_name++;
else prog_name = prog_path;
printf( "\n" );
printf( "*********************** aevol - Artificial Evolution ******************* \n" );
printf( "* * \n" );
printf( "* Robustness post-treatment program * \n" );
printf( "* * \n" );
printf( "************************************************************************ \n" );
printf( "\n\n" );
printf( "This program is Free Software. No Warranty.\n" );
printf( "\n" );
printf( "Usage : %s -h\n", prog_name);
printf( " or : %s -V or --version\n", prog_name );
printf( " or : %s -g GENER [-n NBCHILDREN] [-r RANK | -i INDEX]\n", prog_name);
printf( "\n" );
printf( "This program computes the replication statistics of all the individuals of a given generation,\n");
printf( "like the proportion of neutral, beneficial, deleterious offsprings. This is done by simulating\n");
printf( "NBCHILDREN replications for each individual, with its mutation, rearrangement and transfer rates.\n" );
printf( "Depending on those rates and genome size, there can be several events per replication.\n" );
printf( "Those statistics are written in analysis-generationGENER/robustness-allindivs-gGENER.out, with one \n" );
printf( "line per individual in the specified generation. \n\n" );
printf( "The program also outputs detailed statistics for one of the individuals (the best one by default). \n");
printf( "The detailed statistics for this individual are written in the file called \n");
printf( "analysis-generationGENER/robustness-singleindiv-details-gGENER-iINDEX-rRANK.out, with one line per simulated\n");
printf( "child of this particular individual.\n");
printf( "\n" );
printf( "\n" );
printf( "\t-h or --help : Display this help, then exit\n" );
printf( "\n" );
printf( "\t-V or --version : Print version number, then exit\n" );
printf( "\n" );
printf( "\t-g GENER or --gener GENER : \n" );
printf( "\t Generation at which the statistics are computed\n" );
printf( "\n" );
printf( "\t-i INDEX or --index INDEX : \n" );
printf( "\t Index of individual of interest. Should be comprised between 0 and N-1, where\n" );
printf( "\t N is the size of the population.\n" );
printf( "\n" );
printf( "\t-r RANK or --rank RANK : \n" );
printf( "\t Rank of individual of interest. Should be comprised between 1 and N, where\n" );
printf( "\t N is the size of the population. Default = N (fittest individual).\n" );
printf( "\n" );
printf( "\t-n NBCHILDREN or --nb-children NBCHILDREN : \n" );
printf( "\t Perform NBCHILDREN replications per individual to compute its statistics. \n" );
printf( "\t Default = 1000.\n" );
printf( "\n" );
printf( "\n" );
printf("\n");
printf("*********************** aevol - Artificial Evolution ******************* \n");
printf("* * \n");
printf("* Robustness post-treatment program * \n");
printf("* * \n");
printf("************************************************************************ \n");
printf("\n\n");
printf("This program is Free Software. No Warranty.\n");
printf("\n");
printf("Usage : %s -h\n", prog_name);
printf(" or : %s -V or --version\n", prog_name);
printf(" or : %s -g GENER [-n NBCHILDREN] [-r RANK | -i INDEX]\n", prog_name);
printf("\n");
printf("This program computes the replication statistics of all the individuals of a given generation,\n");
printf("like the proportion of neutral, beneficial, deleterious offsprings. This is done by simulating\n");
printf("NBCHILDREN replications for each individual, with its mutation, rearrangement and transfer rates.\n");
printf("Depending on those rates and genome size, there can be several events per replication.\n");
printf("Those statistics are written in analysis-generationGENER/robustness-allindivs-gGENER.out, with one \n");
printf("line per individual in the specified generation. \n\n");
printf("The program also outputs detailed statistics for one of the individuals (the best one by default). \n");
printf("The detailed statistics for this individual are written in the file called \n");
printf("analysis-generationGENER/robustness-singleindiv-details-gGENER-iINDEX-rRANK.out, with one line per simulated\n");
printf("child of this particular individual.\n");
printf("\n");
printf("\n");
printf("\t-h or --help : Display this help, then exit\n");
printf("\n");
printf("\t-V or --version : Print version number, then exit\n");
printf("\n");
printf("\t-g GENER or --gener GENER : \n");
printf("\t Generation at which the statistics are computed\n");
printf("\n");
printf("\t-i INDEX or --index INDEX : \n");
printf("\t Index of individual of interest. Should be comprised between 0 and N-1, where\n");
printf("\t N is the size of the population.\n");
printf("\n");
printf("\t-r RANK or --rank RANK : \n");
printf("\t Rank of individual of interest. Should be comprised between 1 and N, where\n");
printf("\t N is the size of the population. Default = N (fittest individual).\n");
printf("\n");
printf("\t-n NBCHILDREN or --nb-children NBCHILDREN : \n");
printf("\t Perform NBCHILDREN replications per individual to compute its statistics. \n");
printf("\t Default = 1000.\n");
printf("\n");
printf("\n");
}
......@@ -54,7 +54,7 @@ void print_help(char* prog_path);
int main( int argc, char* argv[] )
int main(int argc, char* argv[])
{
// Initialize command-line option variables with default values
char* init_file_name = NULL;
......@@ -70,50 +70,50 @@ int main( int argc, char* argv[] )
// Get actual values of the command-line options
int option;
while ( ( option = getopt_long(argc, argv, options_list, long_options_list, NULL) ) != -1 )
while ((option = getopt_long(argc, argv, options_list, long_options_list, NULL)) != -1)
{
switch ( option )
switch (option)
{
case 'h' :
{
print_help(argv[0]);
exit( EXIT_SUCCESS );
exit(EXIT_SUCCESS);
}
case 'V' :
{
Utils::PrintAevolVersion();
exit( EXIT_SUCCESS );
exit(EXIT_SUCCESS);
}
case 'f' :
{
init_file_name = new char[strlen(optarg) + 1];
sprintf( init_file_name, "%s", optarg );
sprintf(init_file_name, "%s", optarg);
break;
}
}
}
if ( init_file_name == NULL )
if (init_file_name == NULL)
{
printf("You must specify an indiv file. Please use the option -f or --from.\n");
exit(EXIT_FAILURE);
}
int32_t _num_gener=0;
int64_t _num_gener = 0;
//~ // We create a new simulation
//~ printf("Creating the new simulation.\n");
ae_experiment* sim1 = new ae_experiment();
//~ ae_param_loader* param_loader = new ae_param_loader( "param.in" );
//~ sim1->load_params( param_loader, NULL );
//~ ae_param_loader* param_loader = new ae_param_loader("param.in");
//~ sim1->load_params(param_loader, NULL);
//~ delete param_loader;
// We modify its individuals
printf("Loading the individual.\n");
gzFile init_file = gzopen( init_file_name, "r" );
ae_individual* indiv = new ae_individual( init_file );
gzFile init_file = gzopen(init_file_name, "r");
ae_individual* indiv = new ae_individual(init_file);
printf("Closing the file.\n");
gzclose(init_file);
......@@ -124,23 +124,23 @@ int main( int argc, char* argv[] )
// int i;
// for (i=0;i<nb_indivs;i++)
// {
// ae_individual* new_indiv = new ae_individual( *indiv );
// ae_individual* new_indiv = new ae_individual(*indiv);
// ae_individual* old_indiv = (ae_individual*) indiv_node->get_obj();
// delete old_indiv;
// indiv_node->set_obj(new_indiv);
// indiv_node = indiv_node->get_next();
// }
// if ( ae_common::pop_structure == true )
// if (ae_common::pop_structure == true)
// {
// ae_list_node* indiv_node = list_indivs->get_first();
// ae_grid_cell*** _pop_grid = NULL;//sim1->get_pop()->get_pop_grid();
// for ( int16_t x = 0 ; x < ae_common::grid_x ; x++ )
// for (int16_t x = 0 ; x < ae_common::grid_x ; x++)
// {
// for ( int16_t y = 0 ; y < ae_common::grid_y ; y++ )
// for (int16_t y = 0 ; y < ae_common::grid_y ; y++)
// {
// _pop_grid[x][y]->set_individual((ae_individual*) indiv_node->get_obj());
// _pop_grid[x][y]->get_individual()->set_grid_cell( _pop_grid[x][y] );
// _pop_grid[x][y]->get_individual()->set_grid_cell(_pop_grid[x][y]);
// indiv_node = indiv_node->get_next();
// }
// }
......@@ -148,18 +148,18 @@ int main( int argc, char* argv[] )
// Evaluate the new individuals
ae_population* pop = NULL;
/*sim1->get_pop()*/pop->evaluate_individuals( sim1->get_env() );
/*sim1->get_pop()*/pop->evaluate_individuals(sim1->get_env());
// Delete the backup files created by the ae_experiment constructor
char backup_file_name[50];
char best_indiv_file_name[50];
#ifdef __REGUL
sprintf( backup_file_name, "backup/gen_%06"PRId32".rae", _num_gener );
sprintf( best_indiv_file_name, "backup/best_%06"PRId32".rae", _num_gener );
sprintf(backup_file_name, "backup/gen_%06"PRId64".rae", _num_gener);
sprintf(best_indiv_file_name, "backup/best_%06"PRId64".rae", _num_gener);
#else
sprintf( backup_file_name, "backup/gen_%06"PRId32".ae", _num_gener );
sprintf( best_indiv_file_name, "backup/best_%06"PRId32".ae", _num_gener );
sprintf(backup_file_name, "backup/gen_%06"PRId64".ae", _num_gener);
sprintf(best_indiv_file_name, "backup/best_%06"PRId64".ae", _num_gener);
#endif
remove(backup_file_name);
......@@ -174,8 +174,8 @@ int main( int argc, char* argv[] )
void print_help(char* prog_name)
{
printf( "\n************* aevol - Artificial Evolution ************* \n\n" );
printf( "This program is Free Software. No Warranty.\n\n\
printf("\n************* aevol - Artificial Evolution ************* \n\n");
printf("This program is Free Software. No Warranty.\n\n\
Usage : set_genome_from_indiv -h\n\
or : set_genome_from_indiv -f source\n\n\
\t-h : Display this screen\n\
......
......@@ -57,7 +57,7 @@ void print_help(char* prog_path);
int main( int argc, char* argv[] )
int main(int argc, char* argv[])
{
......@@ -67,7 +67,7 @@ int main( int argc, char* argv[] )
// =================================================================
//
// 1) Initialize command-line option variables with default values
int32_t gener = 0;
int64_t gener = 0;
// 2) Define allowed options
const char * options_list = "hVg:";
......@@ -79,29 +79,29 @@ int main( int argc, char* argv[] )
// 3) Get actual values of the command-line options
int option;
while ( ( option = getopt_long(argc, argv, options_list, long_options_list, NULL) ) != -1 )
while ((option = getopt_long(argc, argv, options_list, long_options_list, NULL)) != -1)
{
switch ( option )
switch (option)
{
case 'h' :
{
print_help(argv[0]);
exit( EXIT_SUCCESS );
exit(EXIT_SUCCESS);
}
case 'V' :
{
Utils::PrintAevolVersion();
exit( EXIT_SUCCESS );
exit(EXIT_SUCCESS);
}
case 'g' :
{
if ( strcmp( optarg, "" ) == 0 )
if (strcmp(optarg, "") == 0)
{
printf( "%s: error: Option -g or --gener : missing argument.\n", argv[0] );
exit( EXIT_FAILURE );
printf("%s: error: Option -g or --gener : missing argument.\n", argv[0]);
exit(EXIT_FAILURE);
}
gener = atol( optarg );
gener = atol(optarg);
break;
}
}
......@@ -109,14 +109,14 @@ int main( int argc, char* argv[] )
printf( "Displaying generation %" PRId32 "...\n", gener );
printf("Displaying generation %" PRId64 "...\n", gener);
// =================================================================
// Read the backup file
// =================================================================
// Load simulation from backup
ae_exp_manager_X11* exp_manager = new ae_exp_manager_X11();
exp_manager->load( gener, false, true, false );
exp_manager->load(gener, false, true, false);
......@@ -127,7 +127,7 @@ int main( int argc, char* argv[] )
exp_manager->toggle_display_on_off();
exp_manager->display();
while ( exp_manager->quit_signal_received() == false )
while (exp_manager->quit_signal_received() == false)
{
exp_manager->handle_events();
}
......@@ -142,11 +142,11 @@ int main( int argc, char* argv[] )
void print_help(char* prog_name)
{
printf( "\n************* aevol - Artificial Evolution ************* \n\n" );
printf( "This program is Free Software. No Warranty.\n" );
printf( "Copyright (C) 2009 LIRIS.\n" );
printf( "Usage : %s -h\n", prog_name );
printf( " or : %s -f file.ae\n", prog_name );
printf( "\t-h : Display this screen\n" );
printf( "\t-g or --gener n : Display the population at generation n\n" );
printf("\n************* aevol - Artificial Evolution ************* \n\n");
printf("This program is Free Software. No Warranty.\n");
printf("Copyright (C) 2009 LIRIS.\n");
printf("Usage : %s -h\n", prog_name);
printf(" or : %s -f file.ae\n", prog_name);
printf("\t-h : Display this screen\n");
printf("\t-g or --gener n : Display the population at generation n\n");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment