I would like to free the different amount of pallets sitting in my wait block to the certain time. I don't know how to use the free function in my dynamic event. The database is called lkw76 and my different pallet amounts called amount in my database which are released to the certain date. So I have the wait block where the pallets sit in before they will be released to the time of my database. So I need the function for my dynamic event which release the amount of pallets in my wait block. In main on startup I have following function to connect the dynamic event with my database. In general I don't have java knowledge so I am currently in the process to learn it. Thank you for helping.
List< Tuple > amounts =selectFrom( lkw76 ).list();
for( Tuple tup : amounts ) {
Date today=date();
Date future=tup.get(lkw76.dates);
long diff = future.getTime() - today.getTime();
int amount=tup.get(lkw76.amount);
create_MyDynamicEvent(diff,MILLISECOND,amount);
}
database
dynamic_event
process
You may do it like this in the dynamic event:
for(int i=min(amount,wait.size());i>0;i--){
wait.free(wait.get(i-1));
}
This implies FIFO and will free the first amount agents that entered the wait block, unless there are less agents in the wait block, in which case it will free all of them
Related
I have a queue block where agents enter and exit. Each agent has the following attributes (parameters): ID, processing time and due date. After one hour, I want to use an event block to collect the info (ID,processing time and due date) of the agents that are still waiting in the queue at that moment, and write this info to Excel. In Excel, I would like 3 columns, one with the ID's, one with the processing times and one with the due dates of each order in the queue.
I have tried adding and removing info to a LinkedList, but this did not work. Does anyone know how I could get the information I need?
In your event, simply loop across all agents in the queue and write a dbase query to insert data for them using the insertInto syntax.
Could look like this:
for (int i=0; i<queue.size(); i++) {
MyAgent currentAgent = queue.get(i);
insertInto(myDbaseTable)
.columns(myDbaseTable.column1, myDbaseTable.column2)
.values(currentAgent.someInfo, currentAgent.otherInfo)
.execute();
}
Utilizing a source generating agents on an Interarrival time basis, I would like to stop the source block from generating agents after a certain amount of time passing so that the model can continue to process the agents.
One option to encapsulate all the logic inside the source block, without external events or variables, would be to select Multiple agents per arrival as true and then have a conditional statement for the number of agents, for example time() > 10 ? 0 : 1, so that after 10 model time units there will no agents arriving
Sure. If it is a inter-arrival source block, make it use a variable as the interrarrival time, of type double:
Then, create an event that triggers once only, after your specific time. Make it change the variable to 0 as below. Make SURE to trigger it not at time 0 (as in the screen but when you need it!):
NOTE: Do not set myRate = 0;. Instead, set it to infinity` to actually have no more arrivals.
i am new in using Anylogic , and i see in the PedWait block , Delay end on free function call , what does that mean and what is the difference between choosing it and the on delay time expiry ?
Thank you
the free function call is used in case you want to use something different than a time delay to allow the pedestrian to continue to the next block.
For example, a pedestrian can wait until a resource is available... since you don't know if the resource is going to be available in an exact amount of time, you can't use a time delay, so you use a free function call.
And when the resource becomes available, you can free the pedestrian by doing pedWait.free(ped)
I would like to use my custom flowchart for different process flows and the delay time of my process is coming from a database. I tried to use the parameter but doesn't work. How can I get access to my database and connect it with my delay block in my custom flowchart to get my delay from the dbase. My target is to pick my pallets from the racks to the certain times.
delaytime =timearrival_minutes
Use a DynamicEvent.
Create a function at the model start that loops across all dbase entries. Create a dynamic event for each entry that is triggered by "the dbase-entry date" minus "your current model start date".
In the Dynamic Event, trigger rawMaterialStorage.free(some agent), obviously it is up to you to free from the correct custom block.
Check example models and the help on looping dbase entries and Dynamic Events :)
Let's say we have a reactive sales forecasting system.
Every time we make a sale we re-calculate our Forecast for future sales.
This works beautifully if there are lots of sales triggering our re-forecasting.
What happens however if sales go from 100 events per second, to 0. And stay 0 for a long time?
The forecast we published back when sales were good stays being the most up to date forecast.
How would you model in this situation an event that represents 'No sales happening' without falling back to some batch hourly/minutely/arbitrary time segment event that says 'X time has passed'.
This is a specific case of a generic question - How do you model time passing with nothing happening in an event based system - without using a ticking clock style event which would wake everyone up to reconsider their current values [an implementation which would not scale].
The only option I have considered that makes sense:
Every time we take a sale, we also schedule a deferred event 2 hours in the future that asks us to reconsider our assessment of that sale.
In handling that deferred event we may then choose to schedule further deferred events for re-considering.
Considering this is a very generic scenario, you've made a rather large assumption that it's not possible to come up with a design for re-evaluating past sales in a scalable way unless it's done one sale at a time.
There are many different scale related numbers in the scenario, and you're only looking at the one whereby a single scheduled forecast updater may attempt to process a very large number of past sales at the same time.
Other scalability issues I can think of:
Reevaluating the forecast for every single new sale doesn't sound great if you're expecting 100s of sales per second. If you're talking about a financial forecasting model for accounting, it's unlikely it needs to be updated every single time the organisation makes a sale, if the organisation is making hundreds of sales a second.
If you're talking about a short term predictive engine to be used for financial markets (ie predicting how much cash you'll need in the next 10 seconds, or energy, or other resources), then it sounds like you have constant volatility and you're not really likely to have a situation where nothing happens for hours. And if you do need forecasts updated very frequently, waiting a couple of hours before triggering a re-update is not likely to get you the kind of information you need in the way you need it.
With your approach, you will end up with one future scheduled event per product (which could be large), and every time you make a sale, you'll be dropping the old scheduled event and scheduling a new one. So for frequently selling products, you'll be doing repetitive work to constantly kick the can down the road a bit further, when you're not likely to ever get there.
What constitutes a good design is going to be based on the real scenario. The generic case is interesting to think about, but good designs need to be shaped to their circumstances.
Here are a few ideas I have that might be appropriate:
If you want an updated forecast per product when that product has a sale, but some products can sell very frequently, then a good approach may be to throttle or buffer the sales on a per product basis. If a product is selling 50 times a second, you can probably afford to wait 1 second, 10 seconds, 2 hours, whatever and evaluate all those sales at once, rather than re-forecasting 50 times a second. Especially if your forecasting process is heavy, doing it for every sale is likely to cause high load for low value, as the information will be outdated almost straight away by the next sale.
You could also have a generic timer that updates forecasts for all products that haven't sold in the last window, but handle the products in buffers. For example, every hour you could pick the 10 products with the oldest forecasts and update them. This prevents the single timer from taking on re-forecasting the entire product set in one hit.
You could use only the single timer approach above and forget the forecast updates on every sale if you want something dead simple.
If you're worried about load from batch forecasting, this kind of work should be done on different hardware from the ones handling sales.