pycsp3-scheduling 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. pycsp3_scheduling-0.2.0/.github/workflows/docs.yml +60 -0
  2. pycsp3_scheduling-0.2.0/.github/workflows/publish.yml +27 -0
  3. pycsp3_scheduling-0.2.0/.gitignore +104 -0
  4. pycsp3_scheduling-0.2.0/CONTRIBUTING.md +103 -0
  5. pycsp3_scheduling-0.2.0/LICENSE +21 -0
  6. pycsp3_scheduling-0.2.0/PKG-INFO +234 -0
  7. pycsp3_scheduling-0.2.0/README.md +198 -0
  8. pycsp3_scheduling-0.2.0/docs/Makefile +26 -0
  9. pycsp3_scheduling-0.2.0/docs/_static/custom.css +160 -0
  10. pycsp3_scheduling-0.2.0/docs/_templates/page.html +33 -0
  11. pycsp3_scheduling-0.2.0/docs/api/constraints.md +176 -0
  12. pycsp3_scheduling-0.2.0/docs/api/expressions.md +249 -0
  13. pycsp3_scheduling-0.2.0/docs/api/functions.md +191 -0
  14. pycsp3_scheduling-0.2.0/docs/api/interop.md +195 -0
  15. pycsp3_scheduling-0.2.0/docs/api/variables.md +145 -0
  16. pycsp3_scheduling-0.2.0/docs/changelog.md +119 -0
  17. pycsp3_scheduling-0.2.0/docs/cheatsheet.md +234 -0
  18. pycsp3_scheduling-0.2.0/docs/conf.py +133 -0
  19. pycsp3_scheduling-0.2.0/docs/contributing.md +247 -0
  20. pycsp3_scheduling-0.2.0/docs/examples/flexible_job_shop.ipynb +1 -0
  21. pycsp3_scheduling-0.2.0/docs/examples/job_shop.ipynb +1 -0
  22. pycsp3_scheduling-0.2.0/docs/examples/rcpsp.ipynb +1 -0
  23. pycsp3_scheduling-0.2.0/docs/examples/vrptw.ipynb +1 -0
  24. pycsp3_scheduling-0.2.0/docs/index.rst +112 -0
  25. pycsp3_scheduling-0.2.0/docs/requirements.txt +7 -0
  26. pycsp3_scheduling-0.2.0/docs/roadmap.rst +46 -0
  27. pycsp3_scheduling-0.2.0/docs/user_guide/getting_started.md +132 -0
  28. pycsp3_scheduling-0.2.0/docs/user_guide/installation.md +62 -0
  29. pycsp3_scheduling-0.2.0/docs/user_guide/modeling_guide.md +367 -0
  30. pycsp3_scheduling-0.2.0/docs/user_guide/scheduling_concepts.md +335 -0
  31. pycsp3_scheduling-0.2.0/examples/EmployeeScheduling.py +123 -0
  32. pycsp3_scheduling-0.2.0/examples/FlexibleJobShop.py +109 -0
  33. pycsp3_scheduling-0.2.0/examples/FlowShop.py +73 -0
  34. pycsp3_scheduling-0.2.0/examples/OpenShop.py +74 -0
  35. pycsp3_scheduling-0.2.0/examples/RCPSP.py +31 -0
  36. pycsp3_scheduling-0.2.0/examples/SchedulingJS.py +41 -0
  37. pycsp3_scheduling-0.2.0/examples/VRPTW.py +321 -0
  38. pycsp3_scheduling-0.2.0/examples/models/README.md +46 -0
  39. pycsp3_scheduling-0.2.0/examples/models/models.json +189 -0
  40. pycsp3_scheduling-0.2.0/examples/models/realistic/AircraftLanding/AircraftLanding.py +122 -0
  41. pycsp3_scheduling-0.2.0/examples/models/realistic/AircraftLanding/data/airland01.json +39 -0
  42. pycsp3_scheduling-0.2.0/examples/models/realistic/CyclicRCPSP/CyclicRCPSP.py +148 -0
  43. pycsp3_scheduling-0.2.0/examples/models/realistic/CyclicRCPSP/data/easy-4.json +92 -0
  44. pycsp3_scheduling-0.2.0/examples/models/realistic/FlexibleJobshop/FlexibleJobshop.py +129 -0
  45. pycsp3_scheduling-0.2.0/examples/models/realistic/FlexibleJobshop/data/easy01.json +21 -0
  46. pycsp3_scheduling-0.2.0/examples/models/realistic/MRCPSP/MRCPSP.py +168 -0
  47. pycsp3_scheduling-0.2.0/examples/models/realistic/MRCPSP/data/j30-15-05.json +78 -0
  48. pycsp3_scheduling-0.2.0/examples/models/realistic/MSPSP/MSPSP.py +163 -0
  49. pycsp3_scheduling-0.2.0/examples/models/realistic/MSPSP/data/easy-01.json +43 -0
  50. pycsp3_scheduling-0.2.0/examples/models/realistic/RCPSP/RCPSP.py +94 -0
  51. pycsp3_scheduling-0.2.0/examples/models/realistic/RCPSP/data/j030-01-01.json +39 -0
  52. pycsp3_scheduling-0.2.0/examples/models/realistic/SchedulingFS/SchedulingFS.py +97 -0
  53. pycsp3_scheduling-0.2.0/examples/models/realistic/SchedulingFS/data/04-04-0.json +6 -0
  54. pycsp3_scheduling-0.2.0/examples/models/realistic/SchedulingJS/SchedulingJS.py +107 -0
  55. pycsp3_scheduling-0.2.0/examples/models/realistic/SchedulingJS/data/e0ddr1-0.json +12 -0
  56. pycsp3_scheduling-0.2.0/examples/models/realistic/SchedulingOS/SchedulingOS.py +111 -0
  57. pycsp3_scheduling-0.2.0/examples/models/realistic/SchedulingOS/data/GP-os-01.json +5 -0
  58. pycsp3_scheduling-0.2.0/examples/models/realistic/TestScheduling/TestScheduling.py +165 -0
  59. pycsp3_scheduling-0.2.0/examples/models/realistic/TestScheduling/data/t020m10r03-1.json +26 -0
  60. pycsp3_scheduling-0.2.0/notebooks/01_getting_started.ipynb +1704 -0
  61. pycsp3_scheduling-0.2.0/notebooks/02_job_shop.ipynb +562 -0
  62. pycsp3_scheduling-0.2.0/notebooks/03_flexible_job_shop.ipynb +627 -0
  63. pycsp3_scheduling-0.2.0/notebooks/04_rcpsp.ipynb +570 -0
  64. pycsp3_scheduling-0.2.0/notebooks/05_vrptw.ipynb +944 -0
  65. pycsp3_scheduling-0.2.0/pycsp3_scheduling/__init__.py +220 -0
  66. pycsp3_scheduling-0.2.0/pycsp3_scheduling/constraints/__init__.py +87 -0
  67. pycsp3_scheduling-0.2.0/pycsp3_scheduling/constraints/_pycsp3.py +701 -0
  68. pycsp3_scheduling-0.2.0/pycsp3_scheduling/constraints/cumulative.py +227 -0
  69. pycsp3_scheduling-0.2.0/pycsp3_scheduling/constraints/grouping.py +382 -0
  70. pycsp3_scheduling-0.2.0/pycsp3_scheduling/constraints/precedence.py +376 -0
  71. pycsp3_scheduling-0.2.0/pycsp3_scheduling/constraints/sequence.py +814 -0
  72. pycsp3_scheduling-0.2.0/pycsp3_scheduling/expressions/__init__.py +80 -0
  73. pycsp3_scheduling-0.2.0/pycsp3_scheduling/expressions/element.py +313 -0
  74. pycsp3_scheduling-0.2.0/pycsp3_scheduling/expressions/interval_expr.py +495 -0
  75. pycsp3_scheduling-0.2.0/pycsp3_scheduling/expressions/sequence_expr.py +865 -0
  76. pycsp3_scheduling-0.2.0/pycsp3_scheduling/functions/__init__.py +111 -0
  77. pycsp3_scheduling-0.2.0/pycsp3_scheduling/functions/cumul_functions.py +891 -0
  78. pycsp3_scheduling-0.2.0/pycsp3_scheduling/functions/state_functions.py +494 -0
  79. pycsp3_scheduling-0.2.0/pycsp3_scheduling/interop.py +356 -0
  80. pycsp3_scheduling-0.2.0/pycsp3_scheduling/output/__init__.py +13 -0
  81. pycsp3_scheduling-0.2.0/pycsp3_scheduling/solvers/__init__.py +14 -0
  82. pycsp3_scheduling-0.2.0/pycsp3_scheduling/solvers/adapters/__init__.py +7 -0
  83. pycsp3_scheduling-0.2.0/pycsp3_scheduling/variables/__init__.py +45 -0
  84. pycsp3_scheduling-0.2.0/pycsp3_scheduling/variables/interval.py +450 -0
  85. pycsp3_scheduling-0.2.0/pycsp3_scheduling/variables/sequence.py +244 -0
  86. pycsp3_scheduling-0.2.0/pycsp3_scheduling/visu.py +1315 -0
  87. pycsp3_scheduling-0.2.0/pyproject.toml +110 -0
  88. pycsp3_scheduling-0.2.0/tests/__init__.py +1 -0
  89. pycsp3_scheduling-0.2.0/tests/conftest.py +14 -0
  90. pycsp3_scheduling-0.2.0/tests/test_constraints.py +867 -0
  91. pycsp3_scheduling-0.2.0/tests/test_cumulative.py +575 -0
  92. pycsp3_scheduling-0.2.0/tests/test_expressions.py +399 -0
  93. pycsp3_scheduling-0.2.0/tests/test_grouping.py +475 -0
  94. pycsp3_scheduling-0.2.0/tests/test_interval.py +245 -0
  95. pycsp3_scheduling-0.2.0/tests/test_sequence.py +224 -0
  96. pycsp3_scheduling-0.2.0/tests/test_sequence_constraints.py +671 -0
  97. pycsp3_scheduling-0.2.0/tests/test_state_functions.py +407 -0
  98. pycsp3_scheduling-0.2.0/tests/test_visu.py +504 -0
  99. pycsp3_scheduling-0.2.0/uv.lock +1349 -0
