Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
d-krupke committed Oct 28, 2023
1 parent 20a991f commit 0f1f522
Show file tree
Hide file tree
Showing 24 changed files with 253 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
pip install --verbose .
- name: Test with pytest
run: |
pytest -s tests
pytest -s tests
2 changes: 1 addition & 1 deletion .github/workflows/pytest_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
python3 -m pip install -v .
- name: Test with pytest
run: |
python3 -m pytest -s tests
python3 -m pytest -s tests
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
- name: Build SDist and wheel
run: pipx run build --sdist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1
117 changes: 73 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# CG:SHOP - Official pyutils24 for the 2024 Challenge on Packing Polygons

Utilities for verifying solutions of the CG:SHOP 2024 Competition.
Feel free to use the code, but it is optimized for *exact* verification not for sampling or other purposes.
Utilities for verifying solutions of the CG:SHOP 2024 Competition. Feel free to
use the code, but it is optimized for _exact_ verification not for sampling or
other purposes.

## Installation

Expand All @@ -11,19 +12,18 @@ You can install this package via PyPI:
pip install -U -v cgshop2024-pyutils
```

During the installation, CGAL and other dependencies will be downloaded and compiled.
This can take a while but should happen mostly automatic.
You need to have a C++ compiler installed.
During the installation, CGAL and other dependencies will be downloaded and
compiled. This can take a while but should happen mostly automatic. You need to
have a C++ compiler installed.

> Please check for updates of the utils frequently as we are still working on them.
> Please check for updates of the utils frequently as we are still working on
> them.
## Usage

### Reading instances


```python

from cgshop_pyutils24 import InstanceDatabase

db = InstanceDatabase("../cgshop2024_benchmark.zip")
Expand All @@ -38,38 +38,57 @@ for instance in db:
The instances are dicts of the following format:

```json
{"type": "cgshop2024_instance",
"instance_name": "test",
"num_items": 9,
"container": {"x": [26, 2, 0, 12, 91, 158, 180, 194, 225, 232, 225, 210, 200],
"y": [250, 202, 149, 107, 0, 30, 42, 56, 131, 151, 177, 225, 243]},
"items": [
{"value": 601,
"quantity": 1,
"x": [3, 40, 113, 134, 85, 143, 152, 157, 157, 92, 18, 12, 2, 0],
"y": [31, 59, 59, 27, 6, 0, 51, 95, 139, 141, 77, 145, 152, 65]},
{"value": 90,
"quantity": 1,
"x": [1, 6, 25, 54, 49, 39, 25, 31, 14, 0, 13],
"y": [11, 10, 8, 0, 23, 28, 37, 56, 34, 39, 26]},
{"value": 1, "quantity": 1, "x": [12, 0, 28], "y": [16, 26, 0]},
{"value": 9, "quantity": 1, "x": [8, 5, 0, 12, 13], "y": [14, 19, 12, 0, 5]},
{"value": 133, "quantity": 1, "x": [101, 61, 0], "y": [0, 104, 95]},
{"value": 51, "quantity": 2, "x": [68, 48, 0, 71], "y": [45, 38, 17, 0]},
{"value": 25, "quantity": 1, "x": [21, 28, 0, 1], "y": [0, 47, 17, 0]},
{"value": 37,
"quantity": 1,
"x": [11, 1, 17, 26, 19, 0, 9],
"y": [16, 0, 16, 12, 34, 34, 26]},
{"value": 32, "quantity": 1, "x": [58, 73, 79, 0], "y": [5, 10, 39, 0]}
]
{
"type": "cgshop2024_instance",
"instance_name": "test",
"num_items": 9,
"container": {
"x": [26, 2, 0, 12, 91, 158, 180, 194, 225, 232, 225, 210, 200],
"y": [250, 202, 149, 107, 0, 30, 42, 56, 131, 151, 177, 225, 243]
},
"items": [
{
"value": 601,
"quantity": 1,
"x": [3, 40, 113, 134, 85, 143, 152, 157, 157, 92, 18, 12, 2, 0],
"y": [31, 59, 59, 27, 6, 0, 51, 95, 139, 141, 77, 145, 152, 65]
},
{
"value": 90,
"quantity": 1,
"x": [1, 6, 25, 54, 49, 39, 25, 31, 14, 0, 13],
"y": [11, 10, 8, 0, 23, 28, 37, 56, 34, 39, 26]
},
{ "value": 1, "quantity": 1, "x": [12, 0, 28], "y": [16, 26, 0] },
{
"value": 9,
"quantity": 1,
"x": [8, 5, 0, 12, 13],
"y": [14, 19, 12, 0, 5]
},
{ "value": 133, "quantity": 1, "x": [101, 61, 0], "y": [0, 104, 95] },
{ "value": 51, "quantity": 2, "x": [68, 48, 0, 71], "y": [45, 38, 17, 0] },
{ "value": 25, "quantity": 1, "x": [21, 28, 0, 1], "y": [0, 47, 17, 0] },
{
"value": 37,
"quantity": 1,
"x": [11, 1, 17, 26, 19, 0, 9],
"y": [16, 0, 16, 12, 34, 34, 26]
},
{ "value": 32, "quantity": 1, "x": [58, 73, 79, 0], "y": [5, 10, 39, 0] }
]
}
```

