Deterministic weighted hypergraph bipartitioning with independent validation
python scripts/prepare_package.py
moon version --all
moon test --target native --deny-warn
moon run cmd/main --target native -- --help
moon run cmd/main --target native -- inspect testdata/tiny_optimum.hgr
moon run cmd/main --target native -- partition testdata/tiny_optimum.hgr --output tiny.part --report tiny.json --capacities 3,3 --starts 1
moon run cmd/main --target native -- verify testdata/tiny_optimum.hgr tiny.part --capacities 3,3moon add Ag108/MoonHyperPart@0.1.0
python scripts/consumer.py --registry///|
test "usage/public weighted bipartition" {
let graph = @MoonHyperPart.build(
[1L, 1L, 1L, 1L, 1L, 1L],
[[0, 1, 2], [3, 4, 5], [2, 3]],
[10L, 10L, 1L],
).unwrap()
let options : @MoonHyperPart.Options = {
..@MoonHyperPart.Options::default(),
starts: 1,
}
let result = @MoonHyperPart.partition(graph, [3L, 3L], options~).unwrap()
assert_eq(result.metrics.cut_net, 1L)
let checked = @MoonHyperPart.verify(graph, result.assignment, [3L, 3L]).unwrap()
assert_eq(checked.part_weights, (3L, 3L))
}| 退出码 | 含义 |
|---|---|
| 0 | 成功,partition/verify 已独立验证 |
| 2 | 参数、格式、权重、UTF-8 或输入资源错误 |
| 3 | 可证明的必要条件失败,或预算内未找到可行划分,具体看 code |
| 4 | 外部分区验证失败 |
| 5 | 文件 I/O 或输出路径错误 |
| 6 | 内部一致性检查失败 |
python scripts/examples.py tiny_optimum
python scripts/examples.py weighted_balance
python scripts/examples.py hmetis_roundtrip
python scripts/examples.py bad_input_and_budget
python scripts/examples.py cli_consumer
python scripts/examples.py allmoon run cmd/main --target native --build-only
python scripts/benchmark.py --exe _build/native/debug/build/cmd/main/main.exe --output _build/benchmark.jsonmoon fmt --check
moon check --target native --deny-warn
moon test --target native --deny-warn
moon check --target js --deny-warn
moon test --target js --deny-warn
moon check --target wasm-gc --deny-warn
moon test --target wasm-gc --deny-warn
moon info
moon fmtpub(all) struct Options {
seed : UInt
starts : Int
search_nodes : Int
refinement : RefinementBudget
} derive(Debug)pub struct PartitionResult {
assignment : Array[Int]
metrics : Metrics
initial_cut : Int64
starts_tried : Int
search_nodes : Int
options : Options
refinement : RefineResult
} derive(Debug)fn build(vertex_weights : Array[Int64], edges : Array[Array[Int]], edge_weights : Array[Int64], limits? : Limits) -> Result[Hypergraph, InputError]fn parse_partition(text : StringView, vertex_count : Int, limits? : Limits) -> Result[Array[Int], InputError]fn partition(graph : Hypergraph, capacities : Array[Int64], options? : Options) -> Result[PartitionResult, SolveError]fn partition_text(g : Hypergraph, assignment : Array[Int], capacities : Array[Int64]) -> Result[String, InputError]fn verify(graph : Hypergraph, assignment : Array[Int], capacities : Array[Int64]) -> Result[Metrics, InputError]