@dytsou/intern-corner-scheduler
v1.2.8
Published
Round-table Scheduler (CP-SAT) - Python CLI and web interface using OR-Tools CP-SAT to generate round-table seating across rounds with fixed hosts, balanced tables, and pair-wise constraints
Maintainers
Readme
Round-table Scheduler (CP-SAT)
Python CLI and web interface using OR-Tools CP-SAT to generate round-table seating across rounds with fixed hosts, balanced tables, and pair-wise constraints.
Input (stdin)
- Line 1:
a b c - Line 2:
d(number of same-once pairs) - Next
dlines:e_i f_i - Next line:
x(number of never-together pairs) - Next
xlines:y_i z_i
Interpretation:
a: participants 1..ab: tables 1..b; participants 1..b are hosts, fixed at their table number each roundc: number of rounds- Same-once pairs: each pair should be seated together in exactly one round if possible
- Never-together pairs: must never be seated together
Output (stdout)
JSON with fields:
participants,tables,roundstable_sizes: balanced per tableassignments: list per round, each a list per table of participant IDssatisfied_same_once_pairs,unsatisfied_same_once_pairsnever_together_violations(should be empty)objective_value,solver_status
Install
make installRun
Pipe input into the program:
# example
cat <<EOF | make run
6 2 3
1
3 5
1
4 6
EOFOr directly:
cd python && python3 main.py < input.txtWeb Interface
A modern React + Vite web interface is available for easier use. The frontend is built with React and deployed to GitHub Pages, and the backend runs in Docker on an Ubuntu workstation.
Quick Start (Local Development)
Install dependencies:
make installThis will install both Python backend dependencies and Node.js frontend dependencies.
Note: This project uses pnpm as the package manager. If you don't have pnpm installed, you can install it with:
npm install -g pnpmOr follow the pnpm installation guide.
Configure environment variables (optional):
cp .env.example .env # Edit .env with your settings if neededStart the backend server:
make serve-backendThe API will be available at
http://localhost:8000(or the port specified in.env)Start the frontend development server:
make serve-frontendThe frontend will be available at
http://localhost:5173and will automatically reload on changes.Update backend URL (if needed):
- Edit
src/config.jsand setBACKEND_URLto your backend address - For production builds, update the URL before running
make build
- Edit
API Documentation
The FastAPI backend provides a REST API for scheduling. When the server is running, interactive API documentation is available at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
API Endpoint
POST /api/schedule
Generate a schedule based on constraints.
Request Body:
{
"participants": 6,
"tables": 2,
"rounds": 3,
"same_once_pairs": [
{"u": 3, "v": 5}
],
"never_together_pairs": [
{"u": 4, "v": 6}
],
"time_limit_seconds": 60
}Response:
{
"participants": 6,
"tables": 2,
"rounds": 3,
"table_sizes": [3, 3],
"table_sizes_per_round": [[3, 3], [3, 3], [3, 3]],
"assignments": [
[[1, 3, 5], [2, 4, 6]],
[[1, 4, 5], [2, 3, 6]],
[[1, 3, 6], [2, 4, 5]]
],
"satisfied_same_once_pairs": [[3, 5]],
"unsatisfied_same_once_pairs": [],
"never_together_violations": [],
"objective_value": 1005,
"solver_status": "OPTIMAL"
}Health Check
GET /health
Returns the health status of the API.
Response:
{
"status": "healthy"
}Modeling Notes
- Hosts (1..b) are fixed to their own table every round.
- Tables are balanced: first
a % btables have sizea//b + 1, othersa//b. - Non-hosts do not sit at the same table in consecutive rounds.
- Objective maximizes how many same-once pairs are met exactly once; never-together is enforced strictly.
License
This project is licensed under the MIT License - see the LICENSE file for details.
