[rules-users] Optaplanner: Shadow Variables vs insertLogical
Geoffrey De Smet
ge0ffrey.spam at gmail.com
Tue Jul 16 09:47:59 EDT 2013
On 16-07-13 15:22, jonathan.labin wrote:
> It turns out that the score corruption was caused by something unrelated. In
> fact, a rule that will be removed in the re-design I am asking about. If I
> see a similar problem after the re-design I'll pursue your suggestions to
> determine the reason.
Great that you found it :) What exactly was causing the score corruption?
I 'd like to document all types of score corruption in the documentation.
>
> However I was wondering if you had more insight into the Shadow Variable vs
> insertLogical() question for my domain.
>
> I imagine that the insertLogical() approach would fire for each line of an
> order (Planning Entity) and insert a fact for each type of raw material in
> the order where each fact contains the number of that type of raw material.
> Then, a rule with a different salience would accumulate all of these facts
> to produce total counts of each type across all orders. Is this an
> appropriate approach?
Yes
> Does this approach break the delta score calculation?
No - do note that the equals/hashcode of the logically inserted object
must be correct.
> Will the creation, (automated) retraction, and accumulation of these facts
> create a slowdown or is this an intended use?
I don't have any decent benchmarks yet about "Shadow Variables vs
insertLogical",
so I can't tell what's slower yet. My gut feeling would say
insertLogicals are slower...
If you do end up coding a POC for both designs, let us know about how
they compare benchmark wise.
>
> I imagine that the Shadow Variable approach would update a similar set of
> total count variables but instead do so appropriately when the Planning
> Variable changes. Would the classes representing the raw material types
> themselves become Planning Entities in this case?
Yes
> Is this the intended use?
At first glimpse, I 'd say insertLogical is the intended use for your
use case,
because you don't want to persist those total counts in your database,
so you don't want to make those total counts part of your domain.
Once I have more experience with shadow variables, I 'll document this
question better.
Shadow variables were invented to deal with timewindowed VRP:
insertLogicals are too much of a PITA to solve that problem
and also because score rules must not modify the domain
(because planner does not calculate the score if it can predict it).
>
> Thanks,
>
> Jon
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-Shadow-Variables-vs-insertLogical-tp4024863p4024928.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list