AnyLogic: free specific agents from wait block - simulation

I have equipped my agent with a parameter barcode. Input is an Excel with different barcodes as arrival in the source.
There are four different types of parts in my model. Part 1 is multiplied in the model by a split block w times, part 2 x times, part 3 y times and part 4 z times.
The parts run different paths through my model. That means they have different times and therefore do not arrive back in the sink at the same time. Because I want all parts to end up in the sink at the same time, I want to work with a wait block.
When the parts are multiplied, they keep their unique barcode.
Example: Part 3 is multiplied y times. So there are y many part 1 with the same barcode. So in the wait block I want all agents (parts) to wait until ALL multiplied parts of this part arrive in the wait block just before the sink.
My approach is: a switch case within the wait block after Part 1, Part 2 ect.
And then inside the case a code like: if w agents with the same barcode are inside the wait block, free them. But not all other agents. So you could say that this wait block is like a sorting station.

I would approach this differently. Instead of Wait block, I would keep it as Queue. Then join it to a Pickup block. Inside Pickup, select While condition is true and type below the condition (assuming your total number should be 7) (agent.barcode==container.barcode) && (count(queue, q-> q.barcode==agent.barcode)==7 )
.
Whenever a new barcode enters the system, create a dummy agent with agent.barcode set to that value and send the dummy agent to enter1 with code like enter1.take(agent). Then this dummy agent will wait in queue2, once the count is reached, it will pick up exactly that number of agents and depart to sink. If you want, you can put a Dropoff block and then Sink.

Related

calculate avarage waiting time in anylogic

Two groups of men and women arrive at the same entrance source at the same time to avail a certain service, then how can we get the entire average waiting time of both separately in anylogic .please help me.
You can use these two block provided by AnyLogic.
Or as I do, create two variables for your agents called enterTime and leaveTime and set them to time() when they enter and leave the Queue. Like agent.enterTime = time(). Create a variable in the Main (assuming your blocks are there) called totalTimeInQueueMen and totalTimeInQueueWomen and set it to totalTimeInQueueMen=totalTimeInQueueMen+(agent.leaveTime-agent.enterTime). Also count your number of agents with a variable called count. Every time they enter the queue, increment it by 1; like count+=1;. At the end of the the simulation you can calculate the average as totalTimeInQueueMen/count (the same for women).

Modeling a waiting line in a call centre in AnyLogic

I need to model a waiting line in a call centre in AnyLogic. This is what I don't understand. It says:
If all of the service representatives are busy, an arriving customer is placed on hold, but ties up on the phone lines.
I am not sure what block or how to model customers waiting. Can someone help me? Thank You!
Here is my solution, although I'm absolutely sure other methods exist.
To represent an arrival rate of 15/hr, use a source block with arrivals defined by rate, with the rate set to 15 per hour.
To represent 24 phone lines and 3 service reps, use a queue block (callsWaiting) followed by a delay block (service). The queue block should have capacity = 21 and the delay block should have capacity = 3 with a delay time of exponential(0.1,0) minutes representing the exponential service time (with mean 10 min).
To represent losing calls when all of the phone lines are tied up, place a selectOutput block before the callsWaiting queue and set its condition to: callsWaiting.canEnter(). It will return false if the queue is at maximum capacity. On the false branch for that selectOutput, place a sink block for dropped calls.

agent cannot be resolved to a variable when timing segments of AnyLogic model

In the model, I need to time segments in which some agents go through, but not all, rendering the use of timeMeasureStart and End blocks ineffective as any agents who go through a certain End block MUST go through it's corresponding Start block, but not all agents that will encounter the End block will have gone through it's corresponding Start block.
I have done the following and receive the error that 'agent cannot be resolved to a variable' in the Histogram
Defined the variables startTime endTime cycleTime in the agent class Patient which is being pushed through the model.
Put agent.cycleTime=agent.endTime-agent.startTime; in the On enter slot of the block in which I want the timing to end.
Defined a Histogram Data called myDataSet with the Value agent.cycleTime in Main
Made a histogram in Main which takes myDataSet in it's Histogram slot.
First, you can still use TimeMeasureStart/end blocks. Just let some agents bypass them with a SelectOutput block upstream of the TimeMeasureStart block. The condition would be determined by who should be measured.
Ok, then to your details:
Put agent.cycleTime=agent.endTime-agent.startTime; in the On enter slot of the block in which I want the timing to end.
This is not how you would measure time. The variables are a good start, though. Do this instead:
Wherever timing should start, you write agent.startTime = time() (logs curr model time)
Wherever timing should end, you write agent.cycleTime = time() - agent.startTime, essentially measuring how much time has passed since the start.
Now you do what you want with agent.cycletime
Defined a Histogram Data called myDataSet with the Value agent.cycleTime in Main
this is not how you use Histogram Data. You need to use the API calls on it properly, for example myHistogramData.add(someValue):
Also, always check example models and the help, many issues can be solved by checking those first :)

I have a process to move a picking agent and a product through the same delay block

Currently, I have two delay blocks above each other, where one agent goes through one of the blocks and the other through the other one.
But when I want exponentially distributed values with a mean of 120 seconds, They both need to have the same value always. So they are done at the same time.
You simply need to have the two delay blocks use their own (but with the same seed) random object.
Start off by creating two identical random objects
And have each of the delay blocks use of them of them
Then the numbers they will sample will be the same for every sampling iteration.
See this post for a similar problem
Why do two flowcharts set up exactly the same end with different results every time the simulation is run even when I use a fixed seed?
Not questioning your probably bad design by not using resources, These are the steps to follow to ensure things happen at the exact same time:
1.Create a variable called seed of type long
2.create a cyclic event that runs every 1 minute and has the following code:
seed=(new Random()).nextLong();
3.In both blocks you will use the following code to calculate the exponential distribution:
exponential(120,0,new Random(seed))

how to detect 2nd crossing to point simulink

How to detect the 2nd falling crossing when it reaches the 2nd point. The signal will rise again after the 2nd crossing and then repeats.
Each time the signal falls at 20(2nd time) i want to capture it via relational block like the output signal in the image
Input Signal:
Model:
Output
There are multiple ways this could be done. One approach is to create a triggered counter, using a Triggered Subsystem, with the counter resetting itself if the count tries to go above 2.
An example of this is shown below. The trigger is generated by comparing your input to a constant (in this case 20) and incrementing the counter based on a rising edge of that trigger. Initialize the counter to 1, then either
increment the counter if the count value is currently less than 1.
reset the counter to 1 if the counter is already at 2.
In this example the counter resets every second crossing of the threshold.
If data typing is important this could also be done using logical/boolean values (i.e. True and False), rather than the 1 and 2 used in the example.
Using the answer above by Phil, i was able to create my version without using triggered subsystem
Sample answer