Assign beds to patient stays to produce a better schedule for hospitals.
| Name | Level | Description |
|---|---|---|
| Same bed in same night | Hard | Two patients cannot be assigned to the same bed on the same night. |
| Female in male room | Hard | A female patient cannot be assigned to a male-only room (GenderLimitation.MALE_ONLY). |
| Male in female room | Hard | A male patient cannot be assigned to a female-only room (GenderLimitation.FEMALE_ONLY). |
| Different gender in same gender room in same night | Hard | Patients of different genders cannot share a same-gender room (GenderLimitation.SAME_GENDER) on the same night. |
| Department minimum age | Hard | A patient must meet the minimum age requirement of their assigned department. |
| Department maximum age | Hard | A patient must not exceed the maximum age requirement of their assigned department. |
| Required patient equipment | Hard | A patient's required medical equipment must be available in the assigned bed's room. |
| Assign every patient to a bed | Medium | Every patient must be assigned to a bed. |
| Preferred maximum room capacity | Soft | Patients prefer rooms within their preferred maximum capacity. |
| Department specialty | Soft | A stay's department specialty should match the assigned room's specialty. |
| Department specialty not first priority | Soft | Penalize when a patient is not placed in their first specialty priority. |
| Preferred patient equipment | Soft | Penalize when a patient's preferred equipment is not available in the assigned room. |
-
Install Java and Maven, for example with Sdkman:
$ sdk install java $ sdk install maven
-
Git clone the timefold-quickstarts repo and navigate to this directory:
$ git clone https://github.com/TimefoldAI/timefold-quickstarts.git ... $ cd timefold-quickstarts/java/bed-allocation -
(Optional) If you want to run a licensed edition (Plus / Enterprise), set up your license key first. See the Timefold license tool for instructions.
-
Start the application with Maven:
-
Community Edition
$ mvn quarkus:dev
-
Plus / Enterprise Edition: The profile sets up the correct Maven artifacts to run the licensed version. See the
pom.xmlfor the implementation details.$ mvn quarkus:dev -Denterprise
-
-
Visit http://localhost:8080 in your browser.
-
Click on the Solve button.
Then try live coding:
- Make some changes in the source code.
- Refresh your browser (F5).
Notice that those changes are immediately in effect.
When you're done iterating in quarkus:dev mode, package the application to run as a conventional jar file.
-
Build it with Maven:
$ mvn package
-
Run the Maven output:
$ java -jar ./target/quarkus-app/quarkus-run.jar
Note To run it on port 8081 instead, add
-Dquarkus.http.port=8081. -
Visit http://localhost:8080 in your browser.
-
Click on the Solve button.
-
Build a container image:
$ mvn package -Dcontainer
-
Run a container:
$ docker run -p 8080:8080 --rm $USER/bed-allocation:1.0-SNAPSHOT
To increase startup performance for serverless deployments, build the application as a native executable:
-
Compile it natively. This takes a few minutes:
$ mvn package -Dnative
-
Run the native executable:
$ ./target/*-runner -
Visit http://localhost:8080 in your browser.
-
Click on the Solve button.
Visit timefold.ai.
