を参考に、以前に作ったシフト割り振りをoptaplannerを使ってヒューリスティック法で探索するプログラムを作る。
GitHub - vascarpenter/ShiftSolver: shift solver sample application using optaplanner
とりあえず doctorA,B,Cの3人を Employeeに
日付を Dayに
拘束割り付けモデルを WorkDayAssignmentにする
solutionParameterを使ったあまり美しくないやりかたも継承
とりあえずdrlは
rule "countLeveling" when $solutionParameter : SolutionParameter() $employee : Employee() $workCountPerPeople : Number() from accumulate( $workDayAssignment : WorkDayAssignment( employee == $employee ), count( $workDayAssignment ) ) then scoreHolder.addSoftConstraintMatch(kcontext, new BigDecimal((int)(-10000D * Math.pow($solutionParameter.getCountAverage() - $workCountPerPeople.doubleValue(), 2) ))); end
のみとした (均等割り付けモデルのみ)
実際走らせてみると
Day People 1 Doctor A 2 Doctor C 3 Doctor B 4 Doctor A 5 Doctor C
...
<secondsSpentLimit>10</secondsSpentLimit>
で10秒間だけ探索するよう指定したけれど上記のようにうまくいってそうな感じ
あとは休み希望や専門の縛り、土日拘束回数の均一化、
非同期探索、swingやkotlin/TornadeFXのガワもかぶせないとな..