why doesn't rackstore see the path to reach the palletrack? - anylogic

I don't know why the resources don't follow the path in order to arrive the pallet rack. I thought it was because of the path (maybe not linked) but with a moveto block the problem disappears.What's the reason?
All the paths are bidirectional.

The problem that you have is the issue of teleportation... you move your boxes teleporting them from one node to the next by using the agent location parameter of the rackstore... This has the effect that the agents do not belong to the network as you expect.
instead you need to use a moveTo block instead as you see in the following image
Notice that I removed the agent location from the rackStore and also in the moveTo block i use JumpTo option instead of moveTo so you maintain the teleportation as you did...
Anyways, teleporting is not very good

Related

Customize the coordinates of the entity in pedWait

In a pedwait entity, I want each element that enters to have my own specified coordinates. I use the method: ped.setXY(100,100), but it has no effect. What should I do?
First you need to read the Java doc when using a new function.
The setXY function states "Sets the coordinates of the agent location. Should only be used to initialize the agent location. Assumes the agent is not moving."
The other options that I would have suggested if you were using normal agents would be to use jumpto() or moveTo() but if you try these in a pedestrian model you will get an UnsupportedOperationException error.
Pedestrians are special kind of agents so you can use all the normal agent functions on them.
The correct way to do this is to use the waiting location inside the Wait block

Limit the number of Pedestrian in service 'queue'?

I have a simple model which has two Pedestrian Service blocks after one another. Is there a way to limit the queue for a service so it has a 'knock-back effect' on the queue/path area before?
I assume you can add a wait block before every ped-service that frees an agent if the ped-service queue is below a certain length. But, that seems a little messy (maybe a limitation of the pedestrian library) - would be keen to hear what best practices are from the experts (cough Ben & Felipe) :)
You can add a simple wait or queue block before the service block and only let them exit the queue if the pedestrians in the service blocks are below a threshold.
You need to implement the release logic in the on enter for the queue
as well as for the exit at the service block
But, in order to make your snake path act as a queue you will need to add walls around it, else as per your example the pedestrians will group around the end of the path in a bunch. You will also need to set your pedestrain width to just more than half your path width to ensure they don't bunch inside the path

How to get around using Enter and Exit blocks in "Prepare" flowchart (Execution error "0 isn't supported for building resource behavior flowcharts")

