Skip to content

Commit

Permalink
0.5.0 (#82)
Browse files Browse the repository at this point in the history
* 0.5.0

* fixes

* add set.py

* Introduce the strict argument to the disjunctive constraint

* fix docs

* add abs function

* small test fix

* Add mathematical functions and enhance array indexing

- Introduce `exp`, `ln`, `log`, `log10`, `log2`, `sqrt`, and `product` functions.
- Update array indexing to require all indices for multidimensional arrays.
- Fix assertions in tests to reflect changes in array slicing behavior.

* Refactor type hints to use Union for function parameters

* Update task scheduling examples and expected outputs in documentation

* remove strict disjunctive sample as no one know, what the difference should we expect

* Add trigonometric functions

* Fix type hint for _generate_solution_class_and_field_names function

* test

* comment out hyperbolic functions as they cause an error in minizinc 2.6.0

* comment out hyperbolic functions to prevent errors in minizinc 2.6.0

* Update changelog to remove hyperbolic trigonometric functions from the list

* update doctest github action

* capitalize some docstrings for consistency

* use 3.12 in doctest twmr/pytest-sphinx#67
  • Loading branch information
artsiomkaltovich authored Dec 21, 2024
1 parent 1456394 commit 500a88d
Show file tree
Hide file tree
Showing 28 changed files with 1,012 additions and 223 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/doc.yml → .github/workflows/doctest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
minizinc-version: ["2.8.2", "2.6.0"]
# use 3.12 until pytest-sphinx doesn't work with 3.13
# https://github.com/twmr/pytest-sphinx/issues/67
python-version: ["3.8", "3.12"]
minizinc-version: ["2.8.7", "2.6.0"]

env:
MINIZINC_URL: https://github.com/MiniZinc/MiniZincIDE/releases/download/${{ matrix.minizinc-version }}/MiniZincIDE-${{ matrix.minizinc-version }}-x86_64.AppImage
Expand Down Expand Up @@ -59,4 +61,4 @@ jobs:
pip install nox
- name: Doc tests
run: |
nox -s doc --reuse-existing-virtualenvs
nox -s doctest --reuse-existing-virtualenvs
4 changes: 2 additions & 2 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
minizinc-version: ["2.8.2", "2.6.0"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
minizinc-version: ["2.8.7", "2.6.0"]

env:
MINIZINC_URL: https://github.com/MiniZinc/MiniZincIDE/releases/download/${{ matrix.minizinc-version }}/MiniZincIDE-${{ matrix.minizinc-version }}-x86_64.AppImage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
minizinc-version: ["2.8.2", "2.6.0"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
minizinc-version: ["2.8.7", "2.6.0"]

env:
MINIZINC_URL: https://github.com/MiniZinc/MiniZincIDE/releases/download/${{ matrix.minizinc-version }}/MiniZincIDE-${{ matrix.minizinc-version }}-x86_64.AppImage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
minizinc-version: ["2.8.2", "2.6.0"]
python-version: ["3.8", "3.13"]
minizinc-version: ["2.8.7", "2.6.0"]

env:
MINIZINC_URL: https://github.com/MiniZinc/MiniZincIDE/releases/download/${{ matrix.minizinc-version }}/MiniZincIDE-${{ matrix.minizinc-version }}-x86_64.AppImage
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/source/api

# PyBuilder
target/
Expand Down
104 changes: 92 additions & 12 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,206 @@
### 0.4.4
#### CI changes
- use minizinc 2.8.2 as maximum version in CI
## 0.5.0

#### Python interpreters support

- Add 3.13 CPython.

#### Added

- Introduce the ``strict`` argument to the ``disjunctive`` constraint.
- Add ``abs``, ``exp``, ``ln``, ``log``, ``log10``, ``log2``, and ``sqrt`` functions.
- Add ``product`` function to calculate product of all elements in the array.
- Add trigonometric functions: `acos`, `asin`, `atan`, `cos`, `sin`, `tan`.

#### Changed

- Array indexing must now specify all indices.

#### CI changes:

- Use minizinc 2.8.7 instead of 2.8.2

### 0.4.3

#### Added

- `disjunctive` constraint

#### Fixed

- array slices with upper slice as operations should compile correctly now

#### Documentation
- simplify and fix layout of ``count``, ``cumulative``

- simplify and fix layout of ``count``, ``cumulative``
``table`` and ``max`` examples

### 0.4.2

#### CI changes

- use minizinc 2.7.6 as maximum version in CI (as in minizinc-python)
- use minizinc 2.6.0 as minimum version in CI (as in minizinc-python)

#### Python interpreters support

- add 3.12 CPython

### 0.4.1

#### Added

- ``table`` constraint
- ``contains`` method for arrays and sets, to check if elem presented
in collection
- ``except_`` argument to ``all_different`` constraint

## 0.4.0

#### Added

- ``cumulative`` constraint
- ``forall`` constraint now supports enums which is not model's field

#### CI changes

- use minizinc 2.7.2 as maximum version in CI
- use minizinc 2.5.4 as minimum version in CI (as in minizinc-python)

### 0.3.1

#### Added

- var can be parametrized (you can assign values to them)

#### Fixed

- int fallback as a result of operation where both operands are float

#### CI changes

- use ruff for style checks

## 0.3

#### Syntax and compatibility

- some arguments are made positional only

#### Fixes

- fix enum doc example
- some minor fixes for internal code

#### Python interpreters support

- add 3.11 CPython
- drop 3.7 CPython
- drop pypy

### 0.2.4

#### Added

- available_solver_tags function to get available solvers
- optimization_level, n_processes, timeout and random_seed arg to solve

#### Fixed

- solve_maximize now correctly use solver arg

#### Changed

- add some type hints

### 0.2.3

#### Added

- validation for float ranges in some constraints, e.g. forall

#### Fixed

- ranges with float values correctly set bigger limit

#### Deleted
- check for minizinc executable is available,
as it seems, python-minizinc implement it by itself.

- check for minizinc executable is available,
as it seems, python-minizinc implement it by itself.

### 0.2.2

#### Added

- sets support enums

### 0.2.1

#### Added

- integer sets

#### Changed

- refactor some code

## 0.2

#### Changed
- zython doesn't redefine builtin range function,

- zython doesn't redefine builtin range function,
use ``zn.range`` for float, zython's var/par types.

#### Python interpreters support

- drop 3.6 CPython
- add 3.10 CPython

### 0.1.5

#### Added

- possibility to choose solver
- float fields support
- float ranges support

### 0.1.4

#### Changed

- an error about minizinc wasn't found in $PATH was changed to warning

### 0.1.3

#### Added

- check for minizinc in $PATH for startup
- documentation page about model parts

#### CI Changes
- Use minizinc 2.5.5 in CI.

- Use minizinc 2.5.5 in CI.

### 0.1.2

#### Fixed

- some method of Operation and Constraint classes which were
accessible by and visible for user are now hidden

#### Added

- ``increasing`` and ``decreasing`` constraints


### 0.1.1

#### Added

- ``allequal`` constraint
- ``ndistinct`` function
- ``except_0`` argument to ``alldifferent`` constraint

#### Changed:
#### Changed

- project description in readme.md
- link to the html doc

Expand Down
12 changes: 0 additions & 12 deletions doc/readme.md

This file was deleted.

2 changes: 1 addition & 1 deletion doc/source/guides/array_advanced/sudoku.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Python Model
def __init__(self):
self.a = zn.Array(zn.var(range(1, 10)), shape=(9, 9))

self.constraints = [zn.forall(range(9), lambda i: zn.alldifferent(self.a[i])),
self.constraints = [zn.forall(range(9), lambda i: zn.alldifferent(self.a[i, :])),
zn.forall(range(9), lambda i: zn.alldifferent(self.a[:, i])),
zn.forall(range(3),
lambda i: zn.forall(range(3),
Expand Down
52 changes: 30 additions & 22 deletions doc/source/guides/array_advanced/tasks_sheduling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ Tasks Scheduling
================

The disjunctive constraint takes an array of start times for each task and
an array of their durations and makes sure that only one task is active at
any one time.
an array of their durations, ensuring that only one task is active at
any given time.

.. note::

It is suggested to use ranges and sequences of ranges instead of int,
because minizinc can return strange result when type of any arg is int
It is recommended to use ranges and sequences of ranges instead of integers,
because MiniZinc can return unexpected results when any argument is an integer.

Model
-----

We will recreate the example of task sheduling problem from the
`minizinc <https://www.minizinc.org/doc-2.7.6/en/predicates.html#ex-jobshop3>`_
We will recreate the example of the task scheduling problem from the
`MiniZinc <https://www.minizinc.org/doc-2.7.6/en/predicates.html#ex-jobshop3>`_
documentation.

The model consists of several jobs, which can be separated into several
steps. There are following restrictions:
The model consists of several jobs, which can be divided into several
steps. The following restrictions apply:

- to complete job, all steps should be executed
- different steps are independent:
if there is a job on first step, other job can be processed on second step,
without necessity to wait.
- if there is an active task on any step, not other job can be executed
on this step and should wait.
- To complete a job, all steps must be executed.
- Different steps are independent:
If there is a job on the first step, another job can be processed on the second step
without waiting.
- If there is an active task on any step, no other job can be executed
on that step and must wait.

You can think about this as a conveyor with `n_jobs` lines,
one part on every line and
`n_steps` independent machines which is shared between lines.
Every machine can complete only one manipulation with any part
and should work with a part processed by previous machine.
We are searching for the fastest way to processed all the parts.
You can think of this as a conveyor with `n_jobs` lines,
one part on every line, and
`n_steps` independent machines that are shared between lines.
Each machine can complete only one operation with any part
and must work with a part processed by the previous machine.
We are searching for the fastest way to process all the parts.

Python Model
------------
Expand Down Expand Up @@ -76,8 +76,8 @@ Python Model
return zn.forall(
range(self.n_jobs),
lambda i: zn.forall(
zn.range(self.n_tasks - 1),
lambda j: self.start[i, j] + self.durations[i, j] <= self.start[i, j + 1],
zn.range(self.n_tasks - 1),
lambda j: self.start[i, j] + self.durations[i, j] <= self.start[i, j + 1],
) & (
self.start[i, self.n_tasks - 1] + self.durations[i, self.n_tasks - 1] <= self.end
)
Expand All @@ -92,3 +92,11 @@ Python Model
.. testoutput::

Solution(objective=30, total=86, end=30, start=[[8, 9, 13, 18, 21], [5, 13, 18, 25, 27], [1, 5, 9, 13, 17], [0, 1, 2, 3, 9], [9, 16, 25, 27, 29]])


Strict Mode
-----------

The strict mode is specified by setting the `strict` argument to True. In this mode, there is a significant difference:

- Tasks with a duration of 0 CANNOT be scheduled at any time but only when no other task is running.
Loading

0 comments on commit 500a88d

Please sign in to comment.