TiLearn
website·Indexed 30 days ago
https://bancie.github.io/TiLearn/An open-source Python library for single-machine scheduling workflows. It provides tools for classic sequencing rules, including weighted completion-time ranking (WSPT) and Earliest Due Date (EDD) for controlling lateness, along with helpers for job table schemas and CSV-backed list orchestration.
What's inside TiLearn
- TiLearn is an open-source Python project designed for single-machine scheduling workflows. Its primary goal is to provide practical and transparent scheduling tools that are easy to read, test, and extend for both research and production environments.
Implement WSPT scheduling for single-machine jobs
The Weighted Shortest Processing Time (WSPT) algorithm is used for single-machine scheduling to minimize the weighted sum of completion times (∑wjCj). It processes jobs in descending order of the ratio w/p, where 'w' is the job weight (priority) and 'p' is the processing time. If all weights are equal, WSPT is equivalent to the Shortest Processing Time (SPT) rule.tilearn module map
The
tilearnpackage is organized into the following functional modules:tilearn.bs.basis: Core matrix helpers, factors, and schedule metrics.tilearn.wsptandtilearn.edd: Sequencing rules for weighted completion and maximum lateness workflows.tilearn.data: CSV backup, read, update, and cleanup helpers.tilearn.joblist.platandtilearn.joblist.run: Multi-list orchestration APIs and the end-to-endoptimal_listpipeline.
Minimize maximum lateness using EDD in tilearn
When due-date compliance is the primary concern for single-machine scheduling, use the Earliest Due Date (EDD) ordering algorithm. This is implemented via thetilearn.eddAPI entry point.import tilearn # Use tilearn.edd for Earliest Due Date orderingTiLearn contribution guidelines
When contributing to the project, adhere to the following checklist:
- Keep API documentation aligned with the actual code and docstrings.
- Submit small, focused pull requests.
- Update examples whenever function signatures or behaviors change.
- Remove any stale references to deprecated APIs.
Install TiLearn development prerequisites
To contribute to TiLearn, ensure the following software is installed on your local machine:
- Python 3.10+
- pip
- Git
- Node.js 18+ (required for the documentation site)
Minimize weighted completion behavior using WSPT in tilearn
To prioritize jobs with higher weights and shorter processing times in a single-machine environment, use the Weighted Shortest Processing Time (WSPT) ordering. This is implemented via thetilearn.wsptAPI entry point.import tilearn # Use tilearn.wspt for Weighted Shortest Processing Time orderingInstall TiLearn via pip
Install thetilearnPython library using pip and verify the installation by importing the module in a Python shell.pip install tilearn python -c "import tilearn; print('tilearn imported successfully')"Run and build TiLearn documentation locally
The documentation site is managed via npm. Navigate to thedocsdirectory to install dependencies and either start a local development server or build the site for production.cd docs npm install # To run the docs locally (usually at http://localhost:3000) npm run start # To build the docs for production npm run buildImplement Earliest Due Date (EDD) sorting for jobs
The Earliest Due Date (EDD) rule sorts jobs by increasing due date (d_j) to control lateness in single-machine settings. Intilearn, theeddfunction sorts jobs based on the due date located at column index 3 of the input list. The sorting is stable, meaning jobs with identical due dates maintain their original relative order.import tilearn as tl # Input format: [name, processing_time (p), release_date (r), due_date (d), weight (w)] jobs = [ ["J1", 4.0, 0, 10, 1.0], ["J2", 2.0, 0, 6, 2.0], ["J3", 1.0, 0, 8, 1.0], ] # Sort jobs by due date (index 3) ordered = tl.edd(jobs) for row in ordered: print(row)Contribute to the TiLearn project
TiLearn welcomes community contributions in the following areas:
- Algorithm improvements
- Documentation and examples
- Bug fixes and refactoring
- Tests and reproducibility tooling.
Migrate from deprecated tilearn.show_mytime to current API
The function
tilearn.show_mytimeis deprecated and no longer part of the current TiLearn package API. Depending on your scheduling goal, replace it with one of the following functions from the sorting and joblist modules:- For weighted completion sequencing (
1 || sum(w_j C_j)): Usetilearn.wspt. - For maximum lateness-oriented due-date ordering: Use
tilearn.edd. - For mixed multi-list workflows with precedence and non-precedence files: Use
tilearn.optimal_list.
import tilearn as tl jobs = [ ["Job 1", 4.0, 0, 10, 1.0], ["Job 2", 2.0, 0, 7, 3.0], ] # Old docs: tl.show_mytime(jobs, due_date) # Current API replacement for weighted completion sequencing: schedule = tl.wspt(jobs)- For weighted completion sequencing (