I am trying to define two independent but related processes, criminal career and crime enforcement (imprisonment). Here is a diagram:
Crimes will be committed only if an agent has already started his criminal career through an internal transition. Desistance (to move away from crime) is a final state that can happen while an agent is imprisoned (that's why I define this problem as two independent processes).
When a crime occurs (internal transition commitCrime) the variable committedCrime is set to true. The commitCrime transition has as a guard this.ImprisonmentStateChart.isStateActive(Free), so an agent cannot commit crimes if he is imprisoned.
Every time a crime is committed, a condition transition is assessed from state Free: this.committedCrime == true. Once in prison, an agent will be eventually released.
My problem is that the commitCrime transition is not restarted after coming back to the Free state. The idea would be to restart the commitCrime transition after releaseFromPrison is triggered, but I haven't found how to do it with Anylogic 7.
Any ideas?
I think the simplest way is to remove guard and wrap the action in if statement:
if ( ImprisonmentStateChart.isStateActive(Free) )
committedCrime == true;
Related
I am trying to simulate thousands of actors in a parallel fashion in order to simulate the real world scenario of a distributed environment. I was reading up on how simulators are built and came across the concept of ticking. I think I am understanding it, but would like correction where I am wrong.
For the sake of simplicity, let's say I want to simulate 5 actors, so I spin up 5 threads. In each actor I have an infinite loop listening in on its message queue to process any messages and any change in state will be reflective on the GUI. The issue I suspect would be all 5 actors could be processing messages that require different amounts of time or have outdated messages that are invalid given a change in the environment. This is where the concept of ticking comes in. The current tick is only complete once all the modules have performed an action for that tick. So for example:
Simulator has a variable var tick = 0 and var num_actors = 5
Simulator will have a callback that is called when an actor has processed their message
Simulator will have a counter completed_ticks for tick = 0 and when completed_actors == num_actors then tick += 1 and call .tick() for each of the actors which will now perform the next action given the current environment
This now ensures that all actors are evaluating the same environment
Is this the correct understanding of ticks?
I have the following problem which I am unable to solve:
I have a situation where a security point (added as delay) holds every half an hour a 15 min break. After the break, the security guards increase their speed till the queue is shorter than 10pp.
I wanted to model this as follows: a state chart with delay.set_capacity(0) after 30 minutes and delay.set_capacity(1) again after the 15 min break. For the increased speed after the break, I added an additional state with condition: queue.size()>10 and now I want to set the action such that the delay function changes the delay time from exponential (1/10) to exponential (1/5) as long as queue.size()>10.
Anyone experience with which function in the action box to use? Or would you suggest a different function?
Since you are using, or at least want to use a statechart I would suggest the following design, where you have composite states inside the working state to indicate if the security agent is working fast or normal and a message transition to let it move from one state to the next.
It is advised to use a message transition and trigger it as needed instead of a conditional state which gets chected for every change inside the agent since this can be a computational expensive exercise.
I assume you already implemented the correct capacity settings for the different on enter actions for working and breaking
Now you simply need to send the message every time an agent enters the queue and every time it exits the delay block, and of course, see the delay time based on the state of the statechart.
Aee screenshot below.
im creating some paths with the process modeling library. The trucks shall stop in series when waiting for the "go" signal to go on.
At the moment the trucks are waiting "within" each other.
How to tell the trucks to recognize not the stopnode only but also the hitbox of the truck which arrived before him?
Thanks in advance
Chris
The trucks shall stop in series when waiting for the "go" signal to go on.
At the moment the trucks are waiting "within" each other. [...]
How to tell the trucks to recognize not the stopnode only but also the
hitbox of the truck which arrived before him?
AnyLogic allows for agents to queue along a path (from an animation perspective) whilst in a Queue block. So don't make them move to the stop-node (which I assume you are doing explicitly): make them (from a process point-of-view) go into a Queue which is animated via the path from the stop node 'backwards'. (This is the "Agent location" setting of the Queue block.) How you hold them in the queue and release them when they need to depends on the nature of your model; e.g.,
Use a Hold block following the Queue (if it makes sense to release them all at once)
Use a 'dangling' Queue block which you pull agents out of programmatically (e.g., via its removeFirst function) and then add them somewhere else in the process via an Enter block.
Use a Seize block (which has a built-in Queue you can set the location of) with the resource seized representing the 'token' you need to proceed.
NB: From the process perspective, they are in a Queue which happens to be animated as queueing along a path. This isn't exactly the same as modelling the 'spatial reality' of being in a queue: see this question.
Simple solution is to turn your truck agents into Transporters from the Material-handling library. They have build-in collision avoidance.
However, this can slow large models so you may want to convert them only when you need collision avoidance and then convert back to "simple" Truck agents again.
Else, you need to build your own additional stop-nodes and code spatial queuing manually. Possible but not straight forward
I am modelling earthmoving operation. Every trench agent seize two transporters, one excavator, and one truck. When truck is released it will do some other job before been seized again by the same trench. So this process repeat until the trench will be empty.
The process is occuring for two three times without any problem but after two three times the trench agent is not go out of the seizeTransporter block (the one that seize truck). I have a delay block after the seizeTransporter block and it use Maximum Capacity. So it should not be a problem and it should not prevent the seizeTransporter block out port to push the trench out.
I noticed this is hapenning when the truck stop to resolve a collision. It looks like the collision cannot be resolved and the truck stay where it is for ever. :))
I have tried so many things that could solve this problem but none of them works.
There is an option in the material-handling library TransporterControl element to override transporter conflicts after some time. Maybe reduce the default timeout of 10 model time units, see below:
I have long-running workflow service, based on state machine, that at some point has to compare two values and if they are equal it should transition to a new state.
However, once I introduce trigerless transition with compare, workflow instance never goes to idle.
What is the best approach to do this, to have conditional transition that is evaluated once per entering source state, and goes back idle if condition is false.