I want to simulate a supermarket with the arena to find the proper number of cashiers which market needs.
I want to start the simulation with one cashier then increase the number of cashiers in next simulations until the utilization of cashiers is less than 70%.
each cashier is a "resource module" and has a "process module" for it's service time.
am I make a separate model for each different number of the cashier(for example a model for a supermarket with one cashier, another model for a supermarket with two cashiers and so on) or is there a better way?
It's a little more advance but it sounds like Arena's Process Analyzer would help you determine the number of cashiers needed.
The Process Analyzer assists in the evaluation of alternatives
presented by the execution of different simulation model scenarios.
This is useful to simulation model developers, as well as decision-
makers
The Process Analyzer is focused at post-model development
comparison of models. The role of the Process Analyzer then is to
allow for comparison of the outputs from validated models based on
different model inputs.
via pelincec.isep.pw.edu.pl/doc/Simulation_Warsaw%20Part%205.pdf
A Google search for Arena Process Analyzer provides plenty of lecture notes, book references and examples:
https://www.google.com/search?q=arena+process+analyzer
Also, it sounds like this model isn't very complicated so, although it may be tedious, it'll probably be quicker to alter your model and run n simulations for each solution {1 cashier, 2 cashiers, ...}.
Also, if the model is indeed pretty simple, why not create multiple independent models in the same simulation file. For instance, one simulation file has three independent models of 1, 2 and 3 cashiers. The next has 4, 5 and 6 cashiers and so on. This would consolidate the statistics a little more and make analysis easier.
There are several ways to do this without making multiple models. A cashier is simply a resource, but it could also be an entity.
You can build your model to require throughput (customers) to be processed when two entities are available - a register entity and a cashier entity. This could be done with a batch module.
cashier entities would be set up according to a schedule you would like to test... from minimum cashier availability to full cashier availability.
Register entities would probably be held constant, but you could make them variable according to a schedule, too.
Your batched entity would then go into the process entity until a schedule called for the cashier to "leave" the system - split the batch and destroy the cashier entity. Register entity loops back to the batch to be grouped with another cashier or wait.
Related
I know that one can utilize multiple KieBases and multiple KieSessions, but I don't understand under what scenarios one would use one approach vs the other (I am having some trouble in general understanding the definitions and relationships between KieContainer, KieBase, KieModule, and KieSession). Can someone clarify this?
You use multiple KieBases when you have multiple sets of rules doing different things.
KieSessions are the actual session for rule execution -- that is, they hold your data and some metadata and are what actually executes the rules.
Let's say I have an application for a school. One part of my application monitors students' attendance. The other part of my application tracks their grades. I have a set of rules which decides if students are truant and we need to talk to their parents. I have a completely unrelated set of rules which determines whether a student is having trouble academically and needs to be put on probation/a performance plan.
These rules have nothing to do with one another. They have completely separate concerns, different rule inputs, and are triggered in different parts of the application. The part of the application that is tracking attendance doesn't need to trigger the rules that monitor student performance.
For this application, I would have two different KieBases: one for attendance, and one for academics. When I need to fire the rules, I fire one or the other -- there is no use case for firing both at the same time.
The KieSession is the runtime for when we fire those rules. We add to it the data we need to trigger the rules, and it also tracks some other metadata that's really not relevant to this discussion. When firing the academics rules, I would be adding to it the student's grades, their classes, and maybe some information about the student (eg the grade level, whether they're an "honors" student, tec.). For the attendance rules, we would need the student information, plus historical tardiness/absence records. Those distinct pieces of data get added to the sessions.
When we decide to fire rules, we first get the appropriate KieBase -- academics or attendance. Then we get a session for that rule set, populate the data, and fire it. We technically "execute" the session, not the rules (and definitely not the rule base.) The rule base is just the collection of the rules; the session is how we actually execute it.
There are two kinds of sessions -- stateful and stateless. As their names imply, they differ with how data is stored and tracked. In most cases, people use stateful sessions because they want their rules to do iterative work on the inputs. You can read more about the specific differences in the documentation.
For low-volume applications, there's generally little need to reuse your KieSessions. Create, use, and dispose of them as needed. There is, however, some inherent overhead in this process, so there comes a point in which reuse does become something that you should consider. The documentation discusses the solution provided out-of-the box for Drools, which is session pooling.
(When trying to wrap your head around this, I like to use an analogy of databases. A session is like a JDBC connection: for small applications you can create them, use them, then close them as you need them. But as you scale you'll quickly find that you need to look into connection pooling to minimize this overhead. In this particular analogy, the rule base would be the database that the rules are executing against -- not the tables!)
Say, I have System1 that connect to System 2 through the adapter-microservice between them.
System1 -> rest-calls --> Adapter (converts request-response + some extra logic, like validation) -> System2
System1 is more like a monolith, exists for many countries (but it may change).
Question is: From the perspective of MicroService architecture and deployment, should the Adapter be one per country. Say Adapter-Uk, Adappter-AU, etc. Or it should be just the Adapter that could handle many countries at the same time?
I mean:
To have a single system/adapter-service :
Advantage: is having one code-base in or place, the adaptive code-logic between countries in 90 % are the same. Easy to introduce new changes.
Disadvantage: once we deploy the system, and there is a bug, it could affect many countries at the same time. Not safe.
To have a separate system:
Disadvantage: once some generic change has been introduced to one system, then it should be "copy-pasted" for all other countries/services. Repetitive, not smart.. work, from developer point of view.
Advantage:
Safer to change/deploy.
Q: what is a preferable way from the point of view of microservice architecture?
I would suggest the following:
the adapter covers all countries in order to maintain single codebase and improve code reusability
unit and/or integration tests to cope with the bugs
spawn multiple identical instances of the adapter with load balancer in front
Since Prabhat Mishra asked in the comment.
After two years.. (took some time to understand what I have asked.)
Back then, for me was quite critical to have a resilient system, i.e. if I change a code in one adapter I did not want all my countries to go down (it is SAP enterprise system, millions clients). I wanted only once country to go down (still million clients, but fewer millions :)).
So, for this case: i would create many adapters one per country, BUT, I would use some code-generated common solution to create them, like common jar - so I would would not repeat my infrastructure or communication layers. Like scaffolding thing.
country-adapter new "country-1"
add some country specific code (not changing any generated one (less code to repeat, less to support))
Otherwise, if you feel safe (like code reviewing your change, making sure you do not change other countries code), then 1 adapter is Ok.
Another solution, is to start with 1 adapter, and split to more if it is critical (feeling not safe about the potential damage / cost if fails).
In general, seems, all boils down to the same problem, which is: WHEN to split "monolith" to pieces. The answer is always: when it causes problems to be as big as it is. But, if you know your system well, you know in advance that WHEN is now (or not).
I am building a fairly simple model to record the time taken by a product to be manufactured.
Need any guidance on how to segregate "virgin products" from "rework products".
I have around 4 rework loops. The product might visit either one or all four rework loops. I am not sure on how I can classify any "agent" that enters a rework loop in anylogic. I can measure individual rework times per block, but unable to classify an overview of how many agents entered rework as a whole and how many did not. I am using a DES approach.
Thanks
You need to turn your products into individual agents that flow through the DES flow. Then, you can access each individual product and flag it as "reworked", log individual times...
Suggest you check out a few DES example models, most use agents to flow through the blocks, so you can see how it is done.
btw, this is one of the most powerful features of AnyLogic that competitors cannot compare with in terms of flexibility, so worth learning :-)
I am documenting a user workflow where part of the flow is automated by a system (e.g. if the order quantity is less than 10 then approve the order immediately rather than sending it to a staff for review).
I have swim lanes that goes from people to people but not sure where I can fit this system task/decision path. What's the best practice? Possibly a dumb idea but I'm inclined to create a new swim lane and call it the "system".
Any thoughts?
The approach of detaching system task into separate lane is quite possible as BPMN 2.0 specification does not explicitly specify meaning of lanes and says something like that:
Lanes are used to organize and categorize Activities within a Pool.
The meaning of the Lanes is up to the modeler. BPMN does not specify
the usage of Lanes. Lanes are often used for such things as internal
roles (e.g., Manager, Associate), systems (e.g., an enterprise
application), an internal department (e.g., shipping, finance), etc.
So you are completely free to fill them with everything you want. However, your case is quite evident and doesn't require such separation at all. According to your description we have typical conditional activity which can be expressed via Service task or Sub-process. These are 2 different approaches and they hold different semantics.
According to BPMN specification Service Task is a task that uses some sort of service, which could be a Web service or an automated application. I.e it is usually used when modeller don't want to decompose some process and is intended to outsource it to some external tool or agent.
Another cup of tea is Sub-process, which is typically used when you
want to wrap some complex piece of workflow for reuse or if that
piece of workflow can be decomposed into sub-elements.
In your use case sub-process is a thing of choice. It is highly adjustable, transparent and maintainable. For example, inside sub-process you can use Business Rules Engine for your condition parameter (Order Quantity) and flexibly adjust its value on-the-fly.
In greater detail you can learn the difference of these approcahes from this blog.
There is a technique of expressing system tasks/decisions via dedicated participant/lane. Then all system tasks are collocated on a system lane.
System tasks (service tasks in BPMN) are usually done on behalf of an actor, so in my opinion it is useful to position them in the lane for that actor.
Usually such design also help to keep the diagram easy to read by limiting the number of transition between "users" lanes and "system" lane.
I am working for a school district, and we are planning on using Drools to implement the following types for rules for the student population of the districts constituent schools:
If a student has 3 absences during a year their attendance metric moves to a WARN status.
If a student has 6 absences during a year their attendance metric moves to a CRITICAL status.
If a student has 3 major behavior incidents during a year their behavior metric moves to a WARN status.
If a student has 2 minor and 2 major behavior incidents during a year their behavior metric moves to a CRITICAL status.
...these are just examples from the top of my head, but there are many more rules of a similar nature.
All of these rules can be simply expressed using Drools expert. Also, the processing of the rules for a student does not need to be synchronous. I have a couple of questions about the best way to implement this.
From one standpoint this could be viewed a monitoring system for a stream of events. This made me think of creating a stateful session into which each new event would be inserted. However, the events happen over the course of 9 months and are relatively infrequent. Also, we could build a session per school, or a session per student.
Would keeping a session in memory for that long be a problem?
If the server failed, would we need to rebuild the session state from scratch or would it be advisable to take regular snapshots and just restore the facts that occurred since the time of the snapshot.
Another option would be to persist a session for each student after an event is processed for that student. When the next event comes in we would retrieve their session from storage and insert the new fact. This way we wouldn't need to retrieve all the facts for each run of the engine to get the student's status. Would a configuration like this be supported? Are there any cons to doing this?
A third approach would be to respond to a new fact for a student by retrieving all other facts the rules need to run, create a new KnowledgeSession and run the rules.
Any advice on what might be the best approach would be greatly appreciated.
Dave
I would go with solution number 2: one session per student. Given the fact that you are not going to be interacting too much with the session, I would keep it in a db and only restore it when needed: a new absence/incident arrives, the session for that student is restored from db, the facts are inserted, the rules are executed and the resulting status is retrieved.
The main disadvantage I see with this scenario is that creating rules about more than one student is not straightforward and you have to feed your facts to more than one session. For example, if you want rise an alert if you have more than 10 students with CRITICAL status in a single class. In this case, a session per class would be enough. So, as you can see, you have to decide what is better for you. But no matter the 'unit' you choose (school, class, student) I would still recommend you the execution flow I mentioned earlier.
Drools already comes with support for database persistence using JPA. You could get more information about this feature here: http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/#d0e3961
The basic idea is that instead of creating your ksessions using kbase.newStatefulKnowledgeSession() you use the helper class called JPAKnowledgeService. This class will return a wrapper of a StatefulKnowledgeSession that will persist its state after each method invocation. In this class you will find 2 important methods: newStatefulKnowledgeSession(), to create a new ksession and loadStatefulKnowledgeSession() to retrieve an existing session from the database.
Hope it helps,
There is a fourth option to make the maintenance simpler. Build one single stateful knowledge session for entire school district for all the students. After each event is processed successfully persist the session in case you need to reconstruct the working memory in case of JVM failure. You will need larger RAM and heap space allocation, but in today's time RAM is cheap. (We use 32 GB RAM and allocate 16 GB XMs and Xmx) Most likely, your JVM will never go down provided you have 24x7 server.
Being lazy I would go for the third approach. I will store all the events in a DB, Then I will process all the students in batch once per: day, week, month (as you need). That will allow you to create just one session with rules that covers multiple students, classes, etc.
If you don't have 3+ Million students you will be fine and it will be a performant app.
Thanks for the suggestions and advice. I'm leaning towards #2 for a couple of reasons:
I think that gathering up all the facts for a given student to rerun them from scratch for every event that comes in will be a heavy-weight process that I'd rather avoid.
The use case I'm dealing with models as a very long-running monitoring process which leads me to believe (after reading the use cases for Fusion) that inserting events into a persistent KnowledgeSession is the way to go.
I don't think the scope of the problem space (i.e. a student vs a classroom, a school or the whole district) is a problem. If we need classroom metrics then we will just have a new rulebase for classes that also consumes the relevant events (tests, absences etc.)
The one caveat is that if the rules change, we need to re-evaluate all affected students against the new rulebase which means gathering up all the facts and starting from the beginning of the school year. This shouldn't happen much at all, but if it become more frequent then I might move to the 3rd approach.
Thanks again for the assisstance.