@@ -0,0 +1,60 @@
1
+ name: Deploy Documentation to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - master
8
+ paths:
9
+ - 'docs/**'
10
+ - 'pycsp3_scheduling/**'
11
+ - '.github/workflows/docs.yml'
12
+ workflow_dispatch:
13
+
14
+ permissions:
15
+ contents: read
16
+ pages: write
17
+ id-token: write
18
+
19
+ concurrency:
20
+ group: "pages"
21
+ cancel-in-progress: false
22
+
23
+ jobs:
24
+ build:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - name: Checkout repository
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Set up Python
31
+ uses: actions/setup-python@v5
32
+ with:
33
+ python-version: '3.11'
34
+
35
+ - name: Install dependencies
36
+ run: |
37
+ python -m pip install --upgrade pip
38
+ pip install -e ".[dev]"
39
+ pip install -r docs/requirements.txt
40
+
41
+ - name: Build Sphinx documentation
42
+ run: |
43
+ cd docs
44
+ make html
45
+
46
+ - name: Upload artifact
47
+ uses: actions/upload-pages-artifact@v3
48
+ with:
49
+ path: docs/_build/html
50
+
51
+ deploy:
52
+ environment:
53
+ name: github-pages
54
+ url: ${{ steps.deployment.outputs.page_url }}
55
+ runs-on: ubuntu-latest
56
+ needs: build
57
+ steps:
58
+ - name: Deploy to GitHub Pages
59
+ id: deployment
60
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,27 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ push:
7
+ tags:
8
+ - "v*"
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+
15
+ jobs:
16
+ build-and-publish:
17
+ environment:
18
+ name: pypi
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: '3.11'
25
+ - run: python -m pip install --upgrade pip build
26
+ - run: python -m build
27
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,104 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+
51
+ # Translations
52
+ *.mo
53
+ *.pot
54
+
55
+ # Sphinx documentation
56
+ docs/_build/
57
+
58
+ # PyBuilder
59
+ .pybuilder/
60
+ target/
61
+
62
+ # Jupyter Notebook
63
+ .ipynb_checkpoints
64
+
65
+ # IPython
66
+ profile_default/
67
+ ipython_config.py
68
+
69
+ # pyenv
70
+ .python-version
71
+
72
+ # Environments
73
+ .env
74
+ .venv
75
+ env/
76
+ venv/
77
+ ENV/
78
+ env.bak/
79
+ venv.bak/
80
+
81
+ # IDE
82
+ .idea/
83
+ .vscode/
84
+ *.swp
85
+ *.swo
86
+ *~
87
+
88
+ # mypy
89
+ .mypy_cache/
90
+ .dmypy.json
91
+ dmypy.json
92
+
93
+ # ruff
94
+ .ruff_cache/
95
+
96
+ # XCSP3 output files
97
+ *.xml
98
+
99
+ # OS
100
+ .DS_Store
101
+ Thumbs.db
102
+
103
+ # Project specific
104
+ *.log
@@ -0,0 +1,103 @@
1
+ # Contributing to pycsp3-scheduling
2
+
3
+ Thank you for your interest in contributing to pycsp3-scheduling!
4
+
5
+ ## Development Setup
6
+
7
+ 1. Clone the repository:
8
+ ```bash
9
+ git clone https://github.com/sohaibafifi/pycsp3-scheduling.git
10
+ cd pycsp3-scheduling
11
+ ```
12
+
13
+ 2. Create a virtual environment:
14
+ ```bash
15
+ python -m venv .venv
16
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
17
+ ```
18
+
19
+ 3. Install development dependencies:
20
+ ```bash
21
+ pip install -e ".[dev]"
22
+ ```
23
+
24
+ ## Code Style
25
+
26
+ This project uses:
27
+ - **ruff** for linting and formatting
28
+ - **mypy** for type checking
29
+
30
+ Run checks before committing:
31
+
32
+ ```bash
33
+ # Linting
34
+ ruff check .
35
+
36
+ # Formatting
37
+ ruff format .
38
+
39
+ # Type checking
40
+ mypy pycsp3_scheduling
41
+ ```
42
+
43
+ ## Testing
44
+
45
+ Run tests with pytest:
46
+
47
+ ```bash
48
+ # Run all tests
49
+ pytest
50
+
51
+ # Run with coverage
52
+ pytest --cov=pycsp3_scheduling --cov-report=html
53
+ ```
54
+
55
+ ## Project Structure
56
+
57
+ ```
58
+ pycsp3_scheduling/
59
+ ├── variables/ # IntervalVar, SequenceVar
60
+ ├── expressions/ # start_of, end_of, etc.
61
+ ├── constraints/ # Precedence, grouping, sequence constraints
62
+ ├── functions/ # CumulFunction, StateFunction
63
+ ├── output/ # XCSP3 output generator
64
+ └── solvers/ # Solver adapters
65
+ ```
66
+
67
+ ## Adding New Features
68
+
69
+ ### Adding a New Constraint
70
+
71
+ 1. Create or update the appropriate module in `constraints/`
72
+ 2. Follow the existing constraint class pattern
73
+ 3. Add exports to `constraints/__init__.py`
74
+ 4. Add exports to main `__init__.py`
75
+ 5. Write unit tests in `tests/`
76
+ 6. Update documentation
77
+
78
+ ### Adding a New Variable Type
79
+
80
+ 1. Create the variable class in `variables/`
81
+ 2. Implement required methods for pycsp3 integration
82
+ 3. Add XCSP3 output support in `output/`
83
+ 4. Write comprehensive tests
84
+
85
+ ## Pull Request Process
86
+
87
+ 1. Create a feature branch from `master`
88
+ 2. Make your changes with clear commit messages
89
+ 3. Ensure all tests pass
90
+ 4. Update documentation if needed
91
+ 5. Submit a pull request with a description of changes
92
+
93
+ ## Reporting Issues
94
+
95
+ When reporting issues, please include:
96
+ - Python version
97
+ - pycsp3-scheduling version
98
+ - Minimal reproducible example
99
+ - Expected vs actual behavior
100
+
101
+ ## Questions
102
+
103
+ For questions about the project, open a GitHub issue or discussion.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Univ. Artois
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,234 @@
1
+ Metadata-Version: 2.4
2
+ Name: pycsp3-scheduling
3
+ Version: 0.2.0
4
+ Summary: Scheduling extension for PyCSP3 with interval variables, sequence variables, and scheduling constraints
5
+ Project-URL: Homepage, https://github.com/sohaibafifi/pycsp3-scheduling
6
+ Project-URL: Repository, https://github.com/sohaibafifi/pycsp3-scheduling
7
+ Project-URL: Issues, https://github.com/sohaibafifi/pycsp3-scheduling/issues
8
+ Author-email: Sohaib AFIFI <sohaib.lafifi@univ-artois.fr>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: constraint-programming,interval-variables,job-shop,optimization,pycsp3,rcpsp,scheduling,xcsp3
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: lxml>=4.9
25
+ Requires-Dist: matplotlib>=3.7
26
+ Requires-Dist: pycsp3>=2.5
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy>=1.0; extra == 'dev'
29
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
30
+ Requires-Dist: pytest>=7.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.1; extra == 'dev'
32
+ Provides-Extra: docs
33
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == 'docs'
34
+ Requires-Dist: sphinx>=6.0; extra == 'docs'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # pycsp3-scheduling
38
+
39
+ Scheduling extension for [pycsp3](https://pycsp.org) with interval variables, sequence variables, and scheduling constraints.
40
+
41
+ ## Features
42
+
43
+ - **Interval Variables**: Represent tasks/activities with start, end, size, length, and optional presence
44
+ - **Intensity Functions**: Stepwise intensity metadata with granularity scaling for size/length
45
+ - **Sequence Variables**: Ordered sequences of intervals on disjunctive resources
46
+ - **Precedence Constraints**: `end_before_start`, `start_at_start`, etc.
47
+ - **Grouping Constraints**: `span`, `alternative`, `synchronize`
48
+ - **Cumulative Functions**: `pulse`, `step_at_start`, `step_at_end` for resource modeling
49
+ - **State Functions**: Model resource states with transitions
50
+ - **XCSP3 Extension**: Output scheduling models in extended XCSP3 format
51
+ - **Visualization**: Gantt charts and resource profiles
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install pycsp3-scheduling
57
+ ```
58
+
59
+ For development:
60
+
61
+ ```bash
62
+ git clone https://github.com/sohaibafifi/pycsp3-scheduling.git
63
+ cd pycsp3-scheduling
64
+ pip install -e ".[dev]"
65
+ ```
66
+
67
+ ## Quick Start
68
+
69
+ ```python
70
+ from pycsp3 import *
71
+ from pycsp3_scheduling import *
72
+
73
+ # Create interval variables for tasks
74
+ task1 = IntervalVar(size=10, name="task1")
75
+ task2 = IntervalVar(size=15, name="task2")
76
+ task3 = IntervalVar(size=8, name="task3")
77
+
78
+ # Precedence: task1 must finish before task2 starts
79
+ satisfy(end_before_start(task1, task2))
80
+
81
+ # No overlap: task2 and task3 cannot overlap
82
+ satisfy(SeqNoOverlap([task2, task3]))
83
+
84
+ # Minimize makespan
85
+ minimize(max(end_time(task1), end_time(task2), end_time(task3)))
86
+ ```
87
+
88
+ ## Example: Job Shop Scheduling
89
+
90
+ ```python
91
+ from pycsp3 import *
92
+ from pycsp3_scheduling import *
93
+
94
+ # Data
95
+ n_jobs, n_machines = 3, 3
96
+ durations = [[3, 2, 2], [2, 1, 4], [4, 3, 3]]
97
+ machines = [[0, 1, 2], [0, 2, 1], [1, 0, 2]]
98
+
99
+ # Create interval variables for each operation
100
+ ops = [[IntervalVar(size=durations[j][o], name=f"op_{j}_{o}")
101
+ for o in range(n_machines)] for j in range(n_jobs)]
102
+
103
+ # Sequences for each machine
104
+ sequences = [SequenceVar(
105
+ intervals=[ops[j][o] for j in range(n_jobs)
106
+ for o in range(n_machines) if machines[j][o] == m],
107
+ name=f"machine_{m}"
108
+ ) for m in range(n_machines)]
109
+
110
+ # Precedence within jobs
111
+ satisfy(
112
+ end_before_start(ops[j][o], ops[j][o+1])
113
+ for j in range(n_jobs) for o in range(n_machines-1)
114
+ )
115
+
116
+ # No overlap on machines
117
+ satisfy(SeqNoOverlap(seq) for seq in sequences)
118
+
119
+ # Minimize makespan
120
+ minimize(Maximum(end_time(ops[j][-1]) for j in range(n_jobs)))
121
+ ```
122
+
123
+ ## Example: RCPSP (Resource-Constrained Project Scheduling)
124
+
125
+ ```python
126
+ from pycsp3 import *
127
+ from pycsp3_scheduling import *
128
+
129
+ # Data
130
+ durations = [3, 2, 5, 4, 2]
131
+ demands = [[2, 1], [1, 2], [3, 0], [2, 1], [1, 3]]
132
+ capacities = [4, 3]
133
+ precedences = [(0, 2), (1, 3), (2, 4)]
134
+
135
+ # Interval variables
136
+ tasks = [IntervalVar(size=durations[i], name=f"task_{i}")
137
+ for i in range(len(durations))]
138
+
139
+ # Precedence constraints
140
+ satisfy(end_before_start(tasks[p], tasks[s]) for p, s in precedences)
141
+
142
+ # Cumulative resource constraints
143
+ for r in range(len(capacities)):
144
+ resource = sum(pulse(tasks[i], demands[i][r])
145
+ for i in range(len(tasks)) if demands[i][r] > 0)
146
+ satisfy(resource <= capacities[r])
147
+
148
+ # Minimize makespan
149
+ minimize(Maximum(end_time(t) for t in tasks))
150
+ ```
151
+
152
+ ## API Reference
153
+
154
+ ### Variables
155
+
156
+ | Function | Description |
157
+ |----------|-------------|
158
+ | `IntervalVar(size, start, end, length, intensity, granularity, optional, name)` | Create an interval variable |
159
+ | `IntervalVarArray(size, ...)` | Create array of interval variables |
160
+ | `SequenceVar(intervals, types, name)` | Create a sequence variable |
161
+
162
+ ### Expressions
163
+
164
+ | Function | Description |
165
+ |----------|-------------|
166
+ | `start_of(interval, absent_value=0)` | Start time of interval |
167
+ | `end_of(interval, absent_value=0)` | End time of interval |
168
+ | `size_of(interval, absent_value=0)` | Size/duration of interval |
169
+ | `length_of(interval, absent_value=0)` | Length of interval |
170
+ | `presence_of(interval)` | Boolean presence status |
171
+
172
+ ### Interop Helpers
173
+
174
+ | Function | Description |
175
+ |----------|-------------|
176
+ | `start_time(interval)` | pycsp3 variable for start time |
177
+ | `end_time(interval)` | pycsp3 expression for end time |
178
+
179
+ ### Precedence Constraints
180
+
181
+ | Constraint | Semantics (when both present) |
182
+ |------------|------------------------------|
183
+ | `start_before_start(a, b, delay)` | `start(b) >= start(a) + delay` |
184
+ | `start_before_end(a, b, delay)` | `end(b) >= start(a) + delay` |
185
+ | `end_before_start(a, b, delay)` | `start(b) >= end(a) + delay` |
186
+ | `end_before_end(a, b, delay)` | `end(b) >= end(a) + delay` |
187
+ | `start_at_start(a, b, delay)` | `start(b) == start(a) + delay` |
188
+ | `start_at_end(a, b, delay)` | `start(b) == end(a) + delay` |
189
+ | `end_at_start(a, b, delay)` | `end(a) == start(b) + delay` |
190
+ | `end_at_end(a, b, delay)` | `end(b) == end(a) + delay` |
191
+
192
+ ### Grouping Constraints
193
+
194
+ | Constraint | Description |
195
+ |------------|-------------|
196
+ | `span(main, subtasks)` | Main interval spans all present subtasks |
197
+ | `alternative(main, alts, card=1)` | Select `card` alternatives matching main |
198
+ | `synchronize(main, intervals)` | All present intervals sync with main |
199
+
200
+ ### Cumulative Functions
201
+
202
+ | Function | Description |
203
+ |----------|-------------|
204
+ | `pulse(interval, height)` | Constant consumption during interval |
205
+ | `step_at(time, height)` | Step at fixed time point |
206
+ | `step_at_start(interval, height)` | Step at interval start |
207
+ | `step_at_end(interval, height)` | Step at interval end |
208
+ | `cumul_range(cumul, min, max)` | Constrain cumul to [min, max] |
209
+
210
+ ### State Functions
211
+
212
+ | Function | Description |
213
+ |----------|-------------|
214
+ | `StateFunction(transition_matrix)` | Create state function |
215
+ | `always_in(func, interval, min, max)` | State in range during interval |
216
+ | `always_equal(func, interval, value)` | State equals value during interval |
217
+ | `always_constant(func, interval)` | State constant during interval |
218
+
219
+ ## Requirements
220
+
221
+ - Python >= 3.10
222
+ - pycsp3 >= 2.5
223
+ - lxml >= 4.9
224
+ - matplotlib >= 3.7 (optional, for visualization)
225
+ - java >= 8 (optional, for solving with ACE/Choco)
226
+
227
+ ## License
228
+
229
+ MIT License - see [LICENSE](LICENSE) file.
230
+
231
+ ## References
232
+
233
+ - [PyCSP3 Documentation](https://pycsp.org)
234
+ - [XCSP3 Specification](https://xcsp.org/specifications/)