Let’s go through this simple example that will allow an agent to move through a network, avoiding the use of deprecated constructors in AnyLogic 8.4.
Create the network. This network will be necessary for an agent to follow the proper paths from point A to point B. All these functions can be run on startup of Main.
Network myNetwork = new Network( this, “myNetwork”);
Next step, generating the initial point nodes in Main. In this example I use 3 points. The agent will go from point p1 to p3 passing through p2.
PointNode p1=new PointNode(this, 100, 100, 0.0 );
PointNode p2=new PointNode(this, 200, 100, 0.0);
PointNode p3=new PointNode(this, 200,200,0.0);
Then you need to construct the markup segments.
ms1 = new MarkupSegmentLine(p1.getX(),p1.getY(),0.0, p2.getX(), p2.getY(), 0.0 );
ms2 = new MarkupSegmentLine(p2.getX(),p2.getY(),0.0, p3.getX(), p3.getY(), 0.0 );
Then, construct the paths that will use ms1 and ms2. If you want them to be bidirectional, this is the place to set that up.
Path path1=new Path(this);
Path path2=new Path(this);
Then you need to generate the connections for each point node. Each of them must be connected to one or more paths. In this case, p1 is the initial point and p3 is the end point, but since the paths are bidirectional, it doesn’t really matter if you set the pathEndType as BEGIN or END.
Everything is set up, now you can safely initialize everything.
After initialization, add everything to your network and initialize it.
Everything is ready, make the paths and nodes visible if you want:
Now you can create an agent and move it from p1 to p3, or vice-versa.