0

I was trying to model an agent-based anylogic model where pedestrian agents will maintain a distance of 6 feet between them when moving in the continuous space. How I can do that?

I tried to put a circle of 6 feet radius around the agent and iterated whether any other agent is within that "socialDistance" circle. If yes, then the person agent will move (current distance between agents + 6 units) to maintain social distance. I used "moveTo" & I know it's not the right command. Additionally, my distance calculation is also not right. For example, if the agents are in 5 feet distance initially, I command asks to move (5+6=11 feet), which should not be the situation. Moreover, sometimes, my code may push the agent out of the simulation area (seems to me).

So, in summary, can someone help me to model that 6 feet distance between agents? It will be a great help.

Code (wrong!) that I tried: for (person socialD : get_Main().people) {

double pedSocialX = socialD.getX() -this.getX();
double pedSocialY = socialD.getY()- this.getY();
if (this.socialDistance.contains(pedSocialX, pedSocialY))
    {
    double a= socialD.getX()+ 6;
    double b= socialD.getY()+ 6;
    moveTo( a, b);
    //[this is wrong command, what should be a good command?]
    traceln ("social distance not mainted");
    }
else 
    traceln (" social Distance maintained");

errors:

error1 error javascript

Tariq
  • 57
  • 6
  • using moveTo is in fact correct and you should do that, but you have too many other problems and the solution depends on your overall objectives, which i don't know. – Felipe Jun 03 '20 at 03:16
  • But as I know, moveTo refers new X & Y coordinate. But in my model I am not referring to any specific coordinate rather a distance, in that case will it work? For example: if the distance between agents are 3 in X axis & 4 in Y axis, the moveTo refers to (3+6=9 & 4+6=10) or moveTo(9,10). But those are the distance from current location I am referring to not the absolute coordinate. Am I interpreting wrong? – Tariq Jun 03 '20 at 03:23
  • a and b are coordinates from what you have written – Felipe Jun 03 '20 at 03:27
  • yes, those are coordinate, but I should not refer to any coordinate rather I am trying to push the agent at a distance of 6+ feet. That's where I am stucked. Can you suggest any common code/ format to push the agent to certain distance (any direction) from the current location? – Tariq Jun 03 '20 at 03:30
  • I feel I do not any other complications in the code which may impact the functionality of this agent distance issue. So, if you can suggest something which I can try will be a great help. – Tariq Jun 03 '20 at 03:33
  • moveTo(getX()+dx,getY()+dy) where dx and dy represent the distance in which you want your agent to move – Felipe Jun 03 '20 at 03:33
  • Thanks, I just tried your suggestion, it's showing error. Maybe it's because my new coordinate for the agent is outside of simulation area or some pedestrian wall is blocking that location (not sure though). Error screenshot attached in edited version of the question. – Tariq Jun 03 '20 at 03:44
  • oh.. you are using the pedestrian library? Are you trying to move the pedestrian while he is in a pedMoveTo or a pedWait block? – Felipe Jun 03 '20 at 03:54
  • Yes, pedestrian library. Actually I am using a pedestrian library with a custom agent type so that I can model agent behavior also. For now, I am trying to maintain distance between agents during their waiting time in a queue. But my next part will be to maintain that distance during their movement also. As I am using statechart, I am trying to put a code so that agent will be 6 ft distance no matter what they are in service, queue or moving around. – Tariq Jun 03 '20 at 04:03
  • Perhaps you need to step back a level, list scenarios, and then decide what logic to apply in those situations. You've already identified one: what happens if an Agent's movement is restricted in one or more direction. Others are, for example, what happens if an Agent can only be sufficiently distanced from all other Agents if one or more of those Agents moves; in turn, what is the maximum number of Agents that can be within your defined environment (because if you have any more than that then no amount of moving within the space will distance them) etc. – Rich Harding Jun 11 '20 at 11:07

0 Answers0