Time Measuring from order placement to delivery in AnyLogic - time

I'd like to measure the time from order placement (agent Order) to delivery to the shop.
There are some delays inbetween due to assembly of the goods. But after that I need to transport it to a defined port by trucks and vice versa in the country of destination.
I figuered I have to use sources (creates my good agents) and sinks (arrival of my good at destination) for timemeasuring. So I can use TimeMeasureStart and TimeMeasureEnd but I am having trouble with how I acutally implement this in my flowchart in AnyLogic.
Any thoughts?
Thanks in advance!
Benj

Create three parameters in your order agent: timeEnter, timeLeave, timeInSystem. When the order is created, set agent.timeEnter=time() and whenever you dispose of them, type
agent.timeLeave=time();
agent.timeInSystem=agent.timeLeave-agent.timeEnter;
You can add this value into a dataSet, for example.

You can use the time measure start and time measure end blocks.
You simply place the 'start' block where you want to start measuring and the 'end' block where you want to stop measuring and then refer to the associated start block inside the end block
The screenshot is from the how to model that can be found in the AnyLogic How to examples in the Software
Or check the link here https://anylogic.help/library-reference-guides/process-modeling-library/time-in-system.html#measuring-time-in-system

Related

How do I create a time-based delay that starts and ends by a clock time?

I'm trying to simulate a movie theater. Movies start and end at specified times, no matter when a customer arrives and sits down. I want to be able to start and end the delay by time based units, kicking everyone out at the same time (once the movie is over)
I've tried googling - because I am a student and this was way too ambitious to try but I really wanted to. I'm literally hoping for any kind of insight
Select output, 4 different services (not ped), ped go to, then all same sink
I want it to work and it doesn't
Try thinking of your movie as an agent. Each movie can have its own event, which you could set to go off at a specific calendar date/time. In the action of the event, you could send a message to all your customers that they can now leave the theater...or, if your customers are in a queue with a hold block for that particular movie, you can just unblock the hold.
With movies as agents, you could have a start/end time and then create your population of movies from a database linked to Excel. That is, you would be able to set up your movie schedule outside of AnyLogic, which would probably be easier for whoever your stakeholders are.
Your question is probably too broad to answer fully in stack overflow. There are a million different ways to model a movie theater, and approach would depend on what you are trying to answer, animation requirements, your comfort level with programming, user interface requirements, etc.

a Kafka Stream back to itself

I have just defined a KStreams topology for the first time and wanted a quick sanity check to make sure I'm not doing something stupid (or if there's a better way.) Essentially what I have boils down to:
[input-topic] --> alltime-store
--> thisweek-store --> (logic) --> {new-record} -->[input-topic]
Records are read from the input-topic and then groupBy() and Materialized onto two separate counting stores.
The thisweek-store is windowedBy a specific time duration and passed onto a filter that applies some logic, which an example might be:
if value > 10
then send new-record
If it's not obvious, at a very high level, I am trying to award a bonus if somebody does something enough times in one week.
Is it OK to create a cycle like this in your topology?
The only obvious problem I can see is you might create an infinite loop; but hopefully this could be prevented in the [logic] block.
It is perfectly fine to use the Streams.to() output topic as builder.stream() input topic in the same application.
As there can be valid scenarios i.e. reinforcement learning. If you are training some data where you produce newer events based on previous one.

Using the agent's methods on events

Im using anylogic in order to build a model of randomly moving cars.
In that model i want to gather some information on the agents (Cars) using a varivable and an event block.
On the model i want the event to set the variable carsLane with the lane of the car that is currently on the road and to do so every 2 seconds.
The thing is that every time the event is suppose to take place i get "NullpointerException" error and it happen so on every method of Car that im trying to use using the Event.
The event is on the Main tab and the code im using on the action box:
carsLane=Car.getLaneIndex();
On the image you can see the formation of the blocks and the code on the event's action box
Am i using the event wrong or is it something else?
Thank you for any kind of help.
This will be confusing to you, but the Agent Car that you defined in the model is NOT or does not contain the agents that are created in the carSource module, so doing carLane=Car.anything will give you an error, since the Car agent is probably empty or is not in any Lane.
To solve this, you need to do a bunch of things (and I will assume that you generate cars in your carsource in a way that there will be a maximum of 1 car in the road... if there are more, you have to do something different.
First: create a new Car agent with a population of cars, let's call it thecar (use the agent from the agent palette... not the "car type") with an initial population of 0.
This agent will be an extension of the Car type you created:
Second: In the car source, add your cars to a custom population:
And also, your car source will generate cars of the type thecar:
third: In your event now you can do:
carsLane=thecars.get(0).getLaneIndex();
And I created the model for you... find it here:
https://ufile.io/5jkqu

BaseStatefulBolt (Storm Core) vs StateFactory (Storm Trident)

i am confused about using storm. I am going to measure status of data source using its streamed data. Status will be calculated with combine of some fields, and these field can be achieved different time interval. That's why i need to save fields to measure status of data source.
Can i use BaseStatefulBolt? Or the only solution is trident for this cenario?
What is the difference btw them. Because there is a statefactory inside trident too.
Thank you.
I think the difference is trident is higher level than BaseStatefulBol, it has some options for counting like group by,persistentAggregate,aggregate .
I have used trident for counting total view per user. If we only care about current total count, I think we can use trident by using MemoryMapState.Factory() and class implement action for counting or summing.
In your case you need to managing status of some current fields , I think implement BaseStatefulBolt is a good choice, it has KeyValueState for save current state.

Solution for graphing application events metrics in real time

We have an application that parses tweets and we want to see the activity in real time. We have tried several solution without success. Our main problems is that the graphing solution (example:graphite), needs a continious flow of metrics. When the db aggregates the metrics it's an average operation which is done, not a a sum.
We recently saw cube from square which would fit our requirement but it's too new.
Any alternatives?
I found the solution in the last version of graphite:
http://graphite.readthedocs.org/en/latest/config-carbon.html#storage-aggregation-conf
If I understood correctly, you cannot feed graphite in realtime, for instance as soon as you discover a new tweet?
If that's the case, it looks like you can specify a unix timestamp when updating graphite metric_path value timestamp\n so you could pass in the time of discovery/publication/whatever, regardless of when you process it.

Resources