112
X-Machines for Agent-Based Modeling: FLAME Perspectives
double rnum;
rnum=(double)rand()/(double)RAND_MAX;
if (rnum<0.5) //break a tie
{
for(i=0,i {
add_bond(&bond_list,MYBONDS.array[i].from, MYBONDS.array[i].to);
}
random_position=(double)rand()/(double)RAND_MAX*MYBONDS.size;
//remove bond from a random actor
remove_bond(&MYBONDS,random_position);
}
else // form a tie with an actor Im not connected to
{
actor_location_message=get_first_actor_location_message();
while(actor_location_message)
{
for(i=0;i {
//check if I already have a bond with another actor
if(bond_list.array[i].from==ID) AND
(bond_list.array[i].to==actor_message->id)
{ //ignore
actor_found =0;
}
else
{
actor_found =actor_message->id;
}
}//end of for loop
actor_location_message=get_next_actor_location_message
(actor_location_message);
}
if(actor_found!=0)
{
add_bond(&MYBONDS, ID, actor_found);
}
return 0;
}
5.2.1 Set Up a Recurring Function
Time units can allow functions to run only at certain iteration steps. The
complexity of calculating this is handled by FLAME, but needs to be defined
by modelers in the model XML file. In the example, using popBoard unit and
setting its frequency to 10,000 means that this function will run every 10,000
steps in the simulation. The function Actor post location() should then add
this time condition. This function will thus run once in iteration 1, and then
only run every 10,000th iteration.
Précédent

- 141/329

Suivant