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

Charles hiicharles at gmail.com
Thu Jun 14 06:19:15 EDT 2012


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.


More information about the rules-users mailing list