From: Zohrieh Y. <z_y...@ya...> - 2013-03-25 15:42:44
|
Exactly Nick, the question is how can we get the getDirection on those Agents which are from another class in nested neighbourhoods. It is not straight forward like routine java for example saying: SAgent.getDirection on those Agents. It doesn't accept it. Cheers, Zahrieh ________________________________ From: Nick Collier <nic...@ve...> To: Zohrieh Yousefi <z_y...@ya...> Cc: "rep...@li..." <rep...@li...> Sent: Monday, 25 March 2013, 13:01 Subject: Re: [Repast-interest] this. concept in nested neighbourhoods I think this is because you are calling this.getDirection which returns the direction of the agent whose step method is currently being called. If you want the direction of the agents in the cells, you'll have to call getDirection on those. Perhaps I'm missing something here though. Nick On Mar 22, 2013, at 1:48 PM, Zohrieh Yousefi wrote: Thanks Nick, I got stuck and your help is very appreciated. >In the statement below "this" means the "VaAgent" which is the current class. >So the step() method is regarding to the VaAgent. >We are using it in the first neighbourhood and it works: >GridPoint point = patch.getLocation(this); > >In the second neighbourhood I want to have access to the direction field of whatever Agent that exists in each cell of this neighbourhood. >There is a method that finds what kind of Agent exists in a cell which works as well. >The problem starts when: >The method that wants to have access to each cell's Agent's direction field returns only the the direction of VaAgent. >publicintgetDirection() { >returndirection; >} >If you look at the attached shape, the Va Agent from red cell wants to move to the white cell but first it should find the direction of all Agents in white cell neighbourhood, for example the direction of the A agent. >Hope it is clear now, please let me know if it is not. > > > Regards, > Zohrieh > > > > > > > > > >________________________________ > From: Nick Collier <nic...@ve...> >To: Zohrieh Yousefi <z_y...@ya...> >Cc: "rep...@li..." <rep...@li...> >Sent: Friday, 22 March 2013, 13:31 >Subject: Re: [Repast-interest] this. concept in negnested neighbourhoods > > >Zorieh, > > >Can you clarify this a bit. What class is the "this" below? What is the implementation of the getDirection() called by "this". > > >Nick > >On Mar 21, 2013, at 9:23 AM, Zohrieh Yousefi wrote: > >Hi All, >> >>I have to use a nested neighbourhoods in my model. >>There are six different agents in the model which all extend from one main agent. >>For one the agents (class VaAgent) there is a neighbourhood. For each cell of this neighbourhood there is another neighbourhood of another agent(called Grass) which other agents can move on its grids. >>Also there is a getDirection() method defined in Main Agent. We need to use this method in the second neighbourhood to find thedirection of any agent which exists in each cell of the neighbourhood.The coding looks like this: >> >> >>GridPoint point = patch.getLocation(this); >> >>GridCellNgh<VaAgent> nghCreator = newGridCellNgh<VaAgent>(patch,point, VaAgent.class, 1, 1); >> >>List<GridCell<VaAgent>> gridCells = nghCreator.getNeighborhood(true); >>... >>for (GridCell<VaAgent> cell : gridCells) {pointMove = cell.getPoint(); >>... >>if( cellIsEmpty){GridCellNgh<Grass> nghCreatorG = newGridCellNgh<Grass>(patch,pointMove,Grass.class, 1, 1);List<GridCell<Grass>> gridCellsGrass = nghCreatorG.getNeighborhood(true);for (GridCell<Grass> cell : gridCellsGrass) { >>...findArrayDirectionOfMovement(this.getDirection()); The highlighted method needs to return the direction of any agent which is in this negibourhood cell, but at the >>moment it returns the dirction of the VaAgent which exists in GridPoint point. >> >> Cheers, >> Zohrieh >> ------------------------------------------------------------------------------ >>Everyone hates slow websites. So do we. >>Make your web apps faster with AppDynamics >>Download AppDynamics Lite for free today: >>http://p.sf.net/sfu/appdyn_d2d_mar >>_______________________________________________ >>Repast-interest mailing list >>Rep...@li... >>https://lists.sourceforge.net/lists/listinfo/repast-interest >> > > > <shape.docx>------------------------------------------------------------------------------ >Everyone hates slow websites. So do we. >Make your web apps faster with AppDynamics >Download AppDynamics Lite for free today: >http://p.sf.net/sfu/appdyn_d2d_mar >_______________________________________________ >Repast-interest mailing list >Rep...@li... >https://lists.sourceforge.net/lists/listinfo/repast-interest > |