Re: [rules-users] Planner - NurseRostering: MaxWorkingWeekendsInFourWeeks

2013-01-22 Thread Geoffrey De Smet
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@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Planner - NurseRostering: MaxWorkingWeekendsInFourWeeks

2013-01-22 Thread john poole
Thanks. It's a different rule, but it's good to know that I'm not duplicating
something.




--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-Planner-NurseRostering-MaxWorkingWeekendsInFourWeeks-tp4021702p4021743.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Planner - NurseRostering: MaxWorkingWeekendsInFourWeeks

2013-01-21 Thread John Poole
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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users