Avoid Exceptions after a train collision in Anylogic - anylogic

I need to create a model of a simple train station where I want to have the "unwanted" option to have trains collide without the model crashing with one exception. Is there any chance to avoid the model crashing maybe stopping the two trains colliding when it happens (or just a moment before)?
Thanks a lot!

Drag and drop Rail Settings and it has a few things for conflict resolution.
On car hit car section allows you to type in any code.
Here are the local variables that you can use:
You can also watch this video from AnyLogic: https://www.youtube.com/watch?v=ERvdz0w_Zgk

You can also simply use the outHit port on the TrainMoveTo block:
Best do the simple rail-model step-by-step tutorial (hump yard) as it shows how to use it

Related

Transport gets stuck

I'm implementing a model in which many transport (Transport fleet, Material Handling library) move in the same network.
I've got some limited access paths ( limited to 1 transport).
The intersection between two or more path are nodes; in this way if a path is already occupied it will stay in the node until the path is free again.
The model seems to run until some transport get stuck (see screenshot).
At the moment Transport are able to resolve collision, but if the Resolve collision parameter is false then when transports get stuck a collision is detected.
I think transport cannot choose who can be the first to can cross the path (my thought, any suggestion is appreciated).
It is not a constant problem, it can happen at different times of the one year simulation or not happen at all.
What's the problem? How can I solve it?
Thanks
Transport stuck image
The problem is that the underlying algorithms cannot possibly work for any situation or foresee any eventuality.
Either you use the build-in resolution or you have to apply custom intelligence, route-finding and decision-making, which is possible but not trivial :)

Anylogic: Running a model but stuck suddenly without any error

I'm new to Anylogic and created a simple traffic model. Only use 'carSource', 'CarMoveTo', 'Car Dispose' blocks to set the car routes. But After I ran the model, it worked for a while, then all the cars froze without any error occurring. ’Events‘ panel also stopped. How to solve it?
Most likely your model is running into an infinite loop somewhere in the logic. The first place to check would be all your loops that might become infinite,e.g Do loops, Do-while loops, iterator for loops where you perhaps change the counter variable manually...
If you have the professional version of AnyLogic the best option is to run the model in debug mode until you get this to the point where it freezes and then press pause. You will then see where in the code the model is getting stuck.
If this does not work you might need to start putting traceln in major functions and see ing you can spot the last traceln that gets printed and keep on adding more and more until you can find the point between two traceln where the model freezes
I had the same problem, that after a certain time, all cars froze and there wasn't a signle error.
The problem on my side was that the stop line was too close to the intersection, so I moved it a little bit farther.

Instantiation of equation

I am trying to model a pump system. The system consists of a controller, two ON/OFF valves, and a swept volume acting as a chamber. The controller is responsible for the state of the valves as well as filling the volume and pumping it.
When connecting all the components together, i started getting errors saying " Failed to instantiate equation between components ", for example between the swept volume and the first valve. I tried to delete the valves from the whole system and connect the piston directly to the source, but i then got an error saying "Failed to instantiate equation .." between the piston displacment and its input.
I couldn't understand where is my problem to be exact. Is it with the model themselves that they cannot be connected together or am i missing something else?
I am not an expert in modelica obviously, but i got the basics of course.
To make things clearer, here's the link to my model:
https://www.dropbox.com/s/g9dr40jame3lk2n/pumpsystem.zip?dl=0
Any help would be appreciated.
OpenModelica complains about obsolete connections. You have many connections in your model between components which don't exist anymore.
For example:
connect(ChamberController.PistonDisplacment, sweptVolume1.flange) annotation(...);
connect(close.on, ChamberController.deflate) annotation(...);
To remove these connections, simply click the link in the Messages Browser, which will bring you directly to the correct position in the code.

Update S-function Parameters in Fast Restart

I have read the Mathworks documentation carefully and tried to find a solution on forums as well. However, I have not been able to find a solution to my problem yet.
I am using Matlab/Simulink to simulate the dynamics of a vehicle, which picks up an object during operation. The way I am planning to do this is to:
Simulate the motions of the vehicle by itself at the start of the simulation;
Stop the simulation, save the final state, update the model parameters (so that they now represent the vehicle and the object)
Initialize the simulation again starting from the end time of the previous run and using the previous final state as input state to the new simulation.
To do this, I have been using the options FastRestart, SaveFinalState, SaveCompleteFinalSimState and update. Unluckily, the simulation runs seamlessly, but the model parameters are not updated.
The dynamics of the vehicle and vehicle+body are modelled by the same C-coded S-function. This function receives the parameters of the dynamic equations (e.g. inertia, damping, etc.) as parameters to the S-function block. I think this is the main problem with my approach: even though I run the update command, the S-function does not recognize the update of the parameters in the workspace. Do I need to recompile it? I guess that is not feasible under Fast Restart mode, is it?
Any advise is really appreciated! Thank you!
I have a similar issue to this in a different situation. Trying to update the initial state target of a revolute joint, the fast restart option does not change the property.
I have had some luck updating the model in fastrestart with other parameters, however, using:
set_param('Model_Name','TunableVars','Variable Name')
Not sure if this will help in your situation, perhaps saving the final state as a variable and having the respective variables as initial parameters.

UE4 Objects overlap position after collision

I'm new to unreal engine, I'm trying to add large force to an object with a box collider but after it collide with other object (just another instance) the overlap inside each others and become like one object and moving with each others.
Cab anyone explain their behavior and how i should resolve this?
What happens here is that both objects collide with each other continously. To fix that you could try to deactive the OnOverlap()-Event on either the overlapping Object or the colliding object.
In blueprints you can achieve that by setting the Generate Overlap Events-Variable of one of the colliding static meshes of the overlapping objects to false.
In C++ you could simply remove the dynamic event callback for one of the colliding objects like that:
CollidingComponent->OnComponentBeginOverlap.RemoveDynamic(this, &ACollidingActor::OnBeginOverlap);
Where CollidingComponent is the component of your object, which causes the overlap event to trigger.
Like #Alex said, they overlap with each other, over and over. If you didn't know, you can add breakpoints to your blueprint nodes, just like in your code, by right-clicking a node and select Enable Breakpoint (or smth like that). Your game will stop when reaching it and switch to that exact point in your blueprint. You can then hover over that node and see every variables value going in and out of it.
Hope this helps you learing to use the Unreal Engine.