No project description provided
Project description
GeneralDichotomy
A general and minimalist toolkit for multi-objective optimization
GeneralDichotomy is a library and a package to enumerate supported extreme solutions of general multi-objective optimization problems.
This package is independent of any single-objective optimization solver.
The user implements the solving function that is called by the GeneralDichotomy algorithm.
In return, the solving function provides to the algorithm the objective cost vector associated to the solution.
Solution assignments are managed by the user and they can be associated to the objective cost vectors from their indices at the end of the search.
Internally, the GeneralDichotomy algorithm relies on polytope vertices enumeration to maintain a precise description of the convex hull of the Pareto front. Two polytope computation libraries can be currently used as backends: CDD and PPL. This organized search procedure provide an exhaustive set of supported (extreme) solutions when such set is enumerable. More generally, this tool can also be used with stochastic and heuristic optimizers to create a proxy of the Pareto convex hull.
The GeneralDichotomy core algorithm is implemented in C++. A C++ and a Python interface are available for the user-side (see examples). An additional Julia implementation interfaced with the JuMP package is also available.
Usage
The GeneralDichomy package can be used via the C++ or the Python programming interface. In both cases, the used creates a class where they can implement the call to their solver (which can be run from an external package for instance).
pygeneraldichotomy
Getting started
A simple example for solving linear assignment problems with cpmpy as single-objective optimization backend:
from pygeneraldichotomy import GeneralDichotomy, AbstractSolver
import cpmpy as cp
import numpy as np
class MyLapSolver(AbstractSolver):
def __init__(self, instance):
self.instance = instance
def nobj(self):
return self.instance.shape[0]
def is_new(self, is_new_arg):
...
def solve(self, weights, adj_solutions):
nvar = self.instance.shape[1]
x = cp.boolvar(shape=(nvar,nvar), name="x")
weighted_obj = np.tensordot(weights, self.instance, axes=1)
m = cp.Model([cp.sum(x[i])==1 for i in range(self.instance.shape[1])], minimize=cp.sum(weighted_obj*x))
assert(m.solve())
y = np.sum(x.value()*self.instance, (1,2))
z = (y*weights).sum()
assert(abs(m.objective_value() - z) <= 1e-3)
return y.tolist(),z
obj1 = np.array([[3,6,4,5],
[2,3,5,4],
[3,5,4,2],
[4,5,3,6]])
obj2 = np.array([[2,3,5,4],
[5,3,4,3],
[5,2,6,4],
[4,5,2,5]])
obj3 = np.array([[4,2,4,2],
[4,2,4,6],
[4,2,6,3],
[2,4,5,3]])
lapsolver = MyLapSolver(np.stack([obj1, obj2, obj3]))
gdalgorithm = GeneralDichotomy(lapsolver)
res = gdalgorithm.run(verbose=0)
print('solution cost vectors: ')
for elt in res[0]:
print(elt)
install from releases
pygeneraldichotomy is available on pypi! It can be easily installed:
pip install pygeneraldichotomy
⚠️ We strongly recommend to install it in a virtual environment (conda, venv, ...) as it is still in a prototyping phase.
build from sources
Build and install from sources:
python -m build --wheel
pip install dist/*.whl
Build and test locally (for developers only):
cd "your_build_directory"
cmake .. [...]
cmake --build . -t pygdichotomy
export PYTHONPATH="your_build_directory"
python your_test_script.py
Or, in your python script:
import sys
sys.path.append("path_to_your_build_directory")
libgeneraldichotomy
libgeneraldichotomy is the C++ library
Library and package compilation
As a C++ library, the GeneralDichotomy development package must be compiled from its sources to be tested. Compilation instructions can be found on the dedicated wiki page [[Library compilation|Library-compilation]]. Note that the Python binding also needs a compilation step.
Examples
- Linear assignment [cpp,ortools]
cmake --build . -t example_lap_cpp_otools
- Linear assignment [cpp,toulbar2]
cmake --build . -t example_lap_cpp_tb2
- Linear assignment [python,pytoulbar2]
This example depends on the python package pytoulbar2 (python binding of the toulbar2 solver).
It can be installed via pip install pytoulbar2 in a python environment.
To run the example from the example/python_lap directory:
export PYTHONPATH="${PYTHONPATH}:generaldichotomy_build_dir/pygeneraldichotomy" && python3 python_lap.py
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 Distributions
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 pygeneraldichotomy-0.0.1.5.tar.gz.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a4de221f4f8384e7515fff85f2141729c4cdf7c0489ae2c0d5b1ead62d5af12
|
|
| MD5 |
575d67819de2e1f4e132e6a180346284
|
|
| BLAKE2b-256 |
41fb01b6640a16a27eed6bf6a563e22cff860a4fea47b3b3469375a9597ba801
|
File details
Details for the file pygeneraldichotomy-0.0.1.5-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 131.4 kB
- Tags: CPython 3.14t, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9813f280a82bb59a1617aa4f9582a5c51044191396b740c1bf698ecd06f1cfb
|
|
| MD5 |
2da901fdc48e9f0101e5c74343b52716
|
|
| BLAKE2b-256 |
4142ad2ae0a54656b768a35cf48224d84b3cda966f056735b0d7eec4e8877284
|
File details
Details for the file pygeneraldichotomy-0.0.1.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 131.2 kB
- Tags: CPython 3.14, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05517fd90510c723144a2b5ef98122d5f97f5141cbf23a2c16ba5e142e11ac09
|
|
| MD5 |
6d610cd73531e5c5ab800d3cce65defc
|
|
| BLAKE2b-256 |
20c6e33e3a4fd7137cd5b4687307617a60af958b6809872fc7432af701c4223b
|
File details
Details for the file pygeneraldichotomy-0.0.1.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 131.2 kB
- Tags: CPython 3.13, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c797b378f4dbf07e6de64539cb5df8500bddb7f712c683bd35aa28f7347ab2f3
|
|
| MD5 |
c871b7d7bcefd9e848f038c5ce7576e5
|
|
| BLAKE2b-256 |
de12ed87cc1153339f5a3b00db840091f05df7bd546bfad628e637d11287e1e7
|
File details
Details for the file pygeneraldichotomy-0.0.1.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 131.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08b4b689a4235bbaf36c14d7bca6b32a50b2c6ac6cafb9b5dabfaeac40d7b825
|
|
| MD5 |
7e01d4b50bcd0a4af7781f39101fb19c
|
|
| BLAKE2b-256 |
fb06ea2d5b8c8ba2a7a9a638ccc10c8ec6e5100a299c9f2c5c9ea7dbcebba336
|
File details
Details for the file pygeneraldichotomy-0.0.1.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 131.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
072c98b072e86c028e8d7c7adbb8f9b5d20bd67b4659ab6bf39b40d6fafbdc7b
|
|
| MD5 |
73ee2b99120813fa9ec7c4b1f00de4ba
|
|
| BLAKE2b-256 |
36fe19fa99c317fa6cd1bb1dbb421ec7be737c95543d168011e61ca3b0f7aeea
|
File details
Details for the file pygeneraldichotomy-0.0.1.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 131.1 kB
- Tags: CPython 3.10, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e53c47b2059313606880f0104f161b9119b31e315b682fbf5fb393c1876869ce
|
|
| MD5 |
59a1dbebd342c45f962a74279bb03218
|
|
| BLAKE2b-256 |
0bdef468e974d450416cdd41f9fa1b74578a9672d2f9db74143ad242bea7a4f3
|
File details
Details for the file pygeneraldichotomy-0.0.1.5-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 131.1 kB
- Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69120359ba4002b19e6b2ff2d658f019c1e8354e19254601723597cd7a0f8db8
|
|
| MD5 |
e50c67d532a565b59a3db20ffef88639
|
|
| BLAKE2b-256 |
38f9bc1a52e5892818aea3745bb76c14473cb23bb893fe03bf57a671f4421807
|
File details
Details for the file pygeneraldichotomy-0.0.1.5-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pygeneraldichotomy-0.0.1.5-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 130.8 kB
- Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84cb6f1a300581b66e8eb80213351b708c6e1eb9060a57e71d0a5cee57c079af
|
|
| MD5 |
84b763271fc48a9d8fa1e7175d5fbc9d
|
|
| BLAKE2b-256 |
0e4d2d5abd948157a3e1563efac12205fce03da8f2852d18c33c40d2028fd151
|