In this part of our tutorial, we’ll add the trucks that deliver the pallets to the job shop. Let’s start by creating an agent type to represent them.
Let’s add two more elements to our network: a node where the trucks will appear and the path that they will follow to the receiving dock.
Make sure all space markup elements connect to one network.
– MoveTo – Delay – MoveTo – Sink.
MoveTo flowchart blocks move agents to new locations in the network. If resources are attached to the agent, they will move with it.
The operation’s duration depends on how quickly the pallets are unloaded and removed by forklift trucks. We’ll consider this operation complete when the RackStore block has finished storing pallets, and we’ll model this by changing the Delay block’s operating mode.
Programmatically controlling the delay time
You’ll typically specify a Delay time for the Delay block’s operation. It can be a fixed duration such as five minutes or a stochastic expression that produces a delay time such as triangular(1, 2, 6).
You can also programmatically control the operation’s duration and stop the delay when necessary by calling the block’s corresponding function. If you need to stop waiting for all agents that are in the Delay, call the block’s function stopDelayForAll(). Another function - stopDelay(agent) - ends the operation and releases the specified agent.
Our model’s two Source blocks generate two agent types: the trucks that appear each hour and the pallet that is generated every five minutes. Since we want pallets to appear when the truck unloads, we’ll change the arrival mode for the Source block that generates them.
Controlling agent generation
You can have the Source block generate agents at set intervals by setting the block’s Arrivals defined by parameter to Calls of inject() function. You’ll be able to control the agent creation at runtime by calling the block’s function inject(int n).
This function generates the given number of agents at the time the call occurs. You set the number of agents that the block will generate by using a function argument such as sourcePallets.inject(12);.
sourcePallets.inject(16);This Java function will ensure our model generates 16 pallets each time a truck starts to unload.
Now that we’ve added trucks to our model, let’s make the first delivery truck appear on the model startup so we don’t have to wait for an hour of model time to elapse.
Model startup codeThe model’s Startup code executes at the model initialization's final stage after the model's blocks are constructed, connected, and initialized. This is a place for additional initialization and starting agent activities such as events.
== 0 )
In this example, self is a shortcut we use to refer to the block storeRawMaterial from its own action.
If there are no pallets in the storage queue, the unloading block’s delay time ends (in other words, stopDelayForAll() is called), and the truck leaves the unloading block and enters the next flowchart block, drivingToExit.
We’ve changed the truck figure’s position, but we’ll also need to change AnyLogic’s default setting to make sure the program doesn’t rotate it a second time.
Attractors in nodesAttractors allow us to control agent location inside a node.
Attractors also define the agent animation’s orientation while the agent waits inside the node. Here we use attractor for this particular purpose. You can add attractors by dragging them individually onto the Main diagram, but if attractors form a regular structure, you should use the special wizard to add several attractors at the same time. The wizard offers several different creation modes as well as the option to clear all attractors, and you can display it by clicking the Attractors button in a node’s Properties area.
The animation should work as we expect.
Reference model: Job Shop - Phase 4
Phase 3. Creating 3D animationPhase 5. Modeling CNC machines