Op 29-11-12 20:17, Oliver Libutzki schreef:
Hello everyone,
as I try to find the best solution for a scheduling problem Drools
Planner seems to be the perfect fit.
Instead of using drl files I want to implement the rules in Java, but I
still would like to use the power of Drools (Planner) to find the best
solution as fast as possible.
My first attempt is to use the Description API (Examples:
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test...).
This might work, but I wonder if I really have to write the whole rule
this way. Of course I can use "eval" Expressions to integrate Java code,
but I would like to know how expensive this is in certain situations.
So, which information does Drools use to optimize the algorithm?
An example taken from the Test class I mentioned:
.lhs()
.pattern("StockTick").constraint("company ==
\"RHT\"").end()
.end()
I guess it's important to select the StockTick by using the pattern. But
what about the company criteria? Is using the constraint faster than
invoking a method like "checkType"?
.lhs().pattern("StockTick").name("myStockTick").eval().constraint(
"checkCompany(myCheese, \"RHT\"").end()
.end()
In general, I would like to know which parts can be implemented in
"secret Java" which the drools compiler doesn't know and which parts
should be implemented by using the explicit descr api elements in order
to use the full power of the Drools engine. Thanks for your answers!
Make sure you
understand the notion of Incremental score calculation,
that will help to answer that question for you:
http://docs.jboss.org/drools/release/5.5.0.Final/drools-planner-docs/html...
Generally, reusing Java methods such as isHoliday(Country, Day) is fine,
but Java methods like canQueensAttackEachOther(Queen, Queen) is not
because the latter kills incremental score calculation.
Planner supports writing your entire scoring in Java (no Drools at all),
but it's downside is that you need to write incremental score
calculation manually:
http://docs.jboss.org/drools/release/5.5.0.Final/drools-planner-docs/html...
Kind regards Oliver
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users