A SINGLE FORAGER IN A COMPLEX MEDIUM:
A SINGLE FORAGER IN A COMPLEX MEDIUM:

See the corresponding manuscript (Proc. R. Soc. B) here.

 

The Fortran code is greedy.weight.f

N point-like targets are distributed randomly in a square domain of length 1. Both x(i) and y(i), the coordinates of target number i (i=1,…,N), are random numbers uniformly and independently chosen in the interval (0,1). rkiss() is the random number generator.

The fruit content of target number i is a positive integer, stored as eta(i), distributed according to an inverse power law p(k)=C k–λ (k=1,2…,kmax). C is the normalization constant such that Σk=1...kmax p(k) = 1. The exponent λ is β in the manuscript. The maximum value kmax is a cut-off that depends on N and λ: kmax is chosen such that there is at most one site, among the N ones, with size larger or equal to kmax. kmax therefore satisfies the equation: N Σk=kmax...∞ p(k) = 1.

 

A forager starts from a site i0 located near the center of the square domain. The values of the ratio d(i0,j)/eta(j) are calculated for all j different from i0, where d(i0,i) is the Euclidian distance between sites i0 and j, and eta(j) fruit content of target j.The site with lowest ratio is im. The forager’s new position is set to x(im), y(im). The target i0 is removed from the box (x(i0)=y(i0)=100, eta(i0)=1) and im becomes the new i0. The process is carried out recursively. (The program has not been optimized.)

The result file is <namerun>.<run number>.pos: for instance, the file <namerun>.024.pos contains the results of the 24th independent run, if various runs are performed with the same parameters. Each result file records 3 quantities per line: x(i0), y(i0), eta(i0). The lines correspond to the sequence of visited targets.

 

Parameters of the program:

 

ntrap :total number of targets

tmax : number of visited targets by a forager during the run (‹‹ ntrap).

namerun : first letters of the name of the result files. It is a character chain of 13 letters, see line: character*13 namerun. The length can be changed accordingly.

lambda : parameter β in the manuscript.

iruni : usually set to 1.

irunf : number of independent runs (different environments and starting positions).