[rules-users] Rule For Counting Planning Variables/Entities

newbie dspecialist18 at yahoo.com
Mon Nov 11 04:26:48 EST 2013


I am new user of drools and I'm trying to recreate an application similar to
nurse rostering. This time assigning an employee to a department for a
specific period of time. My hard constraint was an employee must be assigned
to a department at least 3 months. My planning entity is
DepartmentAssignment and planning variable Employee. The planning entity
class looks like this: 

@PlanningEntity(difficultyComparatorClass =
DepartmentAssignmentDifficultyComparator.class)
@XStreamAlias("DepartmentAssignment ")
public class DepartmentAssignment extends AbstractPersistable{

	private Duration duration; // per month
	private Department department;
	
	//Planning variable : changes during planning, between score calculations.
	private Employee employee;

How can I make such rule? I tried using this but it seems not working. Am i
missing something?

rule "minimumNumberofMonths"
    when
    	$employee : Employee()
	$department : Department()
    	$assignedNumberOfMonths : Number(intValue > 0 && < 3) from accumulate(
	    	$assignment: DepartmentAssignment( 
	    		employee!= null,
	    		department== $department,
	    		employee== $employee
	    	), count($assignment)  
        ) 
        
        
        
    then
        insertLogical(new IntConstraintOccurrence("minimumNumberofMonths",
ConstraintType.NEGATIVE_HARD,
                1,
                $employee, $department));

end



--
View this message in context: http://drools.46999.n3.nabble.com/Rule-For-Counting-Planning-Variables-Entities-tp4026724.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list