-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Add unwanted shift type successions preference
The `ortools_expression_to_bool_var` utility function is directly copied from the 2023/08/20 POC.
- Loading branch information
Showing
13 changed files
with
184 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
import glob | ||
import io | ||
import logging | ||
import os | ||
|
||
import nurse_scheduling | ||
import pandas | ||
import pytest | ||
|
||
|
||
def test_all(): | ||
for filepath in glob.glob("tests/testcases/*.yaml"): | ||
print(f"Testing '{filepath}' ...") | ||
base_filepath = os.path.splitext(filepath)[0] | ||
logging.info(f"Testing '{base_filepath}' ...") | ||
df = nurse_scheduling.schedule(filepath, validate=False, deterministic=True) | ||
print(df) | ||
with open(f"{base_filepath}.csv", 'r') as f: | ||
expected_csv = f.read() | ||
assert df.to_csv(index=False, header=False) == expected_csv | ||
actual_csv = df.to_csv(index=False, header=False) | ||
if actual_csv != expected_csv: | ||
logging.info(f"Actual CSV:\n{actual_csv}") | ||
logging.info(f"Actual output:\n{df}") | ||
logging.info(f"Expected output:\n{pandas.read_csv(io.StringIO(expected_csv))}") | ||
pytest.fail(f"Output mismatch for '{base_filepath}'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
,18,19,20,21,22,23,24 | ||
,Fri,Sat,Sun,Mon,Tue,Wed,Thu | ||
Nurse 0,E,E,E,E,D,D,D | ||
Nurse 1,N,N,N,N,N,N,N | ||
Nurse 2,D,D,D,D,,, | ||
Nurse 3,,,,,E,E,E |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: alpha | ||
description: Test unwanted pattern with length 1 constraints | ||
startdate: 2023-08-18 | ||
enddate: 2023-08-24 | ||
people: | ||
- description: Nurse 0 | ||
- description: Nurse 1 | ||
- description: Nurse 2 | ||
- description: Nurse 3 | ||
requirements: | ||
- id: D | ||
description: Day shift requirement | ||
required_people: 1 | ||
- id: E | ||
description: Evening shift requirement | ||
required_people: 1 | ||
- id: N | ||
description: Night shift requirement | ||
required_people: 1 | ||
preferences: | ||
- type: all requirements fulfilled | ||
- type: all people work at most one shift per day | ||
- type: unwanted shift type successions | ||
person: 0 | ||
pattern: [N] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
,18,19,20,21,22,23,24 | ||
,Fri,Sat,Sun,Mon,Tue,Wed,Thu | ||
Nurse 0,N,D,N,E,N,E,N | ||
Nurse 1,D,N,E,N,D,N,E | ||
Nurse 2,,,D,D,,D,D | ||
Nurse 3,E,E,,,E,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: alpha | ||
description: Test unwanted pattern with length 2 constraints | ||
startdate: 2023-08-18 | ||
enddate: 2023-08-24 | ||
people: | ||
- description: Nurse 0 | ||
- description: Nurse 1 | ||
- description: Nurse 2 | ||
- description: Nurse 3 | ||
requirements: | ||
- id: D | ||
description: Day shift requirement | ||
required_people: 1 | ||
- id: E | ||
description: Evening shift requirement | ||
required_people: 1 | ||
- id: N | ||
description: Night shift requirement | ||
required_people: 1 | ||
preferences: | ||
- type: all requirements fulfilled | ||
- type: all people work at most one shift per day | ||
- type: unwanted shift type successions | ||
person: 0 | ||
pattern: [N, N] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
,18,19,20,21,22,23,24 | ||
,Fri,Sat,Sun,Mon,Tue,Wed,Thu | ||
Nurse 0,N,D,N,N,D,N,N | ||
Nurse 1,D,N,E,E,N,E,E | ||
Nurse 2,,,D,D,,D,D | ||
Nurse 3,E,E,,,E,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: alpha | ||
description: Test unwanted pattern with length 3 constraints | ||
startdate: 2023-08-18 | ||
enddate: 2023-08-24 | ||
people: | ||
- description: Nurse 0 | ||
- description: Nurse 1 | ||
- description: Nurse 2 | ||
- description: Nurse 3 | ||
requirements: | ||
- id: D | ||
description: Day shift requirement | ||
required_people: 1 | ||
- id: E | ||
description: Evening shift requirement | ||
required_people: 1 | ||
- id: N | ||
description: Night shift requirement | ||
required_people: 1 | ||
preferences: | ||
- type: all requirements fulfilled | ||
- type: all people work at most one shift per day | ||
- type: unwanted shift type successions | ||
person: 0 | ||
pattern: [N, N, N] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
,18,19,20,21,22,23,24 | ||
,Fri,Sat,Sun,Mon,Tue,Wed,Thu | ||
Nurse 0,N,N,N,N,E,E,E | ||
Nurse 1,E,E,E,E,D,D,D | ||
Nurse 2,D,D,D,D,,, | ||
Nurse 3,,,,,N,N,N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: alpha | ||
description: Test unwanted pattern without constraints | ||
startdate: 2023-08-18 | ||
enddate: 2023-08-24 | ||
people: | ||
- description: Nurse 0 | ||
- description: Nurse 1 | ||
- description: Nurse 2 | ||
- description: Nurse 3 | ||
requirements: | ||
- id: D | ||
description: Day shift requirement | ||
required_people: 1 | ||
- id: E | ||
description: Evening shift requirement | ||
required_people: 1 | ||
- id: N | ||
description: Night shift requirement | ||
required_people: 1 | ||
preferences: | ||
- type: all requirements fulfilled | ||
- type: all people work at most one shift per day |