Search code examples
anylogic

Anylogic: Type mismatch: cannot convert from Agent to MyAgent


The objective is to get the closest agent on the path to the east of wait.get(0) (So the closest to the agent in the Wait Block in position 0).

The code below, throws the following error in the commented line. "Type mismatch: cannot convert from Agent to MyAgent". All the agents I "send" along the path are type MyAgent...or so I assume. What am I doing wrong?

MyAgent leading_agent;
MyAgent trailing_agent;
double separation = 0.0;

    //check that one aircraft has passed into approach
     if(moveToApproach.in.count()>0)
        {
        //check that there is at least one airplace in que
        if (wait.size()>0)
            {
             //***** The line below throws the error ******
            leading_agent = wait.get(0).getAgentNextToMe(EAST);
             //********************************************
            trailing_agent = wait.get(0);
            trailing_agent.plane.setVisible(true);

Solution

  • "getAgentNextToMe(EAST)" will only work in Discrete space. Since mine is Continuos, this method will not/cannot work.