[英]Why Opta planner employee rostering not assigning employees to shift even though they are available?
目前,我有 30 個輪班和 25 名員工的名冊。 這 25 名員工將輪班開始和結束時間與員工可用性相匹配。 盡管如此,Opta 只分配了 19 個班次,而將所有其他班次留空,並且不分配剩余的 6 名員工。
我的假設是,它應該分配所有 25 名員工,因為他們的時間與班次相匹配。 我在這里錯過了什么還是應該看看其他方面?
以下是我的 Opta 規則文件,我已刪除所有其他規則,因為它們在我的情況下不是必需的。
Opta 員工排班版本目前使用 7.28.0-SNAPSHOT 時間給定名冊解決 240 秒。
// ############################################################################
// Hard constraints
// ############################################################################
rule "Unavailable time slot for an employee"
when
EmployeeAvailability(
$e : employee,
$employeeName : employee.getName(),
$startDateTime : startDateTime,
$endDateTime : endDateTime)
Shift(
employee == $e,
!DateTimeUtils.doTimeslotsMatch($startDateTime,$endDateTime, startDateTime, endDateTime, $employeeName))
then
scoreHolder.addHardConstraintMatch(kcontext, -100);
end
rule "No overlapping shifts for an employee"
when
$s : Shift( employee != null,
$e : employee,
$employeeName : employee.getName(),
$firstStartDateTime: startDateTime,
$firstEndDateTime : endDateTime)
$s2: Shift( employee == $e,
this != $s,
DateTimeUtils.doTimeslotsMatch($firstStartDateTime,$firstEndDateTime, startDateTime, endDateTime, $employeeName))
then
scoreHolder.addHardConstraintMatch(kcontext, -100);
end
// ############################################################################
// Medium constraints
// ############################################################################
rule "Assign every possible shift"
when
Shift(employee == null)
then
scoreHolder.addMediumConstraintMatch(kcontext, -100);
end
// ############################################################################
// Soft constraints
// ############################################################################
rule "available time slot for an employee"
when
$rosterParametrization : RosterParametrization(desiredTimeSlotWeight != 0)
EmployeeAvailability(
$e : employee,
$employeeName : employee.getName(),
$startDateTime : startDateTime,
$endDateTime : endDateTime)
Shift(
employee == $e,
DateTimeUtils.doTimeslotsMatch($startDateTime,$endDateTime, startDateTime, endDateTime, $employeeName))
then
scoreHolder.addSoftConstraintMatch(kcontext, 100);
end
rule "Skill set preference"
when
Shift(employee != null, matchedPreferencedDisciplineCount > 0,$matchedPreferencedDisciplineCount : matchedPreferencedDisciplineCount)
then
scoreHolder.addSoftConstraintMatch(kcontext, + $matchedPreferencedDisciplineCount);
end
這是我更新的求解器配置文件。
<?xml version="1.0" encoding="UTF-8"?>
<solver>
<!--<environmentMode>FAST_ASSERT</environmentMode>-->
<solutionClass>org.optaweb.employeerostering.domain.roster.Roster</solutionClass>
<entityClass>org.optaweb.employeerostering.domain.shift.Shift</entityClass>
<scoreDirectorFactory>
<scoreDrl>org/optaweb/employeerostering/service/solver/employeeRosteringScoreRules.drl</scoreDrl>
</scoreDirectorFactory>
<termination>
<secondsSpentLimit>240</secondsSpentLimit>
</termination>
<localSearch>
<unionMoveSelector>
<pillarChangeMoveSelector>
<subPillarType>SEQUENCE</subPillarType>
</pillarChangeMoveSelector>
<pillarSwapMoveSelector>
<subPillarType>SEQUENCE</subPillarType>
</pillarSwapMoveSelector>
</unionMoveSelector>
<acceptor>
<entityTabuSize>7</entityTabuSize>
</acceptor>
<forager>
<acceptedCountLimit>800</acceptedCountLimit>
</forager>
</localSearch>
</solver>
它還強制我在計划實體轉移時實施 Comparable
public class Shift extends AbstractPersistable implements Comparable<Shift> {
private static final Comparator<Shift> PILLAR_SEQUENCE_COMPARATOR = Comparator
.comparing((Shift a) -> a.getStartDateTime())
.thenComparing(a -> a.getEndDateTime());
這是否會解決我的求解器不分配員工的問題,盡管他們是可用的,並且會從局部最優解中移除。
使用基於 Pilar 的移動選擇器更有效地避開局部最優。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.