question

London MT avatar image
0 Likes"
London MT asked anthony.johnson edited

How does Flexsim simulate 3D events when the renderer is turned off?

Hi,

I'm having a question based on the following reasoning:

If you run your model with your 3D model open, Flexsim will schedule events based on the frames per second to calculate the position of every object. Two objects cannot have the same spatial coordinates, so you create an effect of hindrance.

If the 3D model is closed, Flexsim will not schedule events at the rate of frames per second, but rather schedules events based on when an object will arrive at its destination. The object is not actually moving through the 3D space anymore.

Given that my reasoning is correct here, how does Flexsim take into account the possible clashes between objects in case of no rendering?

Thanks,

Jarek

RHDHV

FlexSim 19.1.1
event scheduling
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

anthony.johnson avatar image
4 Likes"
anthony.johnson answered anthony.johnson edited

There is no "default" collision avoidance mechanism in FlexSim. Collision avoidance is completely dependent on the context that the modeler builds into the model. There are several different mechanisms available. If you don't expressly use one of these mechanisms, then objects will freely run over each other. As everyone has said, events fire in the system independent of the 3D painting mechanism.

AGVs

When you use an AGV network, there are two different possible mechanisms for collision avoidance. The first, and default, mechanism is to simply use control point allocation to manage collision avoidance. This is technically not collision avoidance, but rather a much simpler allocation-based scheme. The idea is that, if any given control point on the network can only be "claimed" by one AGV at any given time, and the control points are spaced apart sufficiently, then AGVs will inherently never collide. This is essentially the way that "traditional" AGV systems work in real life (although modern AGV systems are more sophisticated). The way this works is that an AGV will allocate ahead to the next control point at the time when it "pre-arrives" at its current control point, i.e. the point at which it could still stop at its current control point if it fails to allocate ahead, as described by Mischa. An event fires at the pre-arrival time to allocate ahead, and if successful, the AGV continues to the next control point, otherwise the AGV decelerates to stop at its current control point and wait until it can allocate ahead.

The second AGV collision avoidance mechanism is to use accumulating AGV paths. This is used in addition to the control point allocation mechanism. When an AGV enters a path, if that path is accumulating, then the AGV will detect which AGV, if any, is in front of it on that path. Then it will do an analysis of the kinematic profile of the AGV in front, relative to its own kinematic profile, and detect a time, if any, at which the distance between the two AGVs will cross a proximity threshold. If it finds such a time, then it will create a "proximity stop" event on the behind AGV. When that event happens the AGV will go into a proximity stop state and will decelerate to stop until a "resume threshold" distance has been cleared between the two AGVs.

Travel Networks

Travel Networks (using network nodes) are our older travel system, and are much simpler than the AGV system. When a path on a travel network is set to accumulating, it just assumes a FIFO ordering and limits the rate with which travelers can exit the path, based on traveler size and speed. The 3D paint routine is used to update the locations of the travelers (a behind traveler will not be updated too close to an ahead traveler), but this is technically irrelevant to a statistical/simulation perspective. Statistically, the only thing that matters is the event for when a traveler enters a path and the event for when a traveler exits a path.

A*

The A* travel system uses a basic grid allocation mechanism, so again, it's not technically collision avoidance, but mutual exclusion through allocation. Each traveler allocates ahead to the next grid location before continuing to that grid location. For reasons of complexity, at this point there is no "pre-arrival" like in AGVs. In other words, A* travelers do not simulate acceleration/deceleration. They travel to a grid location they've allocated, and when they arrive at the grid location, they allocate ahead to the next grid location, and stop if they can't allocate ahead. For the purposes of speed and event-optimization, however, A* actually uses more of an "allocation scheduling" mechanism. There is technically no event that actually fires every time an A* traveler allocates ahead. Instead, when the A* traveler originally builds his path, the traveler "schedules" the allocations for that path. In other words, each grid point stores a "schedule" of allocations, which define which traveler is scheduling it, what time the allocation will start, and what time the allocation will end. Only when there are "collisions" in the allocations will the A* network create events to block travelers until they can allocate ahead.

TaskExecuter Collision Detection

You can also define a collision detection mechanism on each task executer individually. This is collision detection in the more traditional sense of the term. When enabled, the TaskExecuter will create collision detection events at regular intervals, will detect sphere-based collisions with other objects, and will fire triggers when collisions are detected. However, this mechanism is much more do-it-yourself, so it involves a lot more work on the modeler's part (and in my opinion could use some improvements). Even with improvements though, there are inherent problems with using a traditional collision detection mechanism in a discrete event paradigm, specifically in relation to run speed. Traditional collision detection, like that used in gaming, works well in gaming specifically because a game only needs to run in real-time. It can therefore use its update (repaint) loop to detect collisions. However, for many reasons already described by the other answers, discrete event simulation cannot rely on the 3D paint routine for simulation-critical logic. Thus it must create "tick" events to move the clock forward slightly and then redetect collisions. Unlike in gaming, discrete event simulation users expect their simulations to run hundreds or thousands of times faster than real time. Creating "ticks" for tiny time increments can create real problems when fast run speed is the goal. This is why most of FlexSim's "collision avoidance" mechanism are not "tick" based, and thus are not technically "collision avoidance" per se. They were designed this way specifically so that they will not hamper run speed.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

London MT avatar image London MT commented ·

Thanks everyone for the answers.

It is clear to me now. I assume that TaskExecuter Collision Detection will also be quite expensive computationally, but sometimes you need behaviour that is not path-related, and in the same time you want these collision to be taken into account as it will contribute to bottlenecks.

