26 character (len=*),
parameter,
private ::
modname =
"(THE_BEHAVIOUR)"
38 character(len=LABEL_LENGTH),
private :: label
50 real(
srp) :: arousal_expected
67 procedure,
public :: attention_transfer => &
103 class(
move),
intent(inout) :: this
115 real(
srp) :: stomach_increment_from_food
118 real(
srp) :: mass_increment_from_food
135 procedure,
public :: expectancies_calculate => &
147 real(
srp) :: reprfact_decrement_testosterone
150 real(
srp) :: reprfact_decrement_estrogen
154 real(
srp) :: decrement_mass
168 procedure,
public :: expectancies_calculate => &
180 real(
srp) :: expected_cost_moving
183 real(
srp) :: expected_food_gain
185 real(
srp) :: expected_food_dir
187 real(
srp) :: expected_pred_dir_risk
190 real(
srp) :: expected_predation_risk
206 procedure,
public :: expectancies_calculate => &
217 real(
srp) :: expected_food_gain
221 real(
srp) :: expected_pred_dir_risk
228 real(
srp) :: expected_predation_risk
254 real(
srp) :: expected_food_gain
258 real(
srp) :: expected_cost_moving
260 real(
srp) :: expected_pred_dir_risk
265 real(
srp) :: expected_predation_risk
281 procedure,
public :: expectancies_calculate => &
297 real(
srp) :: expected_cost_moving
326 real(
srp) :: expected_food_gain
328 real(
srp) :: expected_pred_dir_risk
331 real(
srp) :: expected_predation_risk
349 procedure,
public :: expectancies_calculate => &
359 real(
srp) :: expected_cost_moving
361 real(
srp) :: expected_food_gain
363 real(
srp) :: expected_food_dir
366 integer :: expected_consp_number
368 real(
srp) :: expected_pred_dir_risk
371 real(
srp) :: expected_predation_risk
400 real(
srp) :: decrement_mass_cost
404 real(
srp) :: expected_food_gain
407 integer :: expected_consp_number
410 real(
srp) :: expected_predation_risk
439 real(
srp) :: decrement_mass_cost
443 real(
srp) :: expected_food_gain
446 integer :: expected_consp_number
449 real(
srp) :: expected_predation_risk
477 procedure,
public ::expectancies_calculate => &
530 character(len=LABEL_LENGTH) :: behaviour_label
535 character(len=LABEL_LENGTH),
dimension(HISTORY_SIZE_BEHAVIOURS) :: &
539 integer :: n_eats_all_indicator
541 integer :: n_eaten_indicator
543 real(
srp) :: mass_eaten_indicator
560 procedure,
public :: behaviour_is => &
573 procedure,
public :: food_item_select_nearest => &
578 procedure,
public :: consp_select_nearest => &
671 class(
appraisal),
intent(in) :: this_agent
681 hunger: associate( ex=>this%expectancy%hunger%attention_weight, &
682 ag=>this_agent%motivations%hunger%attention_weight )
685 ex%food_dir = ag%food_dir
686 ex%food_mem = ag%food_mem
687 ex%conspec = ag%conspec
688 ex%pred_dir = ag%pred_dir
689 ex%predator = ag%predator
690 ex%stomach = ag%stomach
691 ex%bodymass = ag%bodymass
692 ex%energy = ag%energy
694 ex%reprfac = ag%reprfac
702 a_active: associate( ex=>this%expectancy%fear_defence%attention_weight, &
703 ag=>this_agent%motivations%fear_defence%attention_weight )
706 ex%food_dir = ag%food_dir
707 ex%food_mem = ag%food_mem
708 ex%conspec = ag%conspec
709 ex%pred_dir = ag%pred_dir
710 ex%predator = ag%predator
711 ex%stomach = ag%stomach
712 ex%bodymass = ag%bodymass
713 ex%energy = ag%energy
715 ex%reprfac = ag%reprfac
716 end associate a_active
723 reprod: associate( ex=>this%expectancy%reproduction%attention_weight, &
724 ag=>this_agent%motivations%reproduction%attention_weight )
727 ex%food_dir = ag%food_dir
728 ex%food_mem = ag%food_mem
729 ex%conspec = ag%conspec
730 ex%pred_dir = ag%pred_dir
731 ex%predator = ag%predator
732 ex%stomach = ag%stomach
733 ex%bodymass = ag%bodymass
734 ex%energy = ag%energy
736 ex%reprfac = ag%reprfac
748 real(srp) :: gos_expected
750 gos_expected = this%arousal_expected
764 is_exec = this%is_active
775 class(
eat_food),
intent(inout) :: this
780 this%label =
"EAT_FOOD"
783 this%is_active = .false.
786 call this%expectancy%init()
788 this%arousal_expected = 0.0_srp
795 this%stomach_increment_from_food = 0.0_srp
796 this%mass_increment_from_food = 0.0_srp
808 this%label =
"WALK_RANDOM"
811 this%is_active = .false.
814 call this%expectancy%init()
815 this%arousal_expected = 0.0_srp
818 this%distance = missing
821 this%distance_cv = missing
822 this%expected_cost_moving = missing
823 this%expected_food_gain = missing
824 this%expected_food_dir = missing
825 this%expected_pred_dir_risk = missing
826 this%expected_predation_risk = missing
834 class(
freeze),
intent(inout) :: this
839 this%label =
"FREEZE"
842 this%is_active = .false.
845 call this%expectancy%init()
846 this%arousal_expected = 0.0_srp
849 this%distance = 0.0_srp
852 this%expected_food_gain = 0.0_srp
853 this%expected_pred_dir_risk = missing
854 this%expected_predation_risk = missing
864 class(
freeze),
intent(inout) :: this
866 class(appraisal),
intent(in) :: this_agent
872 real(SRP),
parameter :: WEIGHT_DIRECT = predation_risk_weight_immediate
880 integer,
parameter :: MEM_WIND = history_size_perception
885 this%expected_food_gain = 0.0_srp
891 this%expected_pred_dir_risk = this_agent%risk_pred( is_freezing=.true. )
906 this%expected_predation_risk = &
907 predation_risk_backend( &
909 pred_memory_mean=this_agent%memory_stack%get_pred_mean(mem_wind), &
910 weight_direct=weight_direct )
919 time_step_model, rescale_max_motivation)
921 class(
freeze),
intent(inout) :: this
923 class(appraisal),
intent(in) :: this_agent
926 integer,
optional,
intent(in) :: time_step_model
931 real(SRP),
optional,
intent(in) :: rescale_max_motivation
934 integer :: time_step_model_here
937 real(SRP) :: max_motivation
940 real(SRP) :: agent_stomach
945 real(SRP) :: expect_pred_dir
949 real(SRP) :: expect_predator
952 real(SRP) :: expect_stomach
955 real(SRP) :: expect_bodymass
959 real(SRP) :: expect_energy
962 character(len=*),
parameter :: PROCNAME = &
963 "(freeze_motivations_expect)"
968 if (
present(time_step_model))
then
969 time_step_model_here = time_step_model
971 time_step_model_here = global_time_step_model_current
986 call this%do_this(this_agent = this_agent)
993 agent_stomach = this_agent%get_stom_content()
997 expect_stomach = max( zero, &
999 stomach_emptify_backend(agent_stomach) )
1004 expect_bodymass = max( zero, &
1005 this_agent%get_mass() - this_agent%living_cost() )
1012 expect_energy = energy_reserve( expect_bodymass, this_agent%length() )
1017 expect_pred_dir = this%expected_pred_dir_risk
1018 expect_predator = this%expected_predation_risk
1041 call this%expectancy%hunger%percept_component%motivation_components &
1044 param_gp_matrix_light = light_hunger_genotype_neuronal, &
1045 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
1046 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
1047 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
1048 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
1049 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
1050 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
1051 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
1052 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
1053 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
1054 param_gp_matrix_age = age_hunger_genotype_neuronal, &
1055 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
1057 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
1058 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
1059 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
1060 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
1061 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
1062 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
1063 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
1064 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
1065 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
1066 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
1067 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
1068 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
1073 perception_override_pred_dir = expect_pred_dir, &
1074 perception_override_predator = expect_predator, &
1075 perception_override_stomach = expect_stomach, &
1076 perception_override_bodymass = expect_bodymass, &
1077 perception_override_energy = expect_energy &
1088 call this%expectancy%fear_defence%percept_component%motivation_components &
1091 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
1092 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
1093 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
1094 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
1095 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
1096 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
1097 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
1098 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
1099 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
1100 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
1101 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
1102 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
1104 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
1105 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
1106 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
1107 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
1108 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
1109 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
1110 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
1111 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
1112 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
1113 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
1114 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
1115 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
1119 perception_override_pred_dir = expect_pred_dir, &
1120 perception_override_predator = expect_predator, &
1121 perception_override_stomach = expect_stomach, &
1122 perception_override_bodymass = expect_bodymass, &
1123 perception_override_energy = expect_energy &
1129 call this%expectancy%reproduction%percept_component%motivation_components &
1132 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
1133 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
1134 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
1135 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
1136 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
1137 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
1138 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
1139 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
1140 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
1141 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
1142 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
1143 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
1145 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
1146 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
1147 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
1148 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
1149 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
1150 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
1151 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
1152 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
1153 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
1154 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
1155 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
1156 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
1160 perception_override_pred_dir = expect_pred_dir, &
1161 perception_override_predator = expect_predator, &
1162 perception_override_stomach = expect_stomach, &
1163 perception_override_bodymass = expect_bodymass, &
1164 perception_override_energy = expect_energy &
1171 if (
present(rescale_max_motivation))
then
1174 max_motivation = rescale_max_motivation
1177 max_motivation = this%expectancy%max_perception()
1184 call this%attention_transfer(this_agent)
1187 call this%expectancy%motivation_primary_calc(max_motivation)
1190 call log_dbg( ltag_info //
"Primary motivations: " // &
1192 tostr(this%expectancy%hunger%motivation_prim) // &
1193 ", fear_defence: " // &
1194 tostr(this%expectancy%fear_defence%motivation_prim) // &
1195 ", reproduce: " // &
1196 tostr(this%expectancy%reproduction%motivation_prim), &
1201 call this%expectancy%modulation_none()
1207 this%arousal_expected = this%expectancy%max_final()
1211 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
1222 class(
freeze),
intent(inout) :: this
1224 class(appraisal),
intent(inout) :: this_agent
1241 call this%do_this(this_agent = this_agent)
1242 call log_dbg(ltag_info //
"Executed FREEZING; Perception values: " // &
1243 "Food gain: " // tostr(this%expected_food_gain) // &
1244 ", Direct risk: " // tostr(this%expected_pred_dir_risk) // &
1245 ", Indirect risk: " // tostr(this%expected_predation_risk) )
1272 this%label =
"ESCAPE_DART"
1275 this%is_active = .false.
1278 call this%expectancy%init()
1279 this%arousal_expected = 0.0_srp
1282 this%distance = missing
1285 this%expected_food_gain = 0.0_srp
1286 this%expected_cost_moving = missing
1287 this%expected_pred_dir_risk = missing
1288 this%expected_predation_risk = missing
1297 dist_is_stochastic, time_step_model)
1300 class(appraisal),
intent(in) :: this_agent
1304 class(spatial),
optional,
intent(in) :: predator_object
1308 logical,
optional,
intent(in) :: dist_is_stochastic
1311 integer,
optional,
intent(in) :: time_step_model
1317 real(SRP),
parameter :: WEIGHT_DIRECT = predation_risk_weight_immediate
1325 integer,
parameter :: MEM_WIND = history_size_perception
1328 integer :: time_step_model_here
1331 real(SRP) :: visibility_range_predator
1337 if (
present(time_step_model))
then
1338 time_step_model_here = time_step_model
1340 time_step_model_here = global_time_step_model_current
1346 this%expected_food_gain = 0.0_srp
1354 if (
present(predator_object))
then
1363 select type (predator_object)
1368 visibility_range_predator = &
1369 predator_object%visibility( &
1370 time_step_model = time_step_model_here)
1378 type is (spatialobj_percept_comp)
1382 visibility_range_predator = &
1383 predator_object%visibility( &
1384 time_step_model = time_step_model_here)
1393 visibility_range_predator = &
1395 visual_range( irradiance= &
1396 predator_object%illumination( &
1397 time_step_model_here), &
1399 length2sidearea_fish( &
1400 cm2m( predator_body_size ) ), &
1401 prey_contrast=preycontrast_default ) )
1409 visibility_range_predator = &
1411 visual_range( irradiance= &
1412 this_agent%illumination(time_step_model_here),&
1414 length2sidearea_fish( &
1415 cm2m( predator_body_size ) ), &
1416 prey_contrast=preycontrast_default ) )
1434 if (
present(dist_is_stochastic))
then
1435 if (dist_is_stochastic)
then
1437 rnorm(visibility_range_predator*escape_dart_distance_default_factor,&
1438 cv2variance(escape_dart_distance_default_stoch_cv, &
1439 visibility_range_predator* &
1440 escape_dart_distance_default_factor))
1443 this%distance = visibility_range_predator * &
1444 escape_dart_distance_default_factor
1448 this%distance = visibility_range_predator * &
1449 escape_dart_distance_default_factor
1458 this%expected_cost_moving = &
1459 this_agent%cost_swim( distance=this%distance, &
1460 exponent=swimming_cost_exponent_turbulent)
1464 this%expected_pred_dir_risk = zero
1471 this%expected_predation_risk = &
1472 predation_risk_backend( &
1474 pred_memory_mean = &
1475 this_agent%memory_stack%get_pred_mean(mem_wind), &
1476 weight_direct = weight_direct )
1485 time_step_model, rescale_max_motivation )
1488 class(appraisal),
intent(in) :: this_agent
1492 class(spatial),
optional,
intent(in) :: predator_object
1495 integer,
optional,
intent(in) :: time_step_model
1500 real(SRP),
optional,
intent(in) :: rescale_max_motivation
1503 integer :: time_step_model_here
1506 real(SRP) :: max_motivation
1511 real(SRP) :: expect_pred_dir
1515 real(SRP) :: expect_predator
1519 real(SRP) :: expect_stomach
1523 real(SRP) :: expect_bodymass
1527 real(SRP) :: expect_energy
1530 character(len=*),
parameter :: PROCNAME = &
1531 "(escape_dart_motivations_expect)"
1537 if (
present(time_step_model))
then
1538 time_step_model_here = time_step_model
1540 time_step_model_here = global_time_step_model_current
1555 if (
present(predator_object))
then
1556 call this%do_this( this_agent = this_agent, &
1557 predator_object = predator_object, &
1558 dist_is_stochastic = .false., &
1559 time_step_model = time_step_model_here )
1561 call this%do_this( this_agent = this_agent, &
1562 dist_is_stochastic = .false., &
1563 time_step_model = time_step_model_here )
1569 expect_stomach = max( zero, &
1570 this_agent%get_stom_content() - &
1571 stomach_emptify_backend( &
1572 this_agent%get_stom_content() ) )
1578 expect_bodymass = max( zero, &
1579 this_agent%get_mass() - &
1580 this%expected_cost_moving - &
1581 this_agent%living_cost() )
1587 expect_energy = energy_reserve( expect_bodymass, this_agent%length() )
1591 expect_pred_dir = this%expected_pred_dir_risk
1595 expect_predator = this%expected_predation_risk
1618 call this%expectancy%hunger%percept_component%motivation_components &
1621 param_gp_matrix_light = light_hunger_genotype_neuronal, &
1622 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
1623 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
1624 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
1625 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
1626 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
1627 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
1628 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
1629 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
1630 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
1631 param_gp_matrix_age = age_hunger_genotype_neuronal, &
1632 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
1634 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
1635 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
1636 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
1637 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
1638 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
1639 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
1640 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
1641 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
1642 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
1643 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
1644 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
1645 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
1650 perception_override_pred_dir = expect_pred_dir, &
1651 perception_override_predator = expect_predator, &
1652 perception_override_stomach = expect_stomach, &
1653 perception_override_bodymass = expect_bodymass, &
1654 perception_override_energy = expect_energy &
1666 call this%expectancy%fear_defence%percept_component%motivation_components &
1669 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
1670 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
1671 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
1672 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
1673 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
1674 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
1675 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
1676 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
1677 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
1678 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
1679 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
1680 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
1682 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
1683 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
1684 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
1685 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
1686 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
1687 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
1688 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
1689 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
1690 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
1691 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
1692 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
1693 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
1697 perception_override_pred_dir = expect_pred_dir, &
1698 perception_override_predator = expect_predator, &
1699 perception_override_stomach = expect_stomach, &
1700 perception_override_bodymass = expect_bodymass, &
1701 perception_override_energy = expect_energy &
1707 call this%expectancy%reproduction%percept_component%motivation_components &
1710 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
1711 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
1712 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
1713 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
1714 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
1715 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
1716 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
1717 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
1718 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
1719 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
1720 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
1721 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
1723 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
1724 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
1725 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
1726 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
1727 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
1728 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
1729 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
1730 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
1731 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
1732 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
1733 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
1734 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
1738 perception_override_pred_dir = expect_pred_dir, &
1739 perception_override_predator = expect_predator, &
1740 perception_override_stomach = expect_stomach, &
1741 perception_override_bodymass = expect_bodymass, &
1742 perception_override_energy = expect_energy &
1749 if (
present(rescale_max_motivation))
then
1752 max_motivation = rescale_max_motivation
1755 max_motivation = this%expectancy%max_perception()
1762 call this%attention_transfer(this_agent)
1765 call this%expectancy%motivation_primary_calc(max_motivation)
1768 call log_dbg( ltag_info //
"Primary motivations: " // &
1770 tostr(this%expectancy%hunger%motivation_prim) // &
1771 ", fear_defence: " // &
1772 tostr(this%expectancy%fear_defence%motivation_prim) // &
1773 ", reproduce: " // &
1774 tostr(this%expectancy%reproduction%motivation_prim), &
1779 call this%expectancy%modulation_none()
1785 this%arousal_expected = this%expectancy%max_final()
1789 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
1803 class(appraisal),
intent(inout) :: this_agent
1807 class(spatial),
optional,
intent(in) :: predator_object
1813 class(environment),
intent(in),
optional :: environment_limits
1816 integer :: iter_debug
1832 if (
present(predator_object))
then
1833 call this%do_this( this_agent = this_agent, &
1834 predator_object = predator_object, &
1835 dist_is_stochastic = .false. )
1837 call this%do_this( this_agent = this_agent, &
1838 dist_is_stochastic = .false. )
1843 call log_dbg(ltag_info //
"Executed ESCAPE; Perception values: " // &
1844 "Escape distance: " // tostr(this%distance) // &
1845 ", Food gain: " // tostr(this%expected_food_gain) // &
1846 ", Direct risk: " // tostr(this%expected_pred_dir_risk) // &
1847 ", Indirect risk: " // tostr(this%expected_predation_risk) )
1852 if (
present(predator_object))
then
1858 if (
present(environment_limits))
then
1859 call this_agent%corwalk( &
1860 target=predator_object, &
1861 meanshift=this%distance, &
1862 cv_shift=escape_dart_distance_default_stoch_cv, &
1864 environment_limits=environment_limits, &
1865 debug_reps = iter_debug )
1867 call this_agent%corwalk( &
1868 target=predator_object, &
1869 meanshift=this%distance, &
1870 cv_shift=escape_dart_distance_default_stoch_cv, &
1872 environment_limits=global_habitats_available( &
1873 this_agent%find_environment( &
1874 global_habitats_available) ), &
1875 debug_reps = iter_debug )
1886 if (
present(environment_limits))
then
1887 call this_agent%rwalk( &
1888 meanshift=this%distance, &
1889 cv_shift=escape_dart_distance_default_stoch_cv, &
1890 environment_limits=environment_limits )
1892 call this_agent%rwalk( &
1893 meanshift=this%distance, &
1894 cv_shift=escape_dart_distance_default_stoch_cv, &
1895 environment_limits=global_habitats_available( &
1896 this_agent%find_environment( &
1897 global_habitats_available) ) )
1907 call this_agent%set_mass( value_set = this_agent%get_mass() - &
1908 this_agent%cost_swim(exponent= &
1909 swimming_cost_exponent_turbulent), &
1910 update_history = .true. )
1917 call this_agent%set_length( value_set = this_agent%get_length(), &
1918 update_history = .true. )
1922 call this_agent%energy_update()
1926 if (this_agent%starved_death())
call this_agent%dies()
1937 class(
approach),
intent(inout) :: this
1942 this%label =
"APPROACH"
1945 this%is_active = .false.
1948 call this%expectancy%init()
1949 this%arousal_expected = 0.0_srp
1952 this%distance = missing
1955 this%expected_cost_moving = missing
1966 predict_window_food, time_step_model )
1967 class(
approach),
intent(inout) :: this
1969 class(appraisal),
intent(in) :: this_agent
1972 class(spatial),
intent(in) :: target_object
1977 real(SRP),
optional,
intent(in) :: target_offset
1985 integer,
optional,
intent(in) :: predict_window_food
1991 integer,
optional,
intent(in) :: time_step_model
1995 real(SRP) :: agent_length
1998 real(SRP) :: target_offset_here
2001 character(len=*),
parameter :: PROCNAME =
"(approach_do_this)"
2006 if (
present(target_offset))
then
2007 target_offset_here = target_offset
2009 target_offset_here = approach_offset_default
2013 agent_length = this_agent%get_length()
2022 in_proximity:
if ( this_agent%distance( target_object ) <= &
2023 target_offset_here )
then
2025 this%distance = 0.0_srp
2028 this%expected_cost_moving = 0.0_srp
2040 this%distance = this_agent%distance( target_object ) - target_offset_here
2047 if (this%distance > agent_length * migrate_dist_max_step )
then
2048 call log_msg( ltag_warn //
"Approach travel distance exceeds big " // &
2049 "threshold in " // procname //
" for the agent " // &
2050 this_agent%individ_label() //
". Agent length: " // &
2051 tostr(agent_length) //
", migration distance: " // &
2052 tostr(this%distance) )
2061 this%expected_cost_moving = &
2062 this_agent%cost_swim( distance=this%distance, &
2063 exponent=swimming_cost_exponent_laminar)
2073 target_offset, time_step_model, &
2074 rescale_max_motivation )
2075 class(
approach),
intent(inout) :: this
2077 class(appraisal),
intent(in) :: this_agent
2080 class(spatial),
optional,
intent(in) :: target_object
2085 real(SRP),
optional,
intent(in) :: target_offset
2091 integer,
optional,
intent(in) :: time_step_model
2096 real(SRP),
optional,
intent(in) :: rescale_max_motivation
2099 real(SRP) :: max_motivation
2102 real(SRP) :: target_offset_here
2108 real(SRP) :: perception_override_bodymass
2113 real(SRP) :: perception_override_energy
2116 character(len=*),
parameter :: PROCNAME = &
2117 "(approach_motivations_expect)"
2121 if (
present(target_offset))
then
2122 target_offset_here = target_offset
2124 target_offset_here = approach_offset_default
2137 call this%do_this( this_agent = this_agent, &
2138 target_object = target_object, &
2139 target_offset = target_offset_here )
2145 perception_override_bodymass = max( this_agent%get_mass() - &
2146 this%expected_cost_moving - &
2147 this_agent%living_cost(), &
2153 perception_override_energy = energy_reserve( perception_override_bodymass,&
2154 this_agent%length() )
2174 call this%expectancy%hunger%percept_component%motivation_components &
2177 param_gp_matrix_light = light_hunger_genotype_neuronal, &
2178 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
2179 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
2180 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
2181 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
2182 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
2183 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
2184 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
2185 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
2186 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
2187 param_gp_matrix_age = age_hunger_genotype_neuronal, &
2188 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
2190 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
2191 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
2192 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
2193 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
2194 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
2195 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
2196 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
2197 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
2198 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
2199 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
2200 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
2201 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
2206 perception_override_bodymass = perception_override_bodymass, &
2207 perception_override_energy = perception_override_energy &
2218 call this%expectancy%fear_defence%percept_component%motivation_components &
2221 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
2222 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
2223 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
2224 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
2225 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
2226 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
2227 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
2228 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
2229 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
2230 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
2231 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
2232 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
2234 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
2235 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
2236 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
2237 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
2238 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
2239 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
2240 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
2241 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
2242 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
2243 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
2244 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
2245 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
2249 perception_override_bodymass = perception_override_bodymass, &
2250 perception_override_energy = perception_override_energy &
2256 call this%expectancy%reproduction%percept_component%motivation_components &
2259 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
2260 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
2261 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
2262 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
2263 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
2264 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
2265 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
2266 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
2267 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
2268 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
2269 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
2270 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
2272 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
2273 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
2274 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
2275 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
2276 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
2277 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
2278 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
2279 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
2280 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
2281 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
2282 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
2283 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
2287 perception_override_bodymass = perception_override_bodymass, &
2288 perception_override_energy = perception_override_energy &
2295 if (
present(rescale_max_motivation))
then
2298 max_motivation = rescale_max_motivation
2301 max_motivation = this%expectancy%max_perception()
2308 call this%attention_transfer(this_agent)
2311 call this%expectancy%motivation_primary_calc(max_motivation)
2314 call log_dbg( ltag_info //
"Primary motivations: " // &
2316 tostr(this%expectancy%hunger%motivation_prim) // &
2317 ", fear_defence: " // &
2318 tostr(this%expectancy%fear_defence%motivation_prim) // &
2319 ", reproduce: " // &
2320 tostr(this%expectancy%reproduction%motivation_prim), &
2325 call this%expectancy%modulation_none()
2331 this%arousal_expected = this%expectancy%max_final()
2335 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
2346 target_offset, environment_limits )
2347 class(
approach),
intent(inout) :: this
2349 class(appraisal),
intent(inout) :: this_agent
2352 class(spatial),
intent(in) :: target_object
2358 logical,
optional,
intent(in) :: is_random
2366 real(SRP),
optional,
intent(in) :: target_offset
2369 class(environment),
intent(in),
optional :: environment_limits
2373 type(spatial) :: target_object_tmp, target_object_offset
2376 logical :: is_random_walk
2379 real(SRP) :: target_offset_here
2382 real(SRP) :: agent_length
2385 real(SRP) :: rwalk_meanshift_xy
2388 logical :: is_converged_debug
2389 integer :: iter_debug
2392 character(len=*),
parameter :: PROCNAME =
"(approach_do_execute)"
2401 if (
present(is_random))
then
2402 is_random_walk = is_random
2404 is_random_walk = .false.
2415 if (
present(target_offset))
then
2416 target_offset_here = target_offset
2420 target_offset_here = approach_offset_default
2422 target_offset_here = ( this_agent%get_length() + &
2423 get_prop_size(target_object) ) / 2.0_srp
2425 target_offset_here = approach_offset_default
2434 call target_object_tmp%position( target_object%location() )
2441 call this%do_this( this_agent = this_agent, &
2442 target_object = target_object_tmp, &
2443 target_offset = target_offset_here )
2449 agent_length = this_agent%get_length()
2450 if (this%distance - target_offset_here > &
2451 agent_length * migrate_dist_max_step)
then
2452 call log_msg( ltag_warn //
"Approach travel distance exceeds big " // &
2453 "threshold in " // procname //
" for the agent " // &
2454 this_agent%individ_label() //
". Agent length: " // &
2455 tostr(agent_length) //
", migration distance: " // &
2456 tostr(this%distance) )
2457 this%distance = agent_length * migrate_dist_max_step + target_offset_here
2471 do_walk_random:
if (is_random_walk)
then
2472 if (
present(environment_limits))
then
2473 if (this%distance > zero)
then
2474 rwalk_meanshift_xy = this%distance - target_offset_here
2476 rwalk_meanshift_xy = target_offset_here
2478 call this_agent%corwalk( &
2479 target = target_object_tmp, &
2480 meanshift_xy = rwalk_meanshift_xy, &
2481 cv_shift_xy = walk_random_distance_stochastic_cv, &
2482 meanshift_depth = (this%distance - target_offset_here) * &
2483 walk_random_vertical_shift_ratio, &
2484 cv_shift_depth = walk_random_distance_stochastic_cv * &
2485 walk_random_vertical_shift_cv_ratio, &
2486 is_away = .false., &
2487 environment_limits = environment_limits, &
2488 is_converged = is_converged_debug, &
2489 debug_reps = iter_debug )
2491 if (this%distance > zero)
then
2492 rwalk_meanshift_xy = this%distance - target_offset_here
2494 rwalk_meanshift_xy = target_offset_here
2496 call this_agent%corwalk( &
2497 target = target_object_tmp, &
2498 meanshift_xy = rwalk_meanshift_xy, &
2499 cv_shift_xy = walk_random_distance_stochastic_cv, &
2500 meanshift_depth = (this%distance - target_offset_here) * &
2501 walk_random_vertical_shift_ratio, &
2502 cv_shift_depth = walk_random_distance_stochastic_cv * &
2503 walk_random_vertical_shift_cv_ratio, &
2504 is_away = .false., &
2505 environment_limits = global_habitats_available( &
2506 this_agent%find_environment( &
2507 global_habitats_available) ), &
2508 is_converged = is_converged_debug, &
2509 debug_reps = iter_debug )
2511 call log_dbg( ltag_info //
"Correlated random walk: converged " // &
2512 tostr(is_converged_debug) //
", iterations: " // &
2513 tostr(iter_debug), procname,
modname )
2527 if (this%distance > zero)
then
2528 target_object_offset = offset_dist( this_agent, target_object_tmp, &
2530 call this_agent%position( target_object_offset )
2531 call log_dbg(ltag_info //
"Agent approached the target, distance to " &
2532 //
" the target: " // &
2533 tostr(this_agent%distance(target_object_tmp)) // &
2534 "; distance offset: " // tostr(target_offset_here) // &
2535 ", updated target distance to the target: " // &
2536 tostr(this_agent%distance(target_object_offset)) // &
2537 "; original target: " // tostr([target_object_tmp%xpos(), &
2538 target_object_tmp%ypos(), target_object_tmp%dpos()]) // &
2539 ", new agent position: " // tostr([this_agent%xpos(), &
2540 this_agent%ypos(),this_agent%dpos()]), procname,
modname )
2542 call this_agent%position( this_agent%location() )
2543 call log_dbg(ltag_info //
"Agent has not relocated because it is " // &
2544 "in proximity of the target; distance to target: " // &
2545 tostr(this_agent%distance(target_object)) )
2548 end if do_walk_random
2555 call this_agent%set_mass( &
2556 value_set = this_agent%get_mass() - &
2557 this_agent%cost_swim(exponent= &
2558 swimming_cost_exponent_laminar), &
2559 update_history = .true. )
2566 call this_agent%set_length( value_set = this_agent%get_length(), &
2567 update_history = .true. )
2572 call this_agent%energy_update()
2576 if (this_agent%starved_death())
call this_agent%dies()
2593 this%label =
"APPR_CONSPEC"
2596 this%is_active = .false.
2599 call this%expectancy%init()
2600 this%arousal_expected = 0.0_srp
2603 this%distance = missing
2607 this%expected_cost_moving = missing
2610 this%expected_food_gain = missing
2611 this%expected_predation_risk = missing
2612 this%expected_pred_dir_risk = missing
2624 predict_window_food, &
2628 class(appraisal),
intent(in) :: this_agent
2631 class(spatial),
intent(in) :: target_object
2636 real(SRP),
optional,
intent(in) :: target_offset
2642 integer,
optional,
intent(in) :: predict_window_food
2645 integer,
optional,
intent(in) :: time_step_model
2648 real(SRP) :: agent_length
2651 real(SRP) :: target_offset_here
2654 integer :: predict_window_food_here, time_step_model_here
2657 character(len=*),
parameter :: PROCNAME =
"(approach_conspecifics_do_this)"
2660 character(FILENAME_LENGTH) :: debug_plot_file_sufx
2666 real(SRP),
parameter :: WEIGHT_DIRECT = predation_risk_weight_immediate
2674 integer,
parameter :: MEM_WIND = history_size_perception
2680 real(SRP) :: consp_size, consp_mass, consp_dist
2685 type(spatial) :: target_position_agent
2690 type(predator) :: tmp_predator
2694 real(SRP),
allocatable,
dimension(:) :: risk_pred_expect
2698 integer :: n_pred_now, i
2702 real(SRP) :: body_mass_ratio
2706 real(SRP) :: food_gain_expect_baseline
2710 agent_length = this_agent%get_length()
2719 if (
present(predict_window_food))
then
2720 predict_window_food_here = predict_window_food
2722 predict_window_food_here = floor( history_size_perception * &
2723 history_perception_window_food )
2727 if (
present(time_step_model))
then
2728 time_step_model_here = time_step_model
2730 time_step_model_here = global_time_step_model_current
2735 debug_plot_file_sufx = tostr(global_time_step_model_current) //
"_" // &
2736 mmdd //
"_a_" // trim(this_agent%individ_label()) &
2738 rand_string(label_length, label_cst,label_cen) // ps
2751 get_target:
select type (target_object)
2755 class is (conspec_percept_comp) get_target
2756 consp_size = target_object%get_size()
2757 consp_mass = target_object%get_mass()
2758 consp_dist = target_object%get_dist()
2759 call log_dbg( ltag_info //
"Perception of target conspecific in " // &
2760 procname //
", size: " // tostr(consp_size) // &
2761 ", mass: " // tostr(consp_mass) // &
2762 ", distance (from perception): " // tostr(consp_dist) //&
2763 " and (from object): " // &
2764 tostr( this_agent%distance( target_object ) ) //
"." )
2769 class is (appraisal) get_target
2770 consp_size = target_object%get_length()
2771 consp_mass = target_object%get_mass()
2772 consp_dist = this_agent%distance( target_object )
2773 call log_dbg( ltag_info //
"Explicit target conspecific in " // &
2774 procname //
", size: " // tostr(consp_size) // &
2775 ", mass: " // tostr(consp_mass) // &
2776 ", distance: " // tostr(consp_dist) //
"." )
2785 class default get_target
2786 consp_size = agent_length
2787 consp_mass = this_agent%get_mass()
2788 consp_dist = this_agent%distance( target_object )
2789 call log_dbg( ltag_warn //
"Target conspecific in " // procname // &
2790 " is undefined, get properties from the agent. " // &
2791 "Length: " // tostr(consp_size) //
", " // &
2792 "mass: " // tostr(consp_mass) //
", " // &
2793 "distance: " // tostr(consp_dist) //
". ", &
2795 call log_dbg( ltag_warn //
"Position of the target object: " // &
2796 tostr([ target_object%xpos(), &
2797 target_object%ypos(), &
2798 target_object%dpos() ]) //
" in " // procname,&
2800 end select get_target
2807 if (
present(target_offset))
then
2808 target_offset_here = target_offset
2810 target_offset_here = (agent_length + consp_size) / 2.0_srp
2820 in_proximity:
if ( this_agent%distance( target_object ) <= &
2821 target_offset_here )
then
2823 this%distance = 0.0_srp
2827 target_position_agent = this_agent%location()
2830 this%expected_cost_moving = 0.0_srp
2842 this%distance = this_agent%distance( target_object ) - target_offset_here
2850 if (this%distance > agent_length * migrate_dist_max_step )
then
2851 call log_msg( ltag_warn //
"Target conspecific travel distance " // &
2852 "exceeds big threshold in " // procname // &
2853 " for the agent " // this_agent%individ_label() // &
2854 ". Agent length: " // tostr(agent_length) // &
2855 ", target distance: " // tostr(this%distance) )
2860 target_position_agent = offset_dist( this_agent, target_object, &
2861 target_offset_here )
2869 this%expected_cost_moving = &
2870 this_agent%cost_swim(distance=this%distance, &
2871 exponent=swimming_cost_exponent_laminar)
2884 no_predators:
if ( .not. this_agent%has_pred() )
then
2890 this%expected_predation_risk = &
2891 predation_risk_backend( &
2893 pred_memory_mean = &
2894 this_agent%memory_stack%get_pred_mean(mem_wind), &
2895 weight_direct = weight_direct )
2899 this%expected_pred_dir_risk = 0.0_srp
2907 n_pred_now = this_agent%perceive_predator%get_count()
2919 this%expected_predation_risk = &
2920 predation_risk_backend( &
2921 pred_count = floor( n_pred_now * &
2922 approach_conspecfic_dilute_general_risk ), &
2923 pred_memory_mean = &
2924 this_agent%memory_stack%get_pred_mean(mem_wind),&
2925 weight_direct = weight_direct )
2939 allocate( risk_pred_expect(n_pred_now) )
2967 pred_percept:
do i=1, n_pred_now
2975 call tmp_predator%make( &
2977 this_agent%perceive_predator%predators_seen(i)%get_size(), &
2978 attack_rate = predator_attack_rate_default, &
2980 this_agent%perceive_predator%predators_seen(i)%location(), &
2981 label=
"tmp_object" )
2993 go_closer:
if ( target_position_agent%distance( &
2994 this_agent%perceive_predator%predators_seen(i) ) < &
2995 target_object%distance( &
2996 this_agent%perceive_predator%predators_seen(i) ) ) &
2998 risk_pred_expect(i) = &
2999 tmp_predator%risk_fish( prey_spatial=target_position_agent, &
3000 prey_length=this_agent%get_length(), &
3001 prey_distance=this%distance, &
3002 is_freezing=.false., &
3003 time_step_model=time_step_model_here, &
3005 "plot_debug_exp_predation_risk_" // &
3006 debug_plot_file_sufx )
3015 risk_pred_expect(i) = &
3016 approach_conspecfic_dilute_adjust_pair_behind * &
3017 tmp_predator%risk_fish( prey_spatial=target_position_agent, &
3018 prey_length=this_agent%get_length(), &
3019 prey_distance=this%distance, &
3020 is_freezing=.false., &
3021 time_step_model=time_step_model_here, &
3023 "plot_debug_exp_predation_risk_" // &
3024 debug_plot_file_sufx )
3034 this%expected_pred_dir_risk = maxval(risk_pred_expect)
3038 call log_dbg( ltag_info //
"Saved direct predation risks for " // &
3039 tostr(n_pred_now) //
" predators in perception; " // &
3040 " the maximum value is: " // &
3041 tostr(this%expected_pred_dir_risk) // &
3042 "; full array: " // tostr(risk_pred_expect), &
3060 food_gain_expect_baseline = this_agent%perceive_food%get_meanmass() * &
3061 this_agent%food_probability_capture_subjective( &
3062 predict_window_food_here, time_step_model_here )
3073 body_mass_ratio = this_agent%get_mass() / consp_mass
3085 this%expected_food_gain = &
3086 food_gain_expect_baseline * &
3087 ddpinterpol( approach_food_gain_compet_factor_abscissa, &
3088 approach_food_gain_compet_factor_ordinate, &
3096 call debug_interpolate_plot_save( &
3097 grid_xx=approach_food_gain_compet_factor_abscissa, &
3098 grid_yy=approach_food_gain_compet_factor_ordinate, &
3099 ipol_value=body_mass_ratio, algstr=
"DDPINTERPOL", &
3100 output_file=
"plot_debug_expect_food_gain_" // &
3101 debug_plot_file_sufx )
3110 target_object, target_offset, time_step_model, rescale_max_motivation)
3114 class(appraisal),
intent(in) :: this_agent
3117 class(spatial),
optional,
intent(in) :: target_object
3122 real(SRP),
optional,
intent(in) :: target_offset
3125 integer,
optional,
intent(in) :: time_step_model
3130 real(SRP),
optional,
intent(in) :: rescale_max_motivation
3133 real(SRP) :: max_motivation
3136 real(SRP) :: target_offset_here
3139 integer :: time_step_model_here
3143 type(food_item) :: expected_food_item
3145 real(SRP) :: expected_food_item_distance
3148 real(SRP) :: expected_food_item_prob_capture
3151 real(SRP) :: expected_food_item_gain_fits
3154 real(SRP) :: agent_stomach
3163 real(SRP) :: perception_override_pred_dir
3167 real(SRP) :: perception_override_predator
3171 real(SRP) :: perception_override_food_dir
3176 real(SRP) :: perception_override_stomach
3179 real(SRP) :: perception_override_bodymass
3184 real(SRP) :: perception_override_energy
3187 character(len=*),
parameter :: PROCNAME = &
3188 "(approach_conspecifics_motivations_expect)"
3194 if (
present(time_step_model))
then
3195 time_step_model_here = time_step_model
3197 time_step_model_here = global_time_step_model_current
3206 if (
present(target_offset))
then
3207 target_offset_here = target_offset
3209 target_offset_here = ( this_agent%get_length() + &
3210 get_prop_size(target_object) ) / 2.0_srp
3226 call this%do_this( this_agent = this_agent, &
3227 target_object = target_object, &
3228 target_offset = target_offset_here, &
3229 time_step_model = time_step_model_here )
3241 call expected_food_item%make(location=this_agent%location(), &
3242 size=mass2size_food(this%expected_food_gain),&
3256 if ( this_agent%has_food() )
then
3257 expected_food_item_distance = this_agent%perceive_food%get_meandist()
3260 expected_food_item_distance = expected_food_item%visibility() * &
3261 dist_expect_food_uncertain_fact
3264 expected_food_item_prob_capture = &
3265 expected_food_item%capture_probability( &
3266 distance=expected_food_item_distance )
3276 expected_food_item_gain_fits = &
3277 this_agent%food_fitting( this%expected_food_gain, this%distance ) &
3278 * expected_food_item_prob_capture
3284 agent_stomach = this_agent%get_stom_content()
3285 perception_override_stomach = &
3287 agent_stomach - stomach_emptify_backend(agent_stomach) + &
3288 expected_food_item_gain_fits )
3294 perception_override_bodymass = &
3296 this_agent%get_mass() - &
3297 this_agent%living_cost() + &
3298 expected_food_item_gain_fits )
3303 perception_override_energy = energy_reserve( perception_override_bodymass,&
3304 this_agent%length() )
3313 perception_override_food_dir = real( &
3314 this_agent%perceive_food%get_count(), srp)
3321 perception_override_pred_dir = this%expected_pred_dir_risk
3322 perception_override_predator = this%expected_predation_risk
3349 call this%expectancy%hunger%percept_component%motivation_components &
3352 param_gp_matrix_light = light_hunger_genotype_neuronal, &
3353 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
3354 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
3355 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
3356 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
3357 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
3358 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
3359 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
3360 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
3361 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
3362 param_gp_matrix_age = age_hunger_genotype_neuronal, &
3363 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
3365 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
3366 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
3367 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
3368 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
3369 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
3370 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
3371 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
3372 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
3373 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
3374 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
3375 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
3376 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
3381 perception_override_food_dir = perception_override_food_dir, &
3382 perception_override_pred_dir = perception_override_pred_dir, &
3383 perception_override_predator = perception_override_predator, &
3384 perception_override_stomach = perception_override_stomach, &
3385 perception_override_bodymass = perception_override_bodymass, &
3386 perception_override_energy = perception_override_energy &
3397 call this%expectancy%fear_defence%percept_component%motivation_components &
3400 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
3401 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
3402 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
3403 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
3404 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
3405 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
3406 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
3407 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
3408 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
3409 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
3410 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
3411 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
3413 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
3414 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
3415 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
3416 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
3417 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
3418 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
3419 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
3420 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
3421 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
3422 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
3423 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
3424 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
3428 perception_override_food_dir = perception_override_food_dir, &
3429 perception_override_pred_dir = perception_override_pred_dir, &
3430 perception_override_predator = perception_override_predator, &
3431 perception_override_stomach = perception_override_stomach, &
3432 perception_override_bodymass = perception_override_bodymass, &
3433 perception_override_energy = perception_override_energy &
3439 call this%expectancy%reproduction%percept_component%motivation_components &
3442 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
3443 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
3444 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
3445 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
3446 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
3447 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
3448 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
3449 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
3450 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
3451 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
3452 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
3453 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
3455 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
3456 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
3457 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
3458 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
3459 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
3460 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
3461 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
3462 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
3463 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
3464 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
3465 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
3466 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
3470 perception_override_food_dir = perception_override_food_dir, &
3471 perception_override_pred_dir = perception_override_pred_dir, &
3472 perception_override_predator = perception_override_predator, &
3473 perception_override_stomach = perception_override_stomach, &
3474 perception_override_bodymass = perception_override_bodymass, &
3475 perception_override_energy = perception_override_energy &
3482 if (
present(rescale_max_motivation))
then
3485 max_motivation = rescale_max_motivation
3488 max_motivation = this%expectancy%max_perception()
3495 call this%attention_transfer(this_agent)
3498 call this%expectancy%motivation_primary_calc(max_motivation)
3501 call log_dbg( ltag_info //
"Primary motivations: " // &
3503 tostr(this%expectancy%hunger%motivation_prim) // &
3504 ", fear_defence: " // &
3505 tostr(this%expectancy%fear_defence%motivation_prim) // &
3506 ", reproduce: " // &
3507 tostr(this%expectancy%reproduction%motivation_prim), &
3512 call this%expectancy%modulation_none()
3518 this%arousal_expected = this%expectancy%max_final()
3522 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
3533 class(
migrate),
intent(inout) :: this
3538 this%label =
"MIGRATE"
3541 this%is_active = .false.
3544 call this%expectancy%init()
3545 this%arousal_expected = 0.0_srp
3548 this%distance = missing
3551 this%target_point = spatial(x=missing, y=missing, depth=missing)
3552 this%expected_cost_moving = missing
3553 this%expected_food_gain = missing
3554 this%expected_food_dir = missing
3555 this%expected_consp_number = unknown
3556 this%expected_pred_dir_risk = missing
3557 this%expected_predation_risk = missing
3568 predict_window_food, predict_window_consp, predict_window_pred, &
3570 class(
migrate),
intent(inout) :: this
3572 class(appraisal),
intent(in) :: this_agent
3575 class(environment),
intent(in) :: target_env
3581 integer,
optional,
intent(in) :: predict_window_food
3587 integer,
optional,
intent(in) :: predict_window_consp
3593 integer,
optional,
intent(in) :: predict_window_pred
3596 integer,
optional,
intent(in) :: time_step_model
3599 integer :: predict_window_food_here, predict_window_consp_here, &
3600 predict_window_pred_here, time_step_model_here
3603 real(SRP) :: agent_length
3609 real(SRP),
parameter :: WEIGHT_DIRECT = predation_risk_weight_immediate
3614 type(spatial) :: point_target_env
3616 real(SRP) :: distance_target
3624 real(SRP) :: mean_n_food_memory_old, mean_n_food_memory_new
3632 real(SRP) :: mean_size_food_memory_old, mean_size_food_memory_new
3638 real(SRP) :: food_gain_memory_old, food_gain_memory_new
3643 real(SRP) :: food_gain_memory_baseline
3647 real(SRP) :: mean_n_pred_memory_old, mean_n_pred_memory_new
3652 real(SRP) :: pred_current
3655 character(len=*),
parameter :: PROCNAME =
"(migrate_do_this)"
3663 if (
present(predict_window_food))
then
3664 predict_window_food_here = predict_window_food
3666 predict_window_food_here = history_size_perception
3673 if (
present(predict_window_consp))
then
3674 predict_window_consp_here= predict_window_consp
3676 predict_window_consp_here = history_size_perception
3683 if (
present(predict_window_pred))
then
3684 predict_window_pred_here= predict_window_pred
3686 predict_window_pred_here = history_size_perception
3691 if (
present(time_step_model))
then
3692 time_step_model_here = time_step_model
3694 time_step_model_here = global_time_step_model_current
3698 agent_length = this_agent%get_length()
3717 call target_env%nearest_target( outside_object=this_agent, &
3718 offset_into=agent_length * &
3719 migrate_dist_penetrate_offset, &
3720 point_spatial = point_target_env, &
3721 point_dist = distance_target )
3728 this%distance = distance_target
3729 this%target_point = point_target_env
3734 if (this%distance > agent_length * migrate_dist_max_step )
then
3741 call log_dbg( ltag_warn //
"Migration travel distance exceeds big " // &
3742 "threshold in " // procname //
" for the agent " // &
3743 this_agent%individ_label() //
". Agent length: " // &
3744 tostr(agent_length) //
", migration distance: " // &
3745 tostr(this%distance), procname,
modname )
3753 this%expected_cost_moving = &
3754 this_agent%cost_swim( distance=this%distance, &
3755 exponent=swimming_cost_exponent_laminar )
3776 call this_agent%memory_stack%get_food_mean_n_split( &
3777 window = predict_window_food_here, &
3778 older = mean_n_food_memory_old, &
3779 newer = mean_n_food_memory_new )
3781 call this_agent%memory_stack%get_food_mean_size_split( &
3782 window = predict_window_food_here, &
3783 older = mean_size_food_memory_old, &
3784 newer = mean_size_food_memory_new )
3825 food_gain_memory_old = size2mass_food(mean_size_food_memory_old) * &
3826 within( mean_n_food_memory_old, 0.0_srp, 1.0_srp )
3827 food_gain_memory_new = size2mass_food(mean_size_food_memory_new) * &
3828 within( mean_n_food_memory_new, 0.0_srp, 1.0_srp )
3831 call log_dbg( ltag_info //
"Mean number of old and new " // &
3832 "food items in memory: " // &
3833 tostr(mean_n_food_memory_old) // &
3834 ":" // tostr(mean_n_food_memory_new), &
3836 call log_dbg( ltag_info //
"Mean size of old and new " // &
3837 "food items in memory: " // &
3838 tostr(mean_size_food_memory_old) &
3839 //
":" // tostr(mean_size_food_memory_new), &
3841 call log_dbg( ltag_info //
"Food gain old and new " // &
3842 "food items in memory: " // tostr(food_gain_memory_old) // &
3843 ":" // tostr(food_gain_memory_new), &
3845 log_ratio_check:
if (is_debug)
then
3847 real(SRP) :: debug_ratio
3850 if (food_gain_memory_old < zero)
then
3851 debug_ratio = migrate_food_gain_ratio_zero_hope
3852 elseif (food_gain_memory_old < zero .and. &
3853 food_gain_memory_new < zero)
then
3854 debug_ratio = 1.0_srp
3856 debug_ratio = food_gain_memory_new / food_gain_memory_old
3858 call log_dbg( ltag_info //
"Food gain hope ratio (new/old): " // &
3859 tostr(debug_ratio), procname,
modname )
3861 end if log_ratio_check
3881 food_gain_memory_baseline = &
3883 this_agent%memory_stack%get_food_mean_size( &
3884 predict_window_food_here)) * &
3886 this_agent%memory_stack%get_food_mean_n(predict_window_food_here),&
3887 0.0_srp, 1.0_srp ) * &
3888 this_agent%food_probability_capture_subjective( &
3889 predict_window_food_here, time_step_model_here )
3898 this%expected_food_gain =
hope( food_gain_memory_baseline, &
3899 food_gain_memory_old, &
3900 food_gain_memory_new, &
3901 migrate_food_gain_ratio_zero_hope, &
3902 migrate_food_gain_maximum_hope )
3905 call log_dbg( ltag_info //
"Expected food gain from hope function: " // &
3906 tostr(this%expected_food_gain) //
", with baseline " // &
3907 "value: " // tostr(food_gain_memory_baseline), &
3923 this%expected_food_dir = &
3924 hope( real(this_agent%perceive_food%get_count(),srp), &
3925 mean_n_food_memory_old, &
3926 mean_n_food_memory_new, &
3927 migrate_food_gain_ratio_zero_hope, &
3928 migrate_food_gain_maximum_hope )
3931 call log_dbg( ltag_info //
"Expected food perception from hope " // &
3932 "function: " // tostr(this%expected_food_dir ), &
3937 this%expected_pred_dir_risk = 0.0_srp
3945 call this_agent%memory_stack%get_pred_mean_split( &
3946 window = predict_window_pred_here, &
3947 older = mean_n_pred_memory_old, &
3948 newer = mean_n_pred_memory_new )
3956 predation_risk_backend( &
3957 pred_count=this_agent%perceive_predator%get_count(), &
3958 pred_memory_mean=this_agent%memory_stack%get_pred_mean( &
3959 predict_window_pred_here),&
3960 weight_direct=weight_direct )
3970 this%expected_predation_risk =
hope( pred_current, &
3971 mean_n_pred_memory_old, &
3972 mean_n_pred_memory_new, &
3973 migrate_predator_zero_hope, &
3974 migrate_predator_maximum_hope )
3980 this%expected_consp_number = nint( &
3981 this_agent%memory_stack%get_consp_mean_n(predict_window_consp_here) )
3983 call log_dbg( ltag_info //
"Expected N of conspecifics: " // &
3984 tostr(this%expected_consp_number), procname,
modname )
3993 predict_window_food, predict_window_consp, predict_window_pred, &
3994 time_step_model, rescale_max_motivation)
3995 class(
migrate),
intent(inout) :: this
3997 class(appraisal),
intent(in) :: this_agent
4000 class(environment),
intent(in) :: target_env
4006 integer,
optional,
intent(in) :: predict_window_food
4012 integer,
optional,
intent(in) :: predict_window_consp
4018 integer,
optional,
intent(in) :: predict_window_pred
4021 integer,
optional,
intent(in) :: time_step_model
4026 real(SRP),
optional,
intent(in) :: rescale_max_motivation
4029 character(len=*),
parameter :: PROCNAME =
"(migrate_motivations_expect)"
4032 integer :: predict_window_food_here, predict_window_consp_here, &
4033 predict_window_pred_here, time_step_model_here
4036 real(SRP) :: max_motivation
4039 real(SRP) :: agent_stomach
4043 type(food_item) :: expected_food_item
4045 real(SRP) :: expected_food_item_distance
4048 real(SRP) :: expected_food_item_gain_fits
4051 real(SRP) :: expected_food_item_prob_capture
4057 real(SRP) :: perception_override_conspec
4061 real(SRP) :: perception_override_pred_dir
4065 real(SRP) :: perception_override_predator
4068 real(SRP) :: perception_override_food_dir
4071 real(SRP) :: perception_override_stomach
4074 real(SRP) :: perception_override_bodymass
4079 real(SRP) :: perception_override_energy
4087 if (
present(predict_window_food))
then
4088 predict_window_food_here = predict_window_food
4090 predict_window_food_here = history_size_perception
4097 if (
present(predict_window_consp))
then
4098 predict_window_consp_here= predict_window_consp
4100 predict_window_consp_here = history_size_perception
4107 if (
present(predict_window_pred))
then
4108 predict_window_pred_here= predict_window_pred
4110 predict_window_pred_here = history_size_perception
4115 if (
present(time_step_model))
then
4116 time_step_model_here = time_step_model
4118 time_step_model_here = global_time_step_model_current
4135 call this%do_this( this_agent=this_agent, &
4136 target_env=target_env, &
4137 predict_window_food=predict_window_food_here, &
4138 predict_window_consp=predict_window_consp_here, &
4139 predict_window_pred=predict_window_pred_here, &
4140 time_step_model=time_step_model_here )
4150 call expected_food_item%make(location=this_agent%location(), &
4151 size=mass2size_food(this%expected_food_gain),&
4165 if ( this_agent%has_food() )
then
4166 expected_food_item_distance = this_agent%perceive_food%get_meandist()
4169 expected_food_item_distance = expected_food_item%visibility() * &
4170 dist_expect_food_uncertain_fact
4173 expected_food_item_prob_capture = &
4174 expected_food_item%capture_probability( &
4175 distance=expected_food_item_distance )
4178 call log_dbg( ltag_info //
"Distance to the expected food item: " // &
4179 tostr(expected_food_item_distance) // &
4180 ", capture prpbability of the expected food item: " // &
4181 tostr(expected_food_item_prob_capture) //
".", &
4188 expected_food_item_gain_fits = &
4189 this_agent%food_fitting( this%expected_food_gain, &
4190 expected_food_item_distance ) * &
4191 expected_food_item_prob_capture
4194 call log_dbg( ltag_info //
"Raw food gain: " // &
4195 tostr(this_agent%food_fitting( this%expected_food_gain, &
4196 expected_food_item_distance )) // &
4197 ", subjective food gain weighted by capture prob.: " // &
4198 tostr(expected_food_item_gain_fits) //
".", &
4205 agent_stomach = this_agent%get_stom_content()
4206 perception_override_stomach = &
4208 agent_stomach - stomach_emptify_backend(agent_stomach) + &
4209 expected_food_item_gain_fits )
4225 perception_override_bodymass = &
4227 this_agent%get_mass() - &
4228 this_agent%living_cost() + &
4229 expected_food_item_gain_fits - &
4230 this%expected_cost_moving )
4235 perception_override_energy = energy_reserve( perception_override_bodymass,&
4236 this_agent%length() )
4243 perception_override_food_dir = this%expected_food_dir
4249 perception_override_pred_dir = this%expected_pred_dir_risk
4250 perception_override_predator = this%expected_predation_risk
4255 perception_override_conspec = this%expected_consp_number
4280 call this%expectancy%hunger%percept_component%motivation_components &
4283 param_gp_matrix_light = light_hunger_genotype_neuronal, &
4284 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
4285 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
4286 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
4287 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
4288 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
4289 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
4290 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
4291 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
4292 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
4293 param_gp_matrix_age = age_hunger_genotype_neuronal, &
4294 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
4296 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
4297 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
4298 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
4299 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
4300 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
4301 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
4302 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
4303 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
4304 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
4305 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
4306 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
4307 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
4312 perception_override_food_dir = perception_override_food_dir, &
4313 perception_override_conspec = perception_override_conspec, &
4314 perception_override_pred_dir = perception_override_pred_dir, &
4315 perception_override_predator = perception_override_predator, &
4316 perception_override_stomach = perception_override_stomach, &
4317 perception_override_bodymass = perception_override_bodymass, &
4318 perception_override_energy = perception_override_energy &
4330 call this%expectancy%fear_defence%percept_component%motivation_components &
4333 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
4334 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
4335 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
4336 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
4337 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
4338 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
4339 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
4340 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
4341 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
4342 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
4343 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
4344 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
4346 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
4347 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
4348 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
4349 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
4350 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
4351 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
4352 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
4353 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
4354 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
4355 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
4356 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
4357 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
4361 perception_override_food_dir = perception_override_food_dir, &
4362 perception_override_conspec = perception_override_conspec, &
4363 perception_override_pred_dir = perception_override_pred_dir, &
4364 perception_override_predator = perception_override_predator, &
4365 perception_override_stomach = perception_override_stomach, &
4366 perception_override_bodymass = perception_override_bodymass, &
4367 perception_override_energy = perception_override_energy &
4373 call this%expectancy%reproduction%percept_component%motivation_components &
4376 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
4377 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
4378 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
4379 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
4380 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
4381 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
4382 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
4383 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
4384 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
4385 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
4386 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
4387 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
4389 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
4390 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
4391 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
4392 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
4393 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
4394 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
4395 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
4396 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
4397 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
4398 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
4399 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
4400 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
4404 perception_override_food_dir = perception_override_food_dir, &
4405 perception_override_conspec = perception_override_conspec, &
4406 perception_override_pred_dir = perception_override_pred_dir, &
4407 perception_override_predator = perception_override_predator, &
4408 perception_override_stomach = perception_override_stomach, &
4409 perception_override_bodymass = perception_override_bodymass, &
4410 perception_override_energy = perception_override_energy &
4417 if (
present(rescale_max_motivation))
then
4420 max_motivation = rescale_max_motivation
4423 max_motivation = this%expectancy%max_perception()
4430 call this%attention_transfer(this_agent)
4433 call this%expectancy%motivation_primary_calc(max_motivation)
4436 call log_dbg( ltag_info //
"Primary motivations: " // &
4438 tostr(this%expectancy%hunger%motivation_prim) // &
4439 ", fear_defence: " // &
4440 tostr(this%expectancy%fear_defence%motivation_prim) // &
4441 ", reproduce: " // &
4442 tostr(this%expectancy%reproduction%motivation_prim), &
4447 call this%expectancy%modulation_none()
4453 this%arousal_expected = this%expectancy%max_final()
4457 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
4468 class(
migrate),
intent(inout) :: this
4470 class(appraisal),
intent(inout) :: this_agent
4473 class(environment),
intent(in) :: target_env
4476 character(len=*),
parameter :: PROCNAME =
"(migrate_do_execute)"
4479 real(SRP) :: agent_length
4482 logical :: is_converged_debug
4483 integer :: iter_debug
4487 real(SRP),
parameter :: CIDIF = 1.95996_srp
4490 agent_length = this_agent%get_length()
4499 call this%do_this( this_agent=this_agent, target_env=target_env )
4508 do_walk:
if (this%distance > agent_length * migrate_dist_max_step )
then
4510 call log_dbg( ltag_warn //
"Migration travel distance exceeds big " // &
4511 "threshold in " // procname //
" for the agent " // &
4512 this_agent%individ_label() //
". Agent length: " // &
4513 tostr(agent_length) //
", migration distance: " // &
4514 tostr(this%distance), procname,
modname )
4523 call this_agent%corwalk( &
4524 target = this%target_point, &
4525 meanshift_xy = agent_length * migrate_dist_max_step - &
4526 agent_length * migrate_dist_max_step * cidif * &
4527 (agent_length * migrate_dist_max_step) * &
4528 walk_random_distance_stochastic_cv, &
4529 cv_shift_xy = walk_random_distance_stochastic_cv, &
4530 meanshift_depth = agent_length * &
4531 walk_random_vertical_shift_ratio, &
4532 cv_shift_depth = walk_random_distance_stochastic_cv * &
4533 walk_random_vertical_shift_cv_ratio, &
4534 is_away = .false., &
4535 environment_limits = global_habitats_available( &
4536 this_agent%find_environment( &
4537 global_habitats_available) ),&
4538 is_converged = is_converged_debug, &
4539 debug_reps = iter_debug )
4540 call log_dbg( ltag_info //
"Correlated random walk: converged " // &
4541 tostr(is_converged_debug) //
", iterations: " // &
4542 tostr(iter_debug), procname,
modname )
4547 call log_dbg( ltag_info //
"Agent is about to migrate to " // &
4548 tostr([ this%target_point%xpos(), &
4549 this%target_point%ypos(), &
4550 this%target_point%dpos()]), procname,
modname )
4551 call this_agent%position( this%target_point%location() )
4556 call log_dbg( ltag_info //
"Migration displacement position:" // &
4557 tostr([ this_agent%xpos(), &
4558 this_agent%ypos(), &
4559 this_agent%dpos()] ) //
", distance (way) " // &
4560 "traversed: " // tostr(this_agent%way()) // &
4561 " (distance expected " // tostr(this%distance) //
")", &
4563 call log_dbg( ltag_info //
"Cost of this movement: " // &
4564 tostr(this_agent%cost_swim(exponent = &
4565 swimming_cost_exponent_laminar)), procname,
modname )
4566 call log_dbg( ltag_info //
"The agent is now in [" // &
4567 tostr(this_agent%find_environment()) //
"] environment: "// &
4568 trim(global_habitats_available( &
4569 this_agent%find_environment())%get_label()), &
4577 call this_agent%set_mass( &
4578 value_set = this_agent%get_mass() - &
4579 this_agent%cost_swim(exponent= &
4580 swimming_cost_exponent_laminar), &
4581 update_history = .true. )
4588 call this_agent%set_length( value_set = this_agent%get_length(), &
4589 update_history = .true. )
4594 call this_agent%energy_update()
4596 call log_dbg( ltag_info //
"Updated mass: " // &
4597 tostr(this_agent%get_mass()) // &
4598 ", body length: " // tostr(this_agent%get_length()) // &
4599 ", energy: " // tostr(this_agent%get_energy()), &
4604 if (this_agent%starved_death())
call this_agent%dies()
4656 pure function hope( baseline, memory_old, memory_new, &
4657 zero_hope, maximum_hope, raw_grid_x, raw_grid_y) &
4658 result(expected_value)
4661 real(srp),
intent(in) :: baseline
4664 real(srp),
intent(in) :: memory_old
4667 real(srp),
intent(in) :: memory_new
4670 real(srp),
optional,
intent(in) :: zero_hope
4673 real(srp),
optional,
intent(in) :: maximum_hope
4677 real(srp),
dimension(:),
optional,
intent(in) :: raw_grid_x
4681 real(srp),
dimension(:),
optional,
intent(in) :: raw_grid_y
4695 real(srp) :: expected_value
4699 real(srp) :: memory_ratio
4706 integer,
parameter :: hope_func_grid_dim = 3
4707 real(srp),
dimension(HOPE_FUNC_GRID_DIM) :: hope_func_grid_abscissa, &
4708 hope_func_grid_ordinate
4717 if (memory_old < zero)
then
4718 if (
present(raw_grid_x) .and.
present(raw_grid_y))
then
4719 memory_ratio = maxval(raw_grid_x)
4720 else if (
present(zero_hope) .and.
present(maximum_hope))
then
4721 memory_ratio = zero_hope
4723 expected_value = missing
4731 elseif (memory_old < zero .and. memory_new < zero)
then
4732 memory_ratio = 1.0_srp
4734 memory_ratio = memory_new / memory_old
4737 provide_raw_grid:
if (
present(raw_grid_x) .and.
present(raw_grid_y))
then
4738 expected_value = baseline * ddpinterpol( raw_grid_x, &
4744 end if provide_raw_grid
4752 provide_scalars:
if (
present(zero_hope) .and.
present(maximum_hope))
then
4753 hope_func_grid_abscissa = [ 0.0_srp, 1.00_srp, zero_hope ]
4754 hope_func_grid_ordinate = [ maximum_hope, 1.00_srp, zero ]
4761 expected_value = baseline * ddpinterpol( hope_func_grid_abscissa, &
4762 hope_func_grid_ordinate, &
4766 end if provide_scalars
4772 expected_value = missing
4782 result(depth_walk_out)
4784 real(srp),
intent(in) :: length
4788 real(srp),
intent(in),
optional :: walk_factor
4790 real(srp) :: depth_walk_out
4796 if (
present(walk_factor))
then
4797 depth_walk_out = length * walk_factor
4799 depth_walk_out = length * up_down_walk_step_stdlength_factor
4813 this%label =
"GO_DOWN_DEPTH"
4816 this%is_active = .false.
4819 call this%expectancy%init()
4820 this%arousal_expected = 0.0_srp
4823 this%distance = missing
4826 this%decrement_mass_cost = missing
4827 this%expected_food_gain = missing
4828 this%expected_consp_number = unknown
4829 this%expected_predation_risk = missing
4839 predict_window_food, time_step_model)
4843 class(appraisal),
intent(in) :: this_agent
4845 real(SRP),
intent(in) :: max_depth
4848 real(SRP),
intent(in),
optional :: depth_walk
4854 integer,
optional,
intent(in) :: predict_window_food
4857 integer,
optional,
intent(in) :: time_step_model
4860 real(SRP) :: depth_walk_here
4863 integer :: predict_window_food_here, time_step_model_here
4869 real(SRP),
parameter :: WEIGHT_DIRECT = predation_risk_weight_immediate
4877 integer,
parameter :: MEM_WIND = history_size_perception
4882 if (
present(depth_walk))
then
4883 depth_walk_here = depth_walk
4897 if (
present(predict_window_food))
then
4898 predict_window_food_here = predict_window_food
4900 predict_window_food_here = floor( history_size_perception * &
4901 history_perception_window_food )
4906 if (
present(time_step_model))
then
4907 time_step_model_here = time_step_model
4909 time_step_model_here = global_time_step_model_current
4922 if (this_agent%dpos() + depth_walk_here >= max_depth ) &
4923 depth_walk_here = max( 0.0_srp, &
4924 max_depth - this_agent%dpos() - zero )
4928 this%distance = depth_walk_here
4936 this%decrement_mass_cost = swimming_cost_factor_buoyancy_down * &
4937 this_agent%cost_swim( distance=depth_walk_here, &
4938 exponent=swimming_cost_exponent_laminar )
4943 this%expected_consp_number = this_agent%consp_below()
4950 this%expected_predation_risk = &
4951 predation_risk_backend( &
4952 this_agent%pred_below(), &
4953 this_agent%memory_stack%get_pred_mean(mem_wind),&
4962 this%expected_food_gain = this_agent%food_mass_below() * &
4963 this_agent%food_probability_capture_subjective( &
4964 predict_window_food_here, time_step_model_here )
4973 max_depth, environments, &
4974 time_step_model, rescale_max_motivation )
4978 class(appraisal),
intent(in) :: this_agent
4981 real(SRP),
intent(in),
optional :: depth_walk
4983 real(SRP),
intent(in),
optional :: max_depth
4988 class(environment),
dimension(:),
optional,
intent(in) :: environments
4991 integer,
optional,
intent(in) :: time_step_model
4996 real(SRP),
optional,
intent(in) :: rescale_max_motivation
4999 real(SRP) :: depth_walk_here, max_depth_here
5002 integer :: time_step_model_here
5005 real(SRP) :: target_depth
5009 type(food_item) :: expected_food_item
5012 type(spatial) :: expected_food_item_xyz
5015 real(SRP) :: expect_distance_food
5018 real(SRP) :: expect_mass_increment_from_food
5021 real(SRP) :: expect_stomach_increment_from_food
5025 integer :: n_food_items_below
5028 real(SRP) :: max_motivation
5034 integer :: expect_food_perc_override
5038 real(SRP) :: expect_depth_perc_override
5042 real(SRP) :: expect_light_perc_override
5046 real(SRP) :: expect_mass_perc_override
5050 real(SRP) :: expect_stomach_perc_override
5053 real(SRP) :: agent_stomach
5057 real(SRP) :: expect_energy_perc_override
5061 real(SRP) :: expected_probability_capture
5065 integer :: expect_conspecicifc_perc_override
5070 real(SRP) :: expect_predator_perc_override
5073 character(len=*),
parameter :: PROCNAME = &
5074 "(go_down_motivations_expect)"
5080 if (
present(depth_walk))
then
5081 depth_walk_here = depth_walk
5101 max_depth_here = missing
5103 if (
present(environments))
then
5111 environments(this_agent%find_environment(environments))%depth_max()
5121 max_depth_here = global_habitats_available( &
5122 this_agent%find_environment( &
5123 global_habitats_available) &
5129 if (
present(max_depth)) max_depth_here = max_depth
5134 if (max_depth_here .feq. missing) &
5135 max_depth_here = max( 0.0_srp, this_agent%dpos() )
5136 end block get_maxdepth
5141 if (this_agent%dpos() + depth_walk_here >= max_depth_here ) &
5142 depth_walk_here = max( 0.0_srp, &
5143 max_depth_here - this_agent%dpos() - zero )
5147 if (
present(time_step_model))
then
5148 time_step_model_here = time_step_model
5150 time_step_model_here = global_time_step_model_current
5155 n_food_items_below = this_agent%food_items_below()
5161 if ( n_food_items_below > 0 )
then
5162 expect_distance_food = this_agent%food_dist_below()
5169 expect_distance_food = depth_walk_here
5186 call this%do_this( this_agent = this_agent, &
5187 max_depth = max_depth_here, &
5188 depth_walk = depth_walk_here, &
5189 time_step_model = time_step_model_here )
5194 target_depth = this_agent%dpos() + this%distance
5204 call expected_food_item_xyz%position( &
5205 spatial(this_agent%xpos(), &
5206 this_agent%ypos(), &
5215 call expected_food_item%make( &
5216 location=expected_food_item_xyz, &
5217 size=mass2size_food(this%expected_food_gain),&
5228 expected_probability_capture = &
5229 expected_food_item%capture_probability( &
5230 distance=expect_distance_food, &
5231 time_step_model=time_step_model_here )
5241 expect_mass_increment_from_food = &
5242 this_agent%food_fitting(expected_food_item, expect_distance_food) &
5243 * expected_probability_capture
5248 expect_stomach_increment_from_food = &
5249 max(0.0_srp, expect_mass_increment_from_food)
5256 expect_mass_perc_override = max( zero, &
5257 this_agent%get_mass() - &
5258 this_agent%living_cost() - &
5259 this%decrement_mass_cost + &
5260 expect_mass_increment_from_food )
5265 agent_stomach = this_agent%get_stom_content()
5266 expect_stomach_perc_override = &
5268 agent_stomach - stomach_emptify_backend(agent_stomach) + &
5269 expect_stomach_increment_from_food )
5274 expect_energy_perc_override = &
5275 energy_reserve( expect_mass_perc_override, this_agent%length() + &
5276 this_agent%len_incr(expect_mass_increment_from_food) )
5282 expect_conspecicifc_perc_override = this%expected_consp_number
5287 expect_predator_perc_override = this%expected_predation_risk
5292 expect_food_perc_override = n_food_items_below
5295 expect_depth_perc_override = target_depth
5298 expect_light_perc_override = &
5299 light_depth(depth=expect_depth_perc_override, &
5301 light_surface(tstep=time_step_model_here, &
5302 is_stochastic=daylight_stochastic) )
5327 call this%expectancy%hunger%percept_component%motivation_components &
5330 param_gp_matrix_light = light_hunger_genotype_neuronal, &
5331 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
5332 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
5333 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
5334 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
5335 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
5336 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
5337 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
5338 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
5339 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
5340 param_gp_matrix_age = age_hunger_genotype_neuronal, &
5341 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
5343 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
5344 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
5345 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
5346 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
5347 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
5348 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
5349 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
5350 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
5351 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
5352 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
5353 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
5354 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
5359 perception_override_light = expect_light_perc_override, &
5360 perception_override_depth = expect_depth_perc_override, &
5361 perception_override_food_dir = real(expect_food_perc_override, srp), &
5362 perception_override_predator = expect_predator_perc_override, &
5363 perception_override_stomach = expect_stomach_perc_override, &
5364 perception_override_bodymass = expect_mass_perc_override, &
5365 perception_override_energy = expect_energy_perc_override &
5377 call this%expectancy%fear_defence%percept_component%motivation_components &
5380 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
5381 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
5382 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
5383 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
5384 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
5385 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
5386 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
5387 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
5388 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
5389 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
5390 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
5391 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
5393 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
5394 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
5395 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
5396 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
5397 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
5398 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
5399 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
5400 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
5401 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
5402 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
5403 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
5404 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
5408 perception_override_light = expect_light_perc_override, &
5409 perception_override_depth = expect_depth_perc_override, &
5410 perception_override_food_dir = real(expect_food_perc_override, srp), &
5411 perception_override_predator = expect_predator_perc_override, &
5412 perception_override_stomach = expect_stomach_perc_override, &
5413 perception_override_bodymass = expect_mass_perc_override, &
5414 perception_override_energy = expect_energy_perc_override &
5420 call this%expectancy%reproduction%percept_component%motivation_components &
5423 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
5424 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
5425 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
5426 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
5427 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
5428 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
5429 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
5430 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
5431 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
5432 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
5433 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
5434 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
5436 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
5437 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
5438 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
5439 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
5440 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
5441 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
5442 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
5443 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
5444 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
5445 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
5446 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
5447 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
5451 perception_override_light = expect_light_perc_override, &
5452 perception_override_depth = expect_depth_perc_override, &
5453 perception_override_food_dir = real(expect_food_perc_override, srp), &
5454 perception_override_predator = expect_predator_perc_override, &
5455 perception_override_stomach = expect_stomach_perc_override, &
5456 perception_override_bodymass = expect_mass_perc_override, &
5457 perception_override_energy = expect_energy_perc_override &
5463 if (
present(rescale_max_motivation))
then
5466 max_motivation = rescale_max_motivation
5469 max_motivation = this%expectancy%max_perception()
5476 call this%attention_transfer(this_agent)
5479 call this%expectancy%motivation_primary_calc(max_motivation)
5482 call log_dbg( ltag_info //
"Primary motivations: " // &
5484 tostr(this%expectancy%hunger%motivation_prim) // &
5485 ", fear_defence: " // &
5486 tostr(this%expectancy%fear_defence%motivation_prim) // &
5487 ", reproduce: " // &
5488 tostr(this%expectancy%reproduction%motivation_prim), &
5493 call this%expectancy%modulation_none()
5499 this%arousal_expected = this%expectancy%max_final()
5503 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
5517 max_depth, environments, depth_walk )
5521 class(appraisal),
intent(inout) :: this_agent
5523 real(SRP),
optional,
intent(in) :: max_depth
5528 class(environment),
dimension(:),
optional,
intent(in) :: environments
5531 real(SRP),
intent(in),
optional :: depth_walk
5534 real(SRP) :: depth_walk_here, max_depth_here
5540 if (
present(depth_walk))
then
5541 depth_walk_here = depth_walk
5560 max_depth_here = missing
5562 if (
present(environments))
then
5570 environments(this_agent%find_environment(environments))%depth_max()
5580 max_depth_here = global_habitats_available( &
5581 this_agent%find_environment( &
5582 global_habitats_available) &
5588 if (
present(max_depth)) max_depth_here = max_depth
5594 if (max_depth_here .feq. missing) &
5595 max_depth_here = max( 0.0_srp, this_agent%dpos() )
5596 end block get_maxdepth
5604 call this%do_this(this_agent = this_agent , &
5605 max_depth = max_depth_here, depth_walk = depth_walk_here )
5611 call this_agent%position( spatial( this_agent%xpos(), &
5612 this_agent%ypos(), &
5613 this_agent%dpos() + this%distance) )
5618 call this_agent%set_mass( value_set = this_agent%get_mass() - &
5619 this%decrement_mass_cost, &
5620 update_history = .true. )
5626 call this_agent%set_length( value_set = this_agent%get_length(), &
5627 update_history = .true. )
5631 call this_agent%energy_update()
5635 if (this_agent%starved_death())
call this_agent%dies()
5651 this%label =
"GO_UP_DEPTH"
5654 this%is_active = .false.
5657 call this%expectancy%init()
5658 this%arousal_expected = 0.0_srp
5661 this%distance = missing
5664 this%decrement_mass_cost = missing
5665 this%expected_food_gain = missing
5666 this%expected_consp_number = unknown
5667 this%expected_predation_risk = missing
5677 predict_window_food, time_step_model)
5681 class(appraisal),
intent(in) :: this_agent
5683 real(SRP),
intent(in) :: min_depth
5686 real(SRP),
intent(in),
optional :: depth_walk
5692 integer,
optional,
intent(in) :: predict_window_food
5695 integer,
optional,
intent(in) :: time_step_model
5698 real(SRP) :: depth_walk_here
5701 integer :: predict_window_food_here, time_step_model_here
5707 real(SRP),
parameter :: WEIGHT_DIRECT = predation_risk_weight_immediate
5715 integer,
parameter :: MEM_WIND = history_size_perception
5720 if (
present(depth_walk))
then
5721 depth_walk_here = depth_walk
5735 if (
present(predict_window_food))
then
5736 predict_window_food_here = predict_window_food
5738 predict_window_food_here = floor( history_size_perception * &
5739 history_perception_window_food )
5744 if (
present(time_step_model))
then
5745 time_step_model_here = time_step_model
5747 time_step_model_here = global_time_step_model_current
5760 if (this_agent%dpos() - depth_walk_here <= min_depth ) &
5761 depth_walk_here = max( 0.0_srp, &
5762 this_agent%dpos() - min_depth - zero )
5766 this%distance = depth_walk_here
5774 this%decrement_mass_cost = swimming_cost_factor_buoyancy_up * &
5775 this_agent%cost_swim( distance=depth_walk_here, &
5776 exponent=swimming_cost_exponent_laminar )
5781 this%expected_consp_number = this_agent%consp_above()
5784 this%expected_predation_risk = &
5785 predation_risk_backend( &
5786 this_agent%pred_above(), &
5787 this_agent%memory_stack%get_pred_mean(mem_wind),&
5796 this%expected_food_gain = this_agent%food_mass_above() * &
5797 this_agent%food_probability_capture_subjective( &
5798 predict_window_food_here, time_step_model_here )
5807 min_depth, environments, &
5808 time_step_model, rescale_max_motivation)
5812 class(appraisal),
intent(in) :: this_agent
5815 real(SRP),
intent(in),
optional :: depth_walk
5817 real(SRP),
intent(in),
optional :: min_depth
5822 class(environment),
dimension(:),
optional,
intent(in) :: environments
5825 integer,
optional,
intent(in) :: time_step_model
5830 real(SRP),
optional,
intent(in) :: rescale_max_motivation
5833 real(SRP) :: depth_walk_here, min_depth_here
5836 integer :: time_step_model_here
5839 real(SRP) :: target_depth
5843 type(food_item) :: expected_food_item
5846 type(spatial) :: expected_food_item_xyz
5849 real(SRP) :: expect_distance_food
5852 real(SRP) :: expect_mass_increment_from_food
5855 real(SRP) :: expect_stomach_increment_from_food
5859 integer :: n_food_items_above
5862 real(SRP) :: max_motivation
5868 integer :: expect_food_perc_override
5872 real(SRP) :: expect_depth_perc_override
5876 real(SRP) :: expect_light_perc_override
5880 real(SRP) :: expect_mass_perc_override
5884 real(SRP) :: expect_stomach_perc_override
5887 real(SRP) :: agent_stomach
5891 real(SRP) :: expect_energy_perc_override
5895 real(SRP) :: expected_probability_capture
5899 integer :: expect_conspecicifc_perc_override
5904 real(SRP) :: expect_predator_perc_override
5907 character(len=*),
parameter :: PROCNAME = &
5908 "(go_up_motivations_expect)"
5914 if (
present(depth_walk))
then
5915 depth_walk_here = depth_walk
5934 min_depth_here = missing
5936 if (
present(environments))
then
5944 environments(this_agent%find_environment(environments))%depth_min()
5954 min_depth_here = global_habitats_available( &
5955 this_agent%find_environment( &
5956 global_habitats_available) &
5962 if (
present(min_depth)) min_depth_here = min_depth
5971 if (min_depth_here .feq. missing) &
5972 min_depth_here = max( 0.0_srp, this_agent%dpos() )
5973 end block get_maxdepth
5978 if (this_agent%dpos() - depth_walk_here <= min_depth_here ) &
5979 depth_walk_here = max( 0.0_srp, &
5980 this_agent%dpos() - min_depth_here - zero )
5984 if (
present(time_step_model))
then
5985 time_step_model_here = time_step_model
5987 time_step_model_here = global_time_step_model_current
5992 n_food_items_above = this_agent%food_items_above()
5998 if ( n_food_items_above > 0 )
then
5999 expect_distance_food = this_agent%food_dist_above()
6006 expect_distance_food = depth_walk_here
6023 call this%do_this(this_agent = this_agent, &
6024 min_depth = min_depth_here, depth_walk = depth_walk_here )
6029 target_depth = this_agent%dpos() - this%distance
6039 call expected_food_item_xyz%position( &
6040 spatial(this_agent%xpos(), &
6041 this_agent%ypos(), &
6050 call expected_food_item%make( &
6051 location=expected_food_item_xyz, &
6052 size=mass2size_food(this%expected_food_gain),&
6063 expected_probability_capture = &
6064 expected_food_item%capture_probability( &
6065 distance=expect_distance_food, &
6066 time_step_model=time_step_model_here )
6076 expect_mass_increment_from_food = &
6077 this_agent%food_fitting(expected_food_item, expect_distance_food) &
6078 * expected_probability_capture
6083 expect_stomach_increment_from_food = &
6084 max(0.0_srp, expect_mass_increment_from_food)
6091 expect_mass_perc_override = max( zero, &
6092 this_agent%get_mass() - &
6093 this_agent%living_cost() - &
6094 this%decrement_mass_cost + &
6095 expect_mass_increment_from_food )
6100 agent_stomach = this_agent%get_stom_content()
6101 expect_stomach_perc_override = &
6103 agent_stomach - stomach_emptify_backend(agent_stomach) + &
6104 expect_stomach_increment_from_food )
6109 expect_energy_perc_override = &
6110 energy_reserve( expect_mass_perc_override, this_agent%length() + &
6111 this_agent%len_incr(expect_mass_increment_from_food) )
6117 expect_conspecicifc_perc_override = this%expected_consp_number
6122 expect_predator_perc_override = this%expected_predation_risk
6127 expect_food_perc_override = n_food_items_above
6130 expect_depth_perc_override = target_depth
6133 expect_light_perc_override = &
6134 light_depth(depth=expect_depth_perc_override, &
6136 light_surface(tstep=time_step_model_here, &
6137 is_stochastic=daylight_stochastic) )
6162 call this%expectancy%hunger%percept_component%motivation_components &
6165 param_gp_matrix_light = light_hunger_genotype_neuronal, &
6166 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
6167 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
6168 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
6169 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
6170 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
6171 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
6172 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
6173 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
6174 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
6175 param_gp_matrix_age = age_hunger_genotype_neuronal, &
6176 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
6178 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
6179 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
6180 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
6181 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
6182 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
6183 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
6184 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
6185 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
6186 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
6187 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
6188 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
6189 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
6194 perception_override_light = expect_light_perc_override, &
6195 perception_override_depth = expect_depth_perc_override, &
6196 perception_override_food_dir = real(expect_food_perc_override, srp), &
6197 perception_override_predator = expect_predator_perc_override, &
6198 perception_override_stomach = expect_stomach_perc_override, &
6199 perception_override_bodymass = expect_mass_perc_override, &
6200 perception_override_energy = expect_energy_perc_override &
6212 call this%expectancy%fear_defence%percept_component%motivation_components &
6215 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
6216 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
6217 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
6218 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
6219 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
6220 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
6221 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
6222 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
6223 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
6224 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
6225 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
6226 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
6228 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
6229 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
6230 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
6231 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
6232 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
6233 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
6234 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
6235 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
6236 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
6237 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
6238 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
6239 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
6243 perception_override_light = expect_light_perc_override, &
6244 perception_override_depth = expect_depth_perc_override, &
6245 perception_override_food_dir = real(expect_food_perc_override, srp), &
6246 perception_override_predator = expect_predator_perc_override, &
6247 perception_override_stomach = expect_stomach_perc_override, &
6248 perception_override_bodymass = expect_mass_perc_override, &
6249 perception_override_energy = expect_energy_perc_override &
6255 call this%expectancy%reproduction%percept_component%motivation_components &
6258 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
6259 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
6260 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
6261 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
6262 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
6263 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
6264 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
6265 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
6266 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
6267 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
6268 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
6269 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
6271 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
6272 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
6273 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
6274 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
6275 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
6276 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
6277 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
6278 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
6279 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
6280 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
6281 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
6282 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
6286 perception_override_light = expect_light_perc_override, &
6287 perception_override_depth = expect_depth_perc_override, &
6288 perception_override_food_dir = real(expect_food_perc_override, srp), &
6289 perception_override_predator = expect_predator_perc_override, &
6290 perception_override_stomach = expect_stomach_perc_override, &
6291 perception_override_bodymass = expect_mass_perc_override, &
6292 perception_override_energy = expect_energy_perc_override &
6298 if (
present(rescale_max_motivation))
then
6301 max_motivation = rescale_max_motivation
6304 max_motivation = this%expectancy%max_perception()
6311 call this%attention_transfer(this_agent)
6314 call this%expectancy%motivation_primary_calc(max_motivation)
6317 call log_dbg( ltag_info //
"Primary motivations: " // &
6319 tostr(this%expectancy%hunger%motivation_prim) // &
6320 ", fear_defence: " // &
6321 tostr(this%expectancy%fear_defence%motivation_prim) // &
6322 ", reproduce: " // &
6323 tostr(this%expectancy%reproduction%motivation_prim), &
6328 call this%expectancy%modulation_none()
6334 this%arousal_expected = this%expectancy%max_final()
6338 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
6352 min_depth, environments, depth_walk )
6356 class(appraisal),
intent(inout) :: this_agent
6358 real(SRP),
optional,
intent(in) :: min_depth
6363 class(environment),
dimension(:),
optional,
intent(in) :: environments
6366 real(SRP),
intent(in),
optional :: depth_walk
6369 real(SRP) :: depth_walk_here, min_depth_here
6375 if (
present(depth_walk))
then
6376 depth_walk_here = depth_walk
6395 min_depth_here = missing
6397 if (
present(environments))
then
6405 environments(this_agent%find_environment(environments))%depth_min()
6415 min_depth_here = global_habitats_available( &
6416 this_agent%find_environment( &
6417 global_habitats_available) &
6423 if (
present(min_depth)) min_depth_here = min_depth
6432 if (min_depth_here .feq. missing) &
6433 min_depth_here = max( 0.0_srp, this_agent%dpos() )
6434 end block get_maxdepth
6442 call this%do_this(this_agent = this_agent , &
6443 min_depth = min_depth_here, depth_walk = depth_walk_here )
6449 call this_agent%position( spatial( this_agent%xpos(), &
6450 this_agent%ypos(), &
6451 this_agent%dpos() - this%distance) )
6456 call this_agent%set_mass( value_set = this_agent%get_mass() - &
6457 this%decrement_mass_cost, &
6458 update_history = .true. )
6464 call this_agent%set_length( value_set = this_agent%get_length(), &
6465 update_history = .true. )
6469 call this_agent%energy_update()
6473 if (this_agent%starved_death())
call this_agent%dies()
6489 this%label =
"DEBUG_BASE"
6493 this%is_active = .false.
6496 call this%expectancy%init()
6497 this%arousal_expected = 0.0_srp
6506 rescale_max_motivation)
6510 class(appraisal),
intent(in) :: this_agent
6513 integer,
optional,
intent(in) :: time_step_model
6518 real(SRP),
optional,
intent(in) :: rescale_max_motivation
6521 integer :: time_step_model_here
6524 real(SRP) :: max_motivation
6527 character(len=*),
parameter :: PROCNAME =
"(debug_base_motivations_expect)"
6533 if (
present(time_step_model))
then
6534 time_step_model_here = time_step_model
6536 time_step_model_here = global_time_step_model_current
6546 call this%expectancy%hunger%percept_component%motivation_components &
6549 param_gp_matrix_light = light_hunger_genotype_neuronal, &
6550 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
6551 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
6552 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
6553 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
6554 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
6555 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
6556 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
6557 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
6558 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
6559 param_gp_matrix_age = age_hunger_genotype_neuronal, &
6560 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
6562 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
6563 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
6564 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
6565 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
6566 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
6567 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
6568 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
6569 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
6570 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
6571 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
6572 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
6573 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv &
6579 call this%expectancy%fear_defence%percept_component%motivation_components &
6582 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
6583 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
6584 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
6585 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
6586 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
6587 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
6588 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
6589 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
6590 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
6591 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
6592 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
6593 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
6595 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
6596 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
6597 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
6598 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
6599 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
6600 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
6601 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
6602 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
6603 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
6604 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
6605 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
6606 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv&
6612 call this%expectancy%reproduction%percept_component%motivation_components &
6615 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
6616 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
6617 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
6618 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
6619 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
6620 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
6621 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
6622 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
6623 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
6624 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
6625 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
6626 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
6628 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
6629 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
6630 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
6631 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
6632 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
6633 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
6634 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
6635 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
6636 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
6637 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
6638 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
6639 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv &
6645 if (
present(rescale_max_motivation))
then
6648 max_motivation = rescale_max_motivation
6651 max_motivation = this%expectancy%max_perception()
6658 call this%attention_transfer(this_agent)
6661 call this%expectancy%motivation_primary_calc(max_motivation)
6664 call log_dbg( ltag_info //
"Primary motivations: " // &
6666 tostr(this%expectancy%hunger%motivation_prim) // &
6667 ", fear_defence: " // &
6668 tostr(this%expectancy%fear_defence%motivation_prim) // &
6669 ", reproduce: " // &
6670 tostr(this%expectancy%reproduction%motivation_prim), &
6679 call this%expectancy%modulation_none()
6684 this%arousal_expected = this%expectancy%max_final()
6688 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
6726 time_step_model, distance_food_item, capture_prob, is_captured)
6728 class(
eat_food),
intent(inout) :: this
6730 class(appraisal),
intent(in) :: this_agent
6732 class(food_item),
intent(in) :: food_item_eaten
6736 integer,
optional,
intent(in) :: time_step_model
6738 real(SRP),
optional,
intent(in) :: distance_food_item
6742 real(SRP),
optional,
intent(in) :: capture_prob
6746 logical,
optional,
intent(out) :: is_captured
6749 character(len=*),
parameter :: PROCNAME=
"(eat_food_item_do_this)"
6752 real(SRP) :: capture_prob_here, distance_food_item_here
6755 integer :: time_step_model_here
6763 if (food_item_eaten%is_unavailable())
then
6764 call log_dbg( ltag_warn // procname //
", Cannot capture food item " // &
6765 "as it is not available (has been already eaten?). Check code.")
6770 if (
present(time_step_model))
then
6771 time_step_model_here = time_step_model
6773 time_step_model_here = global_time_step_model_current
6778 if (
present(distance_food_item))
then
6779 distance_food_item_here = distance_food_item
6781 distance_food_item_here = this_agent%distance(food_item_eaten)
6792 if (
present(capture_prob))
then
6793 capture_prob_here = capture_prob
6799 capture_prob_here = &
6800 food_item_eaten%capture_probability( &
6801 distance = distance_food_item_here, &
6802 time_step_model = time_step_model_here )
6816 captured:
if (food_item_eaten%capture_success(capture_prob_here))
then
6819 if (
present(is_captured)) is_captured = .true.
6824 this%mass_increment_from_food = this%mass_increment_from_food + &
6825 this_agent%food_fitting(food_item_eaten, distance_food_item_here)
6826 this%stomach_increment_from_food = this%mass_increment_from_food
6830 if (
present(is_captured)) is_captured = .false.
6836 this%mass_increment_from_food = this%mass_increment_from_food - &
6837 this_agent%food_process_cost(food_item_eaten, distance_food_item_here)
6838 this%stomach_increment_from_food = 0.0_srp
6848 time_step_model, distance_food_item, capture_prob, &
6849 rescale_max_motivation )
6852 class(
eat_food),
intent(inout) :: this
6854 class(appraisal),
intent(in) :: this_agent
6856 class(food_item),
intent(in) :: food_item_eaten
6860 integer,
optional,
intent(in) :: time_step_model
6863 real(SRP),
optional,
intent(in) :: distance_food_item
6867 real(SRP),
optional,
intent(in) :: capture_prob
6873 real(SRP),
optional,
intent(in) :: rescale_max_motivation
6876 real(SRP) :: capture_prob_here, distance_food_item_here
6879 integer :: time_step_model_here
6882 real(SRP) :: max_motivation
6893 real(SRP),
parameter :: FOOD_CAPTURE_PROB = 1.1_srp
6899 real(SRP) :: stomach_increment_from_food_perc
6903 real(SRP) :: stomach_overrride_perc
6909 real(SRP) :: mass_increment_from_food_perc
6913 real(SRP) :: bodymass_override_perc
6918 real(SRP) :: energy_override_perc
6924 real(SRP) :: capture_prob_intrinsic
6927 real(SRP) :: agent_stomach
6930 character(len=*),
parameter :: PROCNAME = &
6931 "(eat_food_item_motivations_expect)"
6937 if (
present(time_step_model))
then
6938 time_step_model_here = time_step_model
6940 time_step_model_here = global_time_step_model_current
6945 if (
present(distance_food_item))
then
6946 distance_food_item_here = distance_food_item
6948 distance_food_item_here = this_agent%distance(food_item_eaten)
6959 if (
present(capture_prob))
then
6960 capture_prob_here = capture_prob
6968 capture_prob_here = food_capture_prob
6974 capture_prob_intrinsic = &
6975 food_item_eaten%capture_probability(distance=distance_food_item_here, &
6976 time_step_model=time_step_model_here)
6979 call log_dbg( ltag_info //
"Distance to the food item: " // &
6980 tostr(distance_food_item_here) // &
6981 ", intrinsic capture probability: " // &
6982 tostr(capture_prob_intrinsic) //
".", procname,
modname )
6996 call this%do_this( this_agent = this_agent, &
6997 food_item_eaten = food_item_eaten, &
6998 distance_food_item = distance_food_item_here, &
6999 capture_prob = capture_prob_here )
7006 stomach_increment_from_food_perc = this%stomach_increment_from_food * &
7007 capture_prob_intrinsic
7009 mass_increment_from_food_perc = this%mass_increment_from_food * &
7010 capture_prob_intrinsic
7013 call log_dbg( ltag_info //
"Raw stomach increment: " // &
7014 tostr(this%stomach_increment_from_food) // &
7015 ", raw mass increment: " // &
7016 tostr(this%mass_increment_from_food) //
".", &
7018 call log_dbg( ltag_info //
"Subjective stomach increment (weighted " // &
7019 "by intrinsic probability): " // &
7020 tostr(stomach_increment_from_food_perc) // &
7021 ", subjective mass increment (weighted by intrinsic " // &
7022 "probability): " // tostr(mass_increment_from_food_perc), &
7030 agent_stomach = this_agent%get_stom_content()
7031 stomach_overrride_perc = &
7034 stomach_emptify_backend(agent_stomach) + &
7035 stomach_increment_from_food_perc )
7037 bodymass_override_perc = &
7039 this_agent%mass() - &
7040 this_agent%living_cost() + &
7041 mass_increment_from_food_perc )
7043 energy_override_perc = &
7044 energy_reserve( bodymass_override_perc, this_agent%length() + &
7045 this_agent%len_incr(mass_increment_from_food_perc)&
7062 call this%expectancy%hunger%percept_component%motivation_components &
7065 param_gp_matrix_light = light_hunger_genotype_neuronal, &
7066 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
7067 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
7068 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
7069 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
7070 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
7071 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
7072 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
7073 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
7074 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
7075 param_gp_matrix_age = age_hunger_genotype_neuronal, &
7076 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
7078 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
7079 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
7080 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
7081 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
7082 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
7083 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
7084 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
7085 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
7086 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
7087 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
7088 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
7089 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
7094 perception_override_stomach = stomach_overrride_perc, &
7095 perception_override_bodymass = bodymass_override_perc, &
7096 perception_override_energy = energy_override_perc &
7113 call this%expectancy%fear_defence%percept_component%motivation_components &
7116 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
7117 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
7118 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
7119 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
7120 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
7121 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
7122 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
7123 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
7124 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
7125 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
7126 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
7127 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
7129 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
7130 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
7131 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
7132 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
7133 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
7134 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
7135 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
7136 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
7137 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
7138 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
7139 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
7140 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
7144 perception_override_stomach = stomach_overrride_perc, &
7145 perception_override_bodymass = bodymass_override_perc, &
7146 perception_override_energy = energy_override_perc &
7152 call this%expectancy%reproduction%percept_component%motivation_components &
7155 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
7156 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
7157 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
7158 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
7159 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
7160 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
7161 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
7162 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
7163 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
7164 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
7165 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
7166 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
7168 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
7169 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
7170 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
7171 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
7172 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
7173 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
7174 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
7175 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
7176 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
7177 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
7178 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
7179 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
7183 perception_override_stomach = stomach_overrride_perc, &
7184 perception_override_bodymass = bodymass_override_perc, &
7185 perception_override_energy = energy_override_perc &
7191 if (
present(rescale_max_motivation))
then
7194 max_motivation = rescale_max_motivation
7197 max_motivation = this%expectancy%max_perception()
7204 call this%attention_transfer(this_agent)
7207 call this%expectancy%motivation_primary_calc(max_motivation)
7210 call log_dbg( ltag_info //
"Primary motivations: " // &
7212 tostr(this%expectancy%hunger%motivation_prim) // &
7213 ", fear_defence: " // &
7214 tostr(this%expectancy%fear_defence%motivation_prim) // &
7215 ", reproduce: " // &
7216 tostr(this%expectancy%reproduction%motivation_prim), &
7225 call this%expectancy%modulation_none()
7230 this%arousal_expected = this%expectancy%max_final()
7234 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
7249 food_resource_real, eat_is_success)
7251 class(
eat_food),
intent(inout) :: this
7253 class(appraisal),
intent(inout) :: this_agent
7255 class(food_item),
intent(inout) :: food_item_eaten
7264 class(food_resource),
intent(inout) :: food_resource_real
7267 logical,
optional,
intent(out) :: eat_is_success
7270 character(len=*),
parameter :: PROCNAME =
"(eat_food_item_do_execute)"
7273 logical :: is_captured
7276 integer :: food_item_real_iid
7284 error_nofood_check:
if (food_item_eaten%is_unavailable())
then
7285 call log_dbg( ltag_warn // procname //
", Cannot capture food " // &
7286 "item as it is not available (has been already eaten?). Check code.")
7288 end if error_nofood_check
7289 error_dead_check:
if (this_agent%is_dead())
then
7290 call log_dbg( ltag_warn // procname //
"Agent is dead, cannot " // &
7291 "enter this subroutine. Check code.")
7293 end if error_dead_check
7309 call this%do_this( this_agent = this_agent, &
7310 food_item_eaten = food_item_eaten, &
7311 is_captured = is_captured)
7315 if (
present(eat_is_success)) eat_is_success = is_captured
7319 call log_dbg(
"INFO: Body mass increment from food item: " // &
7320 tostr(this%mass_increment_from_food) // &
7321 " with raw stomach content increment: " // &
7322 tostr(this%stomach_increment_from_food) // &
7323 "; food item processed has size: " // &
7324 tostr(food_item_eaten%get_size()) // &
7325 " and mass: " // tostr(food_item_eaten%get_mass()), &
7338 call this_agent%len_grow(this%mass_increment_from_food)
7349 call this_agent%mass_grow(this%mass_increment_from_food)
7353 call this_agent%stomach_increment(this%stomach_increment_from_food)
7357 call this_agent%energy_update()
7366 if (this_agent%starved_death())
then
7367 call this_agent%dies()
7368 call log_dbg( ltag_info //
"The agent dies of starvation.", &
7377 captured:
if (is_captured)
then
7379 call food_item_eaten%disappear()
7389 food_item_real_iid = food_item_eaten%get_iid()
7392 out_bound:
if ( food_item_real_iid>food_resource_real%abundance() )
then
7393 call log_msg( ltag_error //
"ID of the food item " // &
7394 tostr(food_item_real_iid) // &
7395 " is outside of the valid range " // &
7396 tostr(food_resource_real%abundance()) // &
7397 ", array size is " // &
7398 tostr(
size(food_resource_real%food) ) //
" in " // &
7399 procname //
". Cannot call (disappear) on this item!" )
7401 call log_dbg( ltag_info //
"The food item " // &
7402 tostr(food_item_real_iid) // &
7403 " from the resource " // &
7404 trim( food_resource_real%get_label() ) // &
7405 " (array size " // &
7406 tostr(
size(food_resource_real%food) ) // &
7408 tostr(food_resource_real%abundance()) // &
7409 " ) is marked eaten: (disappear) method called", &
7411 call food_resource_real%food(food_item_real_iid)%disappear()
7416 call log_dbg(ltag_info //
"Food item capture SUCCESS.", &
7418 call log_dbg(ltag_info // &
7419 "Food item " // tostr(food_item_eaten%get_iid()) // &
7420 " in the physical resource " // &
7421 trim(food_resource_real%food_label) //
" (real iid=" // &
7422 tostr(food_resource_real%food(food_item_real_iid)%get_iid()) // &
7423 ") is now eaten and unavailable; size: " // &
7424 tostr(food_item_eaten%get_size()) // &
7425 ", mass: " // tostr(food_item_eaten%get_mass()) // &
7426 " (physical resource size: " // &
7427 tostr(food_resource_real%food(food_item_real_iid)%get_size()) //&
7429 tostr(food_resource_real%food(food_item_real_iid)%get_mass()) //&
7431 call log_dbg(ltag_info //
"Check food item final status is " // &
7432 tostr(food_item_eaten%is_available()) // &
7433 ", in the physical resource: " // &
7434 tostr(food_resource_real%food(food_item_real_iid)% &
7437 food_item_real_iid = 0
7440 call log_dbg( ltag_info //
"Food item capture FAILED for item " // &
7441 tostr(food_item_eaten%get_iid()), procname,
modname )
7454 real(srp),
parameter :: null_srp = 0.0_srp
7459 this%label =
"REPRODUCE"
7462 this%is_active = .false.
7465 call this%expectancy%init()
7467 this%arousal_expected = null_srp
7474 this%reprfact_decrement_testosterone = null_srp
7475 this%reprfact_decrement_estrogen = null_srp
7476 this%decrement_mass = null_srp
7486 class(appraisal),
intent(in) :: this
7492 integer :: n_conspecifics_perception
7493 integer :: n_males_high_t_perception, n_females_perception
7498 n_conspecifics_perception = this%perceive_consp%get_count()
7501 n_males_high_t_perception = 0
7502 n_females_perception = 0
7508 check_is_alone:
if ( .NOT. this%has_consp() )
then
7511 end if check_is_alone
7515 if (this%is_female())
then
7528 do concurrent(i=1:n_conspecifics_perception)
7529 if ( this%perceive_consp%conspecifics_seen(i)%is_male() )
then
7530 if ( this%testosterone_get() < 1. ) &
7531 n_males_high_t_perception = n_males_high_t_perception + 1
7533 n_females_perception = n_females_perception + 1
7541 max_num = floor( real(n_females_perception, srp) / &
7542 (1.0_srp + real(n_males_high_t_perception, srp)) )
7565 class(appraisal),
intent(in) :: this_agent
7568 real(SRP),
optional,
intent(in) :: p_reproduction
7571 logical,
optional,
intent(out) :: is_reproduce
7574 real(SRP) :: p_reproduction_here
7589 check_mature:
if ( .not. this_agent%is_ready_reproduce() )
then
7590 this%reprfact_decrement_testosterone = 0.0_srp
7591 this%reprfact_decrement_estrogen = 0.0_srp
7592 if (
present(is_reproduce)) is_reproduce = .false.
7601 check_is_alone:
if ( .NOT. this_agent%has_consp() )
then
7602 this%reprfact_decrement_testosterone = 0.0_srp
7603 this%reprfact_decrement_estrogen = 0.0_srp
7604 if (
present(is_reproduce)) is_reproduce = .false.
7606 end if check_is_alone
7613 if (
present(p_reproduction))
then
7614 p_reproduction_here = p_reproduction
7616 p_reproduction_here = this_agent%probability_reproduction()
7621 if ( this_agent%reproduction_success() )
then
7637 if ( this_agent%is_male() )
then
7638 this%reprfact_decrement_testosterone = &
7640 if ( this_agent%testosterone_get() - &
7641 this%reprfact_decrement_testosterone < &
7642 this_agent%testosterone_base_get() ) &
7643 this%reprfact_decrement_testosterone = &
7644 this_agent%testosterone_get() - &
7645 this_agent%testosterone_base_get()
7646 this%decrement_mass = this_agent%reproduction_cost()
7648 this%reprfact_decrement_estrogen = &
7650 if ( this_agent%estrogen_get() - &
7651 this%reprfact_decrement_estrogen < &
7652 this_agent%estrogen_base_get() ) &
7653 this%reprfact_decrement_estrogen = &
7654 this_agent%estrogen_get() - &
7655 this_agent%estrogen_base_get()
7656 this%decrement_mass = this_agent%reproduction_cost()
7659 if (
present(is_reproduce)) is_reproduce = .true.
7665 this%reprfact_decrement_testosterone = 0.0_srp
7666 this%reprfact_decrement_estrogen = 0.0_srp
7667 this%decrement_mass = this_agent%reproduction_cost_unsuccess()
7669 if (
present(is_reproduce)) is_reproduce = .false.
7679 real(srp) :: decrement
7682 real(srp),
parameter :: reprfac_decrement_factor_reproduction = 0.3_srp
7683 decrement = reprfac_decrement_factor_reproduction
7693 reprod_prob, non_stochastic, rescale_max_motivation)
7697 class(appraisal),
intent(in) :: this_agent
7700 integer,
optional,
intent(in) :: time_step_model
7704 real(SRP),
optional,
intent(in) :: reprod_prob
7708 logical,
optional,
intent(in) :: non_stochastic
7713 real(SRP),
optional,
intent(in) :: rescale_max_motivation
7716 integer :: time_step_model_here
7719 real(SRP) :: reprod_prob_here
7722 real(SRP) :: max_motivation
7737 real(SRP),
parameter :: PROBABILITY_REPRODUCTION_BASE_DEF = 1.1_srp
7743 real(SRP) :: reproduction_prob_intrinsic
7752 real(SRP) :: reprfactor_percept
7759 real(SRP) :: body_mass_percept
7764 real(SRP) :: energy_override_perc
7767 character(len=*),
parameter :: PROCNAME =
"(reproduce_motivations_expect)"
7772 reproduction_prob_intrinsic = this_agent%probability_reproduction()
7777 if (
present(time_step_model))
then
7778 time_step_model_here = time_step_model
7780 time_step_model_here = global_time_step_model_current
7791 if (
present(reprod_prob))
then
7792 reprod_prob_here = reprod_prob
7796 reprod_prob_here = reproduction_prob_intrinsic
7807 if (
present(non_stochastic))
then
7808 if(non_stochastic) reprod_prob_here = probability_reproduction_base_def
7811 call log_dbg( ltag_info //
"Probability of peprodiuction: " // &
7812 tostr(reprod_prob_here) //
", P intrinsic: " // &
7813 tostr(reproduction_prob_intrinsic), procname,
modname )
7824 call this%do_this( this_agent = this_agent, &
7825 p_reproduction = reprod_prob_here )
7827 call log_dbg( ltag_info //
"Repfactor decrements: " // &
7828 tostr(this%reprfact_decrement_testosterone) //
"," // &
7829 tostr(this%reprfact_decrement_estrogen) // &
7830 ", mass decrement: " // tostr(this%decrement_mass), &
7848 if ( this_agent%is_male() )
then
7849 reprfactor_percept = this_agent%testosterone_get() &
7850 - this%reprfact_decrement_testosterone * &
7851 reproduction_prob_intrinsic
7853 reprfactor_percept = this_agent%estrogen_get() &
7854 - this%reprfact_decrement_estrogen * &
7855 reproduction_prob_intrinsic
7858 call log_dbg( ltag_info //
"Reproductive factor fake perception:" // &
7859 tostr(reprfactor_percept), procname,
modname )
7864 body_mass_percept = &
7866 this_agent%get_mass() - this_agent%living_cost() - &
7867 this%decrement_mass * reproduction_prob_intrinsic )
7874 energy_override_perc = energy_reserve( body_mass_percept, &
7875 this_agent%length() )
7889 call this%expectancy%hunger%percept_component%motivation_components &
7892 param_gp_matrix_light = light_hunger_genotype_neuronal, &
7893 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
7894 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
7895 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
7896 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
7897 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
7898 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
7899 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
7900 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
7901 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
7902 param_gp_matrix_age = age_hunger_genotype_neuronal, &
7903 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
7905 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
7906 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
7907 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
7908 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
7909 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
7910 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
7911 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
7912 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
7913 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
7914 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
7915 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
7916 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
7921 perception_override_reprfac = reprfactor_percept, &
7922 perception_override_bodymass = body_mass_percept, &
7923 perception_override_energy = energy_override_perc &
7938 call this%expectancy%fear_defence%percept_component%motivation_components &
7941 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
7942 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
7943 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
7944 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
7945 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
7946 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
7947 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
7948 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
7949 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
7950 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
7951 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
7952 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
7954 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
7955 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
7956 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
7957 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
7958 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
7959 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
7960 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
7961 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
7962 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
7963 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
7964 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
7965 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
7969 perception_override_reprfac = reprfactor_percept, &
7970 perception_override_bodymass = body_mass_percept, &
7971 perception_override_energy = energy_override_perc &
7977 call this%expectancy%reproduction%percept_component%motivation_components &
7980 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
7981 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
7982 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
7983 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
7984 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
7985 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
7986 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
7987 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
7988 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
7989 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
7990 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
7991 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
7993 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
7994 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
7995 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
7996 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
7997 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
7998 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
7999 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
8000 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
8001 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
8002 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
8003 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
8004 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
8008 perception_override_reprfac = reprfactor_percept, &
8009 perception_override_bodymass = body_mass_percept, &
8010 perception_override_energy = energy_override_perc &
8016 if (
present(rescale_max_motivation))
then
8019 max_motivation = rescale_max_motivation
8022 max_motivation = this%expectancy%max_perception()
8029 call this%attention_transfer(this_agent)
8032 call this%expectancy%motivation_primary_calc(max_motivation)
8035 call log_dbg( ltag_info //
"Primary motivations: " // &
8037 tostr(this%expectancy%hunger%motivation_prim) // &
8038 ", fear_defence: " // &
8039 tostr(this%expectancy%fear_defence%motivation_prim) // &
8040 ", reproduce: " // &
8041 tostr(this%expectancy%reproduction%motivation_prim), &
8050 call this%expectancy%modulation_none()
8055 this%arousal_expected = this%expectancy%max_final()
8059 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
8072 class(appraisal),
intent(inout) :: this_agent
8075 character(len=*),
parameter :: PROCNAME =
"(reproduce_do_execute)"
8078 logical :: is_reproduce
8083 real(SRP) :: body_mass_after
8090 if (.not. this_agent%has_consp())
then
8091 call log_dbg( ltag_warn // procname //
" Cannot reproduce as " // &
8092 "there are no conspecifics in perception. Check code.")
8095 if (this_agent%is_dead())
then
8096 call log_dbg( ltag_warn // procname //
" Agent is dead, cannot " // &
8097 "enter this subroutine. Check code.")
8110 body_mass_after = this_agent%get_mass() - this_agent%reproduction_cost()
8117 check_starved_after:
if ( is_starved( body_mass_after, &
8118 this_agent%stomach_content_mass, &
8119 this_agent%body_mass_birth, &
8120 this_agent%body_mass_maximum, &
8121 this_agent%energy_current, &
8122 this_agent%energy_maximum) )
then
8132 end if check_starved_after
8146 call this%do_this( this_agent = this_agent, &
8147 p_reproduction=this_agent%probability_reproduction(), &
8148 is_reproduce = is_reproduce)
8152 call log_dbg( ltag_info //
"Reproduction attempted, success is: " // &
8153 tostr(is_reproduce) // &
8154 " for agent " // this_agent%individ_label() )
8155 call log_dbg( ltag_info //
"Agent sex is: " // this_agent%label_sex() // &
8156 "(is male: " // tostr(this_agent%is_male()) //
"); " // &
8157 "testosterone decrement: " // &
8158 tostr(this%reprfact_decrement_testosterone) // &
8159 "; estrogen decrement: " // &
8160 tostr(this%reprfact_decrement_estrogen), procname,
modname )
8169 if ( .not. is_reproduce )
then
8181 call this_agent%reproductions_increment(add_repr=1)
8187 if ( this_agent%is_male() )
then
8188 call this_agent%testosterone_set( &
8189 value_set = max( this_agent%testosterone_base_get(), &
8190 this_agent%testosterone_get() - &
8191 this%reprfact_decrement_testosterone ), &
8192 update_history=.true. )
8194 call this_agent%estrogen_set( &
8195 value_set = max( this_agent%estrogen_base_get(), &
8196 this_agent%estrogen_get() - &
8197 this%reprfact_decrement_estrogen ), &
8198 update_history=.true. )
8205 call this_agent%set_mass( value_set = body_mass_after, &
8206 update_history = .true. )
8212 call this_agent%set_length( value_set = this_agent%get_length(), &
8213 update_history = .true. )
8217 call this_agent%energy_update()
8221 if (this_agent%starved_death())
call this_agent%dies()
8244 call this_agent%set_mass( value_set = this_agent%get_mass() - &
8245 this_agent%reproduction_cost_unsuccess(), &
8246 update_history = .true. )
8249 call this_agent%set_length( value_set = this_agent%get_length(), &
8250 update_history = .true. )
8253 call this_agent%energy_update()
8268 predict_window_pred, predict_window_food, time_step_model)
8271 class(appraisal),
intent(in) :: this_agent
8277 real(SRP),
optional,
intent(in) :: distance
8281 real(SRP),
optional,
intent(in) :: distance_cv
8288 integer,
optional,
intent(in) :: predict_window_pred
8294 integer,
optional,
intent(in) :: predict_window_food
8297 integer,
optional,
intent(in) :: time_step_model
8300 integer :: time_step_model_here, predict_window_food_here, &
8301 predict_window_pred_here
8309 real(SRP) :: mean_n_food_memory_old, mean_n_food_memory_new
8317 real(SRP) :: mean_size_food_memory_old, mean_size_food_memory_new
8323 real(SRP) :: food_gain_memory_old, food_gain_memory_new
8328 real(SRP) :: food_gain_memory_baseline
8331 real(SRP) :: distance_baseline
8337 real(SRP),
parameter :: WEIGHT_DIRECT = predation_risk_weight_immediate
8341 real(SRP) :: mean_n_pred_memory_old, mean_n_pred_memory_new
8345 real(SRP) :: pred_dir_current, pred_current
8351 if (
present(time_step_model))
then
8352 time_step_model_here = time_step_model
8354 time_step_model_here = global_time_step_model_current
8363 if (
present(predict_window_pred))
then
8364 predict_window_pred_here= predict_window_pred
8366 predict_window_pred_here = floor( history_size_perception * &
8367 history_perception_window_pred )
8376 if (
present(predict_window_food))
then
8377 predict_window_food_here = predict_window_food
8379 predict_window_food_here = floor( history_size_perception * &
8380 history_perception_window_food )
8399 if (
present(distance))
then
8400 distance_baseline = distance
8402 distance_baseline = this_agent%get_length() * &
8403 walk_random_distance_default_factor
8408 this%distance = distance_baseline
8416 if (
present(distance_cv))
then
8417 if ( distance_cv > tolerance_high_def_srp )
then
8418 this%distance_cv = distance_cv
8421 this%distance = rnorm( distance_baseline, &
8422 cv2variance(distance_cv, distance_baseline) )
8424 this%distance_cv = 0.0_srp
8434 this%distance_cv = 0.0_srp
8442 this%expected_cost_moving = &
8443 this_agent%cost_swim( distance=this%distance, &
8444 exponent=swimming_cost_exponent_laminar )
8455 call this_agent%memory_stack%get_food_mean_n_split( &
8456 window = predict_window_food_here, &
8457 older = mean_n_food_memory_old, &
8458 newer = mean_n_food_memory_new )
8470 this%expected_food_dir = &
8471 hope( baseline = real( &
8472 this_agent%perceive_food%get_count(),srp ), &
8473 memory_old = mean_n_food_memory_old, &
8474 memory_new = mean_n_food_memory_new, &
8475 raw_grid_x = walk_random_food_hope_abscissa, &
8476 raw_grid_y = walk_random_food_hope_ordinate )
8492 select_dist_food:
if ( ( this_agent%has_food() .and. &
8493 this%distance < walk_random_food_gain_hope * &
8494 this_agent%perceive_food%get_meandist() ) &
8496 ( .not. this_agent%has_food() .and. &
8497 this%distance < walk_random_food_gain_hope_agentl * &
8498 this_agent%get_length() ) )
then
8535 this%expected_food_gain = &
8537 this_agent%memory_stack%get_food_mean_size( &
8538 predict_window_food_here)) * &
8540 this_agent%memory_stack%get_food_mean_n( &
8541 predict_window_food_here),&
8542 0.0_srp, 1.0_srp ) * &
8543 this_agent%food_probability_capture_subjective( &
8544 predict_window_food_here, time_step_model_here )
8549 else select_dist_food
8556 call this_agent%memory_stack%get_food_mean_size_split( &
8557 window = predict_window_food_here, &
8558 older = mean_size_food_memory_old, &
8559 newer = mean_size_food_memory_new )
8587 food_gain_memory_old = size2mass_food(mean_size_food_memory_old) * &
8588 within( mean_n_food_memory_old, 0.0_srp, 1.0_srp )
8589 food_gain_memory_new = size2mass_food(mean_size_food_memory_new) * &
8590 within( mean_n_food_memory_new, 0.0_srp, 1.0_srp )
8604 food_gain_memory_baseline = &
8606 this_agent%memory_stack%get_food_mean_size( &
8607 predict_window_food_here)) * &
8609 this_agent%memory_stack%get_food_mean_n( &
8610 predict_window_food_here), &
8611 0.0_srp, 1.0_srp ) * &
8612 this_agent%food_probability_capture_subjective( &
8613 predict_window_food_here, time_step_model_here )
8620 this%expected_food_gain = &
8621 hope( baseline = food_gain_memory_baseline, &
8622 memory_old = food_gain_memory_old, &
8623 memory_new = food_gain_memory_new, &
8624 raw_grid_x = walk_random_food_hope_abscissa, &
8625 raw_grid_y = walk_random_food_hope_ordinate )
8627 end if select_dist_food
8640 pred_dir_current = this_agent%risk_pred( is_freezing=.false. )
8652 predation_risk_backend( &
8653 pred_count = this_agent%perceive_predator%get_count(), &
8654 pred_memory_mean = this_agent%memory_stack%get_pred_mean( &
8655 predict_window_pred_here), &
8656 weight_direct = weight_direct )
8661 select_dist_pred:
if ( this%distance < walk_random_pred_risk_hope_agentl &
8662 * this_agent%get_length() )
then
8666 this%expected_pred_dir_risk = pred_dir_current
8672 this%expected_predation_risk = pred_current
8677 else select_dist_pred
8684 call this_agent%memory_stack%get_pred_mean_split( &
8685 window = predict_window_pred_here, &
8686 older = mean_n_pred_memory_old, &
8687 newer = mean_n_pred_memory_new )
8700 this%expected_pred_dir_risk =
hope( pred_dir_current, &
8701 mean_n_pred_memory_old, &
8702 mean_n_pred_memory_new, &
8703 migrate_predator_zero_hope, &
8704 migrate_predator_maximum_hope )
8717 this%expected_predation_risk =
hope( pred_current, &
8718 mean_n_pred_memory_old, &
8719 mean_n_pred_memory_new, &
8720 migrate_predator_zero_hope, &
8721 migrate_predator_maximum_hope )
8723 end if select_dist_pred
8732 distance, distance_cv, &
8733 predict_window_pred, predict_window_food, &
8734 time_step_model, rescale_max_motivation)
8737 class(appraisal),
intent(in) :: this_agent
8740 real(SRP),
optional,
intent(in) :: distance
8744 real(SRP),
optional,
intent(in) :: distance_cv
8751 integer,
optional,
intent(in) :: predict_window_pred
8757 integer,
optional,
intent(in) :: predict_window_food
8760 integer,
optional,
intent(in) :: time_step_model
8765 real(SRP),
optional,
intent(in) :: rescale_max_motivation
8768 real(SRP) :: dist_loc
8771 integer :: time_step_model_here, predict_window_food_here, &
8772 predict_window_pred_here
8775 real(SRP) :: max_motivation
8779 type(food_item) :: expected_food_item
8781 real(SRP) :: expected_food_item_distance
8784 real(SRP) :: expected_food_item_prob_capture
8787 real(SRP) :: expected_food_item_gain_fits
8790 real(SRP) :: agent_stomach
8796 real(SRP) :: perception_override_food_dir
8799 real(SRP) :: perception_override_pred_dir
8803 real(SRP) :: perception_override_predator
8806 real(SRP) :: perception_override_stomach
8809 real(SRP) :: perception_override_bodymass
8814 real(SRP) :: perception_override_energy
8817 character(len=*),
parameter :: PROCNAME = &
8818 "(walk_random_motivations_expect)"
8825 if (
present(distance))
then
8828 dist_loc = this_agent%get_length() * walk_random_distance_default_factor
8833 if (
present(time_step_model))
then
8834 time_step_model_here = time_step_model
8836 time_step_model_here = global_time_step_model_current
8845 if (
present(predict_window_pred))
then
8846 predict_window_pred_here= predict_window_pred
8848 predict_window_pred_here = floor( history_size_perception * &
8849 history_perception_window_pred )
8858 if (
present(predict_window_food))
then
8859 predict_window_food_here = predict_window_food
8861 predict_window_food_here = floor( history_size_perception * &
8862 history_perception_window_food )
8878 if (
present(distance_cv))
then
8880 call this%do_this( this_agent=this_agent, &
8881 distance=dist_loc, &
8882 distance_cv=distance_cv, &
8883 predict_window_pred=predict_window_pred_here, &
8884 predict_window_food=predict_window_food_here, &
8885 time_step_model=time_step_model_here )
8888 call this%do_this( this_agent=this_agent, &
8889 distance=dist_loc, &
8890 predict_window_pred=predict_window_pred_here, &
8891 predict_window_food=predict_window_food_here, &
8892 time_step_model=time_step_model_here )
8901 perception_override_food_dir = this%expected_food_dir
8912 call expected_food_item%make(location=this_agent%location(), &
8913 size=mass2size_food(this%expected_food_gain),&
8927 if ( this_agent%has_food() )
then
8928 expected_food_item_distance = this_agent%perceive_food%get_meandist()
8931 expected_food_item_distance = expected_food_item%visibility() * &
8932 dist_expect_food_uncertain_fact
8935 expected_food_item_prob_capture = &
8936 expected_food_item%capture_probability( &
8937 distance=expected_food_item_distance )
8946 expected_food_item_gain_fits = &
8947 this_agent%food_fitting( this%expected_food_gain, this%distance ) &
8948 * expected_food_item_prob_capture
8954 agent_stomach = this_agent%get_stom_content()
8955 perception_override_stomach = &
8957 agent_stomach - stomach_emptify_backend(agent_stomach) + &
8958 expected_food_item_gain_fits )
8964 perception_override_bodymass = &
8966 this_agent%get_mass() - &
8967 this_agent%living_cost() + &
8968 expected_food_item_gain_fits )
8973 perception_override_energy = energy_reserve( perception_override_bodymass,&
8974 this_agent%length() )
8980 perception_override_pred_dir = this%expected_pred_dir_risk
8981 perception_override_predator = this%expected_predation_risk
9005 call this%expectancy%hunger%percept_component%motivation_components &
9008 param_gp_matrix_light = light_hunger_genotype_neuronal, &
9009 param_gp_matrix_depth = depth_hunger_genotype_neuronal, &
9010 param_gp_matrix_food_dir = foodcount_hunger_genotype_neuronal, &
9011 param_gp_matrix_food_mem = food_mem_hunger_genotype_neuronal, &
9012 param_gp_matrix_conspec = conspcount_hunger_genotype_neuronal, &
9013 param_gp_matrix_pred_dir = pred_direct_hunger_genotype_neuronal, &
9014 param_gp_matrix_predator = pred_meancount_hunger_genotype_neuronal, &
9015 param_gp_matrix_stomach = stom_hunger_genotype_neuronal, &
9016 param_gp_matrix_bodymass = bodymass_hunger_genotype_neuronal, &
9017 param_gp_matrix_energy = energy_hunger_genotype_neuronal, &
9018 param_gp_matrix_age = age_hunger_genotype_neuronal, &
9019 param_gp_matrix_reprfac = reprfac_hunger_genotype_neuronal, &
9021 param_gerror_cv_light = light_hunger_genotype_neuronal_gerror_cv, &
9022 param_gerror_cv_depth = depth_hunger_genotype_neuronal_gerror_cv, &
9023 param_gerror_cv_food_dir = foodcount_hunger_genotype_neuronal_gerror_cv,&
9024 param_gerror_cv_food_mem = food_mem_hunger_genotype_neuronal_gerror_cv, &
9025 param_gerror_cv_conspec = conspcount_hunger_genotype_neuronal_gerror_cv,&
9026 param_gerror_cv_pred_dir = pred_direct_hunger_genotype_neuronal_gerror_cv,&
9027 param_gerror_cv_predator = pred_meancount_hunger_genotype_neuronal_gerror_cv,&
9028 param_gerror_cv_stomach = stom_hunger_genotype_neuronal_gerror_cv, &
9029 param_gerror_cv_bodymass = bodymass_hunger_genotype_neuronal_gerror_cv, &
9030 param_gerror_cv_energy = energy_hunger_genotype_neuronal_gerror_cv, &
9031 param_gerror_cv_age = age_hunger_genotype_neuronal_gerror_cv, &
9032 param_gerror_cv_reprfac = reprfac_hunger_genotype_neuronal_gerror_cv, &
9037 perception_override_food_dir = perception_override_food_dir, &
9038 perception_override_pred_dir = perception_override_pred_dir, &
9039 perception_override_predator = perception_override_predator, &
9040 perception_override_stomach = perception_override_stomach, &
9041 perception_override_bodymass = perception_override_bodymass, &
9042 perception_override_energy = perception_override_energy &
9054 call this%expectancy%fear_defence%percept_component%motivation_components &
9057 param_gp_matrix_light = light_actv_avoid_genotype_neuronal, &
9058 param_gp_matrix_depth = depth_actv_avoid_genotype_neuronal, &
9059 param_gp_matrix_food_dir = foodcount_actv_avoid_genotype_neuronal, &
9060 param_gp_matrix_food_mem = food_mem_actv_avoid_genotype_neuronal, &
9061 param_gp_matrix_conspec = conspcount_actv_avoid_genotype_neuronal, &
9062 param_gp_matrix_pred_dir = pred_direct_actv_avoid_genotype_neuronal, &
9063 param_gp_matrix_predator = pred_meancount_actv_avoid_genotype_neuronal, &
9064 param_gp_matrix_stomach = stom_actv_avoid_genotype_neuronal, &
9065 param_gp_matrix_bodymass = bodymass_actv_avoid_genotype_neuronal, &
9066 param_gp_matrix_energy = energy_actv_avoid_genotype_neuronal, &
9067 param_gp_matrix_age = age_actv_avoid_genotype_neuronal, &
9068 param_gp_matrix_reprfac = reprfac_actv_avoid_genotype_neuronal, &
9070 param_gerror_cv_light = light_actv_avoid_genotype_neuronal_gerror_cv, &
9071 param_gerror_cv_depth = depth_actv_avoid_genotype_neuronal_gerror_cv, &
9072 param_gerror_cv_food_dir = foodcount_actv_avoid_genotype_neuronal_gerror_cv,&
9073 param_gerror_cv_food_mem = food_mem_actv_avoid_genotype_neuronal_gerror_cv, &
9074 param_gerror_cv_conspec = conspcount_actv_avoid_genotype_neuronal_gerror_cv,&
9075 param_gerror_cv_pred_dir = pred_direct_actv_avoid_genotype_neuronal_gerror_cv,&
9076 param_gerror_cv_predator = pred_meancount_actv_avoid_genotype_neuronal_gerror_cv,&
9077 param_gerror_cv_stomach = stom_actv_avoid_genotype_neuronal_gerror_cv, &
9078 param_gerror_cv_bodymass = bodymass_actv_avoid_genotype_neuronal_gerror_cv,&
9079 param_gerror_cv_energy = energy_actv_avoid_genotype_neuronal_gerror_cv,&
9080 param_gerror_cv_age = age_actv_avoid_genotype_neuronal_gerror_cv, &
9081 param_gerror_cv_reprfac = reprfac_actv_avoid_genotype_neuronal_gerror_cv,&
9085 perception_override_food_dir = perception_override_food_dir, &
9086 perception_override_pred_dir = perception_override_pred_dir, &
9087 perception_override_predator = perception_override_predator, &
9088 perception_override_stomach = perception_override_stomach, &
9089 perception_override_bodymass = perception_override_bodymass, &
9090 perception_override_energy = perception_override_energy &
9096 call this%expectancy%reproduction%percept_component%motivation_components &
9099 param_gp_matrix_light = light_reproduce_genotype_neuronal, &
9100 param_gp_matrix_depth = depth_reproduce_genotype_neuronal, &
9101 param_gp_matrix_food_dir = foodcount_reproduce_genotype_neuronal, &
9102 param_gp_matrix_food_mem = food_mem_reproduce_genotype_neuronal, &
9103 param_gp_matrix_conspec = conspcount_reproduce_genotype_neuronal, &
9104 param_gp_matrix_pred_dir = pred_direct_reproduce_genotype_neuronal, &
9105 param_gp_matrix_predator = pred_meancount_reproduce_genotype_neuronal, &
9106 param_gp_matrix_stomach = stom_reproduce_genotype_neuronal, &
9107 param_gp_matrix_bodymass = bodymass_reproduce_genotype_neuronal, &
9108 param_gp_matrix_energy = energy_reproduce_genotype_neuronal, &
9109 param_gp_matrix_age = age_reproduce_genotype_neuronal, &
9110 param_gp_matrix_reprfac = reprfac_reproduce_genotype_neuronal, &
9112 param_gerror_cv_light = light_reproduce_genotype_neuronal_gerror_cv, &
9113 param_gerror_cv_depth = depth_reproduce_genotype_neuronal_gerror_cv, &
9114 param_gerror_cv_food_dir = foodcount_reproduce_genotype_neuronal_gerror_cv,&
9115 param_gerror_cv_food_mem = food_mem_reproduce_genotype_neuronal_gerror_cv, &
9116 param_gerror_cv_conspec = conspcount_reproduce_genotype_neuronal_gerror_cv,&
9117 param_gerror_cv_pred_dir = pred_direct_reproduce_genotype_neuronal_gerror_cv,&
9118 param_gerror_cv_predator = pred_meancount_reproduce_genotype_neuronal_gerror_cv,&
9119 param_gerror_cv_stomach = stom_reproduce_genotype_neuronal_gerror_cv, &
9120 param_gerror_cv_bodymass = bodymass_reproduce_genotype_neuronal_gerror_cv,&
9121 param_gerror_cv_energy = energy_reproduce_genotype_neuronal_gerror_cv,&
9122 param_gerror_cv_age = age_reproduce_genotype_neuronal_gerror_cv, &
9123 param_gerror_cv_reprfac = reprfac_reproduce_genotype_neuronal_gerror_cv,&
9127 perception_override_food_dir = perception_override_food_dir, &
9128 perception_override_pred_dir = perception_override_pred_dir, &
9129 perception_override_predator = perception_override_predator, &
9130 perception_override_stomach = perception_override_stomach, &
9131 perception_override_bodymass = perception_override_bodymass, &
9132 perception_override_energy = perception_override_energy &
9139 if (
present(rescale_max_motivation))
then
9142 max_motivation = rescale_max_motivation
9145 max_motivation = this%expectancy%max_perception()
9152 call this%attention_transfer(this_agent)
9155 call this%expectancy%motivation_primary_calc(max_motivation)
9158 call log_dbg( ltag_info //
"Primary motivations: " // &
9160 tostr(this%expectancy%hunger%motivation_prim) // &
9161 ", fear_defence: " // &
9162 tostr(this%expectancy%fear_defence%motivation_prim) // &
9163 ", reproduce: " // &
9164 tostr(this%expectancy%reproduction%motivation_prim), &
9169 call this%expectancy%modulation_none()
9175 this%arousal_expected = this%expectancy%max_final()
9179 call log_dbg( ltag_info //
"Expectancy: " // tostr(this%arousal_expected),&
9193 class(appraisal),
intent(inout) :: this_agent
9198 real(SRP),
optional,
intent(in) :: step_dist
9202 real(SRP),
optional,
intent(in) :: step_cv
9208 class(environment),
intent(in),
optional :: environment_limits
9211 real(SRP) :: step_cv_here
9221 if (
present(step_cv))
then
9222 step_cv_here = step_cv
9224 step_cv_here = walk_random_distance_stochastic_cv
9232 if (
present(step_dist))
then
9233 call this%do_this( this_agent=this_agent, distance=step_dist, &
9234 distance_cv=step_cv_here )
9236 call this%do_this( this_agent=this_agent, distance_cv=step_cv_here )
9261 if (
present(environment_limits))
then
9262 call this_agent%rwalk( &
9263 this%distance, this%distance_cv, &
9264 this%distance * walk_random_vertical_shift_ratio, &
9265 this%distance_cv*walk_random_vertical_shift_cv_ratio, &
9266 environment_limits )
9268 call this_agent%rwalk( &
9269 this%distance, this%distance_cv, &
9270 this%distance * walk_random_vertical_shift_ratio, &
9271 this%distance_cv*walk_random_vertical_shift_cv_ratio, &
9272 global_habitats_available( &
9273 this_agent%find_environment( &
9274 global_habitats_available) ) )
9282 call this_agent%set_mass( &
9283 value_set = this_agent%get_mass() - &
9284 this_agent%cost_swim(exponent= &
9285 swimming_cost_exponent_laminar), &
9286 update_history = .true. )
9293 call this_agent%set_length( value_set = this_agent%get_length(), &
9294 update_history = .true. )
9299 call this_agent%energy_update()
9303 if (this_agent%starved_death())
call this_agent%dies()
9321 this%behaviour_label =
"init_unknown"
9325 call this%deactivate()
9329 call this%cleanup_behav_history()
9333 this%n_eats_all_indicator = 0
9334 this%n_eaten_indicator = 0
9335 this%mass_eaten_indicator = 0.0_srp
9345 this%eat%is_active = .false.
9346 this%reproduce%is_active = .false.
9347 this%walk_random%is_active = .false.
9348 this%freeze%is_active = .false.
9349 this%escape_dart%is_active = .false.
9350 this%approach_spatial%is_active = .false.
9351 this%approach_conspec%is_active = .false.
9352 this%migrate%is_active = .false.
9353 this%depth_down%is_active = .false.
9354 this%depth_up%is_active = .false.
9355 this%debug_base%is_active = .false.
9364 character(len=LABEL_LENGTH) :: label_is
9366 label_is = this%behaviour_label
9374 result(number_in_seen)
9380 real(srp),
optional,
intent(in) :: rescale_max_motivation
9384 integer :: number_in_seen
9390 integer :: iconsp, n_seen_percep
9391 real(srp) :: rescale_max_motivation_here
9394 character(len=*),
parameter :: procname =
"(behaviour_select_conspecific)"
9398 real(srp),
dimension(this%perceive_consp%conspecifics_seen_count) :: &
9407 if (.not. this%has_consp())
then
9415 n_seen_percep = this%perceive_consp%conspecifics_seen_count
9419 if (n_seen_percep==1)
then
9426 if (
present(rescale_max_motivation))
then
9429 rescale_max_motivation_here = rescale_max_motivation
9433 rescale_max_motivation_here = this%motivations%max_final()
9441 consp_expect:
do iconsp = 1, n_seen_percep
9445 call this%approach_conspec%init()
9454 call this%approach_conspec%expectancies_calculate( &
9455 this_agent = this, &
9456 target_object = this%perceive_consp%conspecifics_seen(iconsp),&
9457 rescale_max_motivation = rescale_max_motivation_here )
9462 expected_gos_consp(iconsp) = this%approach_conspec%arousal_expected
9470 number_in_seen = minloc(expected_gos_consp, 1)
9472 call log_dbg(ltag_info //
"arousal expectancies for all conspecifics" // &
9473 "in the perception object: " // tostr(expected_gos_consp), &
9476 call log_dbg(ltag_info //
"minimum arousal # " // tostr(number_in_seen) //&
9477 " = " // tostr(expected_gos_consp(number_in_seen)), &
9492 integer :: number_in_seen
9494 if(this%has_consp())
then
9508 result(number_in_seen)
9514 real(srp),
optional,
intent(in) :: rescale_max_motivation
9518 integer :: number_in_seen
9524 integer :: fitem, n_seen_percep
9525 real(srp) :: rescale_max_motivation_here
9529 real(srp),
dimension(this%perceive_food%food_seen_count) :: &
9533 character(len=*),
parameter :: procname =
"(behaviour_select_food_item)"
9541 if (.not. this%has_food())
then
9549 n_seen_percep = this%perceive_food%food_seen_count
9558 if (n_seen_percep==1)
then
9565 if (
present(rescale_max_motivation))
then
9568 rescale_max_motivation_here = rescale_max_motivation
9572 rescale_max_motivation_here = this%motivations%max_final()
9579 items_expect:
do fitem = 1, n_seen_percep
9583 call this%eat%init()
9588 call this%eat%expectancies_calculate( &
9589 this_agent = this, &
9590 food_item_eaten = this%perceive_food%foods_seen(fitem), &
9591 rescale_max_motivation = rescale_max_motivation_here )
9596 expected_gos_fitem(fitem) = this%eat%arousal_expected
9619 number_in_seen = minloc(expected_gos_fitem, 1)
9621 call log_dbg(ltag_info //
"Arousal expectancies for all food items " // &
9622 "in the perception object: " // tostr(expected_gos_fitem), &
9625 call log_dbg(ltag_info //
"Minimum arousal # " // &
9626 tostr(number_in_seen) //
" = " // &
9627 tostr(expected_gos_fitem(number_in_seen)) //
" item mass=" &
9628 // tostr(this%perceive_food%foods_seen(number_in_seen)%get_mass()), &
9637 real(srp) :: capture_prob_subjective
9641 capture_prob_subjective = &
9642 this%perceive_food%foods_seen(fitem)%capture_probability( &
9643 distance=this%perceive_food%foods_distances(fitem) )
9644 call log_dbg( ltag_info // &
9645 "Subjective capture probability, true value: " // &
9646 tostr(capture_prob_subjective), procname,
modname )
9654 capture_prob_subjective = within( rnorm( capture_prob_subjective, &
9656 food_item_capture_probability_subjective_errorr_cv, &
9657 capture_prob_subjective) ), 0.0_srp, 1.0_srp )
9659 call log_dbg( ltag_info // &
9660 "Subjective capture probability, final value " // &
9661 "with Gaussian error: " // tostr(capture_prob_subjective),&
9680 integer :: number_in_seen
9682 if(this%has_food())
then
9693 number_in_seen, food_resource_real)
9699 integer,
optional,
intent(in) :: number_in_seen
9708 class(food_resource),
intent(inout) :: food_resource_real
9711 integer :: number_in_seen_here
9714 logical :: eat_food_item_is_success
9720 if (.not. this%has_food())
return
9722 if (
present(number_in_seen))
then
9727 if ( number_in_seen == 0 )
return
9729 number_in_seen_here = number_in_seen
9731 number_in_seen_here = 1
9736 call this%eat%init()
9740 this%behaviour_label = this%eat%label
9745 call this%deactivate()
9746 this%eat%is_active = .true.
9750 call this%eat%execute( this_agent = this, &
9752 this%perceive_food%foods_seen( &
9753 number_in_seen_here), &
9754 food_resource_real = food_resource_real, &
9755 eat_is_success = eat_food_item_is_success )
9760 call add_to_history( this%history_behave, this%eat%label )
9765 this%n_eats_all_indicator = this%n_eats_all_indicator +1
9768 if (eat_food_item_is_success)
then
9769 this%n_eaten_indicator = this%n_eaten_indicator + 1
9770 this%mass_eaten_indicator = this%mass_eaten_indicator + &
9771 this%perceive_food%foods_seen(number_in_seen_here)%get_mass()
9777 call this%position( &
9778 this%perceive_food%foods_seen(number_in_seen_here)%location() )
9791 if (.not. this%has_consp())
return
9795 call this%reproduce%init()
9799 this%behaviour_label = this%reproduce%label
9804 call this%deactivate()
9805 this%reproduce%is_active = .true.
9810 call this%reproduce%execute( this )
9815 call add_to_history( this%history_behave, this%reproduce%label )
9824 call this%repeat_position()
9838 real(SRP),
optional,
intent(in) :: distance
9842 real(SRP),
optional,
intent(in) :: distance_cv
9845 real(SRP) :: distance_loc, distance_cv_loc
9852 if (
present(distance))
then
9853 distance_loc = distance
9855 distance_loc = this%get_length() * walk_random_distance_default_factor
9862 distance_cv_loc = walk_random_distance_stochastic_cv
9863 if (
present(distance_cv))
then
9864 if ( distance_cv > tolerance_high_def_srp )
then
9865 distance_cv_loc = distance_cv
9867 distance_cv_loc = 0.0_srp
9873 call this%walk_random%init()
9877 this%behaviour_label = this%walk_random%label
9882 call this%deactivate()
9883 this%walk_random%is_active = .true.
9888 call this%walk_random%execute( this, step_dist=distance_loc, &
9889 step_cv=distance_cv )
9894 call add_to_history( this%history_behave, this%walk_random%label )
9908 call this%freeze%init()
9912 this%behaviour_label = this%freeze%label
9917 call this%deactivate()
9918 this%freeze%is_active = .true.
9922 call this%freeze%execute( this )
9927 call add_to_history( this%history_behave, this%freeze%label )
9936 call this%repeat_position()
9947 class(spatial),
optional,
intent(in) :: predator_object
9952 call this%escape_dart%init()
9956 this%behaviour_label = this%escape_dart%label
9961 call this%deactivate()
9962 this%escape_dart%is_active = .true.
9969 if (
present(predator_object))
then
9970 call this%escape_dart%execute( this, predator_object )
9972 call this%escape_dart%execute( this )
9978 call add_to_history( this%history_behave, this%escape_dart%label )
9991 class(spatial),
intent(in) :: target_object
9997 logical,
optional,
intent(in) :: is_random
10005 real(SRP),
optional,
intent(in) :: target_offset
10008 logical :: is_random_walk
10009 real(SRP) :: target_offset_here
10017 if (
present(is_random))
then
10018 is_random_walk = is_random
10020 is_random_walk = .false.
10025 conspec_other:
select type (target_object)
10036 class is (conspec_percept_comp) conspec_other
10038 if (
present(target_offset))
then
10039 target_offset_here = target_offset
10041 target_offset_here = ( this%get_length() + &
10042 get_prop_size(target_object) ) / 2.0_srp
10044 call this%approach_conspec%init()
10045 this%behaviour_label = this%approach_conspec%label
10046 call this%deactivate()
10047 this%approach_conspec%is_active = .true.
10048 call this%approach_conspec%execute(this, target_object, &
10049 is_random_walk, target_offset_here)
10054 call add_to_history( this%history_behave, this%approach_conspec%label )
10065 class default conspec_other
10067 if (
present(target_offset))
then
10068 target_offset_here = target_offset
10070 target_offset_here = approach_offset_default
10072 call this%approach_spatial%init()
10073 this%behaviour_label = this%approach_spatial%label
10074 call this%deactivate()
10075 this%approach_spatial%is_active = .true.
10076 call this%approach_spatial%execute(this, target_object, &
10077 is_random_walk, target_offset_here)
10082 call add_to_history( this%history_behave, this%approach_spatial %label )
10084 end select conspec_other
10091 class(
behaviour),
intent(inout) :: this
10094 class(environment),
intent(in) :: target_env
10099 call this%migrate%init()
10103 this%behaviour_label = this%migrate%label
10108 call this%deactivate()
10109 this%migrate%is_active = .true.
10114 call this%migrate%execute( this, target_env )
10119 call add_to_history( this%history_behave, this%migrate%label )
10128 result(is_migrated)
10129 class(
behaviour),
intent(inout) :: this
10132 class(environment),
intent(in) :: target_env
10136 real(srp),
optional,
intent(in) :: max_dist
10138 real(srp),
optional,
intent(in) :: prob
10141 logical :: is_migrated
10144 real(srp) :: max_dist_loc, prob_loc
10149 type(spatial) :: point_target_env
10151 real(srp) :: distance_target
10158 real(srp),
parameter :: max_dist_default = migrate_random_max_dist_target
10161 character(len=*),
parameter :: procname =
"(behaviour_do_migrate_random)"
10166 is_migrated = .false.
10175 if (
present(max_dist))
then
10176 max_dist_loc = max_dist
10178 max_dist_loc = max_dist_default
10180 if (
present(prob))
then
10206 call target_env%nearest_target( outside_object=this, &
10207 offset_into=this%get_length() * &
10208 migrate_dist_penetrate_offset, &
10209 point_spatial = point_target_env, &
10210 point_dist = distance_target )
10217 if ( distance_target < max_dist_loc * this%get_length() )
then
10218 if ( rand() < prob_loc )
then
10219 call log_dbg( ltag_info //
"Agent is about to migrate to " // &
10220 tostr([ point_target_env%xpos(), &
10221 point_target_env%ypos(), &
10222 point_target_env%dpos()]), procname,
modname )
10223 call this%position( point_target_env%location() )
10227 is_migrated = .true.
10242 call this%set_mass( value_set = this%get_mass() - &
10243 this%cost_swim(exponent= &
10244 swimming_cost_exponent_laminar), &
10245 update_history = .true. )
10252 call this%set_length(value_set = this%get_length(),update_history = .true.)
10257 call this%energy_update()
10261 if (this%starved_death())
call this%dies()
10268 class(
behaviour),
intent(inout) :: this
10271 real(SRP),
intent(in),
optional :: depth_walk
10276 call this%depth_down%init()
10280 this%behaviour_label = this%depth_down%label
10285 call this%deactivate()
10286 this%depth_down%is_active = .true.
10295 if (
present(depth_walk))
then
10296 call this%depth_down%execute( this, depth_walk = depth_walk )
10298 call this%depth_down%execute( this )
10304 call add_to_history( this%history_behave, this%depth_down%label )
10311 class(
behaviour),
intent(inout) :: this
10314 real(SRP),
intent(in),
optional :: depth_walk
10319 call this%depth_up%init()
10323 this%behaviour_label = this%depth_up%label
10328 call this%deactivate()
10329 this%depth_up%is_active = .true.
10338 if (
present(depth_walk))
then
10339 call this%depth_up%execute( this, depth_walk = depth_walk )
10341 call this%depth_up%execute( this )
10347 call add_to_history( this%history_behave, this%depth_up%label )
10355 class(
behaviour),
intent(inout) :: this
10357 this%history_behave =
""
10368 food_resource_real )
10369 class(
behaviour),
intent(inout) :: this
10377 class(food_resource),
optional,
intent(inout) :: food_resource_real
10382 real(SRP),
optional,
intent(in) :: rescale_max_motivation
10385 character(len=*),
parameter :: PROCNAME =
"(behaviour_select_optimal)"
10388 real(SRP) :: rescale_max_motivation_here
10396 real(SRP) :: expected_gos_debug_base
10399 real(SRP) :: expected_gos_eat
10402 integer :: food_item_selected
10406 real(SRP) :: expected_gos_reproduce
10410 real(SRP) :: expected_gos_walk
10413 real(SRP) :: walk_distance_selected
10417 real(SRP) :: expected_gos_freeze
10421 real(SRP) :: expected_gos_escape
10426 integer :: predator_selected_n
10430 real(SRP) :: expected_gos_approach_conspec
10435 integer :: conspec_selected_n
10441 real(SRP) :: expected_gos_migrate
10446 integer :: habitat_selected_n
10450 real(SRP) :: expected_gos_depth_down
10454 real(SRP) :: go_down_distance_selected
10458 real(SRP) :: expected_gos_depth_up
10462 real(SRP) :: go_up_distance_selected
10470 real(SRP),
allocatable,
dimension(:) :: expected_gos_all
10475 real(SRP),
parameter :: BIG_NEVER_WINS = -1.0_srp * missing
10479 integer :: fres_num
10486 if (
present(rescale_max_motivation))
then
10487 rescale_max_motivation_here = rescale_max_motivation
10489 rescale_max_motivation_here = this%motivations%max_perception()
10511 real(SRP) :: walk_dist_fi
10512 if ( is_near_zero(this%memory_stack%get_food_mean_dist()) )
then
10513 walk_dist_fi = missing
10515 walk_dist_fi = walk_distance_selected / &
10516 this%memory_stack%get_food_mean_dist()
10518 call log_dbg( ltag_info //
"Optimal walk step: " // &
10519 tostr(walk_distance_selected) //
", SL units: " // &
10520 tostr(walk_distance_selected/this%get_length()) // &
10521 ", units of average distance food items: " // &
10522 tostr(walk_dist_fi), procname,
modname )
10543 call go_down_select(expected_gos_depth_down, go_down_distance_selected)
10544 call log_dbg( ltag_info //
"Optimal walk step down: " // &
10545 tostr(go_down_distance_selected) //
", sl units: " // &
10546 tostr(go_down_distance_selected/this%get_length()), &
10551 call go_up_select(expected_gos_depth_up, go_up_distance_selected)
10552 call log_dbg( ltag_info //
"Optimal walk step up: " // &
10553 tostr(go_up_distance_selected) //
", sl units: " // &
10554 tostr(go_up_distance_selected/this%get_length()), &
10571 expected_gos_all = [ expected_gos_eat, &
10572 expected_gos_reproduce, &
10573 expected_gos_walk, &
10574 expected_gos_freeze, &
10575 expected_gos_escape, &
10576 expected_gos_approach_conspec, &
10577 expected_gos_migrate, &
10578 expected_gos_depth_down, &
10579 expected_gos_depth_up ]
10583 if (.not.
allocated(expected_gos_all) )
then
10584 call log_msg( ltag_crit //
"Automatic array allocation is not " // &
10585 "enabled or supported by the compiler. Check " // &
10586 procname //
" code and insert explicit" // &
10587 "'allocate(expected_gos_all(N))' or use compiler " // &
10588 "switch to enable F2003 features." )
10589 call system_halt(is_error=.true., message=error_no_autoalloc )
10594 if (is_debug)
call log_delimiter(log_level_chapter)
10595 call log_dbg( ltag_info //
" +++ GOS arousal array: " // &
10596 tostr(expected_gos_all) // &
10597 ", agent label: " // this%individ_label() // &
10598 ", minimum # " // tostr(minloc(expected_gos_all)) // &
10599 " is value: " // tostr(minval(expected_gos_all)) )
10600 if (is_debug)
call log_delimiter(log_level_chapter)
10614 if ( is_minval( expected_gos_eat, expected_gos_all ) )
then
10615 if (this%has_food())
then
10616 if (
present(food_resource_real))
then
10617 call this%do_eat_food_item( food_item_selected, food_resource_real )
10619 fres_num = this%find_environment(global_habitats_available)
10620 call this%do_eat_food_item( food_item_selected, &
10621 global_habitats_available(fres_num)%food )
10624 call this%do_walk()
10633 if ( is_minval( expected_gos_reproduce, expected_gos_all ) )
then
10634 if (this%is_ready_reproduce() .and. this%has_consp())
then
10635 call this%do_reproduce()
10637 call this%do_walk()
10645 if ( is_minval( expected_gos_walk, expected_gos_all ) )
then
10646 if (walk_distance_selected > tolerance_high_def_srp )
then
10647 call this%do_walk( walk_distance_selected )
10649 call this%do_walk()
10656 if ( is_minval( expected_gos_freeze, expected_gos_all ) )
then
10657 call this%do_freeze()
10665 if ( is_minval( expected_gos_escape, expected_gos_all ) )
then
10666 if (this%has_pred())
then
10667 call this%do_escape( predator_object = &
10668 this%perceive_predator%predators_seen(predator_selected_n) )
10670 call this%do_escape( )
10677 if ( is_minval( expected_gos_approach_conspec, expected_gos_all ) )
then
10678 if (this%has_consp())
then
10679 call this%do_approach( &
10681 this%perceive_consp%conspecifics_seen(conspec_selected_n),&
10682 is_random = .false. )
10684 call this%do_walk()
10693 if ( is_minval( expected_gos_migrate, expected_gos_all ) )
then
10694 if ( habitat_selected_n > 0 .and. &
10695 habitat_selected_n <=
size(global_habitats_available) )
then
10696 call this%do_migrate( &
10697 target_env = global_habitats_available(habitat_selected_n) )
10699 call this%do_walk()
10707 if ( is_minval( expected_gos_depth_down, expected_gos_all ) )
then
10708 if ( go_down_distance_selected > tolerance_high_def_srp )
then
10709 call this%do_go_down( depth_walk = go_down_distance_selected )
10711 call this%do_walk()
10720 if ( is_minval( expected_gos_depth_up, expected_gos_all ) )
then
10721 if ( go_up_distance_selected > tolerance_high_def_srp )
then
10722 call this%do_go_up( depth_walk = go_up_distance_selected )
10724 call this%do_walk()
10734 call log_msg( ltag_error //
"Cannot select optimal behaviour unit in " // &
10735 procname //
". Default random Gaussian walk is executed." )
10737 call this%do_walk()
10749 real(SRP),
intent(out) :: expected_gos
10752 integer,
intent(out) :: selected
10757 call this%eat%init()
10761 if ( this%has_food() )
then
10766 selected = this%food_item_select( &
10767 rescale_max_motivation = rescale_max_motivation_here )
10773 call this%eat%expectancies_calculate( this_agent = this, &
10774 food_item_eaten = this%perceive_food%foods_seen( &
10776 rescale_max_motivation = rescale_max_motivation_here )
10777 expected_gos = this%eat%arousal_expected
10782 expected_gos = big_never_wins
10787 call log_dbg( ltag_info //
"Selected optimal food item number: " // &
10788 tostr(selected) //
", out of total " // &
10789 tostr(this%perceive_food%food_seen_count) // &
10790 " items in perception." , procname,
modname )
10791 end block debug_log
10803 real(SRP),
intent(out) :: expected_gos
10808 if ( this%has_consp() .and. this%is_ready_reproduce() )
then
10809 call this%reproduce%expectancies_calculate( this_agent = this, &
10810 rescale_max_motivation = rescale_max_motivation_here )
10811 expected_gos = this%reproduce%arousal_expected
10813 expected_gos = big_never_wins
10829 real(SRP),
intent(out) :: expected_gos
10832 real(SRP),
intent(out) :: selected
10835 integer :: walk_step
10837 real(SRP) :: walk_current
10851 expected_gos = big_never_wins
10853 do walk_step=1,
size(behav_walk_step_stdlen_static)
10854 walk_current = behav_walk_step_stdlen_static(walk_step)*this%get_length()
10855 call this%walk_random%init()
10856 call this%walk_random%expectancies_calculate( this_agent = this, &
10857 distance = walk_current, &
10858 rescale_max_motivation = rescale_max_motivation_here )
10859 if (this%walk_random%arousal_expected < expected_gos )
then
10860 expected_gos = this%walk_random%arousal_expected
10861 selected = walk_current
10875 real(SRP),
intent(out) :: expected_gos
10880 call this%freeze%init()
10886 call this%freeze%expectancies_calculate( this_agent = this, &
10887 rescale_max_motivation = rescale_max_motivation_here )
10888 expected_gos = this%freeze%arousal_expected
10902 real(SRP),
intent(out) :: expected_gos
10908 integer,
intent(out) :: selected
10911 integer :: escape_step
10921 if ( this%has_pred() )
then
10932 expected_gos = big_never_wins
10934 do escape_step=1, this%perceive_predator%get_count()
10935 call this%escape_dart%init()
10936 call this%escape_dart%expectancies_calculate( this_agent = this, &
10937 predator_object = &
10938 this%perceive_predator%predators_seen(escape_step), &
10939 rescale_max_motivation = rescale_max_motivation_here )
10940 if ( this%escape_dart%arousal_expected < expected_gos )
then
10941 expected_gos = this%escape_dart%arousal_expected
10942 selected = escape_step
10953 call this%escape_dart%expectancies_calculate( this_agent = this, &
10954 rescale_max_motivation = rescale_max_motivation_here )
10955 expected_gos = this%escape_dart%arousal_expected
10971 real(SRP),
intent(out) :: expected_gos
10977 integer,
intent(out) :: selected
10983 call this%approach_conspec%init()
10991 if ( this%has_consp() )
then
10996 selected = this%consp_select( rescale_max_motivation = &
10997 rescale_max_motivation_here)
11004 call this%approach_conspec%expectancies_calculate( this_agent = this, &
11006 this%perceive_consp%conspecifics_seen(selected), &
11007 rescale_max_motivation = rescale_max_motivation_here )
11009 expected_gos = this%approach_conspec%arousal_expected
11016 expected_gos = big_never_wins
11035 real(SRP),
intent(out) :: expected_gos
11041 integer,
intent(out) :: selected
11044 integer :: habitat_step
11058 expected_gos = big_never_wins
11060 do habitat_step=1,
size(global_habitats_available)
11061 if ( habitat_step /= this%find_environment() )
then
11062 call this%migrate%init()
11063 call this%migrate%expectancies_calculate( this_agent = this, &
11064 target_env = global_habitats_available(habitat_step), &
11065 rescale_max_motivation = rescale_max_motivation_here )
11066 if ( this%migrate%arousal_expected < expected_gos )
then
11067 expected_gos = this%migrate%arousal_expected
11068 selected = habitat_step
11074 call log_dbg( ltag_info //
"Current agent's environment number: " // &
11075 tostr(this%find_environment()), procname,
modname )
11076 call log_dbg( ltag_info //
"Selected optimal environment number: " // &
11077 tostr(selected) //
", distance to traverse: " // &
11078 tostr(this%migrate%distance) //
", expected cost of " // &
11079 "moving: " // tostr(this%migrate%expected_cost_moving), &
11081 end block debug_log
11097 real(SRP),
intent(out) :: expected_gos
11101 real(SRP),
intent(out) :: selected
11104 integer :: depth_step
11106 real(SRP) :: walk_current
11124 expected_gos = big_never_wins
11126 do depth_step=1,
size(behav_go_up_down_step_stdlen_static)
11127 walk_current = behav_go_up_down_step_stdlen_static(depth_step) * &
11129 call this%depth_down%init()
11130 call this%depth_down%expectancies_calculate( this_agent = this, &
11131 depth_walk = walk_current, &
11132 environments = global_habitats_available, &
11133 rescale_max_motivation = rescale_max_motivation_here )
11134 if (this%depth_down%arousal_expected < expected_gos )
then
11135 expected_gos = this%depth_down%arousal_expected
11136 selected = walk_current
11154 real(SRP),
intent(out) :: expected_gos
11158 real(SRP),
intent(out) :: selected
11161 integer :: depth_step
11163 real(SRP) :: walk_current
11181 expected_gos = big_never_wins
11183 do depth_step=1,
size(behav_go_up_down_step_stdlen_static)
11184 walk_current = behav_go_up_down_step_stdlen_static(depth_step) * &
11186 call this%depth_up%init()
11187 call this%depth_up%expectancies_calculate( this_agent = this, &
11188 depth_walk = walk_current, &
11189 environments = global_habitats_available, &
11190 rescale_max_motivation = rescale_max_motivation_here )
11191 if (this%depth_up%arousal_expected < expected_gos )
then
11192 expected_gos = this%depth_up%arousal_expected
11193 selected = walk_current
11207 real(SRP),
intent(out) :: expected_gos
11212 call this%debug_base%init()
11217 call this%debug_base%expectancies_calculate( this_agent = this, &
11218 rescale_max_motivation = rescale_max_motivation_here )
11219 expected_gos = this%debug_base%arousal_expected
11221 call log_dbg( ltag_info //
"Expected GOS arousal: " // &
11222 tostr(expected_gos), procname,
modname )
11237 food_resource_real )
11238 class(
behaviour),
intent(inout) :: this
11246 class(food_resource),
optional,
intent(inout) :: food_resource_real
11251 real(SRP),
optional,
intent(in) :: rescale_max_motivation
11254 character(len=*),
parameter :: &
11255 PROCNAME =
"(behaviour_select_fixed_from_gos)"
11258 real(SRP) :: rescale_max_motivation_here
11265 integer :: food_item_selected
11271 integer :: predator_selected_n
11274 integer :: fres_num
11281 if (
present(rescale_max_motivation))
then
11282 rescale_max_motivation_here = rescale_max_motivation
11284 rescale_max_motivation_here = this%motivations%max_perception()
11295 logical :: is_migrated
11296 integer :: current_in, i
11297 is_migrated = .false.
11301 current_in = this%find_environment()
11308 do i = 1,
size(global_habitats_available)
11309 if ( current_in /= i )
then
11310 is_migrated = this%migrate_random( global_habitats_available(i) )
11317 if ( is_migrated )
exit
11322 if ( is_migrated )
return
11323 end block try_migrate
11329 select_behav:
if ( this%motivations%hunger%is_dominant() )
then
11333 if (this%has_food())
then
11334 food_item_selected = 1
11335 if (
present(food_resource_real))
then
11336 call this%do_eat_food_item(food_item_selected, food_resource_real)
11338 fres_num = this%find_environment(global_habitats_available)
11339 call this%do_eat_food_item(food_item_selected, &
11340 global_habitats_available(fres_num)%food)
11346 call this%do_walk()
11349 else if ( this%motivations%fear_defence%is_dominant() )
then select_behav
11352 if (this%has_pred())
then
11353 predator_selected_n = 1
11354 call this%do_escape( predator_object = &
11355 this%perceive_predator%predators_seen(predator_selected_n) )
11360 call this%do_freeze( )
11364 else if ( this%motivations%reproduction%is_dominant() )
then select_behav
11367 if (this%is_ready_reproduce() .and. this%has_consp())
then
11368 call this%do_reproduce()
11373 call this%do_walk()
11375 end if select_behav
11385 call this%init_perception()
11386 call this%init_appraisal()
11387 call this%init_gos()
11388 call this%init_behaviour()
Abstract interface for the deferred init function that has to be overriden by each object that extend...
Abstract interface for the deferred init function that has to be overriden by each object that extend...
subroutine migrate_select(expected_gos, selected)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::migra...
subroutine reproduce_select(expected_gos)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::repro...
subroutine go_down_select(expected_gos, selected)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::go_do...
real(srp) function subjective_capture_prob(fitem)
Calculate subjective probability of food item capture, as objective capture probability and random as...
real(srp) function decrement_factor_fixed()
Calculate the decrement factor for the gonadal steroids based reproductive factor.
subroutine escape_dart_select(expected_gos, selected)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::escap...
subroutine go_up_select(expected_gos, selected)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::go_up...
subroutine reproduction_unsuccessful_cost_subtract()
Process the costs of unsuccessful reproduction. Reproduction can be unsuccessful for various reasons:...
subroutine debug_base_select(expected_gos)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::debug...
subroutine approach_consp_select(expected_gos, selected)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::appro...
subroutine eat_food_select(expected_gos, selected)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::eat_f...
subroutine freeze_select(expected_gos)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::freez...
subroutine walk_random_select(expected_gos, selected)
Calculate the expected GOS arousal that would be predicted from execution of the the_behaviour::walk_...
COMMONDATA – definitions of global constants and procedures.
integer, parameter, public srp
Definition of the standard real type precision (SRP).
Definition of high level behavioural architecture.
elemental subroutine behaviour_cleanup_history(this)
Cleanup the behaviour history stack for the agent. All values are empty.
elemental subroutine, private behaviour_whole_agent_init(this)
Initialise the behaviour components of the agent, the the_behaviour::behaviour class.
subroutine go_up_do_execute(this, this_agent, min_depth, environments, depth_walk)
Execute this behaviour component "go up" by this_agent agent towards.
subroutine reproduce_do_this(this, this_agent, p_reproduction, is_reproduce)
Do reproduce by this_agent (the actor agent) given the specific probability of successful reproductio...
pure subroutine behaviour_root_attention_weights_transfer(this, this_agent)
Transfer attention weights from the actor agent to the behaviour's GOS expectancy object....
subroutine migrate_do_this(this, this_agent, target_env, predict_window_food, predict_window_consp, predict_window_pred, time_step_model)
The "do" procedure component of the behaviour element performs the behaviour without affecting the ac...
subroutine reproduce_do_execute(this, this_agent)
Execute this behaviour component "reproduce" by the this_agent agent.
integer function maximum_n_reproductions(this)
Calculate the maximum number of possible reproductions for this agent. It is assumed that a male can ...
subroutine eat_food_item_motivations_expect(this, this_agent, food_item_eaten, time_step_model, distance_food_item, capture_prob, rescale_max_motivation)
eat_food::motivations_expect() is a subroutine (re)calculating motivations from fake expected percept...
elemental subroutine go_up_depth_init_zero(this)
Initialise the go up to a shallower spatial layer behaviour component to a zero state.
subroutine behaviour_do_go_up(this, depth_walk)
Perform (execute) the the_behaviour::go_up_depth (go up) behaviour.
integer function behaviour_select_conspecific(this, rescale_max_motivation)
Select the optimal conspecific among (possibly) several ones that are available in the perception obj...
elemental subroutine go_down_depth_init_zero(this)
Initialise the go down to a deeper spatial layer behaviour component to a zero state.
integer function behaviour_select_conspecific_nearest(this)
Select the nearest conspecific among (possibly) several ones that are available in the perception obj...
elemental subroutine reproduce_init_zero(this)
Initialise reproduce behaviour object.
subroutine behaviour_do_migrate(this, target_env)
Perform (execute) the the_behaviour::migrate (migration) behaviour.
character(len= *), parameter, private modname
elemental logical function behaviour_root_get_is_executed(this)
Get the execution status of the behaviour unit. If TRUE, the unit is currently active and is being ex...
subroutine eat_food_item_do_execute(this, this_agent, food_item_eaten, food_resource_real, eat_is_success)
Execute this behaviour component "eat food item" by this_agent agent towards the food_item_eaten.
elemental subroutine approach_spatial_object_init_zero(this)
Initialise the approach behaviour component to a zero state. Approach is a generic type but not abstr...
elemental subroutine, private neurobio_init_components(this)
Initialise neuro-biological architecture.
elemental character(len=label_length) function behaviour_get_behaviour_label_executing(this)
Obtain the label of the currently executing behaviour for the this agent.
subroutine behaviour_do_reproduce(this)
Reproduce based on the this agent's current state.
integer function behaviour_select_food_item(this, rescale_max_motivation)
Select the optimal food item among (possibly) several ones that are available in the perception objec...
subroutine go_down_motivations_expect(this, this_agent, depth_walk, max_depth, environments, time_step_model, rescale_max_motivation)
go_down_depth::motivations_expect() is a subroutine (re)calculating motivations from fake expected pe...
subroutine walk_random_do_execute(this, this_agent, step_dist, step_cv, environment_limits)
Execute this behaviour component "random walk" by this_agent agent.
subroutine go_down_do_execute(this, this_agent, max_depth, environments, depth_walk)
Execute this behaviour component "go down" by this_agent agent.
subroutine behaviour_do_eat_food_item(this, number_in_seen, food_resource_real)
Eat a specific food item that are found in the perception object.
subroutine behaviour_do_escape_dart(this, predator_object)
Perform (execute) the the_behaviour::escape_dart behaviour.
subroutine walk_random_motivations_expect(this, this_agent, distance, distance_cv, predict_window_pred, predict_window_food, time_step_model, rescale_max_motivation)
the_behaviour::walk_random::expectancies_calculate() (re)calculates motivations from fake expected pe...
elemental real(srp) function behaviour_root_gos_expectation(this)
Accessor get-function for the final expected GOS arousal from this behaviour. All calculations for ar...
subroutine freeze_do_this(this, this_agent)
Do freeze by this_agent (the actor agent). Subjective assessment of the motivational value for this i...
subroutine freeze_do_execute(this, this_agent)
Execute this behaviour component "freeze" by this_agent agent.
subroutine go_up_motivations_expect(this, this_agent, depth_walk, min_depth, environments, time_step_model, rescale_max_motivation)
go_up_depth::motivations_expect() is a subroutine (re)calculating motivations from fake expected perc...
subroutine escape_dart_motivations_expect(this, this_agent, predator_object, time_step_model, rescale_max_motivation)
escape_dart::motivations_expect() is a subroutine (re)calculating motivations from fake expected perc...
subroutine approach_do_this(this, this_agent, target_object, target_offset, predict_window_food, time_step_model)
The "do" procedure component of the behaviour element performs the behaviour without affecting the ac...
subroutine behaviour_do_go_down(this, depth_walk)
Perform (execute) the the_behaviour::go_down_depth (go down) behaviour.
subroutine debug_base_motivations_expect(this, this_agent, time_step_model, rescale_max_motivation)
the_behaviour::debug_base::motivations_expect() is a subroutine (re)calculating motivations from fake...
subroutine approach_conspecifics_do_this(this, this_agent, target_object, target_offset, predict_window_food, time_step_model)
The "do" procedure component of the behaviour element performs the behaviour without affecting the ac...
elemental subroutine approach_conspecifics_init_zero(this)
Initialise the approach conspecific behaviour to a zero state. Approach conspecific is a special exte...
elemental subroutine migrate_init_zero(this)
Initialise the migrate behaviour component to a zero state.
elemental subroutine freeze_init_zero(this)
Initialise the freeze behaviour component to a zero state. Freeze is a special type of move to a zero...
subroutine freeze_motivations_expect(this, this_agent, time_step_model, rescale_max_motivation)
the_behaviour::freeze::motivations_expect() (re)calculates motivations from fake expected perceptions...
subroutine escape_dart_do_this(this, this_agent, predator_object, dist_is_stochastic, time_step_model)
Do active escape dart by this_agent (the actor agent). Subjective assessment of the motivational valu...
subroutine migrate_motivations_expect(this, this_agent, target_env, predict_window_food, predict_window_consp, predict_window_pred, time_step_model, rescale_max_motivation)
the_behaviour::migrate::expectancies_calculate() (re)calculates motivations from fake expected percep...
subroutine go_up_do_this(this, this_agent, min_depth, depth_walk, predict_window_food, time_step_model)
Do go up by this_agent (the actor agent). Subjective assessment of the motivational value for this is...
subroutine behaviour_do_freeze(this)
Perform (execute) the the_behaviour::freeze behaviour.
subroutine behaviour_select_optimal(this, rescale_max_motivation, food_resource_real)
Select and execute the optimal behaviour, i.e. the behaviour which minimizes the expected GOS arousal...
subroutine behaviour_select_fixed_from_gos(this, rescale_max_motivation, food_resource_real)
Select and execute behaviour based on the current global organismic state. This procedure is signific...
pure real(srp) function hope(baseline, memory_old, memory_new, zero_hope, maximum_hope, raw_grid_x, raw_grid_y)
The hope function for the assessment of expectancy for a completely novel stimulus or environment for...
subroutine migrate_do_execute(this, this_agent, target_env)
Execute this behaviour component "migrate" by this_agent agent.
elemental subroutine walk_random_init_zero(this)
Initialise the walk_random behaviour component to a zero state.
subroutine escape_dart_do_execute(this, this_agent, predator_object, environment_limits)
Execute this behaviour component "escape" by this_agent agent.
elemental real(srp) function depth_walk_default(length, walk_factor)
Calculate the default upward and downward walk step size. This function is called from the_behaviour:...
subroutine approach_do_execute(this, this_agent, target_object, is_random, target_offset, environment_limits)
Execute this behaviour component "approach" by this_agent agent.
elemental subroutine debug_base_init_zero(this)
Initialise the fake debug behaviour behaviour component to a zero state.
elemental subroutine eat_food_item_init_zero(this)
Initialise the eat food item behaviour component to a zero state.
subroutine behaviour_do_walk(this, distance, distance_cv)
Perform a random Gaussian walk to a specific average distance with certain variance (set by the CV).
subroutine approach_conspecifics_motivations_expect(this, this_agent, target_object, target_offset, time_step_model, rescale_max_motivation)
the_behaviour::approach_conspec::expectancies_calculate() (re)calculates motivations from fake expect...
integer function behaviour_select_food_item_nearest(this)
Select the nearest food item among (possibly) several ones that are available in the perception objec...
subroutine walk_random_do_this(this, this_agent, distance, distance_cv, predict_window_pred, predict_window_food, time_step_model)
The "do" procedure component of the behaviour element performs the behaviour without affecting the ac...
subroutine reproduce_motivations_expect(this, this_agent, time_step_model, reprod_prob, non_stochastic, rescale_max_motivation)
reproduce::motivations_expect() is a subroutine (re)calculating motivations from fake expected percep...
subroutine go_down_do_this(this, this_agent, max_depth, depth_walk, predict_window_food, time_step_model)
Do go down by this_agent (the actor agent). Subjective assessment of the motivational value for this ...
elemental subroutine behaviour_whole_agent_deactivate(this)
Deactivate all behaviour units that compose the behaviour repertoire of the agent.
elemental subroutine escape_dart_init_zero(this)
Initialise the escape dart behaviour component to a zero state. Dart is a quick high speed active esc...
subroutine eat_food_item_do_this(this, this_agent, food_item_eaten, time_step_model, distance_food_item, capture_prob, is_captured)
Eat a food item defined by the object food_item_eaten. The "do" procedure component of the behaviour ...
logical function behaviour_try_migrate_random(this, target_env, max_dist, prob)
Perform a simplistic random migration. If the agent is within a specific distance to the target envir...
subroutine behaviour_do_approach(this, target_object, is_random, target_offset)
Approach a specific the_environment::spatial class target, i.e. execute the the_behaviour::approach b...
subroutine approach_motivations_expect(this, this_agent, target_object, target_offset, time_step_model, rescale_max_motivation)
the_behaviour::approach::expectancies_calculate() (re)calculates motivations from fake expected perce...
Definition the physical properties and condition of the agent.
Definition of environmental objects.
Definition of the decision making and behavioural the architecture.
Approach conspecifics is directed movement towards a conspecific.
Approach an arbitrary spatial object is a directed movement to an arbitrary the_environment::spatial ...
This type is an "umbrella" for all the lower-level classes.
Root behaviour abstract type. Several different discrete behaviours encompass the behavioural reperto...
The behaviour of the agent is defined by the the_behaviour::behaviour class. This class defines the b...
This is a test fake behaviour unit that is used only for debugging. It cannot be "execute"'d,...
Eat food is consuming food item(s) perceived.
Escape dart is a very fast long distance movement, normally in response to a direct predation threat.
Freeze is stop any locomotion completely.
Go up raise to a smaller depth. TODO: abstract type linking both Up and Down.
Migrate is move quickly directing to the other habitat
Movement is an umbrella abstract type linked with spatial movement.
Reproduce is do a single reproduction.
Walk_random is a single step of a Gaussian random walk.
Definition of a spatial object. Spatial object determines the position of the agent,...
The appraisal level. At this level, perception objects are feed into the commondata::gamma2gene() sig...
Global organismic state (GOS) level. GOS is defined by the dominant motivational state component (STA...
Motivation is a collection of all internal motivational states of the agent. This type is also used i...