0

Using optapllaner, is it possible to call "Graph.getInstance().mdm()" method in the score calculation drl file ?

I read somewhere that i can only invoke static methods but i'm not sure.

Jack Kass
  • 55
  • 9

1 Answers1

1

Yes it's possible. Of course, for it to make any sense to call a method during score calculation it will need to have a parameter that accepts an entity or a variable-dependent property.

Accept an entity:

when
    $p : Process()
    eval(Graph.getInstance().mdmForProcess($p) == true)
then

Accept an variable-dependent property:

when
    Process($c : computer)
    eval(Graph.getInstance().mdmForComputer($c) == true)
then

Overall, I don't like that design, I prefer a design like this:

when
    Process(mdmIsGood() == true)
then


@PlanningEntity class Process {

     public boolean mdmIsGood() {
         return Graph.getInstance().mdmForProcess($p);
     }

     ...
}

Note: Why doesn't it make sense if the method isn't based on an entity or variable-dependent property? Because than you can precalculate it! So it would be very inefficient to calculate it during every score calculation. See docs section "cached problem facts".

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120