This repository contains an Answer Set Programming (ASP) implementation using Clingo for scheduling the LZV Cup, an amateur indoor football league in Belgium.
The LZV Cup is a time-relaxed double round-robin tournament where each team plays against every other team twice, once at home and once away. The main goal is to generate a schedule that balances the rest days between matches for each team to avoid close succession of games.
lzcup.lp
: The main ASP file containing the problem encoding and constraints.data/instances/
: Directory containing the input instances in text format.data/calendars/gurobi/
: Directory containing Gurobi-generated calendars for validation.solver.py
: Python script to solve the scheduling problem and report results.run_batch.py
: Python script to run a batch of instances.utils.py
: Helper functions used by solver.py
and run_batch.py
.The input instances are located in the data/instances/
directory. Each instance file has the following format:
The generated schedules are saved in the results CSV file. Each schedule is represented in the following format within the CSV:
The console output displays the generated schedule matrix with additional formatting to highlight close games:
The solver.py
script solves a single instance of the scheduling problem.
python solver.py <instance_number> <rmax> <m> [--threads <num_threads>] [--output_dir <output_directory>] [--configuration <clingo_configuration>] [--calendar_path <path_to_calendar>] [--timeout <timeout>] [--name <run_name>] [--heuristic] [--render]
<instance_number>
: (int) The number of the input instance file.<rmax>
: (int) The maximum range for close games.<m>
: (int) The minimum number of time slots between games with the same teams.--threads
: (Optional) (int) The number of threads to use for solving (default: 4).--output_dir
: (Optional) (str) The directory to save the output files (default: "output").--configuration
: (Optional) (str) The configuration for Clingo (default: "auto").--calendar_path
: (Optional) (str) Path to an external calendar file for validation.--timeout
: (Optional) (int) Timeout in seconds (default: 60).--name
: (Optional) (str) Name of the run for identification (default: "default_run").--heuristic
: (Optional) Use Domain heuristic.--render
: (Optional) Render the schedule matrix for each model.The run_batch.py
script runs a batch of instances.
python run_batch.py <instance_lower> <instance_upper> [--rmax <rmax>] [--m <m>] [--threads <num_threads>] [--output_dir <output_directory>] [--configuration <clingo_configuration>] [--timeout <timeout>] [--name <run_name>] [--heuristic] [--render] [--calendar <path_to_calendar>]
<instance_lower>
: (int) The lower bound of instance numbers to solve.<instance_upper>
: (int) The upper bound of instance numbers to solve.--rmax
: (Optional) (int) The maximum range for close games (default: 4).--m
: (Optional) (int) The minimum number of time slots between games with the same teams (default: 60).--threads
: (Optional) (int) The number of threads to use for solving (default: 2).--output_dir
: (Optional) (str) The directory to save the output files (default: "results").--configuration
: (Optional) (str) The configuration for Clingo (default: "auto").--timeout
: (Optional) (int) Timeout in seconds (default: 60).--name
: (Required) (str) Name of the batch run for identification.--heuristic
: (Optional) Use Domain heuristic.--render
: (Optional) Render the schedule matrix for each model.--calendar
: (Optional) (str) Path to calendar file to validate.Van Bulck, D., Goossens, D.R. & Spieksma, F.C.R. (2019). Scheduling a non-professional indoor football league: a tabu search based approach. Annals of Operations Research, 275:715-730.