pareto_dp 0.1.6__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.
@@ -0,0 +1,180 @@
1
+ # This file is autogenerated by maturin v1.13.1
2
+ # To update, run
3
+ #
4
+ # maturin generate-ci github
5
+ #
6
+ name: CI
7
+
8
+ on:
9
+ push:
10
+ branches:
11
+ - main
12
+ - master
13
+ tags:
14
+ - '*'
15
+ pull_request:
16
+ workflow_dispatch:
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ linux:
23
+ runs-on: ${{ matrix.platform.runner }}
24
+ strategy:
25
+ matrix:
26
+ platform:
27
+ - runner: ubuntu-22.04
28
+ target: x86_64
29
+ - runner: ubuntu-22.04
30
+ target: x86
31
+ - runner: ubuntu-22.04
32
+ target: aarch64
33
+ - runner: ubuntu-22.04
34
+ target: armv7
35
+ - runner: ubuntu-22.04
36
+ target: s390x
37
+ - runner: ubuntu-22.04
38
+ target: ppc64le
39
+ steps:
40
+ - uses: actions/checkout@v6
41
+ - uses: actions/setup-python@v6
42
+ with:
43
+ python-version: "3.13"
44
+ - name: Build wheels
45
+ uses: PyO3/maturin-action@v1
46
+ with:
47
+ target: ${{ matrix.platform.target }}
48
+ args: --release --out dist
49
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50
+ manylinux: auto
51
+ - name: Upload wheels
52
+ uses: actions/upload-artifact@v6
53
+ with:
54
+ name: wheels-linux-${{ matrix.platform.target }}
55
+ path: dist
56
+
57
+ musllinux:
58
+ runs-on: ${{ matrix.platform.runner }}
59
+ strategy:
60
+ matrix:
61
+ platform:
62
+ - runner: ubuntu-22.04
63
+ target: x86_64
64
+ - runner: ubuntu-22.04
65
+ target: x86
66
+ - runner: ubuntu-22.04
67
+ target: aarch64
68
+ - runner: ubuntu-22.04
69
+ target: armv7
70
+ steps:
71
+ - uses: actions/checkout@v6
72
+ - uses: actions/setup-python@v6
73
+ with:
74
+ python-version: "3.13"
75
+ - name: Build wheels
76
+ uses: PyO3/maturin-action@v1
77
+ with:
78
+ target: ${{ matrix.platform.target }}
79
+ args: --release --out dist
80
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
81
+ manylinux: musllinux_1_2
82
+ - name: Upload wheels
83
+ uses: actions/upload-artifact@v6
84
+ with:
85
+ name: wheels-musllinux-${{ matrix.platform.target }}
86
+ path: dist
87
+
88
+ windows:
89
+ runs-on: ${{ matrix.platform.runner }}
90
+ strategy:
91
+ matrix:
92
+ platform:
93
+ - runner: windows-latest
94
+ target: x64
95
+ - runner: windows-11-arm
96
+ target: aarch64
97
+ steps:
98
+ - uses: actions/checkout@v6
99
+ - uses: actions/setup-python@v6
100
+ with:
101
+ python-version: "3.13"
102
+ - name: Build wheels
103
+ uses: PyO3/maturin-action@v1
104
+ with:
105
+ target: ${{ matrix.platform.target }}
106
+ args: --release --out dist
107
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
108
+ - name: Upload wheels
109
+ uses: actions/upload-artifact@v6
110
+ with:
111
+ name: wheels-windows-${{ matrix.platform.target }}
112
+ path: dist
113
+
114
+ macos:
115
+ runs-on: ${{ matrix.platform.runner }}
116
+ strategy:
117
+ matrix:
118
+ platform:
119
+ - runner: macos-15-intel
120
+ target: x86_64
121
+ - runner: macos-latest
122
+ target: aarch64
123
+ steps:
124
+ - uses: actions/checkout@v6
125
+ - uses: actions/setup-python@v6
126
+ with:
127
+ python-version: "3.13"
128
+ - name: Build wheels
129
+ uses: PyO3/maturin-action@v1
130
+ with:
131
+ target: ${{ matrix.platform.target }}
132
+ args: --release --out dist
133
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
134
+ - name: Upload wheels
135
+ uses: actions/upload-artifact@v6
136
+ with:
137
+ name: wheels-macos-${{ matrix.platform.target }}
138
+ path: dist
139
+
140
+ sdist:
141
+ runs-on: ubuntu-latest
142
+ steps:
143
+ - uses: actions/checkout@v6
144
+ - name: Build sdist
145
+ uses: PyO3/maturin-action@v1
146
+ with:
147
+ command: sdist
148
+ args: --out dist
149
+ - name: Upload sdist
150
+ uses: actions/upload-artifact@v6
151
+ with:
152
+ name: wheels-sdist
153
+ path: dist
154
+
155
+ release:
156
+ name: Release
157
+ runs-on: ubuntu-latest
158
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
159
+ needs: [linux, musllinux, windows, macos, sdist]
160
+ permissions:
161
+ # Use to sign the release artifacts
162
+ id-token: write
163
+ # Used to upload release artifacts
164
+ contents: write
165
+ # Used to generate artifact attestation
166
+ attestations: write
167
+ steps:
168
+ - uses: actions/download-artifact@v7
169
+ - name: Generate artifact attestation
170
+ uses: actions/attest-build-provenance@v3
171
+ with:
172
+ subject-path: 'wheels-*/*'
173
+ - name: Install uv
174
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
175
+ uses: astral-sh/setup-uv@v7
176
+ - name: Publish to PyPI
177
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
178
+ run: uv publish 'wheels-*/*'
179
+ env:
180
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,133 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "heck"
7
+ version = "0.5.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
10
+
11
+ [[package]]
12
+ name = "libc"
13
+ version = "0.2.185"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
16
+
17
+ [[package]]
18
+ name = "once_cell"
19
+ version = "1.21.4"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
22
+
23
+ [[package]]
24
+ name = "pareto_dp"
25
+ version = "0.1.6"
26
+ dependencies = [
27
+ "pyo3",
28
+ ]
29
+
30
+ [[package]]
31
+ name = "portable-atomic"
32
+ version = "1.13.1"
33
+ source = "registry+https://github.com/rust-lang/crates.io-index"
34
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
35
+
36
+ [[package]]
37
+ name = "proc-macro2"
38
+ version = "1.0.106"
39
+ source = "registry+https://github.com/rust-lang/crates.io-index"
40
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
41
+ dependencies = [
42
+ "unicode-ident",
43
+ ]
44
+
45
+ [[package]]
46
+ name = "pyo3"
47
+ version = "0.28.3"
48
+ source = "registry+https://github.com/rust-lang/crates.io-index"
49
+ checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12"
50
+ dependencies = [
51
+ "libc",
52
+ "once_cell",
53
+ "portable-atomic",
54
+ "pyo3-build-config",
55
+ "pyo3-ffi",
56
+ "pyo3-macros",
57
+ ]
58
+
59
+ [[package]]
60
+ name = "pyo3-build-config"
61
+ version = "0.28.3"
62
+ source = "registry+https://github.com/rust-lang/crates.io-index"
63
+ checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e"
64
+ dependencies = [
65
+ "target-lexicon",
66
+ ]
67
+
68
+ [[package]]
69
+ name = "pyo3-ffi"
70
+ version = "0.28.3"
71
+ source = "registry+https://github.com/rust-lang/crates.io-index"
72
+ checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e"
73
+ dependencies = [
74
+ "libc",
75
+ "pyo3-build-config",
76
+ ]
77
+
78
+ [[package]]
79
+ name = "pyo3-macros"
80
+ version = "0.28.3"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813"
83
+ dependencies = [
84
+ "proc-macro2",
85
+ "pyo3-macros-backend",
86
+ "quote",
87
+ "syn",
88
+ ]
89
+
90
+ [[package]]
91
+ name = "pyo3-macros-backend"
92
+ version = "0.28.3"
93
+ source = "registry+https://github.com/rust-lang/crates.io-index"
94
+ checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb"
95
+ dependencies = [
96
+ "heck",
97
+ "proc-macro2",
98
+ "pyo3-build-config",
99
+ "quote",
100
+ "syn",
101
+ ]
102
+
103
+ [[package]]
104
+ name = "quote"
105
+ version = "1.0.45"
106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
107
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
108
+ dependencies = [
109
+ "proc-macro2",
110
+ ]
111
+
112
+ [[package]]
113
+ name = "syn"
114
+ version = "2.0.117"
115
+ source = "registry+https://github.com/rust-lang/crates.io-index"
116
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
117
+ dependencies = [
118
+ "proc-macro2",
119
+ "quote",
120
+ "unicode-ident",
121
+ ]
122
+
123
+ [[package]]
124
+ name = "target-lexicon"
125
+ version = "0.13.5"
126
+ source = "registry+https://github.com/rust-lang/crates.io-index"
127
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
128
+
129
+ [[package]]
130
+ name = "unicode-ident"
131
+ version = "1.0.24"
132
+ source = "registry+https://github.com/rust-lang/crates.io-index"
133
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
@@ -0,0 +1,33 @@
1
+ [package]
2
+ name = "pareto_dp"
3
+ version = "0.1.6"
4
+ edition = "2024"
5
+ readme = "README.md"
6
+
7
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
+ [lib]
9
+ name = "pareto_dp"
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ pyo3 = { version = "0.28.2", features = ["abi3-py39"] }
14
+
15
+ [lints.clippy]
16
+ # UM, ACTUALLY
17
+ pedantic = { level = "deny", priority = -1 }
18
+ # DEVELOPING LINTS
19
+ nursery = { level = "deny", priority = -1 }
20
+ # DENY PANICS
21
+ unwrap_used = "deny"
22
+ expect_used = "deny"
23
+ indexing_slicing = "deny"
24
+ arithmetic_side_effects = "deny"
25
+ unreachable = "deny"
26
+ unimplemented = "deny"
27
+ unchecked_time_subtraction = "deny"
28
+ todo = "deny"
29
+ string_slice = "deny"
30
+ panic_in_result_fn = "deny"
31
+ panic = "deny"
32
+ exit = "deny"
33
+ as_conversions = "deny"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 txart
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,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: pareto_dp
3
+ Version: 0.1.6
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: License :: OSI Approved :: MIT License
6
+ Classifier: Programming Language :: Rust
7
+ Classifier: Programming Language :: Python :: Implementation :: CPython
8
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Requires-Dist: ruff>=0.15.13
14
+ Requires-Dist: ty>=0.0.35
15
+ License-File: LICENSE
16
+ Summary: Multi-objective optimization using dynamic programming to find Pareto-optimal solutions
17
+ Keywords: optimization,pareto,multi-objective,dynamic-programming
18
+ Author: txart
19
+ License: MIT
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
22
+ Project-URL: Homepage, https://github.com/Txart/pareto_dp
23
+ Project-URL: Repository, https://github.com/Txart/pareto_dp
24
+
25
+ # pareto_dp
26
+
27
+ Simple multi-objective optimization using dynamic programming to approximate the Pareto frontier.
28
+
29
+ Written in Rust, published as a Python PyPI package with `PyO3` and `maturin`.
30
+
31
+ ## Problem specification
32
+
33
+ This library solves a multi-objective multiple-choice combinatorial optimization problem with **additive separable objectives**, designed for scenarios with precomputed data for independent decision points.
34
+
35
+ Here's [an introductory blogpost that provides more motivation for the problem](https://iurzainki.com/blog/pareto).
36
+
37
+ ### Core user-facing properties
38
+ - **Independent groups**: The problem consists of `n` independent groups (e.g., decision stages, components) with no interdependencies.
39
+ - **Additive objective aggregation**: The total objective vector for a configuration is the sum of per-group contributions. For a configuration `x` (one scenario chosen per group), the `v`-dimensional objective is:
40
+ $$
41
+ F(x) = \sum_{i=1}^n a_{i,x_i} \in \mathbb{R}^v
42
+ $$
43
+ where `a_{i,j}` is the precomputed objective vector for group `i`, scenario `j`.
44
+ - **Precomputed lookup table**: All per-group, per-scenario objective values are precomputed (table-lookup/black-box). The library takes this 3D lookup table as direct input.
45
+
46
+ ### Formal structure
47
+ - `n` independent groups
48
+ - Each group `i` has `m_i` scenarios
49
+ - Multiple-choice constraint: A configuration selects exactly one scenario per group
50
+ - `v` objectives, precomputed as `a_{i,j} ∈ ℝᵛ`
51
+ - Goal: Compute the Pareto-optimal frontier in the `v`-dimensional objective space
52
+
53
+ ### Scale challenge
54
+ The configuration space size is `|X| = ∏_{i=1}^n m_i`, which grows exponentially with `n`. Exhaustive search is infeasible for large `n`, so the library uses dynamic programming with epsilon-dominance pruning to efficiently approximate the Pareto front.
55
+
56
+ ## Installation
57
+
58
+ ```bash
59
+ pip install pareto-dp
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ```python
65
+ from pareto_dp import find_pareto_front
66
+
67
+ # Define your multi-objective optimization problem
68
+ # Each stand has multiple scenarios, each scenario has objective values
69
+ data = [
70
+ [[3.0, 2.1], [2.0, 1.0]], # Stand 0: 2 scenarios, 2 objectives
71
+ [[1.0, 1.0], [2.0, 0.5]], # Stand 1: 2 scenarios, 2 objectives
72
+ ]
73
+
74
+ # Find Pareto-optimal solutions with epsilon precision
75
+ solutions = find_pareto_front(data, epsilon=0.01)
76
+
77
+ for sol in solutions:
78
+ print(f"Design: {sol.design_vector}, Objectives: {sol.target_vector}")
79
+ ```
80
+
81
+ ## API
82
+
83
+ ### `find_pareto_front(data, epsilon)`
84
+
85
+ Finds all Pareto-optimal solutions for a multi-objective optimization problem.
86
+
87
+ **Parameters:**
88
+ - `data` (List[List[List[float]]]): A 3D list where:
89
+ - First dimension: decision points
90
+ - Second dimension: options for each decision point
91
+ - Third dimension: objective variable values (e.g., [cost, time, quality])
92
+ - `epsilon` (float): Precision parameter for epsilon-dominance pruning
93
+
94
+ (Note: the context in which this problem originated is forestry land-use, so decision points are called `stands` in the code, and options are called `scenarios`).
95
+
96
+ **Returns:**
97
+ - List of `ParetoFrontSolution` objects, each with:
98
+ - `design_vector` (List[int]): Which scenario to pick for each stand
99
+ - `target_vector` (List[float]): The summed objective values for that design
100
+
101
+ **Raises:**
102
+ - `ValueError`: If data is empty, has only one stand, or has inconsistent dimensions
103
+
104
+ ## Algorithm
105
+
106
+ The algorithm uses dynamic programming to efficiently find the Pareto front:
107
+
108
+ 1. **Data Validation**: Validates input structure and dimensions
109
+ 2. **Shift to Positive Space**: Shifts all objective values to positive space for numerical stability
110
+ 3. **DP Tree Construction**: Builds partial Pareto fronts iteratively for each stand
111
+ 4. **Epsilon-Dominance Pruning**: Uses logarithmic binning to prune dominated solutions
112
+ 5. **Solution Reconstruction**: Traces back through parent pointers to reconstruct full solutions
113
+
114
+ ## Requirements
115
+
116
+ - Python >= 3.9
117
+ - Compatible with CPython and PyPy
118
+
119
+ ## License
120
+
121
+ MIT License - see [LICENSE](LICENSE) file for details.
122
+
123
+ ## Repository
124
+
125
+ https://github.com/Txart/pareto_dp
126
+
@@ -0,0 +1,17 @@
1
+ # Publishing a new version
2
+
3
+ 1. Bump the version in `Cargo.toml` (e.g., `0.1.2` → `0.1.3`)
4
+ 2. Commit the change
5
+ 3. Create a git tag matching the version
6
+ 4. Push the commit and the tag
7
+
8
+ ```bash
9
+ git add Cargo.toml
10
+ git commit -m "bump version to 0.1.3"
11
+ git tag 0.1.3
12
+ git push origin main --tags
13
+ ```
14
+
15
+ The GitHub Actions CI workflow triggers on tag pushes and will:
16
+ - Build wheels for all platforms (Linux, macOS, Windows, musllinux)
17
+ - Publish to PyPI automatically
@@ -0,0 +1,101 @@
1
+ # pareto_dp
2
+
3
+ Simple multi-objective optimization using dynamic programming to approximate the Pareto frontier.
4
+
5
+ Written in Rust, published as a Python PyPI package with `PyO3` and `maturin`.
6
+
7
+ ## Problem specification
8
+
9
+ This library solves a multi-objective multiple-choice combinatorial optimization problem with **additive separable objectives**, designed for scenarios with precomputed data for independent decision points.
10
+
11
+ Here's [an introductory blogpost that provides more motivation for the problem](https://iurzainki.com/blog/pareto).
12
+
13
+ ### Core user-facing properties
14
+ - **Independent groups**: The problem consists of `n` independent groups (e.g., decision stages, components) with no interdependencies.
15
+ - **Additive objective aggregation**: The total objective vector for a configuration is the sum of per-group contributions. For a configuration `x` (one scenario chosen per group), the `v`-dimensional objective is:
16
+ $$
17
+ F(x) = \sum_{i=1}^n a_{i,x_i} \in \mathbb{R}^v
18
+ $$
19
+ where `a_{i,j}` is the precomputed objective vector for group `i`, scenario `j`.
20
+ - **Precomputed lookup table**: All per-group, per-scenario objective values are precomputed (table-lookup/black-box). The library takes this 3D lookup table as direct input.
21
+
22
+ ### Formal structure
23
+ - `n` independent groups
24
+ - Each group `i` has `m_i` scenarios
25
+ - Multiple-choice constraint: A configuration selects exactly one scenario per group
26
+ - `v` objectives, precomputed as `a_{i,j} ∈ ℝᵛ`
27
+ - Goal: Compute the Pareto-optimal frontier in the `v`-dimensional objective space
28
+
29
+ ### Scale challenge
30
+ The configuration space size is `|X| = ∏_{i=1}^n m_i`, which grows exponentially with `n`. Exhaustive search is infeasible for large `n`, so the library uses dynamic programming with epsilon-dominance pruning to efficiently approximate the Pareto front.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install pareto-dp
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ from pareto_dp import find_pareto_front
42
+
43
+ # Define your multi-objective optimization problem
44
+ # Each stand has multiple scenarios, each scenario has objective values
45
+ data = [
46
+ [[3.0, 2.1], [2.0, 1.0]], # Stand 0: 2 scenarios, 2 objectives
47
+ [[1.0, 1.0], [2.0, 0.5]], # Stand 1: 2 scenarios, 2 objectives
48
+ ]
49
+
50
+ # Find Pareto-optimal solutions with epsilon precision
51
+ solutions = find_pareto_front(data, epsilon=0.01)
52
+
53
+ for sol in solutions:
54
+ print(f"Design: {sol.design_vector}, Objectives: {sol.target_vector}")
55
+ ```
56
+
57
+ ## API
58
+
59
+ ### `find_pareto_front(data, epsilon)`
60
+
61
+ Finds all Pareto-optimal solutions for a multi-objective optimization problem.
62
+
63
+ **Parameters:**
64
+ - `data` (List[List[List[float]]]): A 3D list where:
65
+ - First dimension: decision points
66
+ - Second dimension: options for each decision point
67
+ - Third dimension: objective variable values (e.g., [cost, time, quality])
68
+ - `epsilon` (float): Precision parameter for epsilon-dominance pruning
69
+
70
+ (Note: the context in which this problem originated is forestry land-use, so decision points are called `stands` in the code, and options are called `scenarios`).
71
+
72
+ **Returns:**
73
+ - List of `ParetoFrontSolution` objects, each with:
74
+ - `design_vector` (List[int]): Which scenario to pick for each stand
75
+ - `target_vector` (List[float]): The summed objective values for that design
76
+
77
+ **Raises:**
78
+ - `ValueError`: If data is empty, has only one stand, or has inconsistent dimensions
79
+
80
+ ## Algorithm
81
+
82
+ The algorithm uses dynamic programming to efficiently find the Pareto front:
83
+
84
+ 1. **Data Validation**: Validates input structure and dimensions
85
+ 2. **Shift to Positive Space**: Shifts all objective values to positive space for numerical stability
86
+ 3. **DP Tree Construction**: Builds partial Pareto fronts iteratively for each stand
87
+ 4. **Epsilon-Dominance Pruning**: Uses logarithmic binning to prune dominated solutions
88
+ 5. **Solution Reconstruction**: Traces back through parent pointers to reconstruct full solutions
89
+
90
+ ## Requirements
91
+
92
+ - Python >= 3.9
93
+ - Compatible with CPython and PyPy
94
+
95
+ ## License
96
+
97
+ MIT License - see [LICENSE](LICENSE) file for details.
98
+
99
+ ## Repository
100
+
101
+ https://github.com/Txart/pareto_dp
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.13,<2.0"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "pareto_dp"
7
+ description = "Multi-objective optimization using dynamic programming to find Pareto-optimal solutions"
8
+ requires-python = ">=3.9"
9
+ authors = [
10
+ {name = "txart"},
11
+ ]
12
+ license = {text = "MIT"}
13
+ keywords = ["optimization", "pareto", "multi-objective", "dynamic-programming"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Rust",
18
+ "Programming Language :: Python :: Implementation :: CPython",
19
+ "Programming Language :: Python :: Implementation :: PyPy",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Topic :: Scientific/Engineering :: Mathematics",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ ]
25
+ urls = {Homepage = "https://github.com/Txart/pareto_dp", Repository = "https://github.com/Txart/pareto_dp"}
26
+ readme = "README.md"
27
+ dynamic = ["version"]
28
+ dependencies = [
29
+ "ruff>=0.15.13",
30
+ "ty>=0.0.35",
31
+ ]
32
+
33
+ [tool.maturin]
34
+ python-source = "python"
@@ -0,0 +1,3 @@
1
+ from .pareto_dp import *
2
+
3
+ __all__ = ["ParetoFrontSolution", "find_pareto_front"]
@@ -0,0 +1,6 @@
1
+ class ParetoFrontSolution:
2
+ design_vector: list[int]
3
+ target_vector: list[float]
4
+ def __init__(self) -> None: ...
5
+
6
+ def find_pareto_front(data: list[list[list[float]]], epsilon: float) -> list[ParetoFrontSolution]: ...
File without changes
@@ -0,0 +1,10 @@
1
+ import pareto_dp
2
+
3
+ results = pareto_dp.find_pareto_front(
4
+ data=[[[3.0, 2.1], [2.0, 1.0]], [[1.0, 1.0], [2.0, 0.5]]], epsilon=0.001
5
+ )
6
+
7
+ for result in results:
8
+ print(
9
+ f"design vector = {result.design_vector}\ntarget vector = {result.target_vector}\n"
10
+ )