| Crates.io | super_fair_division |
| lib.rs | super_fair_division |
| version | 0.1.0 |
| created_at | 2025-04-18 11:26:50.943939+00 |
| updated_at | 2025-04-18 11:26:50.943939+00 |
| description | A library for fair division algorithms |
| homepage | |
| repository | https://github.com/iunknow588/super_fair_division |
| max_upload_size | |
| id | 1639242 |
| size | 32,690,860 |
A Rust library for fair division algorithms.
超公平分配是一种对于不可分割的共享物品的分配处理程序. 出价最高的参与者会得到该不可分割的物品,其他参与者按照物品的主观估值得到对应的补偿. 该分割模型是基于公平核的分配模式. 其中,公平核是所有参与者应该得到的主观公平值,其大小仅仅由参与者自己的报价得到. 公平核的计算是反策略勾结的,仅仅由参与者自己的主观偏好决定.
Add this to your Cargo.toml:
[dependencies]
super_fair_division = "0.1.0"
use super_fair_division::calculate_fair_division_equal_weights;
fn main() {
let values = vec![100, 200, 300, 400, 500];
match calculate_fair_division_equal_weights(&values) {
Ok(allocation) => println!("Fair division allocation: {:?}", allocation),
Err(err) => eprintln!("Error calculating fair division: {:?}", err),
}
}
use super_fair_division::calculate_fair_division_weighted;
fn main() {
let values = vec![100, 200, 300, 400, 500];
let weights = vec![1, 2, 3, 4, 5]; // 权重比例为 1:2:3:4:5
match calculate_fair_division_weighted(&values, &weights) {
Ok(allocation) => println!("Weighted fair division allocation: {:?}", allocation),
Err(err) => eprintln!("Error calculating weighted fair division: {:?}", err),
}
}
See the examples directory for more usage examples.
For detailed documentation, visit docs.rs/super_fair_division.
Run the tests with:
cargo test
Run the benchmarks with:
cargo bench
This project is licensed under the MIT License - see the LICENSE-MIT file for details.
The source code is available on GitHub.
Contributions are welcome! Please feel free to submit a Pull Request.