That MaxWorkingWeekendsInFourWeeks is not this rule, right?
// Maximum number of consecutive working weekends
rule "maximumConsecutiveWorkingWeekends"
when
$contractLine : MinMaxContractLine(
contractLineType ==
ContractLineType.CONSECUTIVE_WORKING_WEEKENDS, maximumEnabled == true,
$contract : contract, $maximumValue : maximumValue
)
$employee : Employee(contract == $contract)
$employeeWeekendSequence : EmployeeWeekendSequence(
employee == $employee,
weekendLength > $maximumValue,
$weekendLength : weekendLength
)
then
insertLogical(new
IntConstraintOccurrence("maximumConsecutiveWorkingWeekends",
ConstraintType.SOFT,
($maximumValue - $weekendLength) *
$contractLine.getMaximumWeight(),
$employeeWeekendSequence));
end
If it's not, I probably didn't implement it because (IIRC) there were 1
or 2 constraints which were described in the problem description,
but were canceled during the competition, due to:
- ambiguity on how to score them
- and none of the datasets actually violated any of those constraints.
For example, all datasets had exactly 4 weekends IIRC.
hth
Op 21-01-13 23:16, John Poole schreef:
The parameters for MaxWorkingWeekendsInFourWeeks is in some of the
input files for the NurseRostering example, but it doesn't seem to be
the rules(drl) file.
Is it implemented elsewhere? I've tried doing is like this, but it
doesn't work as a HARD constraint. I'm running it as SOFT now, but it
would nice to compare it to a better version.
//Rules for workingweekends
rule "insertWorkingWeekends"
when
MinMaxContractLine(contractLineType ==
ContractLineType.TOTAL_WORKING_WEEKENDS_IN_FOUR_WEEKS, enabled ==
true,
$contract : contract)
$employee : Employee(contract == $contract)
ShiftAssignment(employee == $employee, $shiftDateDayIndex :
shiftDate.dayIndex, weekend == true)
then
insertLogical(new WorkingWeekend($employee, $shiftDateDayIndex/7));
end
// Maximum working weekends in four weeks
rule "insertWorkingWeekendsInFourWeeks"
// salience 1 // Do these rules first (optional, for performance)
when
MinMaxContractLine(contractLineType ==
ContractLineType.TOTAL_WORKING_WEEKENDS_IN_FOUR_WEEKS, enabled ==
true,
$contract : contract)
$employee : Employee(contract == $contract)
WorkingWeekend(employee == $employee, $week: week)
$workingWeekendTotal : Number() from accumulate(
$workingWeekend : WorkingWeekend(employee == $employee,
week >= $week, week-$week < 3 ),
count($workingWeekend)
)
then
insertLogical(new WorkingWeekendTotalFourWeeks($employee,
$workingWeekendTotal.intValue(), $week));
end
// Maximum working weekends in four weeks
rule "maxWorkingWeekendsInFourWeeks"
when
$contractLine : MinMaxContractLine(
contractLineType ==
ContractLineType.TOTAL_WORKING_WEEKENDS_IN_FOUR_WEEKS, maximumEnabled
== true,
$contract : contract, $maximumValue : maximumValue
)
$employee : Employee(contract == $contract)
WorkingWeekendTotalFourWeeks(employeeContract == $contract,
total > $maximumValue,
employee==$employee, $total : total, $week : week)
then
insertLogical(new
IntConstraintOccurrence("maxWorkingWeekendsInFourWeeks",
ConstraintType.NEGATIVE_SOFT,
($total - $maximumValue) * $contractLine.getMaximumWeight(),
$employee, $week));
end
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users