35 character (len=*),
parameter,
private ::
modname =
"(THE_EVOLUTION)"
64 character(len=*),
parameter :: PROCNAME =
"(init_environment_objects)"
72 call log_dbg(
"Initialisation of the environment and the habitat(s)")
118 call log_msg(
ltag_crit //
"Global_Habitats_Available array " // &
119 "cannot be allocated in " // procname //
"!" )
127 call log_msg(
ltag_info //
"Allocated 'Global_Habitats_Available' to " // &
129 call log_msg(
ltag_info //
" " // tostr( &
139 "Saving initial uniform food resources to CSV files.")
141 csv_file_name =
"init_food_safe_habitat" //
csv )
143 csv_file_name =
"init_food_dangerous_habitat" //
csv )
146 call log_msg(
ltag_info //
"Saving predators from habitats into CSV files.")
148 csv_file_name =
"init_predators_safe_habitat" //
csv )
150 csv_file_name =
"init_predators_dangerous_habitat" //
csv )
165 csv_out_file=
"debug_plot_food_safe_"//
mmdd //
"_g" // &
167 delete_csv=.
false., enable_non_debug=.
true. )
170 csv_out_file=
"debug_plot_food_danger_" //
mmdd //
"_g" // &
172 delete_csv=.
false., enable_non_debug=.
true. )
176 csv_out_file=
"debug_plot_predat_safe_" //
mmdd //
"_g" // &
178 delete_csv=.
false., enable_non_debug=.
true. )
181 csv_out_file=
"debug_plot_predat_danger_" //
mmdd //
"_g"// &
183 delete_csv=.
false., enable_non_debug=.
true. )
187 csv_out_file=
"debug_hist_food_safe_size_" //
mmdd //
"_g" //&
189 delete_csv=.
false., enable_non_debug=.
true. )
191 csv_out_file=
"debug_hist_food_dang_size_" //
mmdd //
"_g" //&
193 delete_csv=.
false., enable_non_debug=.
true. )
214 integer,
optional,
intent(in) :: generation
219 real(
srp) :: generation_number
233 real(
srp),
dimension(*),
parameter :: steps_abscissa = &
234 [ real(
srp) :: 1.0_srp, &
246 real(
srp),
dimension(*),
parameter :: steps_ordinate = &
247 [ real(
srp) :: one_cycle * preevol_cycles * 0.30_srp, &
248 one_cycle * preevol_cycles * 0.80_srp, &
249 one_cycle * preevol_cycles * 0.95_srp, &
263 if (
present(generation))
then
264 generation_number = real( generation,
srp )
278 steps = floor(
within( ddpinterpol( steps_abscissa, &
280 generation_number ), &
281 real( one_cycle,
srp ), &
282 real( PREEVOL_TSTEPS, SRP ) ) )
291 character(len=*),
intent(in) :: csv_file_name
294 logical,
optional,
intent(out) :: is_success
296 logical :: csv_file_status
298 integer,
dimension(GENERATIONS) :: generation
299 integer,
dimension(GENERATIONS) :: time_steps
305 call csv_matrix_write ( reshape( [ generation, &
309 [
"GENERATION",
"TIME_STEP " ], &
312 if (
present(is_success)) is_success = csv_file_status
339 integer :: ga_reproduce
369 character(len=*),
parameter :: PROCNAME =
"(mate_reproduce)"
371 real(SRP) :: adapt_mut_point, adapt_mut_batch
378 call log_msg(
ltag_stage //
"Mutation rates: " // &
379 tostr(adapt_mut_point) //
", " // tostr(adapt_mut_batch) // &
395 tostr(i) //
" (" // &
422 p_point = adapt_mut_point, p_set = adapt_mut_batch )
448 character(len=*),
parameter ::
procname =
"(generations_loop_ga)"
454 real(
srp) :: energy_mean_gen1_birth_mort
459 real(
srp) :: energy_sd_gen1_birth_mort
471 type(csv_file) :: csv_file_generstats
475 character(len=:),
allocatable :: file_stats_gener_record
478 character(len=LABEL_LENGTH),
dimension(*),
parameter :: &
479 file_stats_gener_cols = [ character(len=
label_length) :: &
546 integer,
parameter :: file_stats_record_len = &
548 size(file_stats_gener_cols) * 3
559 integer :: ga_alive_generation_1
565 integer :: ga_growing_generation_1
568 integer :: n_alive, n_growing
587 ga_alive_generation_1 = ceiling(
popsize * 0.005_srp )
592 ga_growing_generation_1 =
unknown
609 call log_msg(
"INFO: Initialising generation one objects.")
643 call log_msg(
ltag_info //
"Initialisation of generation one completed" )
644 call log_dbg(
"Population with numeric ID " // &
664 call log_msg(
ltag_stage //
"Birth energy values:" )
665 call log_msg(
ltag_stage //
" mean: " // tostr(energy_mean_gen1_birth_mort))
666 call log_msg(
ltag_stage //
" std.dev.:" // tostr(energy_sd_gen1_birth_mort))
669 call log_msg(
ltag_info //
"Limits of std.dev. for birth mortality:" )
670 call log_msg(
ltag_info //
" [ MEAN, 1 SD, 2 SD, 3 SD]")
673 tostr(energy_mean_gen1_birth_mort,
"(f5.3)") //
", " // &
674 tostr(energy_mean_gen1_birth_mort+ &
675 energy_sd_gen1_birth_mort*1.0_srp,
"(f5.3)") //
", " // &
676 tostr(energy_mean_gen1_birth_mort+ &
677 energy_sd_gen1_birth_mort*2.0_srp,
"(f5.3)") //
", " // &
678 tostr(energy_mean_gen1_birth_mort+ &
679 energy_sd_gen1_birth_mort*3.0_srp,
"(f5.3)") //
"]" )
689 csv_out_file=
"debug_hist_agent_body_len_birth_"//
mmdd // &
692 delete_csv=.
false., enable_non_debug=.
true. )
695 csv_out_file=
"debug_hist_agent_body_mass_birth_"//
mmdd // &
698 delete_csv=.
false., enable_non_debug=.
true. )
701 csv_out_file=
"debug_hist_agent_energy_birth_"//
mmdd // &
704 delete_csv=.
false., enable_non_debug=.
true. )
708 csv_out_file=
"debug_hist_agent_smr_birth_"//
mmdd // &
711 delete_csv=.
false., enable_non_debug=.
true. )
715 save_data_init: block
720 character(len=:),
allocatable :: output_data_file
722 output_data_file =
"init_agents_" //
model_name //
"_" //
mmdd // &
728 output_data_file =
"init_genome_" //
model_name //
"_" //
mmdd // &
735 output_data_file =
"init_tsteps_" //
model_name //
"_" //
mmdd // &
744 csv_file_generstats%name = output_data_file
745 call csv_open_write( csv_file_generstats )
750 file_stats_gener_record = repeat(
" ", file_stats_record_len )
751 call csv_record_append( file_stats_gener_record, file_stats_gener_cols )
752 call csv_record_write ( file_stats_gener_record, csv_file_generstats )
753 end block save_data_init
776 generations_preevol:
do while ( &
785 call log_delimiter(log_level_volume)
788 call log_delimiter(log_level_volume)
794 check_stop_file: block
795 logical :: stop_signalled
796 inquire( file=
stop_file, exist=stop_signalled )
797 if ( stop_signalled )
then
800 exit generations_preevol
802 end block check_stop_file
808 tostr(global_generation_number_current))
825 global_ind_n_eaten_by_predators = 0
835 replenish_food:
if ( global_generation_number_current > 1 )
then
841 end if replenish_food
852 call log_msg( ltag_stage //
"Life cycle parents." )
863 call log_msg( ltag_info //
"N alive: " // tostr(n_alive) // &
864 ", N grown: " // tostr(n_growing) )
870 call log_msg( ltag_stage //
"Fitness calculate in parents." )
874 call log_msg( ltag_stage //
"Sort parents by fitness." )
878 call log_msg( ltag_info //
"Best parent (1), fitness: " // &
883 params_gen_1:
if (global_generation_number_current == 1)
then
884 ga_alive_generation_1 = n_alive
885 ga_growing_generation_1 = n_growing
887 call log_msg( ltag_info //
"This is the first generation" )
888 call log_msg( ltag_info //
"Survival parameters that determine " // &
889 "the stopping rule: N Alive=" // &
890 tostr(ga_alive_generation_1) // &
892 tostr(ga_growing_generation_1) )
898 save_data_inds_generation: block
899 character(len=:),
allocatable :: output_data_file
900 call log_msg( ltag_stage //
"Saving parents." )
902 output_data_file =
"agents_" // model_name //
"_" // mmdd // &
903 "_rev_" // svn_version // &
904 "_gen_" // tostr(global_generation_number_current,&
905 generations) //
"_p1_parents" // csv
906 call proto_parents%save_csv(output_data_file, is_logging=.true.)
908 output_data_file =
"genomes_" // model_name //
"_" // mmdd // &
909 "_rev_" // svn_version // &
910 "_gen_" // tostr(global_generation_number_current,&
914 output_data_file =
"memory_" // model_name //
"_" // mmdd // &
915 "_rev_" // svn_version // &
916 "_gen_" // tostr(global_generation_number_current,&
920 output_data_file =
"movements_" // model_name //
"_" // mmdd // &
921 "_rev_" // svn_version // &
922 "_gen_" // tostr(global_generation_number_current,&
926 output_data_file =
"behaviours_" // model_name //
"_" // mmdd // &
927 "_rev_" // svn_version // &
928 "_gen_" // tostr(global_generation_number_current,&
931 end block save_data_inds_generation
936 save_data_food_post: block
937 character(len=:),
allocatable :: output_data_file
938 call log_msg( ltag_stage //
"Saving food resources." )
939 output_data_file =
"food_habitat_safe_gen_" // &
940 model_name //
"_" // mmdd // &
941 "_rev_" // svn_version // &
942 "_gen_" // tostr(global_generation_number_current,&
945 output_data_file =
"food_habitat_dang_gen_" // &
946 model_name //
"_" // mmdd // &
947 "_rev_" // svn_version // &
948 "_gen_" // tostr(global_generation_number_current,&
951 end block save_data_food_post
967 check_deteriorate:
if ( global_generation_number_current > 1 )
then
968 if ( n_alive < ga_alive_generation_1 / 10 .or. &
969 n_growing < ga_growing_generation_1 / 10 )
then
970 call log_msg( ltag_major //
"GA deterioration detected! " // &
971 "N alive=" // tostr(n_alive) // &
972 " (<" // tostr(ga_alive_generation_1) // &
973 "); N grown=" // tostr(n_growing) // &
974 " (<" // tostr(ga_growing_generation_1) //
")." )
975 call log_msg( ltag_crit // &
976 "Exiting GA due to deterioration in CHECK_DETERIORATE.")
977 exit generations_preevol
983 else check_deteriorate
984 if ( n_alive < popsize / 100 )
then
985 call log_msg( ltag_crit //
"Insufficient number of alive agents: " &
987 call system_halt(message=
"INSUFFICIENT ALIVE AGENTS IN GEN. 1")
988 elseif ( n_growing < 1 )
then
989 call log_msg( ltag_warn //
"LESS THAN ONE AGENT GROWN IN GEN. 1" )
992 end if check_deteriorate
996 call log_msg( ltag_stage //
"Selection (elitism)." )
1002 call log_msg( ltag_stage //
"Mate and reproduce." )
1011 call log_msg( ltag_stage //
"Swap generations." )
1015 call log_delimiter(log_level_volume)
1017 call log_delimiter(log_level_volume)
1022 global_generation_number_current = global_generation_number_current + 1
1024 end do generations_preevol
1028 call csv_close( csv_file_generstats )
1034 call log_msg( ltag_info //
"Best fitness evolved: " // &
1037 call log_delimiter(log_level_volume)
1038 call log_msg( ltag_major //
"Simulation completed." )
1040 call log_delimiter(log_level_volume)
1045 call system_halt( is_error = .false., &
1046 message =
"Normal termination of the pre-evolution" )
1054 class(population),
intent(inout) :: active_population
1057 character(len=*),
parameter :: PROCNAME =
"(lifecycle_preevol)"
1062 integer :: time_step
1068 integer :: steps_gen_current
1074 character(len=FILENAME_LENGTH) :: filename_time_steps
1079 real(SRP),
allocatable,
dimension(:) :: dpos_mean_agents, &
1082 dpos_mean_foods_hab_safe, &
1083 dpos_min_foods_hab_safe, &
1084 dpos_max_foods_hab_safe, &
1085 dpos_mean_foods_hab_dang, &
1086 dpos_min_foods_hab_dang, &
1087 dpos_max_foods_hab_dang, &
1089 dpos_sd_foods_hab_safe, &
1090 dpos_sd_foods_hab_dang
1093 integer,
allocatable,
dimension(:) :: n_agents_alive, &
1095 n_foods_available_safe, &
1096 n_foods_available_dang
1100 real(SRP),
dimension(POPSIZE) :: temp_val_select_alive
1104 real(SRP),
dimension(FOOD_ABUNDANCE_HABITAT_SAFE) :: &
1105 temp_val_select_avail_safe
1106 real(SRP),
dimension(FOOD_ABUNDANCE_HABITAT_DANGER) :: &
1107 temp_val_select_avail_dang
1112 character(len=FILENAME_LENGTH) :: filename_alldata_time_steps
1117 call active_population%individual%age_reset()
1125 call active_population%mortality_birth( &
1126 energy_mean = energy_mean_gen1_birth_mort, &
1127 energy_sd = energy_sd_gen1_birth_mort )
1136 allocate( dpos_mean_agents( steps_gen_current) )
1137 allocate( dpos_min_agents( steps_gen_current) )
1138 allocate( dpos_max_agents( steps_gen_current) )
1139 allocate( dpos_mean_foods_hab_safe( steps_gen_current ) )
1140 allocate( dpos_min_foods_hab_safe( steps_gen_current ) )
1141 allocate( dpos_max_foods_hab_safe( steps_gen_current ) )
1142 allocate( dpos_mean_foods_hab_dang( steps_gen_current ) )
1143 allocate( dpos_min_foods_hab_dang( steps_gen_current ) )
1144 allocate( dpos_max_foods_hab_dang( steps_gen_current ) )
1145 allocate( dpos_sd_agents( steps_gen_current ) )
1146 allocate( dpos_sd_foods_hab_safe( steps_gen_current ) )
1147 allocate( dpos_sd_foods_hab_dang( steps_gen_current ) )
1149 allocate( n_agents_alive( steps_gen_current ) )
1150 allocate( n_agents_eaten( steps_gen_current ) )
1151 allocate( n_foods_available_safe( steps_gen_current ) )
1152 allocate( n_foods_available_dang( steps_gen_current ) )
1156 dpos_mean_agents = missing
1157 dpos_min_agents = missing
1158 dpos_max_agents = missing
1159 dpos_mean_foods_hab_safe = missing
1160 dpos_min_foods_hab_safe = missing
1161 dpos_max_foods_hab_safe = missing
1162 dpos_mean_foods_hab_dang = missing
1163 dpos_min_foods_hab_dang = missing
1164 dpos_max_foods_hab_dang = missing
1165 dpos_sd_agents = missing
1166 dpos_sd_foods_hab_safe = missing
1167 dpos_sd_foods_hab_dang = missing
1168 n_agents_alive = unknown
1169 n_agents_eaten = unknown
1170 n_foods_available_safe = unknown
1171 n_foods_available_dang = unknown
1175 lifecycle_preevol_loop:
do time_step = 1, steps_gen_current
1178 global_time_step_model_current = time_step
1180 if (is_debug)
call log_delimiter(log_level_chapter)
1181 call log_msg( ltag_stage //
"Time step: " // &
1182 tostr(global_time_step_model_current) // &
1183 " of Generation " // &
1184 tostr(global_generation_number_current) // &
1185 " (max: " // tostr(steps_gen_current) &
1195 call migrate_food_vertical( global_habitats_available )
1200 call log_dbg(
"Average distance between food items in the " // &
1203 call log_dbg(
"Average distance between food items in the " // &
1218 call active_population%lifecycle_step()
1224 where ( active_population%individual%is_alive() )
1225 temp_val_select_alive = active_population%individual%dpos()
1227 temp_val_select_alive = missing
1229 dpos_mean_agents(time_step) = average( temp_val_select_alive )
1230 dpos_min_agents(time_step) = minval( temp_val_select_alive, &
1231 temp_val_select_alive/=missing )
1232 dpos_max_agents(time_step) = maxval( temp_val_select_alive, &
1233 temp_val_select_alive/=missing )
1234 dpos_sd_agents(time_step) = std_dev( temp_val_select_alive )
1235 n_agents_alive(time_step) = count( &
1236 active_population%individual%is_alive() )
1237 n_agents_eaten(time_step) = global_ind_n_eaten_by_predators
1253 temp_val_select_avail_safe =
habitat_safe%food%food%depth
1255 temp_val_select_avail_safe = missing
1257 call do_sanitise(temp_val_select_avail_safe,tnote=procname//
"[food_d]")
1258 dpos_mean_foods_hab_safe(time_step)=average(temp_val_select_avail_safe)
1259 dpos_min_foods_hab_safe(time_step)=minval(temp_val_select_avail_safe, &
1260 temp_val_select_avail_safe/=missing)
1261 dpos_max_foods_hab_safe(time_step)=maxval(temp_val_select_avail_safe, &
1262 temp_val_select_avail_safe/=missing)
1263 dpos_sd_foods_hab_safe(time_step)=std_dev(temp_val_select_avail_safe)
1264 n_foods_available_safe(time_step)=count( &
1270 temp_val_select_avail_dang = missing
1272 call do_sanitise(temp_val_select_avail_dang, tnote=procname//
"[depth]")
1273 dpos_mean_foods_hab_dang(time_step)=average(temp_val_select_avail_dang)
1274 dpos_min_foods_hab_dang(time_step)=minval(temp_val_select_avail_dang, &
1275 temp_val_select_avail_dang/=missing)
1276 dpos_max_foods_hab_dang(time_step)=maxval(temp_val_select_avail_dang, &
1277 temp_val_select_avail_dang/=missing)
1278 dpos_sd_foods_hab_dang(time_step)=std_dev(temp_val_select_avail_dang)
1279 n_foods_available_dang(time_step)=count( &
1286 global_rescale_maximum_motivation = &
1287 maxval( active_population%individual%motivations%max_perception() )
1294 if (lifecycle_predation_disabled_debug .eqv. .false.)
then
1295 predation_hab_safe:
do i = 1,
habitat_safe%predators_number
1296 call active_population%attacked(
habitat_safe%predators(i) )
1297 end do predation_hab_safe
1302 end do predation_hab_danger
1308 call active_population%fitness_calc()
1311 call log_dbg( ltag_info //
"Best fitness is " // &
1312 tostr(minval(active_population%individual%fitness)), &
1314 call log_dbg( ltag_info //
"Global maximum motivation: " // &
1315 tostr(global_rescale_maximum_motivation), &
1325 save_all_agents:
if ( enable_save_agents_each_timestep )
then
1326 filename_alldata_time_steps =
"xyz_all_"// model_name //
"_" // &
1327 mmdd //
"_rev_" // svn_version // &
1328 "_gen_" // tostr(global_generation_number_current, &
1329 generations) //
"_step_" // &
1330 tostr(time_step, steps_gen_current) // csv
1331 call active_population%save_csv( filename_alldata_time_steps )
1334 filename_alldata_time_steps =
"xyz_behav_"// model_name //
"_" // &
1335 mmdd //
"_rev_" // svn_version // &
1336 "_gen_" // tostr(global_generation_number_current, &
1337 generations) //
"_step_" // &
1338 tostr(time_step, steps_gen_current) // csv
1340 call csv_matrix_write ( &
1341 reshape( [ active_population%individual%genome_label, &
1342 active_population%individual%history_behave( &
1343 history_size_behaviours ) ], &
1344 [
size(active_population%individual), 2 ] ), &
1345 filename_alldata_time_steps, &
1346 [
character(len=LABEL_LENGTH) :: &
1348 "BEHAV_" // TOSTR(time_step, steps_gen_current) ] )
1351 if ( is_zip_outputs )
then
1352 call call_external( command=cmd_zip_output //
" " // &
1353 filename_alldata_time_steps, &
1354 suppress_output=.true., &
1355 is_background_task=zip_outputs_background )
1357 end if save_all_agents
1359 end do lifecycle_preevol_loop
1364 filename_time_steps=
"timesteps_" // model_name //
"_" // mmdd // &
1365 "_rev_" // svn_version // &
1366 "_gen_" // tostr(global_generation_number_current, &
1369 call csv_matrix_write ( &
1370 reshape( [ dpos_mean_agents, &
1374 real(n_agents_alive,SRP), &
1375 real(n_agents_eaten,SRP), &
1376 dpos_mean_foods_hab_safe, &
1377 dpos_min_foods_hab_safe, &
1378 dpos_max_foods_hab_safe, &
1379 dpos_sd_foods_hab_safe, &
1380 real(n_foods_available_safe,SRP), &
1381 dpos_mean_foods_hab_dang, &
1382 dpos_min_foods_hab_dang, &
1383 dpos_max_foods_hab_dang, &
1384 dpos_sd_foods_hab_dang, &
1385 real(n_foods_available_dang,SRP) ], &
1386 [ steps_gen_current, 16 ] ), &
1387 filename_time_steps, &
1388 [
"DEP_AGENTS_MEAN", &
1389 "DEP_AGENTS_MIN ", &
1390 "DEP_AGENTS_MAX ", &
1394 "DEP_F_MEAN_SAFE", &
1395 "DEP_F_MIN_SAFE ", &
1396 "DEP_F_MAX_SAFE ", &
1398 "FOOD_AVAIL_SAFE", &
1399 "DEP_F_MEAN_DANG", &
1400 "DEP_F_MIN_DANG ", &
1401 "DEP_F_MAX_DANG ", &
1403 "FOOD_AVAIL_DANG" ] )
1408 if ( is_zip_outputs )
then
1409 call call_external(command=cmd_zip_output//
" "//filename_time_steps, &
1410 suppress_output=.true., &
1411 is_background_task=zip_outputs_background )
1428 character(len=*),
parameter :: &
1429 PROCNAME =
"(generation_stats_record_write)"
1432 real(SRP),
dimension(proto_parents%population_size) :: perc_food
1433 real(SRP),
dimension(proto_parents%population_size) :: perc_f_dist
1434 real(SRP),
dimension(proto_parents%population_size) :: perc_consp
1435 real(SRP),
dimension(proto_parents%population_size) :: perc_pred
1438 real(SRP),
dimension(proto_parents%population_size) :: body_mass_l
1439 real(SRP),
dimension(proto_parents%population_size) :: body_leng_l
1440 real(SRP),
dimension(proto_parents%population_size) :: energy_l
1441 real(SRP),
dimension(proto_parents%population_size) :: stomach_l
1442 real(SRP),
dimension(proto_parents%population_size) :: smr_l
1443 real(SRP),
dimension(proto_parents%population_size) :: control_l
1444 real(SRP),
dimension(proto_parents%population_size) :: reprfac_l
1445 real(SRP),
dimension(proto_parents%population_size) :: p_repr_l
1446 integer,
dimension(proto_parents%population_size) :: foods_try_l
1447 integer,
dimension(proto_parents%population_size) :: foods_eaten_l
1448 real(SRP),
dimension(proto_parents%population_size) :: fmass_eaten_l
1449 integer,
dimension(proto_parents%population_size) :: fitness_l
1453 file_stats_gener_record = repeat(
" ", file_stats_record_len )
1460 call csv_record_append( file_stats_gener_record, &
1461 global_generation_number_current )
1463 call csv_record_append( file_stats_gener_record, &
1466 call csv_record_append( file_stats_gener_record, &
1468 ga_mutationrate_point_max))
1470 call csv_record_append( file_stats_gener_record, &
1472 ga_mutationrate_batch_max))
1474 call csv_record_append( file_stats_gener_record, &
1477 call csv_record_append( file_stats_gener_record, &
1480 call csv_record_append( file_stats_gener_record, &
1484 call csv_record_append( file_stats_gener_record, &
1488 call csv_record_append( file_stats_gener_record, &
1492 call csv_record_append( file_stats_gener_record, &
1493 global_ind_n_eaten_by_predators )
1495 call csv_record_append( file_stats_gener_record, &
1499 call csv_record_append( file_stats_gener_record, &
1503 call csv_record_append( file_stats_gener_record, &
1507 call csv_record_append( file_stats_gener_record, &
1511 call csv_record_append( file_stats_gener_record, &
1515 call csv_record_append( file_stats_gener_record, &
1519 call csv_record_append( file_stats_gener_record, &
1523 call csv_record_append( file_stats_gener_record, &
1527 call csv_record_append( file_stats_gener_record, &
1544 fuck_ifort_wa1: block
1545 real(SRP),
dimension(proto_parents%population_size) :: repefact_fi
1552 call do_sanitise(repefact_fi, tnote=procname//
"[repfact]")
1553 call csv_record_append( file_stats_gener_record, &
1554 average( repefact_fi, missing, .false.) )
1555 end block fuck_ifort_wa1
1557 call csv_record_append( file_stats_gener_record, &
1558 average( [(
proto_parents%individual(i)%probability_reproduction(), &
1561 call csv_record_append( file_stats_gener_record, &
1565 call csv_record_append( file_stats_gener_record, &
1569 call csv_record_append( file_stats_gener_record, &
1573 call csv_record_append( file_stats_gener_record, &
1577 call csv_record_append( file_stats_gener_record, &
1581 call csv_record_append( file_stats_gener_record, &
1585 call csv_record_append( file_stats_gener_record, &
1586 average(
proto_parents%individual%memory_stack%get_food_mean_n(), &
1589 call csv_record_append( file_stats_gener_record, &
1590 average(
proto_parents%individual%memory_stack%get_consp_mean_n(), &
1593 call csv_record_append( file_stats_gener_record, &
1594 average(
proto_parents%individual%memory_stack%get_pred_mean(), &
1597 call csv_record_append( file_stats_gener_record, &
1600 call csv_record_append( file_stats_gener_record, &
1603 call csv_record_append( file_stats_gener_record, &
1606 perc_food = missing; perc_consp = missing; perc_pred = missing
1610 perc_food =
proto_parents%individual%memory_stack%get_food_mean_n()
1612 get_food_mean_dist(undef_ret_null=.false.)
1613 perc_consp =
proto_parents%individual%memory_stack%get_consp_mean_n()
1614 perc_pred =
proto_parents%individual%memory_stack%get_pred_mean()
1616 call do_sanitise( perc_f_dist, tnote=procname//
"[food_perc_safe]" )
1618 call csv_record_append( file_stats_gener_record, &
1619 average(perc_food, missing, .false.) )
1621 call csv_record_append( file_stats_gener_record, &
1622 average(perc_f_dist, missing, .false.) )
1624 call csv_record_append( file_stats_gener_record, &
1625 average(perc_consp, missing, .false.) )
1628 call csv_record_append( file_stats_gener_record, &
1629 average(perc_pred, missing, .false.) )
1631 perc_food = missing; perc_consp = missing; perc_pred = missing
1635 perc_food =
proto_parents%individual%memory_stack%get_food_mean_n()
1637 get_food_mean_dist(undef_ret_null=.false.)
1638 perc_consp =
proto_parents%individual%memory_stack%get_consp_mean_n()
1639 perc_pred =
proto_parents%individual%memory_stack%get_pred_mean()
1641 call do_sanitise( perc_f_dist, tnote=procname//
"[food_perc_dang]" )
1643 call csv_record_append( file_stats_gener_record, &
1644 average(perc_food, missing, .false.) )
1646 call csv_record_append( file_stats_gener_record, &
1647 average(perc_f_dist, missing, .false.) )
1649 call csv_record_append( file_stats_gener_record, &
1650 average(perc_consp, missing, .false.) )
1653 call csv_record_append( file_stats_gener_record, &
1654 average(perc_pred, missing, .false.) )
1657 call csv_record_append( file_stats_gener_record, &
1661 call csv_record_append( file_stats_gener_record, &
1664 call csv_record_append( file_stats_gener_record, &
1667 call csv_record_append( file_stats_gener_record, &
1668 average(
proto_parents%individual%fitness, unknown, .false.) )
1670 call csv_record_append( file_stats_gener_record, &
1675 call csv_record_append( file_stats_gener_record, &
1679 body_mass_l = missing
1680 body_leng_l = missing
1687 foods_try_l = unknown
1688 foods_eaten_l = unknown
1689 fmass_eaten_l = missing
1703 fmass_eaten_l =
proto_parents%individual%mass_eaten_indicator
1707 alive_males:
where(
proto_parents%individual%is_alive() .and. &
1710 end where alive_males
1712 alive_females:
where(
proto_parents%individual%is_alive() .and. &
1715 end where alive_females
1721 p_repr_l =
proto_parents%individual(i)%probability_reproduction()
1728 call csv_record_append( file_stats_gener_record, &
1729 average(body_mass_l, missing, .false.) )
1731 call csv_record_append( file_stats_gener_record, &
1732 average(body_leng_l, missing, .false.) )
1734 call csv_record_append( file_stats_gener_record, &
1735 average(energy_l, missing, .false.) )
1737 call csv_record_append( file_stats_gener_record, &
1738 average(smr_l, missing, .false.) )
1740 call csv_record_append( file_stats_gener_record, &
1741 average(control_l, missing, .false.) )
1743 call csv_record_append( file_stats_gener_record, &
1744 average(reprfac_l, missing, .false.) )
1746 call csv_record_append( file_stats_gener_record, &
1747 average(p_repr_l, missing, .false.) )
1750 call csv_record_append( file_stats_gener_record, &
1751 average( foods_try_l, unknown, .false.) )
1753 call csv_record_append( file_stats_gener_record, &
1754 average( foods_eaten_l, unknown, .false.) )
1756 call csv_record_append( file_stats_gener_record, &
1757 average( fmass_eaten_l, missing, .false.) )
1759 call csv_record_append( file_stats_gener_record, &
1763 call csv_record_append( file_stats_gener_record, &
1768 call csv_record_append( file_stats_gener_record, &
1769 average(fitness_l, unknown, .false.) )
1773 call csv_record_write( file_stats_gener_record, csv_file_generstats )
Calculate an average of an array excluding missing code values.
Force a value within the range set by the vmin and vmax dummy parameter values.
Interface to the procedure to assemble the global array of habitat objects the_environment::global_ha...
subroutine lifecycle_preevol(active_population)
This subroutine implements the full life cycle in a whole population of agents. It is built around th...
subroutine generation_stats_record_write()
Save generation-wise statistics. This procedure only writes a single record of data after each genera...
COMMONDATA – definitions of global constants and procedures.
integer, parameter, public preevol_tsteps
Number of time steps in the agent's life at the pre-evolution stage.
character(len= *), parameter, private modname
MODNAME always refers to the name of the current module for use by the LOGGER function LOG_DBG....
integer, public global_generation_number_current
The current global generation number. This is a global non fixed-parameter variable that is updated i...
character(len= *), parameter, public model_name
Model name for tags, file names etc. Must be very short. See Model descriptors.
subroutine debug_histogram_save(x_data, delete_csv, csv_out_file, enable_non_debug)
Produce a debug plot of histogram using an external program hthist from HEDTOOLS tools.
integer, parameter, public srp
Definition of the standard real type precision (SRP).
integer, parameter, public unknown
Numerical code for invalid or missing integer counts.
integer, parameter, public generations
Maximum number of generations in GA.
character(len= *), parameter, public ltag_major
Tag prefixes for the logger system. The log may use tags for some common information pieces,...
character(len= *), parameter, public ltag_crit
subroutine debug_scatterplot_save(x_data, y_data, delete_csv, csv_out_file, enable_non_debug)
Produce a debug plot of 2-d scatterplot using an external program htscatter from HEDTOOLS tools.
character(len= *), parameter stop_file
The name of the stop file. The stop file is checked before each new generation of the Genetic Algorit...
integer, parameter, public label_length
The length of standard character string labels. We use labels for various objects,...
integer, parameter, public food_abundance_habitat_danger
The food abundance in the dangerous habitat.
integer, parameter, public ga_reproduce_n
Upper limit on the number of reproducing individuals in the fixed-fitness pre-evolution phase.
real(srp), parameter, public other_risks_habitat_safe
Habitat-specific mortality risk (not linked with predation) in the safe habitat.
integer, parameter, public predators_num_habitat_safe
The number of predators in the safe habitat.
real(srp), dimension(3), parameter, public habitat_danger_min_coord
real(srp), parameter, public other_risks_habitat_danger
Habitat-specific mortality risk (not linked with predation) in the dangerous habitat.
integer, parameter, public popsize
Maximum population size.
subroutine log_dbg(message_string, procname, modname)
LOG_DBG: debug message to the log. The message goes to the logger only when running in the DEBUG mode...
real(srp), parameter, public ga_mutationrate_batch_max
Maximum batch mutation rate in the adaptive Fixed Fitness Genetic Algorithm.
real(srp), dimension(3), parameter, public habitat_safe_max_coord
integer, parameter, public food_abundance_habitat_safe
The food abundance in the safe habitat.
real(srp), parameter, public mutationrate_point
Mutation rate for point allele mutations.
logical, parameter, public true
Safety parameter avoid errors in logical values, so we can now refer to standard Fortran ....
subroutine system_halt(is_error, message, ignore_lockfile)
Halt execution of the system with a specific message and exit code. The exit code is normally passed ...
real(srp), public global_rescale_maximum_motivation
Global maximum sensory information that is updated for the whole population of agents.
character(len=:), allocatable, public, protected mmdd
MMDD tag, year, month and day, used in file names and outputs. The value of the tag should be obtaine...
character(len= *), parameter, public error_allocation_fail
Error message **"Cannot allocate array or object"** is issued if an array or an object is checked and...
integer, parameter, public dielcycles
Number of days and nights in a lifespan, DIELCYCLES=500.
integer, parameter, public lifespan
Number of time steps in the agent's maximum life length.
real(srp), parameter, public mutationrate_batch
Mutation rate for point allele mutations, a whole batch of allele components.
real(srp) function std_dev(array_in, missing_code, undef_ret_null)
Calculate standard deviation using trivial formula:
logical, public, protected is_plotting
This parameter controls if the debug plots are produced. They can be huge number that takes lots of s...
real(srp), dimension(3), parameter, public habitat_safe_min_coord
Definition of the habitat spatial limits.
real(srp), dimension(3), parameter, public habitat_danger_max_coord
logical, parameter, public preevol_tsteps_force_debug_enabled
This parameter enables the forced smaller fixed number of time steps set by the commondata::preevol_t...
character(len=:), allocatable, public, protected svn_version
Subversion or Mercurial revision number that is parsed by commondata::parse_svn_version()....
character(len= *), parameter, private procname
PROCNAME is the procedure name for logging and debugging (with commondata::modname).
integer, parameter, public preevol_tsteps_force_debug
Number of time steps in the agent's life at the fixed fitness pre-evolution stage....
real(srp), parameter, public ga_mutationrate_point_max
Maximum point mutation rate in the adaptive Fixed Fitness Genetic Algorithm.
character(len= *), parameter, public csv
Standard data file extension for data output is now .csv.
integer, parameter, public predators_num_habitat_danger
The number of predators in the dangerous habitat.
character(len= *), parameter, public ltag_timer
logical, parameter, public false
character(len= *), parameter, public ltag_stage
character(len= *), parameter, public ltag_info
Definition of high level file objects.
Definition of environmental objects.
type(habitat), dimension(:), allocatable, public global_habitats_available
A list (array) of all the the_environment::habitat objects available to the agents....
subroutine save_dynamics(maxdepth, csv_file_name, is_success)
Save diagnostics data that shows the dynamics of the light and the average depth of the food items,...
Implementation of the genetic algorithm.
subroutine, public generations_loop_ga()
This procedure implements the main Genetic Algorithm for evolving the agents.
subroutine mate_reproduce()
Mate, reproduce and mutate.
character(len= *), parameter, private modname
type(population), pointer, public proto_parents
integer function, public preevol_steps_adaptive(generation)
Calculate the adaptive number of time steps for the fixed fitness preevolution stage of the genetic a...
type(timer_cpu), public stopwatch_generation
type(timer_cpu), public stopwatch_op_current
type(habitat), public habitat_dangerous
type(timer_cpu), public stopwatch_global
Model-global stopwatch objects.
subroutine, public preevol_steps_adaptive_save_csv(csv_file_name, is_success)
This is a diagnostic subroutine to save the number of time steps for the adaptive GA.
type(population), target, public generation_two
type(population), target, public generation_one
Here we create instances for two populations which will then serve as parents and offspring....
subroutine selection()
Select reproducing agents, the best commondata::ga_reproduce_pr portion of agents.
subroutine init_environment_objects()
Initialise the environmental objects. Most of the environmental objects, such as the environment,...
type(population), pointer, public proto_offspring
type(habitat), public habitat_safe
We have an environment composed of two habitats, safe and a dangerous.
subroutine generations_swap()
Swap generation pointers between parents and offspring.
Definition the genetic architecture of the agent.
An umbrella module that collects all the components of the individual agent.
Definition of the decision making and behavioural the architecture.
Define the population of agents object, its properties and functions.
CPU timer container object for debugging and speed/performance control. Arbitrary timers can be insta...
Definition of the environment habitat HABITAT object. There can potentially be of several types of ha...
Definition of a spatial object. Spatial object determines the position of the agent,...
Definition of the population object.