wrong matrix values

14 views
Skip to first unread message

Suhad Faisal

unread,
Oct 17, 2014, 8:31:13 AM10/17/14
to gama-p...@googlegroups.com
Hello 

I read the shape file as matrix, but when use its attributes in computations later, it seems wrong , in spite the matrix is correct in init of the model. where the sourtime & tartime are read as only same value  


any comments pleaes ! 

model ProtoType
global 
{   
file         initdata  <-file('../includes/alias519.shp');
file         vor       <-file('../includes/VoronoiVoronoi.shp');
    matrix       mydata    <- 0.0 as_matrix ({5,132});
    geometry     shape     <- envelope(vor);
    int posx; int posy; int tower; int ali; int timy;
init 
{
create alias from:initdata with:[posx ::int(read('pos_x')),posy ::int(read('pos_y')), 
                     tower::int(read('mat_id')),
                     ali  ::int(read('alias')),
                     timy ::int(read('time'))];
ask alias as matrix {
            loop i from: 0 to:mydata.rows-1 {
       //       loop j from: 0 to:mydata.columns-1{
              
            
             mydata[0,i]<-posx ; //write mydata[0,i] + i;
     mydata[1,i]<-posy ; //write mydata[1,i] + i;
     mydata[2,i]<-tower; //write mydata[2,i] + i;
     mydata[3,i]<-ali  ; //write mydata[3,i] + i;
     mydata[4,i]<-timy ; //write mydata[4,i] + i;
    
         // write mydata[j,i] ;
    //  }  
            // write "              "+ i ;
     }       
    
     }
    
     }  // init
        } // global
entities
 {
species alias skills:[moving] {
            point   source;
            float   sourtime<-0.0;
            point   targett ;
            float   tartime<-0.0 ;
            float   difftime;
            float   distance;
            float   speedy;
            int     posx; 
            int     posy;
            int     tower;
            int     ali;
            int     timy;

init { location   <- (point([ mydata[0,0],mydata[1,0]  ])) ;   }     

reflex movement {

loop i from:0 to:mydata.rows-1 {
    loop j from:0 to:mydata.columns-1 {
   
              source   <-point([mydata[0,i],mydata[1,i]]) ;
            sourtime <-mydata[4,i];                          // time of source
               
               write sourtime;
               
                targett   <-point([mydata[0,i+1], mydata[0,i+1]]);
                tartime   <-mydata[4,i+1];                       // time of targett
                
                write tartime; 
                
          if   source!=targett
         {
                difftime   <- abs(tartime-sourtime); 
                distance   <- source distance_to targett; 
                speedy     <- (distance/difftime)       ; 

          write "SourcePoint   "   +   source    ;
          write "timeOfSource  "   +   sourtime  ;
          write "targettPoint  "   +   targett   ;
          write "timeOfTarget  "   +   tartime   ;
          write "timediff      "   +   difftime  ;
          write "distance      "   +   distance  ; 
          write "speedy        "   +   speedy    ; 
          write "                              " ;   
          
          
          do  goto ( target:targett, on:shape ,return_path:true ,speed:speedy);
         
           } //IF
     
            } //loop j
             } // loop i
                       
         } // reflex movement   
        

aspect base {  draw circle(5) color:rgb('red'); }   } //alias species   

                   } //entities 
                   
experiment Trajectory type: gui  {
    output { display  city_display type:java2D  
  {     
   species alias   aspect:base ;
  }  }  }


thanks in advance 

sincerely
Suhad
    
VoronoiVoronoi.shp
alias519.shp
ProtoType 17.10.gaml

Srirama Bhamidipati

unread,
Oct 18, 2014, 11:18:03 PM10/18/14
to gama-p...@googlegroups.com
Hi,

I really don't understand what you wish to do. I am working as traffic and transportation engineer for 15 years, never felt/seen the need to read shape file as a matrix. Are you sure you are taking for the right approach ?

regards,
srirama

Suhad Faisal

unread,
Oct 19, 2014, 4:02:24 AM10/19/14
to gama-p...@googlegroups.com
hi 

yes dear Srirama, after my trilas with this approach,  I'm in the wrong way, and must be changed.

best regards 

cheers
Suhad

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/e2O2aZtYhGU/unsubscribe.
To unsubscribe from this group and all its topics, 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