Op 06-12-12 14:37, Michiel Vermandel schreef:
Hi,

I have got a Planning entity which takes several planning variables.
The provided variable-lists never contain null elements.
Though, in my rules I get planning entities with uninitialized planning variables (null).
Why is that?
The construction heuristics first need to insert all planning entities (uninitialized) into the working memory.
This means the planning variables are still null at that time.

The best way to make your rules null safe is to use null safe getters:

class ShiftAssignment { ...
    public Contract getContract() {
        if (employee == null) {
            return null;
        }
        return employee.getContract();
    }
}

when ShiftAssignment (contract != null, ...)

Can this be avoided?
No, the gain of using construction heuristics is too way big to ignore them.

It's an open discussion currently:
- Users suffer because they need to make their rules null safe. I recognize this.
- Planner implementation wise, it makes far more sense to require the rules to be null safe
-- avoids certain bugs
- What should Planner return if no initialized solution has been found yet?
-- (the constr heuristics aren't finished yet)
-- What would be the Score of that uninitialized solution?
- How does PlanningVariable(nullable = true) affect this?
-- Returning an uninitialized best solution is much better than returning a null best solution
- What can Drools Expert provide to make it easier to have null-safe rules?
-- They now support an elvis-like operator but it's slower because it falls back on mvel.

Thanks

 
-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users