Re: [rules-users] A few general questions on scaling StatefulKnowledgeSessions
See inline. On 17/08/2012, Skiddlebop wrote: > Greetings All! > > I humbly request your guidance and insights! > > Overview: > We are currently undergoing evaluation of how to best proceed using the > Drools Suite to best meet the current and future business needs with the > highest system scalability and performance. We are attempting to make the > proper system design choices, particularly with respect to which of the two > KnowledgeSession types (stateful or stateless) to use and how to best use > them to scale the system. > > The Context: We are using Drools for operational decision making, > monitoring, and workforce resource management; this naturally entails some > degree of event processing, temporal reasoning, state management, and > inference. > Given the nature of this context, it seems that a StatefulKnowledgeSession > is justified and best (but may not be entirely necessary). > > The current approach: > Currently, our rule model is not very mature or stable... Consequently, the > approach is to use one very large long-running StatefulKnowledgeSession > containing all relevant operational data. This single > StatefulKnowledgeSession will be constructed and disposed of (and > reconstructed with operational state) on a very infrequent interval, say > every 24 hours. In this fashion, a single working memory network manages > the > entire operational state and holds all relevant facts; Each fact is updated > on a per-event basis. The number of expected events/time unit is an important factor in deciding about your system's architecture. What do you expect? > > The problem: > This approach has many drawbacks in my opinion... I'll mention just a > few... > StatefulSessions are not thread-safe (require sequential processing) This is not the same thing: a Stateful Session is thread-safe so that its methods can be called by more than one thread. But it is correct that synchronization must guarantee mutual exclusion for all core operations, resulting in what (I think) you mean by sequential processing. > and > consequently will not scale; it is also a single point of failure. Also, as > the size of Working Memory grows, processing time increases and garbage > collection becomes very messy and laggy (when performed). Are these observations or just fears? > > The potential solution: > To enable greater scalability, differentiation, and parallelization, it > seems wise to partition the rules/facts into multiple specialized > concurrently operating StatefulKnowledgeSession (KnowledgeBase) instances. > However, if done improperly, this poses a difficult problem as with greater > separation, the more myopic our reasoning becomes. > > Questions (some of which are intentionally dumb): > > Given the nature of the above mentioned business context, does a Stateful > approach seem justified (or is it advised to follow KISS and remain > stateless)? There's no gain in using a stateless session unless you can use it in sequential mode, which seems very unlikely from your narrative. > > What are the recommended strategies to best scale StatefulKnowledgeSessions > (or a set of StatefulKnowledgeSessions) as they are inherently > single-threaded? You can run multiple sessions in parallel. > > If multiple StatefulKnowledgeSessions/KnowledgeBases are used, what are the > recommended strategies to partition/individualize/classify them? Should we > do this according to type, instance value, unique identifier, group of > interrelated objects, etc? I understand this is very domain/use-case > specific, but I'm curious how others approach this matter. > You can partition your working memory and knowledge base on anything that permits processing all by itself. A set of rules investigating integer numbers might be divided in two sessions: one for even numbers, one for odd numbers. Moreover, if processing implies stages, you might consider passing events from one session to the next. But see my question w.r.t. the numbers you're expecting. > What are the recommended strategies with respect to frequency (or triggers) > of disposal of a StatefulKnowledgeSession and/or the retraction of the > facts > therein? > This doesn't make sense in combination with the processing model you've described. > What would you say a healthy average working-memory size is? Define "healthy" :) And if the *average* size is "healthy", it mean that it grows into unhealthy dimensions :) (Is this one of the "intentionally dumb" questions?) > > What would you say the average lifespan/duration of a > StatefulKnowledgeSession is? For the application my company is running, the sessions run as long as possible, and so the average duration is O(months). - Generally speaking: make it as long as possible. (Another one?) > > If we have an external data store (which holds state) from which we can > query and reconstruct working-memory state for any given object (or set of > objects), would it be best to continue with the single large > Statefu
Re: [rules-users] Hiding a column in web guided decision table disables a condition or action
Hi Jason, That is not supported at present, but is a work-around (that is consistent with enum definitions). Please raise another JIRA and I'll look into that too. With kind regards, Mike On 17 August 2012 02:40, jasonxzhong wrote: > Can @{KeyName} be annotated with the associated enumeration type? This may > be > easier than trying to parse the DRL and make determination of the correct > type of @{KeyName}. I found the ability to use DRL in decision table is > very > helpful and it is just a couple things like this that prevent this feature > to be perfect :-) > > I'll create a JIRA. > > Thanks for the help. > > Jason > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Hiding-a-column-in-web-guided-decision-table-disables-a-condition-or-action-tp4019169p4019227.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Specify enumeration for DSL variables?
Eh? Can you please explain your requirement a bit more. On 17 August 2012 03:09, jasonxzhong wrote: > Is there a way to specify enumeration values or functions for variables in > DSL definition? > > Thanks, > > Jason > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Specify-enumeration-for-DSL-variables-tp4019228.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Guvnor clustering
This might be helpful: http://blog.athico.com/2011/01/configuring-multiple-guvnor-instances.html On 17 August 2012 03:34, jasonxzhong wrote: > Has anyone tried to set up Guvnor in a clustered configuration, i.e. using > more than one instance of Guvnor for high availability? Does it involve > setting up a clustered Jackrabbit repository? > > Thanks, > > Jason > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Guvnor-clustering-tp4019229.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] A few general questions on scaling StatefulKnowledgeSessions
To be honest it sounds to me as though you need to get one of the Red Hat guys in to do some proper consultancy for your specific use case. However... Aiming to produce a system with the "highest scalability and performance" sounds like a strategy to produce an over engineered, overpriced solution. Google process over 30,000 search requests per second from millions of users around the world. Is that the level of scalability you need to achieve? Are you trying to achieve 'web scale'? http://kirkwylie.blogspot.co.uk/2010/09/cartoon-characters-discuss-web-scale.html Given a slightly silly example... Solution A - Processes 1 request per second on one server. Scales perfectly - i.e. Processes 2000 requests per second on 2000 servers. Solution B - Processes 1 request per millisecond on one server. Can't run on multiple servers. … which is the better solution? It depends very much on what your expected load is going to be and how much money you want to spend. The only sensible way to make this decision is to estimate realistic load for your system, measure the system performance and optimise based on those measurements. But here are some slightly more practical thoughts from my experience... Inserting new facts is slow. (although still sub-millisecond) Evaluating rules is fast. If the full set of facts required to evaluate your rules is large then you're probably better off with a stateless session where you load facts into working memory in advance and then fire in small request facts on which you wish to make a decision. If the entirety of what you're making a decision on can be expressed in a handful of facts then it may be reasonable to use a stateless session, as you will need to insert them for every request. If you're concerned about the size of the working memory, then I would have to assume that you have a large volume of facts to insert and would therefore be better off with a stateful session with most of those facts pre-loaded. If you're truly interested in CEP (especially streaming events), then you need stateful sessions. I hope that's a little bit useful. Steve On 17 Aug 2012, at 09:09, Wolfgang Laun wrote: > See inline. > > On 17/08/2012, Skiddlebop wrote: >> Greetings All! >> >> I humbly request your guidance and insights! >> >> Overview: >> We are currently undergoing evaluation of how to best proceed using the >> Drools Suite to best meet the current and future business needs with the >> highest system scalability and performance. We are attempting to make the >> proper system design choices, particularly with respect to which of the two >> KnowledgeSession types (stateful or stateless) to use and how to best use >> them to scale the system. >> >> The Context: We are using Drools for operational decision making, >> monitoring, and workforce resource management; this naturally entails some >> degree of event processing, temporal reasoning, state management, and >> inference. >> Given the nature of this context, it seems that a StatefulKnowledgeSession >> is justified and best (but may not be entirely necessary). >> >> The current approach: >> Currently, our rule model is not very mature or stable... Consequently, the >> approach is to use one very large long-running StatefulKnowledgeSession >> containing all relevant operational data. This single >> StatefulKnowledgeSession will be constructed and disposed of (and >> reconstructed with operational state) on a very infrequent interval, say >> every 24 hours. In this fashion, a single working memory network manages >> the >> entire operational state and holds all relevant facts; Each fact is updated >> on a per-event basis. > > The number of expected events/time unit is an important factor in deciding > about your system's architecture. What do you expect? > >> >> The problem: >> This approach has many drawbacks in my opinion... I'll mention just a >> few... >> StatefulSessions are not thread-safe (require sequential processing) > > This is not the same thing: a Stateful Session is thread-safe so that its > methods can be called by more than one thread. But it is correct that > synchronization must guarantee mutual exclusion for all core operations, > resulting in what (I think) you mean by sequential processing. > >> and >> consequently will not scale; it is also a single point of failure. Also, as >> the size of Working Memory grows, processing time increases and garbage >> collection becomes very messy and laggy (when performed). > > Are these observations or just fears? > >> >> The potential solution: >> To enable greater scalability, differentiation, and parallelization, it >> seems wise to partition the rules/facts into multiple specialized >> concurrently operating StatefulKnowledgeSession (KnowledgeBase) instances. >> However, if done improperly, this poses a difficult problem as with greater >> separation, the more myopic our reasoning becomes. >> >> Questions (some of which are intention
Re: [rules-users] Add attachement file to a Task Form
Thanks Tihomir for your reply, I read the JBPM user guide twice "http://docs.jboss.org/jbpm/v5.3/userguide/"; and can't find where I can insert and retrieve data from "MyDatabase". If you have the exact link, it will be great. Also, I suggest to JBOSS to integrate a tool for database modeling. There is already a lot of open source tool to design a database. The benefit of integration in Drools is: the user will pickup the variables from the database when designing a process in DROOLS (what to read / what to write/update). Also he has the option to export the database design to MySQL or anything else and build his Package and start running his application. I believe this will be a great feature in Drools. Things are little bit hard for me since I am not a developer. Again, if you have the link where I can connect the process to "MyDatabase", it will be appreciated. I already installed JBPM on MySQL. Regards, -- View this message in context: http://drools.46999.n3.nabble.com/Add-attachement-file-to-a-Task-Form-tp4019203p4019238.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] A few general questions on scaling StatefulKnowledgeSessions
On 17/08/2012, Stephen Masters wrote: > But here are some slightly more practical thoughts from my experience... > Inserting new facts is slow. (although still sub-millisecond) > Evaluating rules is fast. Left hand sides of rules are evaluated while new facts are inserted, so the above distinction does not make sense for me. Perhaps you can explain what you mean by "evaluating rules"? Executing ("firing") rules depends on what's done on the right hand side, so you can't mean that. -W ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
How to use boolean variables in the rule. I want to do this rule when //condition then set a boolean to true end Then check at the last rule if all the boolean in the rules are true, which tells me that all the rules have passed. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019240.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
ok I have done this, please find the rule file http://drools.46999.n3.nabble.com/file/n4019241/Rule.txt Rule.txt But it is still not setting the values for Program Fact in the rule file. I am getting null as output. Do I need to return that object. If yes please let me know and how can I get that back from WorkingMemory that I am using. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019241.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
Although you can write rule r when ... then boolean b = true; ... x end there is no way you can access these variables from anywhere else but the place marked with "x", i.e., inside the very same rule. To see whether certain rules have fired in a certain interval, you'll have to use some global data, either a DRL global or some other public instance. At the beginning of the interval you'll have to clear the variable, and at the end of the interval you'll have to iterate over the accumulated collection. For instance: Java code: Set ruleNameSet = new HashSet(); kSession.setGlobal( "ruleNameSet", ruleNameSet ); //... // Loop inserting a fact and firing all rules for(...){ ruleNameSet.clear(); kSession.insert( anotherFact ); kSession.fireAllRules(); for( String ruleName: ruleNameSet ){ //... ruleName has fired } } DRL code: global Set ruleNameSet; rule xyz when...then... ruleNameSet.add( drools.getRule().getName() ); end Alternatively, to avoid the global and the addition to all right hand sides, you can set up a listener and modify the Set ruleNameSet accordingly. -W On 17/08/2012, Rana wrote: > How to use boolean variables in the rule. I want to do this > > rule >when > //condition >then > set a boolean to true > end > > > Then check at the last rule if all the boolean in the rules are true, which > tells me that all the rules have passed. > > Thanks. > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019240.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
I have done this. Please find the rule file attached. http://drools.46999.n3.nabble.com/file/n4019243/Rule.txt Rule.txt But it is still not setting the values for Program Fact in the rule file. I am getting null as output. Do I need to return that object. If yes please let me know and how can I get that back from WorkingMemory that I am using. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019243.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
You must not use this: eval( boolBrandName && boolProviderState && boolDrugStrength ) since changes in global variables are not visible to the Drools rule engine. But you don't need this eval(...) line, since you have rule "Brand Name" rule "Provider State" extends "Brand Name" rule "Drug Strength" extends "Provider State" rule "Check" extends "Drug Strength" and therefore "Check" will not fire unless "Drug Strength" fires; "Drug Strength" will not fire unless "Provider State" fires; "Provider State" will not fire unless "Brand Name" fires. -W On 17/08/2012, Rana wrote: > ok I have done this, please find the rule file > > > http://drools.46999.n3.nabble.com/file/n4019241/Rule.txt Rule.txt > > > But it is still not setting the values for Program Fact in the rule file. I > am getting null as output. Do I need to return that object. If yes please > let me know and how can I get that back from WorkingMemory that I am using. > > Thanks. > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019241.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] A few general questions on scaling StatefulKnowledgeSessions
Actually, I do mean that! :D But maybe I should explain… To be more precise, most of the time in my apps is taken in marshalling facts and inserting them into the session. From firing rules, it tends to take 10s of microseconds for a decision to be made. Obviously if the RHS is doing more than just making a decision based on facts already in the system (i.e. the RHS code queries databases, etc) then firing can get very slow. However, I tend to follow the best practices that I learned from various FICO (!) consultants, who recommended against doing anything heavy in the RHS, but rather getting back out of the rules engine ASAP and doing those heavy tasks in the invoking application. This approach works nicely, because the rules engine does what it's good at (making decisions based on facts that are in working memory) and my Java (Spring) app does what it's good at (getting data and integrating with other systems). The added benefit is that if I need to synchronise access to the session, it's not such an issue if each request is back out of the rules engine in microseconds. Steve On 17 Aug 2012, at 13:01, Wolfgang Laun wrote: > On 17/08/2012, Stephen Masters wrote: > >> But here are some slightly more practical thoughts from my experience... >> Inserting new facts is slow. (although still sub-millisecond) >> Evaluating rules is fast. > > Left hand sides of rules are evaluated while new facts are inserted, > so the above distinction does not make sense for me. Perhaps you can > explain what you mean by "evaluating rules"? > > Executing ("firing") rules depends on what's done on the right hand > side, so you can't mean that. > > -W > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
ok, thank you so much for your help. It works. Thanks. But one tough question for you. How can I know what was the reason a rule condition failed. Lets say rule when test( a == "b" ) then //consequence end I want to know what caused the condition a=="b" to fail was the value of a is "b" or anything else. and I need to log this to a log file. Somebody told me that Verifier does the trick, but we need to add some custom rules to get to the values. I tried to google lot on this. But I never got anything which do what I want to do. Please help me on this. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019245.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Specify enumeration for DSL variables?
Sure I'll explain. Assuming I have the following defined in a DSL: [consequence][]Set result "{name}" to {value} = data.results.put("{name}", {value}); In the guided BRL rule editor, when I choose to use this DSL to add an action, the following is displayed Set rule flag "[name]" to [value] In this case data.results is a map that contains name/value pairs that can be set be the rules. My questions are: a. Can I attach a list of valid names to the {name} variable defined in the DSL? b. Is it possible to specify a list of valid values for the {value} variable based on the value of {name} defined in the DSL? For example if name=="valid", {value} is in [true, false]. If name=="code", {value} is in [1,2,3,4,5]. Or if a helper function can be used for this? Thanks, Jason -- View this message in context: http://drools.46999.n3.nabble.com/Specify-enumeration-for-DSL-variables-tp4019228p4019247.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
Hasn't this been answered only recently on this list? 1) For simple conditions, a rule negating the condition of your rule will fire if the other one fails: rule "a != b" when test( a != "b" ) then //consequence end 2) If you have rules extending each other, the first one not firing contains the condition(s) that are not fulfilled. 3) An individual analysis of the attributes of a fact can be done, collecting the conditions that are fulfilled. At the end of the analysis, you either have the situation that all required attributes are fulfilled (and you can execute the consequence) or not, and thus you know what's missing. -W On 17/08/2012, Rana wrote: > ok, thank you so much for your help. It works. Thanks. > > But one tough question for you. > > How can I know what was the reason a rule condition failed. Lets say > > rule > when > test( a == "b" ) > then > //consequence > end > > I want to know what caused the condition a=="b" to fail was the value of a > is "b" or anything else. and I need to log this to a log file. > > Somebody told me that Verifier does the trick, but we need to add some > custom rules to get to the values. I tried to google lot on this. But I > never got anything which do what I want to do. > > Please help me on this. > > Thanks. > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019245.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Specify enumeration for DSL variables?
http://docs.jboss.org/drools/release/5.4.0.Final/drools-guvnor-docs/html_single/index.html#d0e1802 Best Regards, Esteban Aliverti - Blog @ http://ilesteban.wordpress.com On Fri, Aug 17, 2012 at 4:06 PM, jasonxzhong wrote: > Sure I'll explain. Assuming I have the following defined in a DSL: > > [consequence][]Set result "{name}" to {value} = data.results.put("{name}", > {value}); > > In the guided BRL rule editor, when I choose to use this DSL to add an > action, the following is displayed > >Set rule flag "[name]" to [value] > > In this case data.results is a map that contains name/value pairs that can > be set be the rules. My questions are: > a. Can I attach a list of valid names to the {name} variable defined in the > DSL? > b. Is it possible to specify a list of valid values for the {value} > variable > based on the value of {name} defined in the DSL? For example if > name=="valid", {value} is in [true, false]. If name=="code", {value} is in > [1,2,3,4,5]. Or if a helper function can be used for this? > > Thanks, > > Jason > > > > > > > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Specify-enumeration-for-DSL-variables-tp4019228p4019247.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
That's what our Business doesn't want me to do to write negative rules. In this way there will be 2 rules to be written for 1 business rule. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019250.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
It's worth thinking about it differently. A rule does not fail. It just defines the conditions under which it will activate. If you wish to perform an action whether the condition is true or false, you have 2 options: A positive and a negative condition: when test(a == "b") then ... when test(a != "b") then … A condition which is always true: when test() then if (a.equals("b")) { ... } else { ... } To be honest whether you write 1 or 2 rules should not be a 'business' decision. Why does anybody think there should not be 2 rules? It's probably worth considering what you're trying to achieve. Does logging of a fact value really need to be part of a rule? For instance, if you're actually just looking for an audit trail, you can have a WorkingMemoryEventListener, which can listen for all of the fact insertions, updates and retractions. It can log them all as they happen. Combined with an AgendaEventListener, you can log what rules have activated and what the values of facts were at the time. Use an asynchronous logger and this will have very little impact on rules processing performance. Alternatively if the business are writing rules, and only wish to write the positive match, then maybe you can create a DSL which generates the both the positive and negative rules behind the scenes. A few ideas there for you to try... Steve On 17 Aug 2012, at 15:49, Rana wrote: > That's what our Business doesn't want me to do to write negative rules. In > this way there will be 2 rules to be written for 1 business rule. > > Thanks. > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019250.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Specify enumeration for DSL variables?
Thanks! This and the http://docs.jboss.org/drools/release/5.4.0.Final/drools-guvnor-docs/html_single/index.html#d0e1887 Advanced enumeration concepts in Guvnor would solve the dynamic enumeration requirement I posted earlier. -- View this message in context: http://drools.46999.n3.nabble.com/Specify-enumeration-for-DSL-variables-tp4019228p4019251.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Can two rules use the same template data?
Yes, correct; that was my question. Thanks for your response (and for adding to Jira). -J -- View this message in context: http://drools.46999.n3.nabble.com/Can-two-rules-use-the-same-template-data-Guvnor-5-4-tp4019207p4019252.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] java.lang.LinkageError
That was the root error, the rest is just drools firing its rules. So does this mean there's some sort of incompatibility in the class ShoppingCart/Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50? I assume this is a class that's auto-generated by drools. Is it possible that serializing the rule Package is leading to an incompatible class definition? On Thu, Aug 16, 2012 at 10:41 PM, Wolfgang Laun wrote: > Javadoc: Subclasses of LinkageError indicate that a class has some > dependency on another class; however, the latter class has > incompatibly changed after the compilation of the former class. > > Looks like some incompatibility between your development and > deployment environment. > > Did you truncate any helpful message from the stack trace? > > -W > > On 17/08/2012, David Minor wrote: >> Hi, >> >> We're in the process of moving our web apps from Java 5 to Java 7 and >> Drools 3 to Drools 5.4.0. Our rule base is compiled and serialized to >> the db by one app, and read from the db and fired by another. >> >> Everything went fine during testing, but when we tried to switch to >> production we got this when firing the rule base: >> >> Caused by: java.lang.LinkageError: >> ShoppingCart/Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50 >> at >> ShoppingCart.Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50Eval0InvokerGenerated.evaluate(Unknown >> Source) >> at >> ShoppingCart.Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50Eval0Invoker.evaluate(Unknown >> Source) >> at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114) >> at >> org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:178) >> [snip] >> >> Does anyone have any ideas as to what might cause this? >> >> Here is the rule in question if that helps: >> >> rule "CSMEGBUL" >> salience -1 >> agenda-group "SubtotalDependent" >> when >> delegate: PromotionRuleDelegate ( ) >> cart: ShoppingCart ( ) >> eval ( >> delegate.checkDateRange("118171800","149733720") ) >> eval ( delegate.checkEnabled("false") ) >> eval ( delegate.cartHasPromoCode(cart, "CSMEGBUL") ) >> eval ( delegate.checkUsage(1,100027) ) >> then >> delegate.applyOrderDiscountAmount(cart, 100027, "10.0"); >> delegate.promoCodeApplied(cart, "CSMEGBUL"); >> end >> >> >> -- >> _ >> David Minor >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users -- _ David Minor ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
To determine why some rule does not match, only proposals 2) and 3) will work in the general case anyway. If you're required to determine and log why rules do not fire, you'll have to do what needs to be done. If you have, for example, 5 conditions, failure can be due to each, any combination and all of them, and this information isn't available for free, and even your "Business" should have enough savvy to understand that. Either they drop the requirement, or they give you a free hand to fulfil it. -W On 17/08/2012, Rana wrote: > That's what our Business doesn't want me to do to write negative rules. In > this way there will be 2 rules to be written for 1 business rule. > > Thanks. > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019250.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
I agree with Stephen, if you need an action (e.g. logging) when a constraint is violated, you are actually defining rules to handle the "negative" cases. Drools verifier will not help you here, since knowing whether a fact satisfied a constraint or not is a runtime problem and depends on the combination of data and rules, whereas verifier looks at rules alone. Could you please provide more details about your specific requirement? Do you just need to know when a condition fails? Or do you need a full analysis? I think we already discussed it: if you have a pattern with a number of conditions, the engine will stop evaluating a fact as soon as the first violation is encountered. Like in java, "&&" evaluation is terminated eagerly. (In this case, the "not" CE would help). Also consider this remark: when a constraint such as "field == value" is not satisfied, the engine *silently* stops propagating the fact along that branch of the RETE. So, there is no way to be notified of the failure of a constraint. The WorkingMemoryListener and the AgendaListener will report only events with a coarser granularity, so they won't help you. If you really really really ... really need it, you will have to tweak the engine. I could show you a few possible ways to do that, but I'm a bit reluctant... -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019256.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] A few general questions on scaling StatefulKnowledgeSessions
If you do nothing heavy in the RHS, indeed, rules' action part execution is faster than fact insertion, but this is because of your design, not something relevant for all usages. In an inference system using RETE like drools, the most of time is spent to update the RETE network. Updates of this network is done at insert/retract/modify, and these actions can be called from outside OR inside the rules RHS. In an inference system, you may be interested by chaining, ie your rules' RHS do modify the fact base heavily, and thus the RHS exec takes time. What you describe in your post is almost a sequential behaviour, ie rules exec does not modify the fact base. I agree that this is a very common usage, but you can't oppose fact insertion and RHS execution without the precision of your design choices, which can be too restrictive for other usages that require chaining. - Original Message - From: "Stephen Masters" To: "Rules Users List" Sent: Friday, August 17, 2012 3:54:41 PM Subject: Re: [rules-users] A few general questions on scaling StatefulKnowledgeSessions Actually, I do mean that! :D But maybe I should explain… To be more precise, most of the time in my apps is taken in marshalling facts and inserting them into the session. From firing rules, it tends to take 10s of microseconds for a decision to be made. Obviously if the RHS is doing more than just making a decision based on facts already in the system (i.e. the RHS code queries databases, etc) then firing can get very slow. However, I tend to follow the best practices that I learned from various FICO (!) consultants, who recommended against doing anything heavy in the RHS, but rather getting back out of the rules engine ASAP and doing those heavy tasks in the invoking application. This approach works nicely, because the rules engine does what it's good at (making decisions based on facts that are in working memory) and my Java (Spring) app does what it's good at (getting data and integrating with other systems). The added benefit is that if I need to synchronise access to the session, it's not such an issue if each request is back out of the rules engine in microseconds. Steve On 17 Aug 2012, at 13:01, Wolfgang Laun wrote: > On 17/08/2012, Stephen Masters wrote: > >> But here are some slightly more practical thoughts from my experience... >> Inserting new facts is slow. (although still sub-millisecond) >> Evaluating rules is fast. > > Left hand sides of rules are evaluated while new facts are inserted, > so the above distinction does not make sense for me. Perhaps you can > explain what you mean by "evaluating rules"? > > Executing ("firing") rules depends on what's done on the right hand > side, so you can't mean that. > > -W > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] java.lang.LinkageError
On 17/08/2012, David Minor wrote: > That was the root error, the rest is just drools firing its rules. > > So does this mean there's some sort of incompatibility in the class > ShoppingCart/Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50? I assume > this is a class that's auto-generated by drools. Is it possible that > serializing the rule Package is leading to an incompatible class > definition? It does contain compiled Java code. So if the DRL/Java compilation environment compared to the deployment environment differs w.r.t. to JDK version, you're in for trouble. -W > > On Thu, Aug 16, 2012 at 10:41 PM, Wolfgang Laun > wrote: >> Javadoc: Subclasses of LinkageError indicate that a class has some >> dependency on another class; however, the latter class has >> incompatibly changed after the compilation of the former class. >> >> Looks like some incompatibility between your development and >> deployment environment. >> >> Did you truncate any helpful message from the stack trace? >> >> -W >> >> On 17/08/2012, David Minor wrote: >>> Hi, >>> >>> We're in the process of moving our web apps from Java 5 to Java 7 and >>> Drools 3 to Drools 5.4.0. Our rule base is compiled and serialized to >>> the db by one app, and read from the db and fired by another. >>> >>> Everything went fine during testing, but when we tried to switch to >>> production we got this when firing the rule base: >>> >>> Caused by: java.lang.LinkageError: >>> ShoppingCart/Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50 >>> at >>> ShoppingCart.Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50Eval0InvokerGenerated.evaluate(Unknown >>> Source) >>> at >>> ShoppingCart.Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50Eval0Invoker.evaluate(Unknown >>> Source) >>> at >>> org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114) >>> at >>> org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:178) >>> [snip] >>> >>> Does anyone have any ideas as to what might cause this? >>> >>> Here is the rule in question if that helps: >>> >>> rule "CSMEGBUL" >>> salience -1 >>> agenda-group "SubtotalDependent" >>> when >>> delegate: PromotionRuleDelegate ( ) >>> cart: ShoppingCart ( ) >>> eval ( >>> delegate.checkDateRange("118171800","149733720") ) >>> eval ( delegate.checkEnabled("false") ) >>> eval ( delegate.cartHasPromoCode(cart, "CSMEGBUL") ) >>> eval ( delegate.checkUsage(1,100027) ) >>> then >>> delegate.applyOrderDiscountAmount(cart, 100027, "10.0"); >>> delegate.promoCodeApplied(cart, "CSMEGBUL"); >>> end >>> >>> >>> -- >>> _ >>> David Minor >>> ___ >>> rules-users mailing list >>> rules-users@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users > > > > -- > _ > David Minor > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
Thanks for reply to all. I would like to learn how to do that, but I don't want to implement now, since I do not have time for that. But please do let me know about it. Again, @Laune has helped me fix issues about I am getting null into response, but I am back to that. Please find the rule file attached. Also in rules the logs that I have, is not logging. Nothing is working, Logging, Modify. Also I want to know once the rules of a Rule file is fired and all is done in the rule file. Will it end the process or not. http://drools.46999.n3.nabble.com/file/n4019259/Rule.txt Rule.txt and this is how I am inserting facts Logger logger1 = Logger.getRootLogger(); //log4j object // ProgramRuleValidationLog progRuleValidationLog = new ProgramRuleValidationLog(); ksession.setGlobal("log", logger1); // ksession.setGlobal("progRuleValidationLog", progRuleValidationLog); workingMemory = ksession; workingMemory.insert(logger1); // workingMemory.insert(progRuleValidationLog); workingMemory.insert(drug); workingMemory.insert(address); workingMemory.insert(program); ( (StatefulKnowledgeSession) workingMemory).fireAllRules(); logger = KnowledgeRuntimeLoggerFactory.newFileLogger((KnowledgeRuntimeEventManager) workingMemory, "DroolsLog"); //this is also not logging any thing except Please let me know the problems. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019259.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] java.lang.LinkageError
The webapps are both running in the same instance of Tomcat. We're going to try to run a second instance of Tomcat on production with the new version to see if we can replicate it. On Fri, Aug 17, 2012 at 8:33 AM, Wolfgang Laun wrote: > On 17/08/2012, David Minor wrote: >> That was the root error, the rest is just drools firing its rules. >> >> So does this mean there's some sort of incompatibility in the class >> ShoppingCart/Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50? I assume >> this is a class that's auto-generated by drools. Is it possible that >> serializing the rule Package is leading to an incompatible class >> definition? > > It does contain compiled Java code. So if the DRL/Java compilation > environment compared to the deployment environment differs w.r.t. to > JDK version, you're in for trouble. > -W > >> >> On Thu, Aug 16, 2012 at 10:41 PM, Wolfgang Laun >> wrote: >>> Javadoc: Subclasses of LinkageError indicate that a class has some >>> dependency on another class; however, the latter class has >>> incompatibly changed after the compilation of the former class. >>> >>> Looks like some incompatibility between your development and >>> deployment environment. >>> >>> Did you truncate any helpful message from the stack trace? >>> >>> -W >>> >>> On 17/08/2012, David Minor wrote: Hi, We're in the process of moving our web apps from Java 5 to Java 7 and Drools 3 to Drools 5.4.0. Our rule base is compiled and serialized to the db by one app, and read from the db and fired by another. Everything went fine during testing, but when we tried to switch to production we got this when firing the rule base: Caused by: java.lang.LinkageError: ShoppingCart/Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50 at ShoppingCart.Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50Eval0InvokerGenerated.evaluate(Unknown Source) at ShoppingCart.Rule_CSMEGBUL_b996907c25e3495a94b6b041c1c08c50Eval0Invoker.evaluate(Unknown Source) at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114) at org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:178) [snip] Does anyone have any ideas as to what might cause this? Here is the rule in question if that helps: rule "CSMEGBUL" salience -1 agenda-group "SubtotalDependent" when delegate: PromotionRuleDelegate ( ) cart: ShoppingCart ( ) eval ( delegate.checkDateRange("118171800","149733720") ) eval ( delegate.checkEnabled("false") ) eval ( delegate.cartHasPromoCode(cart, "CSMEGBUL") ) eval ( delegate.checkUsage(1,100027) ) then delegate.applyOrderDiscountAmount(cart, 100027, "10.0"); delegate.promoCodeApplied(cart, "CSMEGBUL"); end -- _ David Minor ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users >>> ___ >>> rules-users mailing list >>> rules-users@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/rules-users >> >> >> >> -- >> _ >> David Minor >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users -- _ David Minor ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
On 17/08/2012, Rana wrote: > Thanks for reply to all. > > I would like to learn how to do that, but I don't want to implement now, > since I do not have time for that. But please do let me know about it. > > > Again, @Laune has helped me fix issues about I am getting null into > response, but I am back to that. Please find the rule file attached. Also > in > rules the logs that I have, is not logging. Nothing is working, Logging, > Modify. > Did you set the agenda-group "AndroGel"? If not, see some previous mail in this thread. > Also I want to know once the rules of a Rule file is fired and all is done > in the rule file. Will it end the process or not. The next statement after fireAllRules() (see below!) is executed. > > http://drools.46999.n3.nabble.com/file/n4019259/Rule.txt Rule.txt > > > and this is how I am inserting facts > > Logger logger1 = Logger.getRootLogger(); //log4j object > //ProgramRuleValidationLog progRuleValidationLog = new > ProgramRuleValidationLog(); > > ksession.setGlobal("log", logger1); > //ksession.setGlobal("progRuleValidationLog", > progRuleValidationLog); > > workingMemory = ksession; > > workingMemory.insert(logger1); > //workingMemory.insert(progRuleValidationLog); > workingMemory.insert(drug); > workingMemory.insert(address); > workingMemory.insert(program); > > ( (StatefulKnowledgeSession) > workingMemory).fireAllRules(); > > logger = > KnowledgeRuntimeLoggerFactory.newFileLogger((KnowledgeRuntimeEventManager) > workingMemory, "DroolsLog"); //this is also not logging any thing except > > > Why should it? It's all over after fireAllRules() -W ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
Yes I have that, but no luck. But again this should be dynamic so I am guessing I should write if-else stmts to focus on? ksession.getAgenda().getAgendaGroup( "AndroGel" ).setFocus(); * Logging is also not working in the rule file. Logger logger = Logger.getRootLogger(); ksession.setGlobal("log", logger); workingMemory = ksession; workingMemory.insert(logger); workingMemory.insert(drug); workingMemory.insert(address); workingMemory.insert(program); ( (StatefulKnowledgeSession) workingMemory).fireAllRules(); When it was working, I included a retract in my rule and flushed all the facts from the memory and since then it is not working. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019262.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
Ok it worked when I changed the rule file a little to add the negative rules. But this should be dynamic so I am guessing I should write if-else stmts to focus on for different drugs? ksession.getAgenda().getAgendaGroup( "AndroGel" ).setFocus(); * Logging is also not working in the rule file. Logger logger = Logger.getRootLogger(); ksession.setGlobal("log", logger); Also I have new requirement saying that when a rule satisfies, they only few rules to get fired based on the user input (like a grouped rules), so I thought I will use activation-groups apart from agenda-groups. But how can I focus on activating those activation-groups from Drools Rule File. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019263.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modifying the problem facts while running the solver - Drools Planner
spinjala wrote > > THis is what is happening now with my sample solution that I am writing.. > Once the solver finds that a workorder (WO1) couldn't be assigned to any > resource in the list of resources (due to the constraints)... Well, it's a slightly different problem them. Planner's approach is to solve problems in parallel, where it's not trivial to determine where a given item can be matched. Part of the motivation beyond using Planner is that whether one item fits may be dependent on how the other items are arranged. If workorders are coming in one at a time, why not apply the rules to that item alone -- and that remove it from the planning scenario if it can't be fit? Jon -- View this message in context: http://drools.46999.n3.nabble.com/modifying-the-problem-facts-while-running-the-solver-Drools-Planner-tp4019099p4019264.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Continuous Planning values for task planning
Hi Geoffrey, Following your advice and after gaining some more understanding of planner, I think approaching the problem as a chain of tasks one of the other makes sense. It would have some 'wait' time between tasks where the end time of the previous task is smaller than the minimum time the task has to wait after its dependency (which could be different from the previous task). I've noticed that in most examples (TSP and VRP), there is some separation between the model and the planning entity that is being moved around in the chain, which also makes sense. (For instance in TSP, Visit is the planning entity while City is the data entity). When the planning entity gets cloned, the data entity gets assigned to the clone. I am concerned however, that with my dependency between tasks and their end times (which are as such a property of the planning entity not the data entity) I won't be able to model them in this way. (For a task to know whether it has violated its hard constraint it needs to get access to the end time of its dependency, which is in the planning entity). My concern is that I might end up with a whole mess when it comes to the cloning of tasks. I am also concerned about the performance of computing the end time of each node recursively based on its previous task and dependent tasks. What is the best approach in this case? thanks, Josef On 25 July 2012 08:30, Geoffrey De Smet wrote: > > Op 24-07-12 23:14, Josef Bajada schreef: > > Hi Geoffrey, > > Thanks for your reply. > > > Does it make sense to wait longer than 7 mins after task A (presuming > no other task forces occupies the user at that time)? > > Put differently: Can we say that the starting time of B = > Math.max((endTime of task before B), (endTime of task A + 7 minutes))? > > If we can say that, it's pointless to investigate the solutions where > task B starts 8 minutes after task A and the user doing no task that last > minute. > > Yes, the starting time of B = Math.max((endTime of task before B), > (endTime of task A + 7mins)) as long as it is smaller than (endTime of task > A + 8mins). > Yes, it is pointless to investigate the solutions where task B starts 8 > minutes after task A and the user doing no task that last minute. > The 8 minute is just a constraint that the task in between tasks A and B > cannot take longer than 7:59s. > > I am thinking that maybe instead of using time itself as the planning > variable, we would use time just to determine the Hard and Soft scores. > So if Task B is scheduled after Task A + 8mins by the solver, then it > inflicts on the hard score. Similarly if Task B is scheduled before Task A > + 7 mins. > Does my reasoning make sense in any way? > > Yes, but personally, I 'd design it differently (although I have no proof > that my way would be better), like this: > "Task B is scheduled after Task A + 8mins by the solver" => make this a > hard constraint > "Task B is scheduled before Task A + 7 mins" => make this a build-in hard > constraint (= not a constraint in the scoreDRL or ScoreCalculator, but by > design, see manual). > Each Task is assigned to a previousTaskOrPerson (and this variable is > chained). It does not know it's startingTime directly. > The scoreDRL or ScoreCalculator calculates the startingTime of a Task > dynamically, by applying this logic: > starting time of B = Math.max((endTime of previousTaskOrPerson of B), > (endTime of task A + 7mins)) > Note: "Chained=true" guarantees that there are no cycles of Tasks and that > no Tasks exists with a previousTaskOrPerson == null. > Note: "(endTime of task A + 7mins)" is not hard coded in the score > function: you won't find "7" or "A" in there. > > > > thanks, > Josef > > > > On 24 July 2012 20:46, Geoffrey De Smet wrote: > >> >> Op 23-07-12 16:26, Josef Bajada schreef: >> >> Hi Geoffrey, >> >> Well I want to leave 'space' between tasks in the situations where >> there are hard constraints that require me to put this space. >> >> This makes the chaining technique harder to model, but I wouldn't write >> it off yet. >> >> >> As a simple example: >> >> Task A: Put pasta in boiling water (duration 40 seconds) >> Task B: Take pasta out of boiling water (duration 50 seconds, cannot >> start before 7 mins after Task A finishes, cannot start after 8 mins after >> Task A finishes) >> >> Does it make sense to wait longer than 7 mins after task A (presuming no >> other task forces occupies the user at that time)? >> Put differently: Can we say that the starting time of B = >> Math.max((endTime of task before B), (endTime of task A + 7 minutes))? >> If we can say that, it's pointless to investigate the solutions where >> task B starts 8 minutes after task A and the user doing no task that last >> minute. >> If we can say that, then chaining can calculate the the starting time of >> a task on the fly differently. >> >> Task C: Chop vegetables (duration 2 minutes). >> >> This will evidently leave some gaps. The ideal result fro