Python implementation of the ROAR-NET API Specification
Project description
ROAR-NET API - Python
This repository contains a library with the python implementation of the ROAR-NET API Specification and several algorithms. You can find the full specification in the roar-net-api-spec repository.
Contents
This library contains protocol types for all operations in the specification, and several algorithms that are currently supported by the specification.
Protocol types
Protocol types for the operations in the ROAR-NET API Specification
are defined in the module
roar_net_api.operations.
For example, the operation
apply_move
is defined in a protocol SupportsApplyMove.
This library considers an object-oriented approach, such that operations should be implemented by a class of the first argument type. For example, for the operation:
apply_move(Move, Solution) -> Solution
we consider that it should be implemented as part of the class Move,
which means that the protocol type is defined as:
SolutionT = TypeVar("SolutionT")
class SupportsApplyMove(Protocol[SolutionT]):
def apply_move(self, solution: SolutionT) -> SolutionT: ...
Algorithms
We support several algorithms that can be implemented following the ROAR-NET API Specification. You can find the algorithms in the module roar_net_api.algorithms. Here is the current list of supported algorithms:
- Beam search:
beam_search - Best improvement:
best_improvement - First improvement:
first_improvement - GRASP:
grasp - Greedy construction:
greedy_construction - Random local search:
rls - Simulated annealing:
sa
Using
Adding it to your project
To use this library add it to your project. For example, to add it to
a uv project you can do:
uv add roar-net-api
Alternatively, you can add it to a requirements.txt file or install
it with pip manually.
Implement a model
To implement a model, we recommend that you take advantage of python
type hints to warn you about potential issues. For example, if you
would like your problem class to support the operations
empty_solution and constructive_neighbourhood, you can inherit
from the protocol types for these operations to get type checking, for
example:
from roar_net_api.operations import (
SupportsEmptySolution,
SupportsConstructiveNeighbourhood
)
class ConstructiveNeighbourhood:
...
class Solution:
...
class Problem(
SupportsEmptySolution[Solution],
SupportsConstructiveNeighbourhood[ConstructiveNeighbourhood]
):
def empty_solution(self) -> Solution:
...
def constructive_neighbourhood(self) -> ConstructiveNeighbourhood:
...
where ... would be for your implementation.
If you do this, your editor/IDE can inform you of potential issues in the implementation.
For a full example, see the tsp.py file in the examples folder, which implements a model for the travelling salesman problem that can be solved by all algorithms.
Development
This library targets Python 3.11, in order to support the latest
version of pypy which allows for faster execution of algorithms. As
such, make sure to test your changes with the latest version of
pypy.
The project is managed with uv, please follow the instructions on
their website to install it.
The code is checked with the following linters:
ruffmypyinstrictmode
Pull requests are checked against these linters.
Copyright and license
Copyright and licence information is declared for each file using the REUSE Specification Version 3.3. Use of any material must comply with its licence.
Acknowledgments
This specification is based upon work from COST Action Randomised Optimisation Algorithms Research Network (ROAR-NET), CA22137, supported by COST (European Cooperation in Science and Technology).
COST (European Cooperation in Science and Technology) is a funding agency for research and innovation networks. Our Actions help connect research initiatives across Europe and enable scientists to grow their ideas by sharing them with their peers. This boosts their research, career and innovation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file roar_net_api-0.1.0.tar.gz.
File metadata
- Download URL: roar_net_api-0.1.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c581c7988400869455e8e4b637a604650612ddcb412d9e73438034a3ecc8f8d
|
|
| MD5 |
b29d407fd766dc71a1007ea8bafdd2ba
|
|
| BLAKE2b-256 |
2b67634ffcefe452719e89fb438209bd20b8ac0b8b11bf501d174d7a1f3b02f7
|
Provenance
The following attestation bundles were made for roar_net_api-0.1.0.tar.gz:
Publisher:
publish.yml on roar-net/roar-net-api-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
roar_net_api-0.1.0.tar.gz -
Subject digest:
5c581c7988400869455e8e4b637a604650612ddcb412d9e73438034a3ecc8f8d - Sigstore transparency entry: 234247065
- Sigstore integration time:
-
Permalink:
roar-net/roar-net-api-py@ce61fa28eb2897bc1489d3ab63d29f09a63d632a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/roar-net
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ce61fa28eb2897bc1489d3ab63d29f09a63d632a -
Trigger Event:
release
-
Statement type:
File details
Details for the file roar_net_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: roar_net_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f46378cbec2d11767a41680d824237694c064acdc86fb836cd5deb81193c092
|
|
| MD5 |
68d9cc2f4e2674db6857e0dee314597f
|
|
| BLAKE2b-256 |
621db801640ba0d168f37f74a31a49f047b51e1d8e43f2f62ab1771d4f5444ce
|
Provenance
The following attestation bundles were made for roar_net_api-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on roar-net/roar-net-api-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
roar_net_api-0.1.0-py3-none-any.whl -
Subject digest:
1f46378cbec2d11767a41680d824237694c064acdc86fb836cd5deb81193c092 - Sigstore transparency entry: 234247068
- Sigstore integration time:
-
Permalink:
roar-net/roar-net-api-py@ce61fa28eb2897bc1489d3ab63d29f09a63d632a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/roar-net
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ce61fa28eb2897bc1489d3ab63d29f09a63d632a -
Trigger Event:
release
-
Statement type: