0
votes

I'm currently trying to build a dynamic process model. The model itself is going to look like this: Dynamic process model creation

The agents get created by the source blocks for each point node and then move along the three paths until they meet on the center path. Example what I'm trying to do: Every path can be seen as a single production line. The finished products meet in the end, get checked and packed. It's not important what exactly happens with the agents. The visualization of the movement is important.

Problem: The model should be dynamic. The actual amount of needed sources, paths and conveyors is unknown until the simulation is started. There could be only one source needed or more than 25. The Agents of each source should take a different path.

I thought about creating (nearly) the complete process model in the "On startup:" window of the main class. I started by trying to "copy" an existing source block, but failed currently doing so.

com.anylogic.libraries.processmodeling.Source<Agent> source2 = new 
com.anylogic.libraries.processmodeling.Source<Agent>( getEngine(), this, null);
source2 = instantiate_source_xjal();
setupParameters_source_xjal( source2 );
create_source_xjal( source2 );

Can someone point me to the right direction or is there maybe an easier way to do this?

1
It would really help other members, if you posted the code you have a problem with and explained your problem more thoroughly. This way you can help us understand better, to help you and add to the community - Soutzikevich
you can create a population of sources... If I have time I will post how to do it tomorrow :) You can also dynamically define the starting points of your agents in only 1 source... there are many options, i suggest you explain more in detail what you want to achieve so you get specific help - Felipe
Ok, I tried to explain my problem better. Thanks! - user3662357

1 Answers

3
votes

Ok, this is a lot of work to do it with conveyors, so I will show you an example only with the source and then you can figure the rest out on your own.

Step1: The Structure. This is the structure of the model: structure

Step2: The pointNode Array. initialPoints is an ArrayList with element type PointNode

Step3: The source population. source population As you can see, the location on arrival is: initialPoints.get(index) where index is the source in the population of sources. Also check in advanced that the agent is a population, initially empty. So now you have a population of sources... all good.

The moveTo block will make the agents move to endConveyorPoint which is the only pointNode that I defined explicitely in the model.

Step4: Initialization. Add the following code on main startup, you need to define a network and the add sources and all the stuff you need, add paths and points to the network and add them also to the presentation... you will have to change the initial X,Y,Z coordinates if needed:

Network n = new Network( this, "nety", SHAPE_DRAW_2D3D, 0, true, true );
n.add(endConveyorPoint);
for(int i=0;i<5;i++){
    Source s = add_source();
    PointNode pn=new PointNode(this, SHAPE_DRAW_2D3D, true, 100.0,300.0+i*50, 0.0, 1.0, dodgerBlue );
    MarkupSegmentLine ms1 = new MarkupSegmentLine(  100.0, 300.0+i*50, 0.0, 350.0, 300.0+i*50, 0.0 );
    MarkupSegmentLine ms2 = new MarkupSegmentLine(  350.0, 300.0+i*50, 0.0, endConveyorPoint.getX(),endConveyorPoint.getY(), 0.0 );
    Path path = new Path( this, SHAPE_DRAW_2D3D, true, true, 
                                PATH_DASHEDLINE, dodgerBlue, 2.0, pn, endConveyorPoint, ms1, ms2 );
    presentation.add(pn);
    presentation.add(path);
    s.set_locationType(s.LOCATION_NODE);
    s.setLocation(pn);

    initialPoints.add(pn);
    n.add(pn);
    n.add(path);
}
n.initialize();