dealing with species as matrix cells

22 views
Skip to first unread message

Suhad Faisal

unread,
Jul 3, 2014, 3:51:52 AM7/3/14
to gama-p...@googlegroups.com
Hello 

my model is 

/**
 *  PeopleMoving
 *  Author: suhad
 *  Description: 
 */

model PeopleMoving

/* Insert your model definition here */

global { 
file Voronoi<-file('../includes/VoronoiVoronoi.shp');
file Peoplefile4<-file('../includes/41821.csv');
geometry   shape<- envelope(Voronoi);
float pos_x;
   float pos_y;  
   int   dens;
//  point location;
init { 
create Polygon from: Voronoi number:190;
create Tower   from: Voronoi header:true  
        with:[pos_x::float(read('pos_x')),pos_y::float(read('pos_y'))];
        location<-point([pos_x, pos_y]);
        
        create People from: Peoplefile4
        with:[dens::int(read('count')),pos_x::float(read('pos_x')),pos_y::float(read('pos_y'))
        ];
       location<-point([pos_x, pos_y]);
               }

  entities {
   species Polygon
    {  aspect  base {draw shape color: rgb([255,255,255]) ;} }
        
    species Tower
       {float pos_x; float pos_y; int   heading;
       
  aspect  Towericon {draw rectangle(1,800) color:rgb("red")
                    at:{location.x,location.y};
                    
                    }   // location size:15 rotate:90;
                                     
                    }
  species People
   {int dens;
   float pos_x;
   float pos_y;
  
 aspect basepeople {draw circle(dens) color:rgb("green") at:{location.x+rnd(300),location.y+rnd(300)}
   ;}
//draw shape (or circle() or whatever) at:{location.x+rnd(100),location.y+rnd(100)}
  }
}
}
 experiment City type: gui {
output { display disp 
     species Polygon  aspect: base  transparency: 0.9;
     species Tower    aspect: Towericon ;
     species People   aspect: basepeople;
  }
    }
  }

I want to give people a distance and direction according to the following equations:

Distance = [X(n)-X (n-1)]*[X(n)-X(n-1)] + [Y(n)-Y(n-1)]*[Y(n)-Y(n-1)]
Direction = arctan ((X(n)-X(n-1)) / (Y(n)-Y(n-1)))

but my problem is the embeding these aquation in the species data structure of species people ; means need to deal with pos_x, pos_y as matrix data with cell locations (i,j).

any advice please !

cheers 
suhad

Patrick Taillandier

unread,
Jul 5, 2014, 5:15:04 AM7/5/14
to gama-p...@googlegroups.com
Hi,

Same answer than the previous one: I do not understand at all your model.
If you a have a matrix "mat", you can access to all its element by using : "mat[i,j]"

Cheers,

Patrick


--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages