2020年11月15日日曜日

Dr.Planning

 https://dmcommunity.org/challenge/challenge-apr-2020/

In a hospital, there has to be a doctor present at all times. In order to make sure this is the case, a planning is made for the next 7 days, starting on a monday. Each day consists of three shifts: an early shift, a late shift and a night shift.


Every shift needs to be assigned to a doctor. In total there are 5 doctors: every doctor has a list of available days, and some have special requirements. In general, the following rules apply:


■A doctor can only work one shift per day.

■A doctor should always be available for his shift (see table below)

■If a doctor has the night shift, they either get the next day off, or the night shift again.

■A doctor either works both days of the weekend, or none of the days.

■A planning should be made in which every requirement is fulfilled.


Name Available

Fleming Friday, Saturday, Sunday

Freud Every day early or late, never night

Heimlich Every day but neven the night shift on weekends

Eustachi Every day, every shift

Golgi Every day, every shift but at max 2 night shifts

という問題を解いてみます。

まずは、上の条件から、スタッフ数5人、シフト数 Early,Late,Night,PaidHolidayの4つ、

月曜から始まる1週間を考えればよいことが分かります。

■A doctor can only work one shift per day.

スケジュールナースは、Default状態でそうなっているので、何も記述する必要がありません。

■A doctor should always be available for his shift (see table below)

意味不明ですが、多分、Dr.毎、シフトは、条件があるのだと思います。テーブル参照。

■If a doctor has the night shift, they either get the next day off, or the night shift again.

Nightの後は、Nightかオフ(PaidHoliday)なので、その他のシフトを禁止すればよいことが分かります。他のシフトは、EarlyかLateしかないので、

Night→Early

Night→Late

を禁止すれば十分です。

■A doctor either works both days of the weekend, or none of the days.

週末の定義が不明ですが、土日と仮定すると、土日のうちの1日だけ働くことを禁止すればよいです。これは、排他的論理和(XOR)ですね。土曜日に働いたら日曜日禁止、日曜日に働いたら、土曜日禁止すれば、よいです。

■A planning should be made in which every requirement is fulfilled.

多分、全てのシフトで、1人以上(or 1人?)が必要だ、ということでしょう。列制約になります。

次にテーブル条件について考えます。

■Fleming Friday, Saturday, Sunday

金土日以外をPaidHolidayで予定を埋めてしまえばよいことが分かります。

■Freud Every day early or late, never night

夜勤以外というラベルを作って、全日予定を埋めます。

■Heimlich Every day but neven the night shift on weekends

夜勤以外というラベルを土日に埋め込みます。

■Golgi Every day, every shift but at max 2 night shifts

Nightシフト数を2以下に制限すればOKです。

非常に簡単なロジックで、実際的には、全然足りてないですが、スケジュールナースで行えば、多分世界最速で、モデル記述とグラフィック10解を得ることが出来ます。初見11分でした。(この文章を書いている時間の方が長い)


動画はこちら

https://youtu.be/pHYFd5IE0U0


0 件のコメント:

コメントを投稿