I have a Supply Chain simulation model where the names and locations of the warehouses are fed from the database that I have in the model. What I want to achieve is the following:
Is this achievable in AnyLogic? If yes, how?
I tried to follow the recommendation of AnyLogic of creating interim variables, but can't really scale this up when I have hundreds of nodes.
I resolved this issue in the following manner. This creates the list of my agents, sorts them alphabetically by agentName in the Main
agent.
quotient
and reminder
helps me to keep track of the columns; which of each should contain 60 agent names numberPerColumn
.int row=0;
int numberPerColumn=60;
int quotient=0;
int remainder=0;
int i1=0;
int newIndex=0;
while (i1<myAgents.size())
{
int ii=i1;
String myAgentName = myAgent.name;
ShapeText text = new ShapeText(
SHAPE_DRAW_2D, true, 300, 300.0, 0.0, 0.0,
black, myAgentName,
font, ALIGNMENT_LEFT )
{
//3. Overriding the onClick() method with the action that I want to happen upon click. In this case, it will take me to the `viewArea` inside `myAgent`.
@Override
public boolean onClick(double x, double y)
{
myAgent.viewArea.navigateTo();
return false;
}};
//4. Setting the objects' position programmatically.
quotient=i1/numberPerColumn;
remainder=i1%numberPerColumn;
text.setPos(quotient*250+50, -4550+remainder*20);
presentation.add(text);
i1+=1;
}