jasonrhansen / cut-optimizer-2d

2D Cut Optimizer
Apache License 2.0
21 stars 11 forks source link

Incorrect ResultCutPiece quantity on second StockPiece for case "pighetti_d" #16

Closed lukepighetti closed 2 years ago

lukepighetti commented 2 years ago

On rev e382e13 if I try to span 6 CutPieces over 2 StockPieces, I end up with 8 CutPieces

Case

fn case_pighetti_d() {
    let case_name = "pighetti_d";

    let plywood = StockPiece {
        quantity: Some(2),
        length: 2440,
        width: 1220,
        pattern_direction: PatternDirection::ParallelToLength,
        price: 130,
    };

    let cut_piece_a = CutPiece {
        quantity: 6,
        external_id: Some(1),
        length: 814,
        width: 465,
        can_rotate: false,
        pattern_direction: PatternDirection::ParallelToLength,
    };

    let mut optimizer = Optimizer::new();
    optimizer.add_stock_piece(plywood);
    optimizer.add_cut_piece(cut_piece_a);
    optimizer.set_cut_width(2);

    optimizer.optimize_and_print(case_name);
}

Expected Result

Actual Result

jasonrhansen commented 2 years ago

Looks like there's still an issue with stock piece quantities. If I set the quantity to None, it gives the correct result.

jasonrhansen commented 2 years ago

@lukepighetti I figured out what was going on. Let me know if you notice any other strange behavior.

lukepighetti commented 2 years ago

On version 4.0.1 this is resolved, thanks!