Why won't my simulation move to the Off state? - matlab

I am currently trying to create a Stateflow chart for a simple elevator. For some reason my simulation is stuck in the "Up" state and will not move to the "Off" state. Screenshot below:
As you can see, the variable "currentFloor" and the variable "destinationFloor" have the same value (2) and so I would expect this to move to the "Off" state. However it's just remaining stuck in the "Up" state. What am I missing?

Related

Agents' detour behaviours in Anylogic

I'm building a pedestrian model using Anylogic. I have set my agents move in several groups between S2/S3/S4 and S1 (the movement direction is indicated by the blue two-way arrow in the figure).
Background picture for problem statement:
One group of my agents should have appeared from any position in S2(line) and moved toward S1(line), but in fact, I found several agents with obvious abnormal detour behaviour appeared. Their trajectories are shown as the red line with arrows. I have checked there was no interference of other agents at the same time.
May I ask what causes such a small amount of agents to produce this abnormal behaviour since I have set the same behaviour for the whole group? And how to fix this behaviour?

Conveyor agent crossing allowed gap

Update: link to simplified model with replicated error added
In simulation model of conveyor technology, we are using a conveyor object type roller and we are moving our custom agents of transporter type by convey block always to the next position on a conveyor (imagine this as a exit or entry point on conveyor). It happens in some random seeds, that our agents cross allowed gap and Anylogic shows following error.
It always happens when some agent enters convey block, but the error occurs on two other transporters, when the one behind crosses the gap. - THIS IS NO LONGER TRUE. Today it happened when there was no agent entering convey block. We did not find any way to ignore this error or to find a workaround. Anyone has any ideas how to resolve it ? Picture of actual situation added, pink conveyors are breaking gap, and error pops up. We also found out that gap is broken also before, but error does not pop up.
link to simple mode file with replicated error: https://cloud.anylogic.com/model/ceafcc2a-9a05-4bb9-a56f-a1c018698b16?mode=SETTINGS&tab=GENERAL

Strange behaviour in Road Traffic Library

I am noticing some "strange" behaviour in the Road Traffic Library. In my model, I seize and release resources based on the position of a vehicle on the road network. The reason for this is not the issue here but in the model execution, some vehicles seemed to miss the seize step. To try and understand what was happening, I created a very simple model with a simple T-junction. Injecting a car on the vertical leg and moving it straight to the stopline at the intersection and specifying that it must stop before the line before proceeding to the next block which moves the vehicle on the horizontal, works as expected. However, if I put another stopline on the vertical road before the junction and add a carMoveTo block to first move the car to this stopline (but setting it to pass through) and then moving it to the stopline at the junction (set to stop before) the behaviour becomes inconsistent. The outer lane on a 2 lane road works as expected, but on the inner lane, the car overshoots the stopline at the junction and ends up in the intersection even before completing the block.
Can anyone explain why AnyLogic is doing this and how I can ensure that the car stop as specified?
EDIT
I have created a demonstration model in the public AnyLogic cloud at
Road Traffic Demo
Also see below screenshot for an illustration
Without the pass-through stopline the vehicle completes the block in column 2 at zero speed (stop at intersection). With the mass-through the vehicle complete the block in column 2 (carMoveTo1) at speed ~30kph (does not stop at the intersection) - I update the value of the variable "speed" on exit from the relevant block in column 2 using the car.getSpeed(KPH) method.
It seems my question was poorly formulated and what I thought was a self-explanatory example wasn't. However, I think Benjamin actually answered it in his first comment. It seems AnyLogic calculates the vehicle physics one block at a time thus it allows the car to accelerate up to its preferred speed at the pass-through StopLine and then only in the next block determines that it needs to stop at the next line and therefore needs to decelerate. If the pass-through line is too close to the stop line then the car cannot decelerate fast enough and "overshoots" the stop line. I have tested this in the example model by moving the pass-through line further away from the stop line and when far enough away, the car stops as expected with or without the pass-through block.

How can I continue simulating a motion with changing parameters in Dymola?

I am building a model of an elevator and want to simulate its motion from the start point to a settled destination in Dymola. After each simulation, e.g. the elevator has reached one destination. I would like to continue the motion to next position from the previous. In my model a PID-controller has been used, which has two inputs(position of destination and current position). I copy each time the "dsfinal" output file and define it as the "dsin" input file as starting conditions for next time. But the signal of the input, which receives the defined destination position, remembers always the one in the first simulation. It means, the defined value out of PID-controller has been changed, but the value, which eventually goes into the PID-controller remains unchanged. Could someone give a tip, how to solve this problem? Thanks.
PID-controller
I think I didn't fully understand the question, but would it be possible to change from the const block to a block with a non-constant output? From your description I think it would make most sense to use a Modelica.Blocks.Sources.TimeTable and specify the destination position over time.
This way you would not have to start a new simulation and you could get rid the file-copying etc. by just increasing the simulation time and specifying the desired trajectory.

Unity - random looping idle

Here is a basic setup of locomotion.
It works this way it is connected, I have walk and run animation, and stand as idle, I added 3 new stand("Idle") animations, and cant figure a way to make them random pick after walk is finished, and loop till next destination is given.
I tried adding new substate machine, but still cant figure a way to connect it the proper way.
Here is the image of current setup, this way when agent stops, it returns to idle state, and animation loops till new destination is given.
I want the same behavior but when he returns to idle, I want it to randomly loop with 3 new states
You can use BlendTree for that.
Just set Random float using Random class and use BlendTree to blend animations using that tree.