Thanks once more everyone.

Regards

Jarek

0 Likes 0 ·
Mischa Spelt avatar image
3 Likes"
Mischa Spelt answered Mischa Spelt commented

Hi Jarek,

I think we need to distinguish two different concepts.

If the 3D model is closed, Flexsim will not schedule events at the rate of frames per second, but rather schedules events based on when an object will arrive at its destination. The object is not actually moving through the 3D space anymore.

FlexSim uses events to decide when something important happens, for example a task executer arriving at its destination (or a flow item entering an object, or a processor finishing its task, or a Process Flow token leaving an activity, etc.).

These events are handled regardless of whether the 3D model is open. Note that the time at which they occur also does not depend on this: the time a processor needs to process an item or a task executer needs to arrive at its destination is not related to whether or not you have a Model view open (or two, or three, or twenty).

The rate at which events are handled, is either trying to let x seconds of simulation time expire per real-time second, or just handle them all as quickly as possible.

Secondly, there is the screen update. This will only happen when you have a model view open. Every once in a while, FlexSim will repaint the current view. In order to do that, it will need to update kinematics and figure out what has moved where since the last update. Note this is purely visual and has, in a sense, nothing to do with the event list. Whether a task executer's 'actual' position is drawn once, fifty times, or never at all does not affect when it arrives at its destination but only whether and by how much you will see it move before that time.

The rate at which repaints are executed, is not related to the run speed or a frame rate but is determined by Windows posting WM_PAINT messages to the application, just like for any other executable (I'm not sure on this one, but I'm sure someone will correct me if I'm wrong).

Like Steven indicates, it is possible to break this system by putting code that affects the end time of the event in the On Draw trigger of an object, which is why you should never do this: the model should produce the same events regardless of how often the screen is repainted.

If you are wondering about things like collisions, in particular: they are also handled through the event list and not through the 3D view. For example, when task executers start moving on an AGV module network, the engine calculates if they will run into something and when, and schedule an event for that time (it's actually a bit more subtle with accumulation and allocation of control points but conceptually this picture good enough). The screen update is only following, there is no collision detection taking place in the on draw event, and there shouldn't be -- the collision will happen whether you have a view open, or are running through the experimenter.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

London MT avatar image London MT commented ·

Hi @Mischa Spelt

Thanks for the answer. First of all, can I have some more reading on the AGV module network, I'd like to know how exactly the engine calculates the collisions.

Secondly, if you are not using the AGV module, how does Flexsim calculates collisions? I'd like to have more info about this too.

I was only assuming that Flexsim was checking for collisions 'on repaint', but it makes sense not to do that there indeed.

Regards

Jarek

0 Likes 0 ·
Mischa Spelt avatar image Mischa Spelt London MT commented ·

I'm sure @anthony.johnson can give you more information about the AGV network, but for starters I would go to the AGV Network properties, and in the General tab enable "Show Control Point/Area Allocations" and "Show Accumulation Associations". Now run an AGV model and FlexSim will visually show you (using the brown lines from the top of the AGV to the path intersections and control points and areas) when these points are claimed and released. You will notice that the (de)allocation happens carefully so that collisions and accumulation stops can be calculated fairly localized - the number of AGVs that can affect each other is limited to the subset that is on the same path or heading towards the same allocated point.

When you dig a bit deeper you will find an OnPreArrival event, which is scheduled at the latest time an AGV can still come to a complete stop, taking into account accumulation distance and deceleration. As far as I understand, this is where the module will look forward to see if it can claim a next intersection or control point / area on its path and continue travelling, or needs to stop and wait for someone else to deallocate first.

Finally, if you are running an AGV model anyway, I recommend leaving the Event List open (Debug menu). That will give you a feeling as to which events are scheduled when -- maybe run a model slowly or step through it, and see if you can correlate those events to what is happening in the 3D view.

1 Like 1 ·
Steven Hamoen avatar image
2 Likes"
Steven Hamoen answered London MT commented

Hi Jarek ( @London MT)

Why do you think that 2 objects cannot have the same spatial coordinates? Because I can put every object on the same position if I want.

I think there are 3 situations where hindrance can take place:

  1. collision detection: Here there is a check every x time and on that time the positions are updated
  2. AGV model: The running is controlled by the navigator
  3. path network: The running is controlled by the navigator

Basically you should never do anything in the onDraw trigger that can influence the order in your model run, because you are right, the model outcome should be the same with or without 3D window open. Also repeatability is very important when you want to debug and if you have code in the ondraw that influence your model run, repeatability is impossible.

Steven

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

London MT avatar image London MT commented ·

Hi @steven.hamoen,

Thanks for your quick answer.

The question is coming from a thought I have. I am thinking of 2 objects (e.g. vehicles) that cannot cross each other, whether travelling freely or by navigator. When you are modelling congested logistics where hindrance effects are having an significant impact, can you then still take them into account when running the experimenter?

The fact that Flexsim's 3D model can detect these clashes is a major pro in my opinion. It is almost impossible to include that for example in a statistical model coded in C++.

Regards

Jarek

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen London MT commented ·

Hi @London MT

You have to have some kind of mechanism in place that detects a collision or hindrance and this has to function without using the 3D (like using a navigator or a collision detection mechanism) If you use the 3D to check you are wrong when run without 3D (because then the ondraw trigger and onpredraw triggers are not fired). You are even wrong when running at different simulation speeds because at low simulation speeds you will have a lot of onDraw triggers to update positions and determine collisions and on high simulation speeds you have very little or even none.

1 Like 1 ·