| Crates.io | binpack |
| lib.rs | binpack |
| version | 0.1.0 |
| created_at | 2025-05-14 02:43:35.539703+00 |
| updated_at | 2025-05-14 02:43:35.539703+00 |
| description | solve binpacking problems using Linear Programming |
| homepage | |
| repository | https://github.com/brannondorsey/binpack |
| max_upload_size | |
| id | 1672803 |
| size | 44,675 |
A rust crate for solving binpacking problems using Linear Programming.
use binpack::Problem;
const PROBLEM: &str = r#"
bins:
b1: 100
b2: 40
b3: 10
items:
i1:
quantity: 30
affinity:
soft:
- weight: 1
bins: [b1]
antiAffinity:
hard:
bins: [b3]
i2:
quantity: 110
affinity:
soft:
- weight: 2
bins: [b1]
i3:
quantity: 10
"#;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let problem: Problem = serde_yaml::from_str(PROBLEM)?;
let solution = problem.solve()?;
println!("{}", serde_yaml::to_string(&solution)?);
assert_eq!(serde_yaml::to_string(&solution)?.trim(), SOLUTION.trim());
Ok(())
}
const SOLUTION: &str = r#"
solution:
i1:
b2: 30
i2:
b1: 100
b3: 10
i3:
b2: 10
"#;
binpack is dual-licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.