I have an airlock (small room called AL_2216) between 2 areas. The airlock has many different agent types passing through it (cart, product, operator, etc). There are queuing areas on either side of the airlock.
Because the space is small, I built a short flowchart that has a queue and restricted area blocks that all agents must pass through when going through this space. If the restricted area's capacity is full, the agents wait in either the InsideQueueArea or OutsideQueueArea depending on the direction they're going.
I send agents via Exit and Enter blocks to this flowchart and it works great on the top portion of the flowchart.
BUT if I try to use an Enter or Exit block in the prepare flowchart, I get this error:
I tried using a custom block instead of Enter and Exit blocks, but that creates a new instance of the code each time and the restrictions don't work together across the multiple custom blocks.
This airlock is just one of many in my model. Without referring to the same code, I'll have multiple copies that need to refer to each other's restricted areas and the flowcharts become huge and complicated. Is there a way to get around this?
EDIT:
I'm not sure what to do with these ports. They have no properties that do anything:
EDIT2:
Here's a file to see the behavior - Model2.zip
The Prepared flowchart portion is set to "ignore" so the code will run. You can see the operators and the carts passing through AL_2216 with only 2 being allowed at a time. If you uncheck "ignore" for the prepare flowchart, the error will trigger.
AnyLogic sent the right answer!!
So I was asking Anylogic a different question and they recognized my name from this post! They sent a fix to me and it works exactly the way it should! The exception error message I was getting "out: 0 isn't supported for..." made me think the exit/enter blocks were not supported in perparation flowcharts.
But actually, the seizeCart block didn't know where to start the prep flowchart because it wasn't directly connected to the resource task start block. A quick setting change under the Advanced section of the seizeCart block defining which resource task start block to start at did the trick! Here's the email from AnyLogic:
-The error text and documentation are not sufficient for understanding this (the error text is confusing), I suppose it is obsolete error text. We will rectify the description;
-Under the question there is a more generic discussion which seems to be unrelated to the initial problem. Please let me know if I miss something or if your model does not work as you expect even after adjustment of seizeCart block property.
I think you should replace the Enter and Exit blocks that lead to the bottom input of your seizeCart Seize block with simple Port objects (from the Agent palette).
As per the help for Seize:
So it wants a direct link to a ResourceTaskStart flow and your Enter/Exit combinations might be ... not "direct" enough... Try it.
So here's what I ended up doing. It's the best I could come up with that could be easily replicated for lots of airlocks.
I've added a wait block (dummyThruAL_2216) to my Product flowchart prior to seizing the cart. This wait block injects a new Agent into sourceDummy at the cartHome node. The dummy then seizes a cart and moves through the airlock and it's restriction. Upon exiting the restriction, I check what type of agent and direct the agent to the correct exit block. The dummy agent and cart move to the Product where the dummy agent releases the cart and sinks. The sink frees the wait block and the Product seizes the cart that is right next to it and continues on it's journey.
It's an easy copy/paste to add more airlocks. Not as nice as my original, but what are you going to do... Thanks for everyone's help and suggestions.
As others have said, there are (not really documented) restrictions on what blocks you can use in preparation and wrap-up flowcharts, which mean what you're attempting won't work.
As you say, it's important to keep a single 'instance' of the airlock flow so that the restrictions (queue and restricted area) are 'global' when this represents the same physical airlock. (Otherwise a repeated custom block is precisely what you should use for each different physical airlock.)
Your best option (and assuming you needed to attach the Cart resource to the Product) is probably to
Add dummy agents (via Source block inject calls) to a separate mini-process that represents your resource preparation requirement (but now not attached to the Seize block).
Replace the Seize in your main process with a Seize-Wait-Release-Seize combination:
The Seize block seizes the cart as normal (without moving or attaching it; no 'Send seized resources' or 'Attach seized resources' options) and then injects an agent into your mini-process (which can use Exit and Enter blocks to use the airlock sub-process). This agent represents the seized resource agent (Cart) and thus should start where it starts and be animated so it looks like it. (You can make the actual Cart temporarily non-visible during this mini-process.)
When the agent reaches the end of the mini-process (at a Sink block), instantly move the related Cart to your node (use jumpTo), make it visible again and free the Product agent from the Wait block
Release the seized Cart and then immediately re-Seize it, but now attaching it (so the animation looks correct). If you use the Resource selection 'Nearest to the agent' option you should be guaranteed to seize the correct cart. (You can also use the 'Customise resource choice' option with some code to ensure that you absolutely always choose the same Cart.)
(It is simpler than the above if you don't care about having a correct animation, and you can use custom blocks to make this block combination reusable and thus not too clunky.)
Edit: A very similar alternative which also works (and is the basis for your own answer) is to have a dummy agent representing your Product in the sub-flow which seizes (and attaches) the actual Cart agent, leaving it at the Product's location to be immediately seized as above. This is slightly better since you don't have to worry about the visibility and 'jumping' of the real resource agent, plus you can move a Seize and a Release from the main flow (which now just has Wait-Seize) to the sub-flow (thus 'hiding them away').

Road Traffic Library - MoveTo block - while loop?

I want to implement a connected autonomous vehicle fleet in AnyLogic. Because of this, a vehicle agent has the ability to change its route. My understanding is that using the standard "MoveTo" block lets you move the vehicle agent only once by telling it what road to move the agent to.
For example:
Any vehicle following the above block can be created on any road that is specified in road4Source, then move to another road specified in moveToRoad2 block and then will be destroyed/deleted/discarded when it reaches the endOfRoute block.
However, since the vehicle can choose the route for itself, I only know the Origin and the Destination of the vehicle and not sure what route it will take. So, the number of MoveTo blocks should ideally be dynamic.
Considering this, is it possible to reuse MoveTo blocks (consider it a kind of a while loop) so that that the vehicle remains in the MoveTo block until it reaches the Destination (a particular road in my case)?
Something like this:
So that in the Road argument of moveToRoad2, I can put something like(could be wrong just for illustration):
car.getRoad() == car.destination ? endOfRoute : car.getRoad()
where car.getRoad() would return the road that the vehicle wants to go to and if it is equal to the destination of the car then it would go the endOfRoute block.
EDIT 1
I understand now that if there are two connections to the same port, AnyLogic will throw an error:
Out port can't be connected with more than one In Port.
So is there any other way to achieve what I want to do here?
First, this is the configuration you want:
Then you need to generate a collection of roads that the car will take... This collection is generated in the carSource... or you can update it as you progress in the "loop".
the car agent must have a variable that will start with 0 and will increment +1 every time it exits carMoveTo...
So the new road that the car will take is:
collection.get(car.variable)
And on exit of carMoveTo:
car.variable++;
In the selectOutput the condition for true would be:
agent.variable==collection.size()
I hope this helps...
Nevertheless, if you have too much traffic, you will see big problems in your model because the car doesn't necessarily recognize traffic after the destination in the carMoveTo so you may have crushes... or maybe not... depends on different factors.

runBlock not working in sequence?

I am trying to create a basic spawn sequence- the block must be created, moveDownLeft, and then removeLeft. moveDownLeft and removeLeft work fine on their own when the block is added using self.addChild(block1) previously, however I need to have self.addchild within the sequence.
The only way that I can see to do this is use runBlock, and I looked at this question when I got an error using that: Swift: SKAction.runBlock -> Missing argument for parameter 'completion' in call BUT WHY?
So now I am left with this:
block1.runAction(SKAction.sequence([SKAction.runBlock({ self.addChild(self.block1) }), moveDownLeft, removeLeft]))
And nothing in the sequence works because the block is not created in the first place. Why is this happening?
Your code fragment is too short but it looks like a typical chicken and egg problem.
node can only run actions once it has been added as child and thus becomes part of the scene graph
your node is supposed to run an action that will eventually add itself to the scene graph but it's not in the scene graph yet so it won't run that action
Add the node as child first, then run the action. If you need the node to be inactive for some time, simply set it's visible property to NO for the duration. You kay also ned to change other properties, ie postpone creation of the physics body.