Re: [rules-users] Rule flows in Drools planner configuration?
by Garf
spinjala wrote
>
> Is it possible to have a rule flow file that defines a set of rules
> (constraints) but executed in the order per the defined ruleflow.? I dont
> see any example doing that so I was wondering if it is possible at all to
> have the constraints defined with a rule flow file instead of single .drl
> file?
>
I guess that the challenge here is that a rule flow file awaits
startProcess() to be fired.
Planner's DroolsScoreDirector.calculateScore() only calls fireAllRules().
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-flows-in-Drools-planner-configurat...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Decision Table Management Process
by dme1
Hi,
I am looking for the best approach to manage decision tables within Drools,
essentially the hand-off process between developers and Business Analysts.
There are 2 ways to create and maintain Decision Tables in Drools
1. Use the XLS based decision tables. This requires developers to create the
initial XLS file with sample data, and work with the BAs to fill in the
actual requirements. On an ongoing basis if BAs require to maintain rules in
XLS based decision tables, they have to download the the existing XLS file,
update the rules using Excel - prettify as required for grouping etc.,
upload back to Guvnor and then test the rules.
2. Use the Guided Decision Table feature. This feature is available only in
Guvnor, and any tables created in Guvnor cannot be opened and maintained in
Eclipse (atleast not easily as at this time you are essentially looking at
updating XML files). So developers have to create/update rules in Guvnor as
well as BAs use the same tools to update/maintain rules in Guvnor.
Are there any other/better options available to create/manage decision
tables and co-ordinate the efforts between development (who prefer to use
Eclipse based tooling) and BAs (who would benefit from the richer features
available in Guvnor).
Thanks,
dme
--
View this message in context: http://drools.46999.n3.nabble.com/Decision-Table-Management-Process-tp401...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
<otherwise> in Excel Decision Table
by dme1
Hi,
How do I use <otherwise> in Decision Tables created using Eclipse (Excel
Spreadsheets). I have created a rule where I have provided "<otherwise>" as
a criteria but its been taken as the value of the parameter instead of
creating a separate rule with the "not" clause. I am providing the
screenshot of the decision table as well as the rules generated by Drools.
I would much appreciate if someone can advise on how I can use <otherwise>
in my rules.
http://drools.46999.n3.nabble.com/file/n4019162/droolsdt.jpg
Drools conversion to ".drl" below (Rule Flight_Type_Rules_15 shows
<otherwise> being used as parameter valUE):
DRL is :: package com.test.BasicDTRules;
//generated from Decision Table
import java.util.Date;
import com.test.Flight;
// rule values at C11, header at C6
rule "Flight Type Rules_11"
when
flight : Flight(flightNumber >= "0001", flightNumber <= "1000",
airlineCode == "BA")
then
flight.setFlightType("SH");
flight.setValid(true);
System.out.println("Row 1");
end
// rule values at C12, header at C6
rule "Flight Type Rules_12"
when
flight : Flight(flightNumber >= "0001", flightNumber <= "1000",
airlineCode == "AA")
then
flight.setFlightType("SH");
flight.setValid(true);
System.out.println("Row 2");
end
// rule values at C13, header at C6
rule "Flight Type Rules_13"
when
flight : Flight(flightNumber >= "1001", flightNumber <= "2500",
airlineCode == "VG")
then
flight.setFlightType("LH");
flight.setValid(true);
System.out.println("Row 3");
end
// rule values at C14, header at C6
rule "Flight Type Rules_14"
when
flight : Flight(flightNumber >= "1001", flightNumber <= "2500",
airlineCode == "AA")
then
flight.setFlightType("550");
flight.setValid(true);
System.out.println("Row 4");
end
// rule values at C15, header at C6
rule "Flight Type Rules_15"
when
flight : Flight(flightNumber >= "2501", flightNumber <= "9999",
airlineCode == "<otherwise>")
then
flight.setFlightType("Invalid");
flight.setValid(false);
System.out.println("Row 5");
end
Thanks,
dme
--
View this message in context: http://drools.46999.n3.nabble.com/otherwise-in-Excel-Decision-Table-tp401...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Re: [rules-users] modifying the problem facts while running the solver - Drools Planner
by Garf
spinjala wrote
>
> I tried setting the scoreAttained and maximum time allowed to spend in my
> termination configuration, but none seems to stop the solver finding the
> solution that violates ALL constraints and hence throws a negative hard
> score. Is this the only way to do it or any other way is available to
> force the solver not to look for a solution when ALL constraints are
> violated?
>
>From Planner's perspective, there are multiple possible solutions.
Each solution has a score, a combination of the hard and soft scores, each
of which represents the sum of constraint violations.
If the scores are <0, then the solution is nonoptimal; and thus, it will
keep looking.
You might try the termination/maximumUnimprovedStepCount config setting.
(see section 6.6.4 of the doc)
This stops the solving after a number of steps have been tried without any
improvement to the score.
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/modifying-the-problem-facts-while-runni...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Re: [rules-users] modifying the problem facts while running the solver - Drools Planner
by Garf
spinjala wrote
>
> 1) When a solution violates all constraints, does it provide a default
> solution? If so, can it be changed so that it doesn't provide one?
> Otherwise, is there a way to assure that no solution is generated when ALL
> constraints are violated.
>
Let's walk through the code.
Solver.solve() will look for solutions until any of the conditions specified
by the termination configuration are met. These could be based on time, or
score, etc.
In your case, your best solution will have a negative hard score. You would
find this via:
Solution Sol = solver.getBestSolution();
if (Sol.getScore().getHardScore() == 0) {
// no constraints are violated
} else {
// Sol = null
}
spinjala wrote
>
> 2) When a feasible solution is not generated, is it possible to make a
> custom solution as the most relevant solution instead of the generated
> one? For ex. if the solution generated by Drools planner assigned a work
> order WO2 to a resource R1, is it possible to create a custom solution
> that assigns it to, possibly R2?
>
Sharpen your grammar here.
Your first sentence's first clause says that the feasible solution is not
generated, but the last clause references "the generated one."
So who (or what) is making this custom solution?
Remember that the Solution is your class. You are free to write your own
code to fill it on your own via your own code (or user actions).
Jon
--
View this message in context: http://drools.46999.n3.nabble.com/modifying-the-problem-facts-while-runni...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Getting Null pointer exception for applying change set
by Rana
Having trouble getting the URL, getting null when getting the ChangeSet file.
Please let me know what is the problem.
ResourceChangeScannerConfiguration conf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
conf.setProperty("drools.resource.scanner.interval", "60");
log.info("Drools Resource Scanner is set to 60 seconds");
ResourceFactory.getResourceChangeScannerService().configure(conf);
ResourceFactory.getResourceChangeScannerService().start();
log.info("Drools Resource Change Scanner Service has started");
ResourceFactory.getResourceChangeNotifierService().start();
log.info("Drools Resource Change Notifier Service has started");
URL url =
this.getClass().getResource("/src/main/resources/DroolsChangeSet.xml");
URLClassLoader customURLClassloader = new URLClassLoader(new URL[]
{url }, this.getClass().getClassLoader());
KnowledgeBuilderConfiguration kbuilderConfig =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null,
customURLClassloader);
// KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(kbuilderConfig);
KnowledgeBaseConfiguration kbaseConfig =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null,
customURLClassloader);
kbaseConfig.setOption( EventProcessingOption.STREAM );
kbaseConfig.setOption( MultithreadEvaluationOption.YES );
// kbaseConfig.setOption( MaxThreadsOption.get(2) );
kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
// create a knowledge agent
KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.scanDirectories", "true");
aconf.setProperty("drools.agent.newInstance", "false");
// KnowledgeAgent kAgent =
KnowledgeAgentFactory.newKnowledgeAgent("Drools Knowledge Agent", null,
aconf);
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("Drools Knowledge Agent", kbase,
aconf, kbuilderConfig);
kagent.applyChangeSet(ResourceFactory.newUrlResource(url));
log.info("Knowledge Agent Created for all the Drools Files");
// load up the knowledge base
kbase = kagent.getKnowledgeBase();
Thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/Getting-Null-pointer-exception-for-appl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months
Creating template column in guvnor for attribute value?
by dunnlow
I'm using Guvnor 5.4
I find myself sometimes wanting to use templates to map a string to a
metadata value or timer. For example, based upon a name, set a value for
the timeout. As far as I can tell however, the only way to create a
template column in guvnor is to include the column identifier in the LHS.
For example, I have a basic rule template that checks a name (there is only
a "name" column in the template matrix). Then, I click on options, add a
timer and give it a value of "@{timeout}" I get an error - the timeout
column does not exist in the template. However, if I write a dummy
expression on the LHS like "foo" not matches timeout, the timeout column is
created and everything is great once I set the value. If I delete the
predicate that uses timeout, I get an error again for the timer attribute.
This gets really ugly because I end up having (seemingly) useless
predicates. Is there a clean way to support this functionality?
Thanks,
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Creating-template-column-in-guvnor-for-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 8 months