-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm_neuro.f90
9458 lines (8274 loc) · 473 KB
/
m_neuro.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!> @file m_neuro.f90
!! The Neurobiological and behaviour architecture of the AHA Model.
!! @author Sergey Budaev <[email protected]>
!! @author Jarl Giske <[email protected]>
!! @date 2016-2017
!-------------------------------------------------------------------------------
! $Id$
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!> @brief Definition of the decision making and behavioural the architecture
!> @section the_neurobio_module THE_NEUROBIO module
!> This module defines the neurobiological architecture of the agent, starting
!! from perception to representation, appraisal, motivation, emotion,
!! determination of the global organismic state, and behaviour.
module THE_NEUROBIO
use COMMONDATA
use THE_ENVIRONMENT
use THE_BODY
implicit none
character (len=*), parameter, private :: MODNAME = "(THE_NEUROBIO)"
!.............................................................................
! Lower-order perception components and objects. These describe
! the stimuli that the agent gets from the environment. These are of
! two kinds: (1) spatial/environmental perception objects which get
! objects from the outside world (e.g. food, conspecifics, predators)
! and (2) internal perception objects that get objects of the self
! organism (self stomach capacity available for food, energy reserve,
! body mass etc).
!.............................................................................
! Spatial / environmental perception components: perception of objects in the
! outer world
!> This type defines how the agent perceives food items.
!! The food perception object the_neurobio::percept_food is basically an
!! array of food objects within the visual range of the agent plus
!! distances to the agent. This is the "objective" perception container,
!! reflecting the "real world". We introduce a perception error when
!! perception object is analysed by the agent's neurobiological system.
type, public :: PERCEPT_FOOD
!> An array of food items found within the visual range, limited by
!! the maximum order of partial indexing
!! `commondata::food_select_items_index_partial`.
!! @note **Food perception** is quite complex to implement as it requires
!! determining individual food items within the current visual range
!! of the agent. There are, however, potentially thousands (or
!! millions) of food items in the food resource, each of the food
!! items is stochastic (e.g. they have different sizes), so visual
!! range differ for each item and each agent should determine
!! food items in its proximity at numerous time steps of the model.
!! This means repeating huge loops many times for each agent at
!! each time step. This is approached by array segmentation: the
!! perception object is obtained by *partial indexing* of a very
!! limited number (=`commondata::food_select_items_index_partial`) of
!! only the nearest food items, the agent's visual range is then
!! determined for each of this nearest neighbouring food items, and
!! finally those food items that individually fall within the
!! visual range
!! are included into the perception object.
! @warning Tried to convert all perception types to allocatable
! (at rev. 1651), food perception worked ok, but other objects were
! broken. (1) pure/elemental procedures have problems with
! allocatable within (allocatable is a side effect); (2) allocatable
! from within user types have problems with whole array passage to
! subroutines dummy parameters, issue error: [`Error: Component to
! the right of a part reference with nonzero rank must not have the
! ALLOCATABLE attribute at... `]. F2003 standard 6.1.2. prohibits
! passing whole arrays of allocatable derived types. So far returned
! to non-allocatable scalars and allocatable arrays, scalars would
! not cause small memory expenditures.
type(FOOD_ITEM), allocatable, dimension(:) :: foods_seen
!> An array of distances towards each of the food items.
real(SRP), allocatable, dimension(:) :: foods_distances
!> Total number of food items within the visual range of the agent.
!! must not exceed the `commondata::food_select_items_index_partial`
!! parameter.
integer :: food_seen_count
contains
!> Initiate an empty **food** perception object with known number of
!! components. See `the_neurobio::percept_food_create_init()`.
procedure, public :: init => percept_food_create_init
!! See `the_neurobio::percept_food_number_seen()`
procedure, public :: number => percept_food_number_seen
!> Set the total number of food items perceived (seen) in the food
!! perception object. Do not reallocate the perception object components
!! with respect to this new number yet.
!! See `the_neurobio::percept_food_make_fill_arrays()`.
procedure, public :: make => percept_food_make_fill_arrays
!> Get the number (count) of food items seen.
!! See `the_neurobio::percept_food_get_count_found()`.
procedure, public :: get_count => percept_food_get_count_found
!> Get the average size of food items seen.
!! See `the_neurobio::percept_food_get_meansize_found()`.
procedure, public :: get_meansize => percept_food_get_meansize_found
!> Get the average mass of food items seen.
!! See `the_neurobio::percept_food_get_meanmass_found()`.
procedure, public :: get_meanmass => percept_food_get_meanmass_found
!> Get the average distance tot the food items seen.
!! See `the_neurobio::percept_food_get_meandist_found()`.
procedure, public :: get_meandist => percept_food_get_meandist_found
!> Deallocate and delete a **food** perception object.
!! See `the_neurobio::percept_food_destroy_deallocate()`.
procedure, public :: destroy => percept_food_destroy_deallocate
end type PERCEPT_FOOD
!> This type defines a single spatial perception component, i.e. some single
!! elementary spatial object that can be perceived by the agent from a big
!! array of objects of the same type which are available in the agent's
!! environment. Different kinds of perception objects (e.g. conspecifics,
!! predators etc.) can be produced by extending this basic type.
!! @note Note that the **food items** the_neurobio::percept_food are
!! implemented separately and do not currently use the spatial
!! perception component objects. For example, individual food items
!! are indexed seperately witghin the food resource object by `iid`
!! data component.
type, public, extends(SPATIAL) :: SPATIAL_PERCEPT_COMPONENT
!> Spatial perception component adds an unique component id (`cid`) number
!! to the basic `the_environment::spatial` so that individual objects
!! within the whole perception object array can be identified. As a
!! consequence, spatial perception component adds only two type-bound
!! procedures that do the \%cid.
integer :: cid
contains
!> Get the unique **id** of the food item object.
!! See `the_neurobio::spatial_percept_get_cid()`.
procedure, public :: get_cid => spatial_percept_get_cid
!> Set unique **id** for the conspecific perception component.
!! See `the_neurobio::spatial_percept_set_cid()`.
procedure, public :: set_cid => spatial_percept_set_cid
end type SPATIAL_PERCEPT_COMPONENT
!> This type defines a **single conspecific** perception component.
!! It is required for the `the_neurobio::percept_conspecifics` type that
!! defines the whole conspecifics perception object (array of conspecifics).
type, public, extends(SPATIAL_PERCEPT_COMPONENT) :: CONSPEC_PERCEPT_COMP
!> Body size. The body size of the perception conspecific.
!! @note We may need body size of the conspecifics as the decision
!! making rules may depend on the conspecific size (e.g.
!! approach big and repulse from small, also may affect
!! mating, e.g. mate with the biggest, etc.).
real(SRP) :: consp_body_size
!> Body mass. The body mass of the perception conspecific.
real(SRP) :: consp_body_mass
!> @note Any other characteristics of the perception conspecifics may
!! be added, e.g. sex etc. What is crucial for the decision making.
!> The distance towards this conspecific in the visual field.
real(SRP) :: consp_distance
!> The sex of the conspecific in the perception object.
logical :: sex_is_male
contains
!> Create a single conspecific perception component at an undefined
!! position with default properties.
!! See `the_neurobio::consp_percept_comp_create()`.
procedure, public :: create => consp_percept_comp_create
!> Make a single conspecific perception component. This is a single
!! conspecific located within the visual range of the agent.
!! See `the_neurobio::consp_percept_make()`.
procedure, public :: make => consp_percept_make
!> Get the **conspecific** perception component body size.
!! See `the_neurobio::consp_percept_get_size()`.
procedure, public :: get_size => consp_percept_get_size
!> Get the **conspecific** perception component body mass.
!! See `the_neurobio::consp_percept_get_mass()`.
procedure, public :: get_mass => consp_percept_get_mass
!> Get the **conspecific** perception component distance.
!! See `the_neurobio::consp_percept_get_dist()`.
procedure, public :: get_dist => consp_percept_get_dist
!> Get the **conspecific** perception component sex flag (male).
!! See `the_neurobio::consp_percept_sex_is_male_get()`.
procedure, public :: is_male => consp_percept_sex_is_male_get
!> Get the **conspecific** perception component sex flag (female).
!! See `the_neurobio::consp_percept_sex_is_female_get()`.
procedure, public :: is_female => consp_percept_sex_is_female_get
end type CONSPEC_PERCEPT_COMP
!> This type defines how the agent perceives conspecifics.
type, public :: PERCEPT_CONSPECIFICS
!> An array of conspecifics seen in proximity, within the visual range.
!! @note Perception of conspecifics is implemented similar to food items.
!! Conspecific perception object the_neurobio::percept_conspecifics
!! is a simple the_environment::spatial object.
type(CONSPEC_PERCEPT_COMP), allocatable, dimension(:) :: conspecifics_seen
!> The number of conspecifics seen.
integer :: conspecifics_seen_count
contains
!> Create conspecifics perception object, it is an array of
!! conspecific perception components.
!! See `the_neurobio::percept_consp_create_init()`.
procedure, public :: init => percept_consp_create_init
!> Set the total number of conspecifics perceived (seen) in the
!! conspecific perception object.
!! See `the_neurobio::percept_consp_number_seen()`.
procedure, public :: number => percept_consp_number_seen
!> Make the conspecifics perception object, fill it with the actual
!! arrays.
!! See `the_neurobio::percept_consp_make_fill_arrays()`.
procedure, public :: make => percept_consp_make_fill_arrays
!> Get the number (count) of conspecifics seen.
!! See `the_neurobio::percept_consp_get_count_seen()`.
procedure, public :: get_count => percept_consp_get_count_seen
!> Deallocate and delete a conspecific perception object.
!! See `the_neurobio::percept_consp_destroy_deallocate()`.
procedure, public :: destroy => percept_consp_destroy_deallocate
end type PERCEPT_CONSPECIFICS
!> This type defines a **single** arbitrary spatial object perception
!! component. For example, a predator perception object is then an array of
!! such spatial object perception components.
type, public, extends(SPATIAL_PERCEPT_COMPONENT) :: SPATIALOBJ_PERCEPT_COMP
!> Size. The size of the perception object.
real(SRP) :: sobj_size
!> @note Any other characteristics of the perception conspecifics may
!! be added, e.g. sex etc. What is crucial for the decision making.
!> The distance towards this conspecific in the visual field.
real(SRP) :: sobj_distance
contains
!> Create a single arbitrary spatial object perception component at an
!! undefined position with default properties.
!! See `the_neurobio::spatialobj_percept_comp_create()`.
procedure, public :: create => spatialobj_percept_comp_create
!> Make a single arbitrary **spatial** object perception component.
!! See `the_neurobio::spatialobj_percept_make()`.
procedure, public :: make => spatialobj_percept_make
!> Get an arbitrary spatial object perception component size.
!! See `the_neurobio::spatialobj_percept_get_size()`.
procedure, public :: get_size => spatialobj_percept_get_size
!> Get the distance to an arbitrary spatial object perception component.
!! See `the_neurobio::spatialobj_percept_get_dist()`.
procedure, public :: get_dist => spatialobj_percept_get_dist
!> Calculate the visibility range of this spatial object. Wrapper to the
!! `visual_range` function. This function calculates the distance from
!! which this object can be seen by a visual object (e.g. predator or
!! prey).
!! See `the_neurobio::spatialobj_percept_visibility_visual_range()`.
procedure, public :: visibility => &
spatialobj_percept_visibility_visual_range
end type SPATIALOBJ_PERCEPT_COMP
!> This type defines how the agent perceives a predator.
type, public :: PERCEPT_PREDATOR
!> An array of predators seen in proximity, within the visual range.
!! @note Perception of an array of predators uses the arbitrary spatial
!! object components type defined by `SPATIALOBJ_PERCEPT_COMP`.
type(SPATIALOBJ_PERCEPT_COMP), allocatable, dimension(:) :: predators_seen
!> An array of the attack rates of the predators in the perception object.
real(SRP), allocatable, dimension(:) :: predators_attack_rates
!> The number of conspecifics seen.
integer :: predators_seen_count
contains
!> Create **conspecifics** perception object, it is an array of
!! conspecific perception components.
!! See `the_neurobio::percept_predator_create_init()`.
procedure, public :: init => percept_predator_create_init
!> Set the total number of **predators** perceived (seen) in the predator
!! perception object.
!! See `the_neurobio::percept_predator_number_seen()`.
procedure, public :: number => percept_predator_number_seen
!> Make the **predator** perception object, fill it with the
!! actual arrays.
!! See `the_neurobio::percept_predator_make_fill_arrays()`.
procedure, public :: make => percept_predator_make_fill_arrays
!> Set an array of the attack rates for the predator perception object.
!! See `the_neurobio::percept_predator_set_attack_rate_vector()`.
procedure, public :: set_attack_rate_v => percept_predator_set_attack_rate_vector
!> Set an array of the attack rates for the predator perception object.
!! See `the_neurobio::percept_predator_set_attack_rate_scalar()`.
procedure, public :: set_attack_rate_s => percept_predator_set_attack_rate_scalar
!> A generic interface to set the attack rates for the predator
!! perception object.
!! See `the_neurobio::percept_predator_set_attack_rate_vector()` and
!! `the_neurobio::percept_predator_set_attack_rate_scalar()`.
generic, public :: set_attack_rate => set_attack_rate_v, set_attack_rate_s
!> Get the number (count) of predators seen.
!! See `the_neurobio:percept_predator_get_count_seen:()`.
procedure, public :: get_count => percept_predator_get_count_seen
!> Deallocate and delete a **predator** perception object.
!! See `the_neurobio::percept_predator_destroy_deallocate()`.
procedure, public :: destroy => percept_predator_destroy_deallocate
end type PERCEPT_PREDATOR
!.............................................................................
! Internal perception components: perception of objects within the
! self organism.
!> This type defines how the agent perceives its own stomach capacity.
type, public :: PERCEPT_STOMACH
!> Available stomach capacity as a proportion of the full stomach. So,
!! 0 is full stomach (no space for new food), 1 is empty stomach (full
!! capacity available).
real(SRP) :: capacity
contains
!> Initiate an empty **stomach** capacity perception object.
!! See `the_neurobio::percept_stomach_create_init()`.
procedure, public :: init => percept_stomach_create_init
!> Get the currently available value of the available **stomach** volume.
!! See `the_neurobio::percept_stomach_get_avail_capacity()`.
procedure, public :: get_available => percept_stomach_get_avail_capacity
!> Set and update the currently available value of the available
!! **stomach** volume.
!! See `the_neurobio::percept_stomach_update_avail_capacity()`.
procedure, public :: set_available =>percept_stomach_update_avail_capacity
!> Destroy the **stomach** perception object and deallocate.
!! See `the_neurobio::percept_stomach_destroy_deallocate()`.
procedure, public :: destroy => percept_stomach_destroy_deallocate
end type PERCEPT_STOMACH
!> This type defines how the agent perceives its own body mass
!> it can be important for state-dependency.
type, public :: PERCEPT_BODY_MASS
!> The current body mass of the agent.
real(SRP) :: body_mass
contains
!> Initiate an empty **body mass** perception object.
!! See `the_neurobio::percept_bodymass_create_init()`.
procedure, public :: init => percept_bodymass_create_init
!> Get the current value of the **body mass** perception.
!! See `the_neurobio::percept_bodymass_get_current()`.
procedure, public :: get_current => percept_bodymass_get_current
!> Set and update the current **body mass** perception value.
!! See `the_neurobio::percept_bodymass_update_current()`.
procedure, public :: set_current => percept_bodymass_update_current
!> Destroy the **body mass** perception object and deallocate.
!! See `the_neurobio::percept_bodymass_destroy_deallocate()`.
procedure, public :: destroy => percept_bodymass_destroy_deallocate
end type PERCEPT_BODY_MASS
!> This type defines how the agent perceives its own energy reserves
!> it can be important for state-dependency.
type, public :: PERCEPT_ENERGY
!> The current energy reserves of the agent.
real(SRP) :: energy_reserve
contains
!> Initiate an empty **energy** perception object.
!! See `the_neurobio::percept_energy_create_init()`.
procedure, public :: init => percept_energy_create_init
!> Get the current value of the **energy** reserves.
!! See `the_neurobio::percept_energy_get_current()`.
procedure, public :: get_current => percept_energy_get_current
!> Set and update the current **energy** perception value.
!! See `the_neurobio::percept_energy_update_current()`.
procedure, public :: set_current =>percept_energy_update_current
!> Destroy the **energy** perception object and deallocate.
!! See `the_neurobio::percept_energy_destroy_deallocate()`.
procedure, public :: destroy => percept_energy_destroy_deallocate
end type PERCEPT_ENERGY
!> This type defines how the agent perceives its own age in terms of
!! the model discrete time step.
type, public :: PERCEPT_AGE
integer :: age
contains
!> Initiate an empty **age** perception object.
!! See `the_neurobio::percept_age_create_init()`.
procedure, public :: init => percept_age_create_init
!> Get the current value of the **age** reserves.
!! See `the_neurobio::percept_age_get_current()`.
procedure, public :: get_current => percept_age_get_current
!> Set and update the current **age** perception value.
!! See `the_neurobio::percept_age_update_current()`.
procedure, public :: set_current =>percept_age_update_current
!> Destroy the **age** perception object and deallocate.
!! See `the_neurobio::percept_age_destroy_deallocate()`.
procedure, public :: destroy => percept_age_destroy_deallocate
end type PERCEPT_AGE
!> Perception of the reproductive factor, reproductive factor depends
!! on the sex hormones differently in males and females.
type, public :: PERCEPT_REPRFACT
real(SRP) :: reproduct_fact
contains
!> Make en empty reproductive factor perception component.
!! See `the_neurobio::percept_reprfac_create_init()`.
procedure, public :: init => percept_reprfac_create_init
!> Get the current perception of the **reproductive factor**.
!! See `the_neurobio::percept_reprfac_get_current()`.
procedure, public :: get_current => percept_reprfac_get_current
!> Set the current **reproductive factor** level into perception component.
!! See `the_neurobio::percept_reprfac_set_current()`.
procedure, public :: set_current => percept_reprfac_set_current
!> Destroy / deallocate **reproductive factor** perception component.
!! See `the_neurobio::percept_reprfac_destroy_deallocate()`.
procedure, public :: destroy => percept_reprfac_destroy_deallocate
end type PERCEPT_REPRFACT
!.............................................................................
! External **direct** non-spatial perception components: perception of the
! general environmental factors like light and depth that are not localised
! in the environment and can be perceived directly. The functions are almost
! wholly trivial, but needed here to make perception structure consistent and
! consisting of the same standardised units.
!> Perception of the ambient illumination. This is a very simple
!! perception component, singular and static.
type, public :: PERCEPT_LIGHT
real(SRP) :: illumination
contains
!> Make en empty light perception component.
!! See `the_neurobio::percept_light_create_init()`.
procedure, public :: init => percept_light_create_init
!> Get the current perception of the illumination.
!! See `the_neurobio::percept_light_get_current()`.
procedure, public :: get_current => percept_light_get_current
!> Set the current **light** level into the perception component.
!! See `the_neurobio::percept_light_set_current()`.
procedure, public :: set_current => percept_light_set_current
!> Destroy / deallocate **light** perception component.
!! See `the_neurobio::percept_light_destroy_deallocate()`.
procedure, public :: destroy => percept_light_destroy_deallocate
end type PERCEPT_LIGHT
!> Perception of the current depth horizon.
type, public :: PERCEPT_DEPTH
real(SRP) :: depth
contains
!> Make en empty depth perception component.
!! See `the_neurobio::percept_depth_create_init()`.
procedure, public :: init => percept_depth_create_init
!> Get the current perception of the **depth**.
!! See `the_neurobio::percept_depth_get_current()`.
procedure, public :: get_current => percept_depth_get_current
!> Set the current **depth** level into the perception component.
!! See `the_neurobio::percept_depth_set_current()`.
procedure, public :: set_current => percept_depth_set_current
!> Destroy / deallocate **depth** perception component.
!! See `the_neurobio::percept_depth_destroy_deallocate()`.
procedure, public :: destroy => percept_depth_destroy_deallocate
end type PERCEPT_DEPTH
!.............................................................................
! Here we collect all the above individual perception components into a
! unitary individual-specific perception object.
!> Individual perception memory(history) stack, a memory component that
!! saves perception values at previous time steps of the model. Not whole
!! perception objects are saved for simplicity, only the most important
!! parameters, integer and real types so commondata::add_to_history() can
!! be used in unmodified form. Decision making can make use of this memory
!! stack.
!! @note Note that age perception `the_neurobio::percept_age` is **not
!! saved** in memory stack as it is trivial to get/predict.
type, public :: MEMORY_PERCEPTUAL
!> Memory for **light**.
real(SRP), dimension(HISTORY_SIZE_PERCEPTION) :: memory_light ! Light
!> Memory for **depth**.
real(SRP), dimension(HISTORY_SIZE_PERCEPTION) :: memory_depth ! Depth
!> Memory for **number of food items** seen (in perception).
integer , dimension(HISTORY_SIZE_PERCEPTION) :: memory_food ! N foods
!> Memory for **mean size of food items** seen (in perception).
real(SRP), dimension(HISTORY_SIZE_PERCEPTION) :: memory_foodsiz ! mean size
!> Memory for **mean distance to the food items** seen (in perception).
real(SRP), dimension(HISTORY_SIZE_PERCEPTION) :: memory_foodist ! mean dist
!> Memory for **number of conspecifics** seen.
integer , dimension(HISTORY_SIZE_PERCEPTION) :: memory_consp ! N consp.
!> Memory for **number of predators**.
integer , dimension(HISTORY_SIZE_PERCEPTION) :: memory_pred ! N pred.
!> Memory for **stomach contents**.
real(SRP), dimension(HISTORY_SIZE_PERCEPTION) :: memory_stom ! Stomach
!> Memory for **body mass**.
real(SRP), dimension(HISTORY_SIZE_PERCEPTION) :: memory_bdmass ! Body mass
!> Memory for **energy reserves**.
real(SRP), dimension(HISTORY_SIZE_PERCEPTION) :: memory_energ ! Energy
!> Memory for **reproductive factor** values.
real(SRP), dimension(HISTORY_SIZE_PERCEPTION) :: memory_reprfac ! Repr.fact.
contains
!> Add perception components into the memory stack.
!! See `the_neurobio::percept_memory_add_to_stack()`.
procedure, public :: add_to_memory => percept_memory_add_to_stack
!> Cleanup and destroy the perceptual memory stack.
!! See `the_neurobio::percept_memory_cleanup_stack()`.
procedure, public :: memory_cleanup => percept_memory_cleanup_stack
!> Get the total number of food items within the whole perceptual memory
!! stack. See `the_neurobio::percept_memory_food_get_total()`.
procedure, public :: get_food_total => percept_memory_food_get_total
!> Get the average number of food items per single time step within the
!! whole perceptual memory stack.
!! See `the_neurobio::percept_memory_food_get_mean_n()`.
procedure, public :: get_food_mean_n => percept_memory_food_get_mean_n
!> Get the **average number** of food items per single time step within
!! the perceptual memory stack, split to the first (older) and second
!! (newer) parts. The whole memory stack ('sample') is split by the
!! `split_val` parameter and two means are calculated: before the
!! `split_val` and after it.
!! See `the_neurobio::percept_memory_food_mean_n_split()`.
procedure, public :: get_food_mean_n_split => &
percept_memory_food_mean_n_split
!> Get the average size of food item per single time step within the
!! whole perceptual memory stack.
!! See `the_neurobio::percept_memory_food_get_mean_size()`.
procedure, public :: get_food_mean_size=>percept_memory_food_get_mean_size
!> Get the **average size** of food items per single time step within the
!! perceptual memory stack, split to the first (older) and second(newer)
!! parts. The whole memory stack 'sample' is split by the `split_val`
!! parameter and two means are calculated: before the `split_val` and
!! after it. See `the_neurobio::percept_memory_food_mean_size_split()`.
procedure, public :: get_food_mean_size_split => &
percept_memory_food_mean_size_split
!> Get the **average distance** to food item per single time step within the
!! whole perceptual memory stack.
!! See `the_neurobio::percept_memory_food_get_mean_dist()`.
procedure, public :: get_food_mean_dist => &
percept_memory_food_get_mean_dist
!> Get the **average distance** to food items per single time step within the
!! perceptual memory stack, split to the first (older) and second(newer)
!! parts. The whole memory stack 'sample' is split by the `split_val`
!! parameter and two means are calculated: before the `split_val` and after
!! it. See `the_neurobio::percept_memory_food_mean_dist_split()`.
procedure, public :: get_food_mean_dist_split => &
percept_memory_food_mean_dist_split
!> Get the **average number** of conspecifics per single time step
!! within the whole perceptual memory stack.
!! See `the_neurobio::percept_memory_consp_get_mean_n()`.
procedure, public :: get_consp_mean_n => percept_memory_consp_get_mean_n
!> Get the total number of predators within the whole perceptual memory
!! stack. See `the_neurobio::percept_memory_predators_get_total()`.
procedure, public :: get_pred_total => percept_memory_predators_get_total
!> Get the average number of predators per single time step within the
!! whole perceptual memory stack.
!! See `the_neurobio::percept_memory_predators_get_mean()`.
procedure, public :: get_pred_mean => percept_memory_predators_get_mean
!> Get the **average number** of predators per single time step within the
!! perceptual memory stack, split to the first (older) and second(newer)
!! parts. The whole memory stack ('sample') is split by the `split_val`
!! parameter and two means are calculated: before the `split_val` and after
!! it. See `the_neurobio::percept_memory_predators_mean_split()`.
procedure, public :: get_pred_mean_split => &
percept_memory_predators_mean_split
end type MEMORY_PERCEPTUAL
!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
!> The perception architecture of the agent. See @ref aha_buildblocks_percept
!! "\"The perception mechanism\"" for a general overview.
!! At this level, lower order perception objects are combined into the
!! the_neurobio::perception class hierarchy level of the agent. The object
!! bound functions see_ and feel_ obtain (**set**) the specific perception
!! objects from the external or internal environments of the agent and put
!! them into the the_neurobio::perception data structure. Also, memory
!! component is updated with the perception data. Perception objects can
!! then be used as input into the individual decision-making procedures.
!! @note **Templates for outer environmental perceptions**:
!! @code
!! call proto_parents%individual(ind)%see_food( &
!! food_resource_available = habitat_safe%food, &
!! time_step_model = 1)
!!
!! call proto_parents%individual(ind)%see_consp( &
!! consp_agents = proto_parents%individual, &
!! time_step_model = 1 )
!!
!! call proto_parents%individual(ind)%see_pred( &
!! spatl_agents = predators, &
!! time_step_model = 1 )
!! call proto_parents%individual(ind)%feel_light(timestep)`
!! call proto_parents%individual(ind)%feel_depth()
!! @endcode
type, public, extends(REPRODUCTION) :: PERCEPTION
type(PERCEPT_LIGHT) :: perceive_light !> perception of light
type(PERCEPT_DEPTH) :: perceive_depth !> perception of depth
type(PERCEPT_FOOD) :: perceive_food !> perception of food
type(PERCEPT_CONSPECIFICS) :: perceive_consp !> conspecifics perception
type(PERCEPT_PREDATOR) :: perceive_predator !> perceive predator
type(PERCEPT_STOMACH) :: perceive_stomach !> perception for stomach
type(PERCEPT_BODY_MASS) :: perceive_body_mass !> perception for bodymass
type(PERCEPT_ENERGY) :: perceive_energy !> percept. for energy
type(PERCEPT_AGE) :: perceive_age !> percept. of age
type(PERCEPT_REPRFACT) :: perceive_reprfac !> percept. of repr.factor
type(MEMORY_PERCEPTUAL) :: memory_stack !> @note Memory object.
contains
!> Get **light** perception objects into the individual
!! the_neurobio::perception object layer.
!! See `the_neurobio::light_perception_get_object()`.
procedure, public :: feel_light => light_perception_get_object
!> Get **depth** perception objects into the **individual**
!! the_neurobio::perception object layer.
!! See `the_neurobio::depth_perception_get_object()`.
procedure, public :: feel_depth => depth_perception_get_object
!> Get available food items within the visual range of the agent, which
!! the agent can perceive and therefore respond to. Food perception is
!! packaged into the food perception object `this%perceive_food` for
!! output. See `the_neurobio::food_perception_get_visrange_objects()`.
procedure, public :: see_food => food_perception_get_visrange_objects
!> Get available conspecific perception objects within the visual range
!! of the agent, which the agent can perceive and therefore respond to.
!! See `the_neurobio::consp_perception_get_visrange_objects()`.
procedure, public :: see_consp => consp_perception_get_visrange_objects
!> Get available predators perception objects within the visual range of
!! the agent, which the agent can perceive and therefore respond to.
!! See `the_neurobio::predator_perception_get_visrange_objects()`.
procedure, public :: see_pred => predator_perception_get_visrange_objects
!> Get the **stomach capacity** perception objects into the **individual**
!! the_neurobio::perception object layer.
!! See `the_neurobio::stomach_perception_get_object()`.
procedure, public :: feel_stomach => stomach_perception_get_object
!> Get the **body mass** perception objects into the **individual**
!! the_neurobio::perception object layer.
!! See `the_neurobio::bodymass_perception_get_object()`.
procedure, public :: feel_bodymass => bodymass_perception_get_object
!> Get the **energy reserves** perception objects into the **individual**
!! the_neurobio::perception object layer.
!! See `the_neurobio::energy_perception_get_object()`.
procedure, public :: feel_energy => energy_perception_get_object
!> Get the **age** perception objects into the **individual**
!! the_neurobio::perception object layer.
!! See `the_neurobio::age_perception_get_object()`.
procedure, public :: feel_age => age_perception_get_object
!> Get the **reproductive factor** perception objects into the
!! **individual** the_neurobio::perception object layer.
!! See `the_neurobio::repfac_perception_get_object()`.
procedure, public :: feel_repfac => repfac_perception_get_object
!> Calculate the risk of **predation** as being **perceived / assessed**
!! by this agent.
!! See `the_neurobio::perception_predation_risk_objective()`.
procedure, public :: predation_risk => perception_predation_risk_objective
!> A single umbrella subroutine to get all **environmental** perceptions:
!! light, depth.
!! See `the_neurobio::perception_objects_get_all_environmental()`.
procedure, public :: perceptions_environ => perception_objects_get_all_environmental
!> A single umbrella subroutine wrapper to get all **inner** perceptions:
!! stomach, body mass, energy, age.
!! See `the_neurobio::perception_objects_get_all_inner()`.
procedure, public :: perceptions_inner => perception_objects_get_all_inner
!> Add the various perception objects to the memory stack object. This
!! procedure is called **after** all the perceptual components (light,
!! depth food, conspecifics, predators, etc.) are collected (using `set`
!! object-bound subroutines) into the perception bundle, so all the
!! values are known and ready to be used.
!! See `the_neurobio::perception_objects_add_memory_stack()`.
procedure, public :: perception_to_memory => perception_objects_add_memory_stack
!> Initialise all the perception objects for the current agent. Do not
!! fill perception objects with the real data yet.
!! See `the_neurobio::perception_objects_init_agent()`.
procedure, public :: init_perception => perception_objects_init_agent
!> Destroy and deallocate all perception objects.
!! See `the_neurobio::perception_objects_destroy()`.
procedure, public :: destroy_perception => perception_objects_destroy
! Accessor methods (get).
!> Check if the agent sees any food items within its visual range.
!! See `the_neurobio::food_perception_is_seeing_food()`.
procedure, public :: has_food => food_perception_is_seeing_food
!> Check if the agent sees any conspecifics within the visual range.
!! See `the_neurobio::consp_perception_is_seeing_conspecifics()`.
procedure, public :: has_consp => consp_perception_is_seeing_conspecifics
!> Check if the agent sees any predators within the visual range.
!! See `the_neurobio::predator_perception_is_seeing_predators()`.
procedure, public :: has_pred => predator_perception_is_seeing_predators
! Relative location functions: Food items
!> Calculate the number of food items in the perception object that are
!! located **below** the actor agent.
!! See `the_neurobio::perception_food_items_below_calculate()`
procedure, public :: food_items_below_all => &
perception_food_items_below_calculate
!> Calculate the number of food items in the perception object that are
!! located **below** the actor agent within a specific vertical horizon
!! [hz_lower,hz_upper]. The horizon limits are relative, in that they
!! start from the depth position of the `this` actor agent:
!! [z+hz_lower, z+hz_upper].
!! See `the_neurobio::perception_food_items_below_horiz_calculate()`.
procedure, public :: food_items_below_horiz => &
perception_food_items_below_horiz_calculate
!> A generic interface for the two functions calculating the number of
!! food items in the perception object that are located **below** the
!! actor agent. See perception::food_items_below_all(),
!! perception::food_items_below_horiz().
generic, public :: food_items_below => &
food_items_below_all, food_items_below_horiz
!> Calculate the average mass of a food item from all the items in the
!! current perception object that are **below** the actor agent.
!! See `the_neurobio::perception_food_mass_below_calculate()`.
procedure, public :: food_mass_below_all => &
perception_food_mass_below_calculate
!> Calculate the average mass of a food item from all the items in the
!! current perception object that are **below** the actor agent within a
!! specific vertical horizon [hz_lower,hz_upper]. The horizon limits are
!! relative, in that they start from the depth position of the `this`
!! actor agent: [z+hz_lower, z+hz_upper].
!! See `the_neurobio::perception_food_mass_below_horiz_calculate()`.
procedure, public :: food_mass_below_horiz => &
perception_food_mass_below_horiz_calculate
!> A generic interface to the two functions that calculating the
!! average mass of food items in the perception object that are located
!! **below** the actor agent. See perception::food_mass_below_all(),
!! perception::food_mass_below_horiz().
generic, public :: food_mass_below => &
food_mass_below_all, food_mass_below_horiz
!> Calculate the number of food items in the perception object that are
!! located **above** the actor agent.
!! See `the_neurobio::perception_food_items_above_calculate()`
procedure, public :: food_items_above_all => &
perception_food_items_above_calculate
!> Calculate the number of food items in the perception object that are
!! located **above** the actor agent within a specific vertical horizon
!! [hz_lower,hz_upper]. The horizon limits are relative, in that they
!! start from the depth position of the `this` actor agent:
!! [z-hz_upper, z-hz_upper].
!! See `the_neurobio::perception_food_items_above_horiz_calculate()`.
procedure, public :: food_items_above_horiz => &
perception_food_items_above_horiz_calculate
!> A generic interface for the two functions calculating the number of
!! food itemsin the perception object that are located **below** the
!! actor agent. See perception::food_items_above_all(),
!! perception::food_items_above_horiz().
generic, public :: food_items_above => &
food_items_above_all, food_items_above_horiz
!> Calculate the average mass of a food item from all the items in the
!! current perception object that are **above** the actor agent.
!! See `the_neurobio::perception_food_mass_above_calculate()`.
procedure, public :: food_mass_above_all => &
perception_food_mass_above_calculate
!> Calculate the average mass of a food item from all the items in the
!! current perception object that are **above** the actor agent within a
!! specific vertical horizon [hz_lower,hz_upper]. The horizon limits are
!! relative, in that they start from the depth position of the `this`
!! actor agent: [z-hz_upper, z-hz_upper].
!! See `the_neurobio::perception_food_mass_above_horiz_calculate()`.
procedure, public :: food_mass_above_horiz => &
perception_food_mass_above_horiz_calculate
!> A generic interface to the two functions that calculating the
!! average mass of food items in the perception object that are located
!! **above** the actor agent. See perception::food_mass_above_all(),
!! perception::food_mass_above_horiz().
generic, public :: food_mass_above => &
food_mass_above_all, food_mass_above_horiz
!> Calculate the average distance to all food items in the current
!! perception object that are **below** the actor agent.
!! See `the_neurobio::perception_food_dist_below_calculate()`.
procedure, public :: food_dist_below => &
perception_food_dist_below_calculate
!> Calculate the average distance to all food items in the current
!! perception object that are **above** the actor agent.
!! See `the_neurobio::perception_food_dist_above_calculate()`.
procedure, public :: food_dist_above => &
perception_food_dist_above_calculate
! Relative location functions: conspecifics
!> Calculate the number of conspecifics in the perception object that are
!! located **below** the actor agent.
!! See `the_neurobio::perception_conspecifics_below_calculate()`.
procedure, public :: consp_below_all => &
perception_conspecifics_below_calculate
!> Calculate the number of conspecifics in the perception object that are
!! located **above** the actor agent.
!! See `the_neurobio::perception_conspecifics_above_calculate()`.
procedure, public :: consp_above_all => &
perception_conspecifics_above_calculate
!> Calculate the number of conspecifics in the perception object that are
!! located **below** the actor agent within a specific vertical horizon
!! [hz_lower,hz_upper].
!! See `the_neurobio::perception_conspecifics_below_horiz_calculate()`.
procedure, public :: consp_below_horiz => &
perception_conspecifics_below_horiz_calculate
!> Calculate the number of conspecifics in the perception object that are
!! located **above** the actor agent within a specific vertical horizon
!! [hz_lower,hz_upper].
!! See `the_neurobio::perception_conspecifics_above_horiz_calculate()`.
procedure, public :: consp_above_horiz => &
perception_conspecifics_above_horiz_calculate
!> A generic interface to the two functions that calculating the
!! number of conspecifics in the perception object that are located
!! **below** the actor agent. See perception::consp_below_all(),
!! perception::consp_below_horiz().
generic, public :: consp_below => consp_below_all, consp_below_horiz
!> A generic interface to the two functions that calculating the
!! number of conspecifics in the perception object that are located
!! **above** the actor agent. See perception::consp_above_all(),
!! perception::consp_above_horiz().
generic, public :: consp_above => consp_above_all, consp_above_horiz
!> Calculate the average distance to all conspecifics in the current
!! perception object that are **below** the actor agent.
!! See `the_neurobio::perception_consp_dist_below_calculate()`.
procedure, public :: consp_dist_below => &
perception_consp_dist_below_calculate
!> Calculate the average distance to all conspecifics in the current
!! perception object that are **above** the actor agent.
!! See `the_neurobio::perception_consp_dist_above_calculate()`.
procedure, public :: consp_dist_above => &
perception_consp_dist_above_calculate
! Relative location functions: predators
!> Calculate the number of predators in the perception object that are
!! located **below** the actor agent.
!! See `the_neurobio::perception_predator_below_calculate()`.
procedure, public :: pred_below_all => perception_predator_below_calculate
!> Calculate the number of predators in the perception object that are
!! located **above** the actor agent.
!! See `the_neurobio::perception_predator_above_calculate()`.
procedure, public :: pred_above_all => perception_predator_above_calculate
!> Calculate the number of predators in the perception object that are
!! located **below** the actor agent within a specific vertical horizon
!! [hz_lower,hz_upper].
!! See `the_neurobio::perception_predator_below_horiz_calculate`.
procedure, public :: pred_below_horiz => &
perception_predator_below_horiz_calculate
!> Calculate the number of predators in the perception object that are
!! located **above** the actor agent within a specific vertical horizon
!! [hz_lower,hz_upper].
!! See `the_neurobio::perception_predator_above_horiz_calculate`.
procedure, public :: pred_above_horiz => &
perception_predator_above_horiz_calculate
!> A generic interface to the two functions that calculating the
!! number of predators in the perception object that are located
!! **below** the actor agent. See perception::pred_below_all(),
!! perception::pred_below_horiz().
generic, public :: pred_below => pred_below_all, pred_below_horiz
!> A generic interface to the two functions that calculating the
!! number of predators in the perception object that are located
!! **above** the actor agent. See perception::pred_above_all(),
!! perception::pred_above_horiz().
generic, public :: pred_above => pred_above_all, pred_above_horiz
!> Calculate the average distance to all predators in the current
!! perception object that are **below** the actor agent.
!! See `the_neurobio::perception_predator_dist_below_calculate()`.
procedure, public :: pred_dist_below => &
perception_predator_dist_below_calculate
!> Calculate the average distance to all predators in the current
!! perception object that are **above** the actor agent.
!! See `the_neurobio::perception_predator_dist_above_calculate()`.
procedure, public :: pred_dist_above => &
perception_predator_dist_above_calculate
!> Calculate the probability of attack and capture of the `this` agent by
!! the predator `this_predator`. This probability is a function of the
!! distance between the predator and the agent and is calculated by the
!! predator-class-bound procedure the_environment::predator::risk_fish().
!! @note Note that this version of the procedure accepts `this_predator`
!! parameter as class the_neurobio::spatialobj_percept_comp that is
!! used for keeping the predator representations in the **perception
!! object**. This representation keeps two separate array for
!! the_neurobio::spatialobj_percept_comp spatial objects and the
!! attack rate.
!! See `the_neurobio::predator_capture_probability_calculate_spatobj()`.
procedure, public :: risk_pred_s => &
predator_capture_probability_calculate_spatobj
!> Calculate the probability of attack and capture of the `this` agent by
!! the predator `this_predator`. This probability is a function of the
!! distance between the predator and the agent and is calculated by the
!! predator-class-bound procedure the_environment::predator::risk_fish().
!! @note Note that this version of the procedure accepts `this_predator`
!! parameter as class the_neurobio::predator, i.e. for the
!! **objective predator object**.
!! See `the_neurobio::predator_capture_probability_calculate_pred()`.
procedure, public :: risk_pred_p => &
predator_capture_probability_calculate_pred
!> Calculate the overall direct predation risk for the agent, i.e.
!! the probability of attack and capture by the nearest predator.
!! See `the_neurobio::predation_capture_probability_risk_wrapper()`.
procedure, public :: risk_pred_w => &
predation_capture_probability_risk_wrapper
!> A single generic interface for the calculation of the probability of
!! attack and capture of the `this` agent by a predator.
!! See `the_neurobio::predator_capture_probability_calculate_spatobj()`,
!! `the_neurobio::predator_capture_probability_calculate_pred()` and
!! `the_neurobio::predation_capture_probability_risk_wrapper()`.
generic, public :: risk_pred => risk_pred_s, risk_pred_p, risk_pred_w
!> Calculate the probability of capture of a subjective representation of
!! food item based on the data from the perceptual memory stack. See
!! `the_neurobio::food_perception_probability_capture_memory_object()`.
procedure, public :: food_probability_capture_subjective => &
food_perception_probability_capture_memory_object
end type PERCEPTION
!> Perceptual components of motivational states. Plugged into all `STATE_`,
!! attention etc. These components are linked to specific inner or outer
!! perception objects (stimuli). Their sum result(s) in the overall
!! value of the motivation component.
type, public :: PERCEPT_COMPONENTS_MOTIV
!> Light perception, direct environmental.
real(SRP) :: light
!> Depth perception, direct environmental.
real(SRP) :: depth
!> Perception of directly seen food items, spatial.
real(SRP) :: food_dir
!> Perception of the food items in the memory stack.
real(SRP) :: food_mem
!> Perception of conspecifics, spatial.
real(SRP) :: conspec
!> Direct perception of predators, spatial. Based on the distance
!! to the nearest predator.
real(SRP) :: pred_dir
!> General perception of predation risk, spatial. Based on a sum of the
!! number of predators in the perception object weighted by the number of
!! predators in the memory stack.
real(SRP) :: predator
!> Perception of the stomach contents, direct, internal.
real(SRP) :: stomach
!> Perception of the body mass, direct, internal.
real(SRP) :: bodymass
!> Perception of the energy reserves, direct, internal.
real(SRP) :: energy
!> Age perception, direct internal.
real(SRP) :: age
!> Perception of the reproductive factor, based on the sex steroid
!! hormones, calculated differently in males and females.
real(SRP) :: reprfac
contains
!> Initialise perception components for a motivation state object.
!! See `the_neurobio::perception_component_motivation_init_zero()`.
procedure, public :: init => perception_component_motivation_init_zero
!> Calculate the **maximum** value over all the perceptual components.
!! See `the_neurobio::perception_component_maxval()`.
procedure, public :: max_value => perception_component_maxval
!> Calculate individual perceptual components for **this** motivational
!! state using the **neuronal response** function, for an agent. This
!! agent has intent[in], so is **unchanged** in this procedure. Also
!! `motivation_components` can take optional arbitrary (fake) perception
!! values.
!! @note This procedure is used for normal calculations of motivation
!! components. A similar method with the agent intent[inout]
!! the_neurobio::percept_components_motiv::motivation_components_init()
!! is used to initialise an agent.
!! See
!! `the_neurobio::perception_components_neuronal_response_calculate()`.
procedure, public :: motivation_components => &
perception_components_neuronal_response_calculate
!> Calculate individual perceptual components for **this** motivational
!! state using the **neuronal response** function, for an agent. This
!! agent has intent[inout], so **is changed** (gene labels reset).
!> @warning This procedure is used only for initialisation of an agent.
!! For normal calculation of the motivational components use
!! the_neurobio::percept_components_motiv::motivation_components()
!! procedure that does not change the actor agent (intent[in]).
!! See `the_neurobio::perception_components_neuronal_response_init_set()`.
procedure, public :: motivation_components_init => &
perception_components_neuronal_response_init_set
!> Initialise the attention components of the emotional state to their
!! default parameter values. Attention sets weights to individual
!! perceptual components when the overall weighted sum is calculated.
!! The default weights are parameters defined in `COMMONDATA`.
!! See `the_neurobio::perception_components_attention_weights_init()`.
procedure, public :: attention_init => &
perception_components_attention_weights_init
end type PERCEPT_COMPONENTS_MOTIV
!> These types describe the **neurobiological states** of the agent.
!! (1) Each state may have several components that are related to specific
!! inner or outer perception objects (stimuli). (2) There is also a
!! `motivation` component that describes the global **motivation** value
!! for this state.
!!
!! This is the **base type** that serves as root for all other
!! motivation and emotion states, which are **extensions** of this
!! the_neurobio::state_motivation_base type.
type, abstract, public :: STATE_MOTIVATION_BASE
!> Label for the motivation state, fixed, **cannot be changed**.
!! @note Note that the label can be used as an **ID** for the motivational
!! state.
!! @note Note that we cannot use `protected` attribute within derived type,
!! so make it `private` and implement the accessor function
!! \%label_is. The label component is then set in each derived
!! motivation object in its respective `clean_init` procedure.
!! @note Note that the `clean_init` procedure is deferred (see abstract
!! interface) in this abstract type. Specific `clean_init` should
!! be implemented for each of the separate motivational/emotional
!! state type.
!! @note The procedure `motivation_components` does not seem to be necessary
!! at this level of class hierarchy as it would duplicate that in
!! the_neurobio::percept_components_motiv. Therefore just call the
!! upper procedure \%percept_component\%motivation_components().
character(len=LABEL_LENGTH), private :: label
!> **Perceptual components**.
type(PERCEPT_COMPONENTS_MOTIV) :: percept_component
!> **Attention** sets the weights given to the individual perceptual
!! components in the calculation of the motivation value.
type(PERCEPT_COMPONENTS_MOTIV) :: attention_weight
!> Overall **primary motivation values**.
real(SRP) :: motivation_prim
!> Overall **final** motivation value after modulation is performed.
real(SRP) :: motivation_finl
!> Overall GOS value, is this motivation state is dominant (TRUE/FALSE)?
!> @note Note that only one state can be dominant at a time (Or not?
logical :: dominant_state
contains
!> Abstract **init** function that has to be overridden by each object
!! that extends the basic motivational state type.
!! @warning Needs abstract interface, with import of the base object
!! type `the_neurobio::state_motivation_base`.
procedure(motivation_init_root), public, deferred :: clean_init
!> These are basically the accessor `get`-functions, the `set`-functions
!! are based on neural response from the perception object
!! the_neurobio::appraisal.
!> Get **light** perception component for this motivation state.
!! See `the_neurobio::state_motivation_light_get()`.
procedure, public :: get_light => state_motivation_light_get
!> Get **depth** perception component for this motivation state.
!! See `the_neurobio::state_motivation_depth_get()`.
procedure, public :: get_depth => state_motivation_depth_get
!> Get **directly perceived food** perception component for this
!! motivation state. See `the_neurobio::state_motivation_food_dir_get()`.
procedure, public :: get_food_dir => state_motivation_food_dir_get
!> Get **food in past memory** perception component for this motivation
!! state. See `the_neurobio::state_motivation_food_mem_get()`.