[rules-users] Rule For Counting Planning Variables/Entities
Wolfgang Laun
wolfgang.laun at gmail.com
Mon Nov 11 05:08:25 EST 2013
Do you have one DepartmentAssignment fact object per employee and
department AND month of the calendar?
-W
On 11/11/2013, newbie <dspecialist18 at yahoo.com> wrote:
> 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.
> _______________________________________________
> 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