[rules-users] [planner] getBestSolution not returning the correct Solution?

Geoffrey De Smet ge0ffrey.spam at gmail.com
Thu Jun 14 08:28:51 EDT 2012


1) First, can you turn on environmentMode TRACE and verify that no 
exceptions are thrown? Then turn it back off.

2) I suspect you have a bug in your Solution's clone() method.
To prove that theory, do Solver.addSolverEventListener(...) and output 
the solution each time the best solution is found.
You should see something like this:

Object: O00010440201002 : -5
new best solution O00010440201002
Object: O00010440201002 : -5
Object: O00010440201010 : -4
new best solution O00010440201010
Object: O00010440201003 : -5
Object: O00010440201004 : -5
Object: O00010440201011 : -4
Object: O00010440201009 : -1
new best solution O00010440201009
Object: O00010440201004 : -5
Object: O00010440201010 : -4
Object: O00010440201002 : -5
Object: O00010440201003 : -5
Object: O00010440201011 : -4
Object: O00010440201002 : -5
Object: O00010440201003 : -5
Object: O00010440201004 : -5
Object: O00010440201009 : -1
Object: O00010440201011 : -4
Object: O00010440201003 : -5
Object: O00010440201011 : -4
Object: O00010440201004 : -5

then, in the end, the best solution must be equal to the last best 
solution (unless the clone() method forgets to clone the entities 
correctly).

If it's not 1) or 2), please provide more info.

Op 14-06-12 12:19, Charles schreef:
> I displayed the score to console on hardConstraintsBroken rule.
>
> rule "hardConstraintsBroken"
> dialect "java"
> 	salience -1 // Do the other rules first (optional, for performance)
>      when
>      	$sd : ServiceRequest( $object : object );
>          $hardTotal : Number() from accumulate (
> 			IntConstraintOccurrence( $weight : weight ),
> 			sum( $weight ) );
>      then
>      	System.out.println( $object.getId() + " : " + (- $hardTotal.intValue())
> );
> 	scoreHolder.setScore(- $hardTotal.intValue() );
> end
>
>
> I found that the getBestSolution() did not return the correct best solution
> based on console output.
>
> For example, in console output
>
> Problem Entity:
> O00010440201002 O00010440201003 O00010440201004 O00010440201009
> O00010440201010 O00010440201011
>
> Object: O00010440201002 : -5
> Object: O00010440201002 : -5
> Object: O00010440201010 : -4
> Object: O00010440201003 : -5
> Object: O00010440201004 : -5
> Object: O00010440201011 : -4
> Object: O00010440201009 : -1
> Object: O00010440201004 : -5
> Object: O00010440201010 : -4
> Object: O00010440201002 : -5
> Object: O00010440201003 : -5
> Object: O00010440201011 : -4
> Object: O00010440201002 : -5
> Object: O00010440201003 : -5
> Object: O00010440201004 : -5
> Object: O00010440201009 : -1
> Object: O00010440201011 : -4
> Object: O00010440201003 : -5
> Object: O00010440201011 : -4
> Object: O00010440201004 : -5
>
> Best Solution return by Solver
> O00010440201011 : -1
>
> My expectation
> O00010440201009 : -1
>
> Previous implementation in 5.3.0 doesn't have this problem.
> Can explain where I might do wrongly?
>
>
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/getBestSolution-not-returning-the-correct-Solution-tp4017948.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
>

-- 
With kind regards,
Geoffrey De Smet




More information about the rules-users mailing list