The following is example CHARON code to show the structure of navigation mode switching based on the variable comfort. The first mode, comfortMode, shows the general structure of each navigation mode.


mode comfortMode ( int a , int b , int k )
{
  write analog real comfort ;
  read discrete real myVelocity ; 

  diff {d(comfort)==0.1*(k*myVelocity/6 + 
            (k*myVelocity/6*Function.getNextRandom()-k*myVelocity/12))}

  inv { comfort >= a && comfort <= b } 
}

As illustrated in the code fragment that follows, this form is repeatedly instantiated to create the comfort modes among which the navigating agent switches. The bounds for each mode are input as arguments a and b. The other argument, k, is a scaling coefficient. (A full explanation of code presented here is beyond the scope of this supplementary material.) Note that the random number generator used in this differential equation form is from Java, not CHARON, in the call Function.getNextRandom(). Throughout the differential equation form, coefficients have been chosen to fit the particulars of our example. They might be different for different navigation applications.

Our paper states that aggressiveness, velocity, and the dynamical function for comfort all change from mode to mode. Only the change in the dynamics of comfort are explicitly represented in the code fragment above. Changes in aggressiveness and velocity are implemented as effects that accompany mode changes, as shown below; aggressiveness is represented by variable d1 and velocity by myVelocity.


mode comfortSelectiveMode () 
{
  write analog real comfort ; 
  read analog real A1x , A1y ;
  read analog real T2x , T2y ;
  read discrete real T2size ;
  write discrete real myVelocity ; 
  write discrete real d1 ;

  mode lessThanTwo = comfortMode ( -10000 , 2 , 40 ) ;
  mode twoFour = comfortMode ( 2 , 4 , 22 ) ;
  mode fourSix = comfortMode ( 4 , 6 , 14 ) ;
  mode sixEight = comfortMode ( 6 , 8 , 16 ) ;
  mode moreThanEight = comfortMode ( 8 , 10000 , 8 ) ;

  trans from default to lessThanTwo when (true) do 
  { comfort = 0.0 ; d1 = 4.0 ; myVelocity = 0.1 ; } 

  trans from lessThanTwo to twoFour when (comfort >= 2)
  do { myVelocity = 0.2 ; d1 = 3.5 ; } 

  trans from twoFour to lessThanTwo when (comfort < 2)
  do { myVelocity = 0.1 ; d1 = 4.0 ; }

  trans from twoFour to fourSix when (comfort >= 4)
  do { myVelocity = 0.25 ; d1 = 3.0 ; } 

  trans from fourSix to twoFour when (comfort < 4)
  do { myVelocity = 0.2 ; d1 = 3.5 ; }

  trans from fourSix to sixEight when (comfort >= 6)
  do {myVelocity = 0.3 ; d1 = 2.5 ; } 

  trans from sixEight to moreThanEight when (comfort >= 8)
  do {myVelocity = 0.35 ; d1 = 2.0 ; } 

  trans from moreThanEight to sixEight when (comfort < 8)
  do {myVelocity = 0.3 ; d1 = 2.5 ; } 

  trans from sixEight to twoFour when (comfort < 6)
  do { comfort = comfort - 2 ; myVelocity = 0.2 ; d1 = 3.5 ; }        

  trans from lessThanTwo to lessThanTwo when (comfort < -10000 )
  do { comfort = -9000 ; }

  trans from moreThanEight to moreThanEight when (comfort > 10000 )
  do { comfort = 9000 ; }


}

This code explicitly presents all the mode switching dynamics based on variable comfort, as graphically represented in the mode switching schematic diagram. It also specifies two transitions not graphically represented: The last two mode transitions in the above code are practical steps to keep value comfort from getting too big or too small in our simulations. They are not part of the main abstraction of agent navigation behavior.


Back to the main CA02 supplementary material page.