### Verifying solutions

```python
from cgshop2024_pyutils import verify, InstanceDatabase, InvalidSolution, BadSolutionFile
from cgshop2024_pyutils import (
verify,
InstanceDatabase,
InvalidSolution,
BadSolutionFile,
)

db = InstanceDatabase("../cgshop2024_benchmark.zip")
solution = parse_solution(SOLUTION_DATA)
Expand All @@ -88,7 +107,14 @@ else:
### Verifying a batch of solutions

```python
from cgshop2024_pyutils import verify_batch, InstanceDatabase, InvalidSolution, BadSolutionFile, ZipSolutionIterator, ZipReaderError
from cgshop2024_pyutils import (
verify_batch,
InstanceDatabase,
InvalidSolution,
BadSolutionFile,
ZipSolutionIterator,
ZipReaderError,
)

db = InstanceDatabase("../cgshop2024_benchmark.zip")
sol_it = ZipSolutionIterator()
Expand All @@ -108,21 +134,24 @@ except ZipReaderError as err:
print("Error while reading zip file:", err)
```


## Trouble Shooting

The native parts are known to cause trouble on some systems.
Check out [this page](https://github.com/d-krupke/skbuild-conan#common-problems) for solutions of various problems.

The native parts are known to cause trouble on some systems. Check out
[this page](https://github.com/d-krupke/skbuild-conan#common-problems) for
solutions of various problems.

## License

The code in this repository can be used under the terms of the MIT license.
However, the package binds against CGAL which is licensed under the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
This should still allow you to modify and use the code for the competition.
However, the package binds against CGAL which is licensed under the
[GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html). This should still allow
you to modify and use the code for the competition.

## Changelog

* **1.0.2:** The previous workaround could lead to excessive memory usage. Changed quadtree implementation to keep large elements on higher levels even if the node is full. Gives a warning in this case.
* **1.0.1:** Only giving a warning if a node cannot be split instead of throwing an exception. [Issue #1](https://github.com/CG-SHOP/pyutils24/issues/1)
* **1.0.0:** Initial release
- **1.1.0:** The previous workaround could lead to excessive memory usage.
Changed quadtree implementation to keep large elements on higher levels even
if the node is full. Gives a warning in this case.
- **1.0.1:** Only giving a warning if a node cannot be split instead of throwing
an exception. [Issue #1](https://github.com/CG-SHOP/pyutils24/issues/1)
- **1.0.0:** Initial release
11 changes: 9 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from setuptools import find_packages
from skbuild_conan import setup


def readme():
"""
:return: Content of README.md
"""
with open("README.md") as file:
return file.read()


setup( # https://scikit-build.readthedocs.io/en/latest/usage.html#setup-options
name="cgshop2024_pyutils",
version="1.0.1",
version="1.1.0",
author="Dominik Krupke",
license="LICENSE",
description="Utilities for verifying solutions of the CG:SHOP 2024 Competition.",
Expand All @@ -19,7 +21,12 @@ def readme():
packages=find_packages("src"), # Include all packages in `./src`.
package_dir={"": "src"}, # The root for our python package is in `./src`.
python_requires=">=3.7", # lowest python version supported.
install_requires=["matplotlib", "numpy","chardet>=4.0.0" , "networkx>=2.0.0"], # Python Dependencies
install_requires=[
"matplotlib",
"numpy",
"chardet>=4.0.0",
"networkx>=2.0.0",
], # Python Dependencies
conan_requirements=["fmt/[>=10.0.0]", "cgal/[>=5.6]"], # C++ Dependencies
cmake_minimum_required_version="3.23",
)
2 changes: 1 addition & 1 deletion src/cgshop2024_pyutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .instance_database import InstanceDatabase
from .io import BadSolutionFile, parse_solution, read_solution
from .verify import verify, InvalidSolution
from .verify import InvalidSolution, verify
from .zip import ZipReaderError, ZipSolutionIterator

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion src/cgshop2024_pyutils/instance_database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# flake8: noqa F401
from .instance_database import InstanceDatabase

__all__ = ["InstanceDatabase"]
__all__ = ["InstanceDatabase"]
16 changes: 14 additions & 2 deletions src/cgshop2024_pyutils/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Just simple parsing of json files, including some checking and cleaning.
"""
# flake8: noqa F401
from .read import read_instance, read_solution, NoSolution, BadSolutionFile, parse_solution
from .read import (
BadSolutionFile,
NoSolution,
parse_solution,
read_instance,
read_solution,
)

__all__ = ["read_instance", "read_solution", "NoSolution", "BadSolutionFile", "parse_solution"]
__all__ = [
"read_instance",
"read_solution",
"NoSolution",
"BadSolutionFile",
"parse_solution",
]
Loading

0 comments on commit 0f1f522

Please sign in to comment.