[rules-users] Re: drools-solver (initialization and starting score)

Geoffrey De Smet ge0ffrey.spam at gmail.com
Fri Feb 13 09:50:48 EST 2009


With kind regards,
Geoffrey De Smet


Andrew Waterman schreef:
> Hi,
> 
> I've been looking through my solver logs and on a problem i have posed, 
> the solver seems to first initialize and setup a best score:
> 
> INFO: Initialization time spend (3) for score (-5000004.0). Updating 
> best solution and best score.
> 
> However, this score is not correct.  I use collect to load Tokens of a 
> certain type for my game, and those that are found, penalize the system 
> with a constraint:
> 
> rule "Too much unclaimed territory"
>     when
>         $list : ArrayList ( size > 2) from collect  (
>             Token ($type : type == TokenType.UNDEVELOPED))
>     then
>         for (int i = 0; i < $list.size(); i++) {
>             insertLogical (new IntConstraintOccurrence (
>                 "Too much unclaimed territory", 
> ConstraintType.NEGATIVE_SOFT, 3, $list));

Doesn't this insert the same logical fact in a loop? So only 1 instance 
actually remains in the working memory?
If you want to have to list.size() affect the score, just do:
   3 * list.size()

>         }
> end

Why use collect anyway?

      when
          $t1 : Token ($type : type == TokenType.UNDEVELOPED, id1 : id)
          $t2 : Token ($type : type == TokenType.UNDEVELOPED, id > id1, 
id2 : id)
          $t3 : Token ($type : type == TokenType.UNDEVELOPED, id > id2, 
id3 : id)

// maybe you need things like this: not Token ($type : type == 
TokenType.UNDEVELOPED, id > id3)
      then
   insertLogical (new IntConstraintOccurrence ("Too much unclaimed 
territory",  ConstraintType.NEGATIVE_SOFT, 3, $t1, $t2, $t3));

> 
> However, the initial score does not seem to account  for these inserted 
> facts.  Due to this, all improving solutions are rejected, and I see no 
> change in the solution the solver finds and my starting solution.  
> 
> Any suggestions on how to delay initialization?  Or get the starting 
> score to take into account this constraint (I've made it SOFT so the 
> values aren't so hard to follow in the logs, it was initially a HARD 
> constraint).  I'd love to find a way around this problem, I've spent 
> most of the day playing with different configurations (acceptors and 
> foragers) trying to find a configuration that works for this base problem.
> 
> best wishes,
> 
> Andrew
> 
> ---------------------------------
> Andrew Waterman
> San Cristóbal de las Casas, Chiapas, Mexico
> +52 1 967 107 5902
> +1 510 342 5693
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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