Skip to content

Kerf, Cutting Process and Coils ​

After your first cutting plan, change kerf, cutting trees and coil supply one at a time. Regenerate patterns; changing a report's process label is insufficient.

1. Understand Kerf with One Cut ​

Cut a 10 × 6 m region vertically at x=4 m with 0.5 m kerf. The left region is 4 m wide; the right starts at x=4.5 m and is 5.5 m wide. Conservation is 4 + 0.5 + 5.5 = 10. Two children still totaling 10 m have not removed kerf.

The next section constructs both products and their demands explicitly. Validate manufacturing process together with geometry.

Exercise: request one 4 × 6 m and one 6 × 6 m product without rotation. One 10×6 sheet fits at zero kerf; positive kerf invalidates that layout. Regenerate and check whether the application uses other supply/more sheets or correctly returns no deliverable.

2. Change Freeform to Guillotine ​

Construct Products, Kerf and Process ​

Build a 10×6 m sheet and one each of a=4×6 m and b=6×6 m, explicitly forbidding rotation. Use makeProblem(0.5) / make_problem(0.5) for positive kerf, or 0.0 for the baseline.

kt
val sheet = Material2(materialId2Of("S"), "sheet", m(10.0), m(6.0))
val a = Product2(productId2Of("a"), "a", m(4.0), m(6.0), allowRotate = false)
val b = Product2(productId2Of("b"), "b", m(6.0), m(6.0), allowRotate = false)
return Csp2dProblem(materials = listOf(sheet), products = listOf(a, b),
    demands = listOf(a, b).map { ProductDemand2(it, DemandValue2.Amount(UInt64.one)) },
    kerf = m(kerf), process = CuttingProcess2.GuillotineTwoStage)
rs
let sheet = Material2::sheet(material_id2("S"), "sheet", m(10.0), m(6.0), 2);
let a = Product2::new(product_id2("a"), "a", m(4.0), m(6.0)).with_allow_rotate(false);
let b = Product2::new(product_id2("b"), "b", m(6.0), m(6.0)).with_allow_rotate(false);
Csp2dProblem::new(vec![sheet], vec![a.clone(), b.clone()],
    vec![ProductDemand2::amount(a, 1), ProductDemand2::amount(b, 1)], m(kerf))
    .with_process(CuttingProcess2::GuillotineTwoStage)
Required informationReason
Region position and dimensionsEvery child must derive from the actual parent
Cut orientation, position and kerfDetermine child boundaries and removed material
Process stagesTwo/three stages are not arbitrary-depth cutting
Product leaves and coordinatesPlacement must agree with leaf regions

Do not only check that a tree exists: products must match leaf regions, cuts must conserve material and the maximum stage must respect the process limit. Reuse the backend configuration from the first lesson.

Update generation, pattern validation and acceptance together. No two-stage candidate does not prove impossibility under every process; report the selected process and search scope.

makeProblem sets GuillotineTwoStage; change process and kerf at input construction, then regenerate patterns.

3. Complete the Pool and Bound Generation ​

Add a Real Through-Cut Pattern When the Pool Is Insufficient ​

The current default Rust shelf generator returns NoCandidatePlan in this tight-height, positive-kerf case: its row pitch reserves kerf and fails to generate these full-height products. That does not disprove cutting a and b on separate sheets. The specialized templates below place a through cut at each product’s right edge, derive remnants through Region2.cut, and validate geometry and tree before master registration.

kt
val region = Region2(zero, zero, material.width, material.height!!)
return problem.products.map { product ->
    val (left, right) = region.cut(CutOrientation2.Vertical, product.width, problem.kerf).getOrThrow()
    val tree = CutTree2.Split2(region, CutLine2(CutOrientation2.Vertical, product.width),
        CutTree2.Leaf2(left, pieceId = product.id.value), CutTree2.Leaf2(right))
    val placement = Placement2(rectangleShape2(product.width, product.height).getOrThrow(),
        QuantityPoint2(zero, zero), itemId = product.id.value)
    val pattern = Pattern2(patternId2Of("cut-${product.id.value}"), material, region, listOf(placement),
        cutTree = tree, process = problem.process)
    pattern.validate(problem.kerf).getOrThrow()
    cuttingPlan2Of(planId2Of("plan-${product.id.value}"), pattern, problem.productsById()).getOrThrow()
}
rs
let region = Region2::new(m(0.0), m(0.0), material.width.clone(), material.height.clone().unwrap());
problem.products.iter().map(|product| {
    let (left, right) = region.cut(CutOrientation2::Vertical, &product.width, &problem.kerf)?;
    let tree = CutTree2::cut(CutLine2 { orientation: CutOrientation2::Vertical, position: product.width.clone(), stage: 1 },
        region.clone(), problem.kerf.clone(), CutTree2::leaf(left, Some(product.id.to_string())), CutTree2::leaf(right, None))?;
    let placement = Placement2::new(PackingShape2::Rectangle(rectangle_shape2(product.width.clone(), product.height.clone())?),
        QuantityPoint2 { x: m(0.0), y: m(0.0) }).with_item_id(product.id.to_string());
    let pattern = Pattern2::new(pattern_id2(format!("cut-{}", product.id)), material.clone(), region.clone(),
        vec![placement], problem.process).with_cut_tree(tree);
    pattern.validate(&problem.kerf)?;
    Ok(CuttingPlan2::from_pattern(pattern))
}).collect()

Section 4’s solveRestricted(solver, kerf = 0.5) / solve_restricted(master_solver, 0.5) sends these two patterns directly to the domain master with an application-supplied backend. Pass 0.0 for the zero-kerf no-mixing exercise. These templates only cover this lesson’s full-height parts with positive right-side remnants, not general nesting.

Switch Entry and Bound Generation ​

For the kerf scenario without the custom no-mixing rule, compare once-generated and incrementally appended pools on the same input. Candidate limits bound patterns per round; iteration limits bound rounds.

kt
suspend fun runBusiness(solver: ColumnGenerationSolver) {
    val problem = makeProblem(kerf = 0.5).copy(config = Csp2dConfiguration(maxCandidatesPerIteration = 24, iterationLimit = 8))
    val milp = Csp2dMilp(solver).solve(problem)
    val cg = Csp2dColumnGeneration(solver).solve(problem)
    println("milp=$milp, cg=$cg")
}
rs
pub fn run_business() -> Ret<()> {
    let problem = make_problem(0.5).with_configuration(Csp2dConfiguration {
        max_candidates_per_iteration: 24, iteration_limit: 8, ..Default::default() });
    let milp = Csp2dSolvers::new().solve_milp(problem.clone())?;
    let cg = Csp2dSolvers::new().solve_column_generation(problem)?;
    println!("milp={:?}, cg={:?}", milp.termination, cg.termination);
    Ok(())
}

Rust Execution Semantics

These Rust examples use default heuristic paths; method names, final statuses and a returned solution do not establish native optimization. CSP2D accepts a master solver, but its high-level path may fall back; call the domain master directly when fallback is forbidden, as in solve_restricted.

4. Apply No-Mixing Rules and Define Waste ​

Minimal Extension: One Product per Pattern ​

Implement PatternGenerator2 by calling default process generation separately for each product to produce single-product alternatives, then reject mixed-product patterns. Wrap the entire Kotlin PatternGenerationContext2, not only one internal generator, so replayed patterns are checked too.

kt
class NoMixedProducts(private val delegate: PatternGenerator2<FltX>) : PatternGenerator2<FltX> {
    override fun generate(request: PatternGenerationRequest2<FltX>): Ret<List<PatternGenerationResult2<FltX>>> {
        val candidates = ArrayList<PatternGenerationResult2<FltX>>()
        // Generate alternatives as well as rejecting mixed historical patterns.
        for (product in request.products) {
            when (val result = delegate.generate(request.copy(products = listOf(product)))) {
                is Ok -> candidates.addAll(result.value.filter { it.pattern.productAmounts().size <= 1 })
                is Failed -> return Failed(result.error)
                is Fatal -> return Fatal(result.errors)
            }
        }
        return Ok(candidates)
    }
}
rs
#[derive(Debug)]
struct NoMixedProducts;
impl PatternGenerator2<f64, Meter> for NoMixedProducts {
    fn name(&self) -> &str { "no-mixed-products" }
    fn generate(&self, request: &PatternGenerationRequest2<f64, Meter>) -> Vec<Pattern2<f64, Meter>> {
        request.products.iter().flat_map(|product| {
            let mut single = request.clone();
            single.products = vec![product.clone()];
            ShelfPatternGenerator2::new().generate(&single)
        }).filter(|p| p.product_amounts().len() <= 1).collect()
    }
}

Injection point:

kt
val generator: PatternGenerator2<FltX> = NoMixedProducts(PatternGenerationContext2())
val request = PatternGenerationRequest2(material = problem.materials.first(),
    products = problem.products.map { it to UInt64.one }, kerf = problem.kerf, process = problem.process)
return when (val generated = generator.generate(request)) {
    is Ok -> {
        val plans = ArrayList<CuttingPlan2<FltX>>()
        for ((index, result) in generated.value.withIndex()) {
            when (val plan = cuttingPlan2Of(planId2Of("restricted-$index"), result.pattern, problem.productsById())) {
                is Ok -> plans.add(plan.value)
                is Failed -> return Failed(plan.error)
                is Fatal -> return Fatal(plan.errors)
            }
        }
        Ok(plans)
    }
    is Failed -> Failed(generated.error)
    is Fatal -> Fatal(generated.errors)
}
rs
let generator: Box<dyn PatternGenerator2<f64, Meter>> = Box::new(NoMixedProducts);
let request = PatternGenerationRequest2::new(problem.materials[0].clone(),
    problem.products.iter().map(|p| (p.clone(), 1)).collect(), problem.kerf).with_process(problem.process);
request.validate()?;
Ok(generator.generate(&request).into_iter().map(CuttingPlan2::from_pattern).collect())

High-Level Extension Boundary

Neither Kotlin high-level solver nor Rust Csp2dSolvers accepts a custom generator. restrictedPlans only produces a restricted pool; calling a normal high-level entry would regenerate patterns and bypass this restriction. The following code sends the restricted pool directly to the domain master and backend. This minimal assembly covers the lesson’s fixed-sheet piece demand; add machine, overproduction and coil pipelines as needed.

kt
val model = LinearMetaModel<FltX>(name = "restricted-csp2d", objectCategory = ObjectCategory.Minimum,
    configuration = MetaModelConfiguration(), converter = IntoValue.fromConverter(FltX))
val assignment = Csp2dPatternAssignment(plans)
assignment.register(model, problem.totalPieceDemand()).getOrThrow()
Csp2dDemandConstraint(plans, assignment, problem.demands).invoke(model).getOrThrow()
Csp2dMaterialAvailabilityConstraint(plans, assignment, problem.materials).invoke(model).getOrThrow()
Csp2dUsageObjective(plans, assignment, { FltX.one }).invoke(model).getOrThrow()
val solved = solver.solveMILPAs("restricted-csp2d", model).getOrThrow()
model.setSolution(solved.values)
plans.forEachIndexed { index, plan ->
    val count = model.tokens.find(assignment.usage[index])?.doubleResult ?: error("Missing plan usage")
    println("plan=${plan.id}, usages=$count, per usage=${plan.pattern.productAmounts()}")
}
rs
let plans = if kerf == 0.0 { restricted_plans()? } else { one_cut_plans(kerf)? };
let assignment = Csp2dPatternAssignment::new(plans, 2)?;
let master = Csp2dMasterProblem::new(assignment, problem.master_demands())?;
let solved = solver.solve_master(&master)?;
require_deliverable(&solved)?;
if solved.usage.len() != master.assignment.len() || !master.assignment.covers_all(&solved.usage, &master.demands)
    || solved.usage.iter().any(|u| !u.is_finite() || *u < 0.0 || (u.round() - u).abs() > 1e-7) {
    return Err(ospf_rust_framework_csp2d::infrastructure::error::validation_error("Invalid or incomplete integer usage"));
}
Ok(solved)

Measure Coils by Consumed Length ​

A coil has fixed width, while each plan needs an actual segment length. A pattern consuming 4 m used three times consumes 12 m, not “one pattern” or “3 m”.

Start with sheet count for fixed sheets and consumed length for coils. Mixed materials, widths or prices require an explicit common objective; adding sheets to meters is not meaningful.

Distinguish net product area, consumed area, kerf loss and remaining regions. Reusable remnants require business width/height/process thresholds; not every blank region returns to inventory. Do not claim the framework exposes every decomposition without checking actual fields.

5. Application Acceptance ​

  1. Contributions times usage satisfy demand without exceeding configured surplus allowances.
  2. Material use respects stock; segment length times usage matches total coil length.
  3. Coordinates obey bounds and non-overlap, with consistent kerf in generation and validation.
  4. Guillotine trees satisfy stage, orientation, child-region and leaf rules.
  5. Preserve actual heuristic/native execution and termination semantics; no added pattern is not automatically certified LP pricing convergence.

Retain input, process configuration and diagnostics using the integration guide. For placement without manufacturing output, compare BPP2D.

Repository regression commands live in Verification. Complete the business input, call and result checks before using them.

Complete Application Sources ​

The snippets come from the same source files. Keep imports and helpers, then call runBusiness / run_business from your application. Constructors can also be used independently for input validation. Reuse first-lesson backend dependencies; these functions do not create an implicit backend.

Full Kotlin / Rust sources
kt
package docs.examples.csp2d.business

import fuookami.ospf.kotlin.math.algebra.number.*
import fuookami.ospf.kotlin.quantities.quantity.times
import fuookami.ospf.kotlin.quantities.unit.Meter
import fuookami.ospf.kotlin.framework.solver.ColumnGenerationSolver
import fuookami.ospf.kotlin.framework.csp2d.application.model.*
import fuookami.ospf.kotlin.framework.csp2d.application.service.*
import fuookami.ospf.kotlin.framework.csp2d.domain.material.model.*
import fuookami.ospf.kotlin.framework.csp2d.domain.pattern_generation.*
import fuookami.ospf.kotlin.framework.csp2d.domain.produce.*
import fuookami.ospf.kotlin.framework.csp2d.infrastructure.*
import fuookami.ospf.kotlin.framework.geometry2d.*
import fuookami.ospf.kotlin.core.model.basic.ObjectCategory
import fuookami.ospf.kotlin.core.model.mechanism.*
import fuookami.ospf.kotlin.core.solver.value.IntoValue
import fuookami.ospf.kotlin.utils.functional.*

fun makeProblem(kerf: Double = 0.0): Csp2dProblem {
    fun m(value: Double) = FltX(value) * Meter
    // #region input
    val sheet = Material2(materialId2Of("S"), "sheet", m(10.0), m(6.0))
    val a = Product2(productId2Of("a"), "a", m(4.0), m(6.0), allowRotate = false)
    val b = Product2(productId2Of("b"), "b", m(6.0), m(6.0), allowRotate = false)
    return Csp2dProblem(materials = listOf(sheet), products = listOf(a, b),
        demands = listOf(a, b).map { ProductDemand2(it, DemandValue2.Amount(UInt64.one)) },
        kerf = m(kerf), process = CuttingProcess2.GuillotineTwoStage)
    // #endregion input
}

// #region rule
class NoMixedProducts(private val delegate: PatternGenerator2<FltX>) : PatternGenerator2<FltX> {
    override fun generate(request: PatternGenerationRequest2<FltX>): Ret<List<PatternGenerationResult2<FltX>>> {
        val candidates = ArrayList<PatternGenerationResult2<FltX>>()
        // Generate alternatives as well as rejecting mixed historical patterns.
        for (product in request.products) {
            when (val result = delegate.generate(request.copy(products = listOf(product)))) {
                is Ok -> candidates.addAll(result.value.filter { it.pattern.productAmounts().size <= 1 })
                is Failed -> return Failed(result.error)
                is Fatal -> return Fatal(result.errors)
            }
        }
        return Ok(candidates)
    }
}
// #endregion rule

// Domain generation seam: the high-level solvers do not accept this generator.
fun restrictedPlans(): Ret<List<CuttingPlan2<FltX>>> {
    val problem = makeProblem()
    // #region injection
    val generator: PatternGenerator2<FltX> = NoMixedProducts(PatternGenerationContext2())
    val request = PatternGenerationRequest2(material = problem.materials.first(),
        products = problem.products.map { it to UInt64.one }, kerf = problem.kerf, process = problem.process)
    return when (val generated = generator.generate(request)) {
        is Ok -> {
            val plans = ArrayList<CuttingPlan2<FltX>>()
            for ((index, result) in generated.value.withIndex()) {
                when (val plan = cuttingPlan2Of(planId2Of("restricted-$index"), result.pattern, problem.productsById())) {
                    is Ok -> plans.add(plan.value)
                    is Failed -> return Failed(plan.error)
                    is Fatal -> return Fatal(plan.errors)
                }
            }
            Ok(plans)
        }
        is Failed -> Failed(generated.error)
        is Fatal -> Fatal(generated.errors)
    }
    // #endregion injection
}

private fun <T> Ret<T>.getOrThrow(): T = when (this) {
    is Ok -> value
    is Failed -> error(error.message)
    is Fatal -> error(errors.joinToString { it.message })
}

// Specialized one-through-cut templates for this lesson's full-height products.
fun oneCutPlans(kerf: Double = 0.5): List<CuttingPlan2<FltX>> {
    val problem = makeProblem(kerf)
    val material = problem.materials.first()
    val zero = FltX.zero * Meter
    // #region cut
    val region = Region2(zero, zero, material.width, material.height!!)
    return problem.products.map { product ->
        val (left, right) = region.cut(CutOrientation2.Vertical, product.width, problem.kerf).getOrThrow()
        val tree = CutTree2.Split2(region, CutLine2(CutOrientation2.Vertical, product.width),
            CutTree2.Leaf2(left, pieceId = product.id.value), CutTree2.Leaf2(right))
        val placement = Placement2(rectangleShape2(product.width, product.height).getOrThrow(),
            QuantityPoint2(zero, zero), itemId = product.id.value)
        val pattern = Pattern2(patternId2Of("cut-${product.id.value}"), material, region, listOf(placement),
            cutTree = tree, process = problem.process)
        pattern.validate(problem.kerf).getOrThrow()
        cuttingPlan2Of(planId2Of("plan-${product.id.value}"), pattern, problem.productsById()).getOrThrow()
    }
    // #endregion cut
}

suspend fun solveRestricted(solver: ColumnGenerationSolver, kerf: Double = 0.0) {
    val problem = makeProblem(kerf)
    val plans = if (kerf == 0.0) restrictedPlans().getOrThrow() else oneCutPlans(kerf)
    // #region master
    val model = LinearMetaModel<FltX>(name = "restricted-csp2d", objectCategory = ObjectCategory.Minimum,
        configuration = MetaModelConfiguration(), converter = IntoValue.fromConverter(FltX))
    val assignment = Csp2dPatternAssignment(plans)
    assignment.register(model, problem.totalPieceDemand()).getOrThrow()
    Csp2dDemandConstraint(plans, assignment, problem.demands).invoke(model).getOrThrow()
    Csp2dMaterialAvailabilityConstraint(plans, assignment, problem.materials).invoke(model).getOrThrow()
    Csp2dUsageObjective(plans, assignment, { FltX.one }).invoke(model).getOrThrow()
    val solved = solver.solveMILPAs("restricted-csp2d", model).getOrThrow()
    model.setSolution(solved.values)
    plans.forEachIndexed { index, plan ->
        val count = model.tokens.find(assignment.usage[index])?.doubleResult ?: error("Missing plan usage")
        println("plan=${plan.id}, usages=$count, per usage=${plan.pattern.productAmounts()}")
    }
    // #endregion master
}

// #region entry
suspend fun runBusiness(solver: ColumnGenerationSolver) {
    val problem = makeProblem(kerf = 0.5).copy(config = Csp2dConfiguration(maxCandidatesPerIteration = 24, iterationLimit = 8))
    val milp = Csp2dMilp(solver).solve(problem)
    val cg = Csp2dColumnGeneration(solver).solve(problem)
    println("milp=$milp, cg=$cg")
}
// #endregion entry
rs
use ospf_rust_base::error::Ret;
use ospf_rust_quantities::{Quantity, unit::Meter};
use ospf_rust_framework_csp2d::application::{Csp2dProblem, Csp2dConfiguration, Csp2dSolvers};
use ospf_rust_framework_csp2d::domain::{material::*, pattern_generation::*};
use ospf_rust_framework_csp2d::infrastructure::cutting_process::CuttingProcess2;
use ospf_rust_framework_csp2d::application::master_solver::{Csp2dMasterSolver, Csp2dMasterSolveResult, require_deliverable};
use ospf_rust_framework_csp2d::domain::produce::{Csp2dMasterProblem, Csp2dPatternAssignment};
use ospf_rust_framework_csp2d::infrastructure::{region::{Region2, CutOrientation2}, cut_tree::{CutTree2, CutLine2}};
use ospf_rust_framework_geometry2d::{Placement2, QuantityPoint2, PackingShape2, rectangle_shape2};

pub fn make_problem(kerf: f64) -> Csp2dProblem {
    let m = |value| Quantity::<f64, Meter>::new_ct(value);
    // #region input
    let sheet = Material2::sheet(material_id2("S"), "sheet", m(10.0), m(6.0), 2);
    let a = Product2::new(product_id2("a"), "a", m(4.0), m(6.0)).with_allow_rotate(false);
    let b = Product2::new(product_id2("b"), "b", m(6.0), m(6.0)).with_allow_rotate(false);
    Csp2dProblem::new(vec![sheet], vec![a.clone(), b.clone()],
        vec![ProductDemand2::amount(a, 1), ProductDemand2::amount(b, 1)], m(kerf))
        .with_process(CuttingProcess2::GuillotineTwoStage)
    // #endregion input
}

// Specialized one-through-cut templates for this lesson's full-height products.
pub fn one_cut_plans(kerf: f64) -> Ret<Vec<CuttingPlan2<f64, Meter>>> {
    let problem = make_problem(kerf);
    let material = problem.materials[0].clone();
    let m = |value| Quantity::<f64, Meter>::new_ct(value);
    // #region cut
    let region = Region2::new(m(0.0), m(0.0), material.width.clone(), material.height.clone().unwrap());
    problem.products.iter().map(|product| {
        let (left, right) = region.cut(CutOrientation2::Vertical, &product.width, &problem.kerf)?;
        let tree = CutTree2::cut(CutLine2 { orientation: CutOrientation2::Vertical, position: product.width.clone(), stage: 1 },
            region.clone(), problem.kerf.clone(), CutTree2::leaf(left, Some(product.id.to_string())), CutTree2::leaf(right, None))?;
        let placement = Placement2::new(PackingShape2::Rectangle(rectangle_shape2(product.width.clone(), product.height.clone())?),
            QuantityPoint2 { x: m(0.0), y: m(0.0) }).with_item_id(product.id.to_string());
        let pattern = Pattern2::new(pattern_id2(format!("cut-{}", product.id)), material.clone(), region.clone(),
            vec![placement], problem.process).with_cut_tree(tree);
        pattern.validate(&problem.kerf)?;
        Ok(CuttingPlan2::from_pattern(pattern))
    }).collect()
    // #endregion cut
}

pub fn solve_restricted(solver: &dyn Csp2dMasterSolver, kerf: f64) -> Ret<Csp2dMasterSolveResult> {
    let problem = make_problem(kerf);
    // #region master
    let plans = if kerf == 0.0 { restricted_plans()? } else { one_cut_plans(kerf)? };
    let assignment = Csp2dPatternAssignment::new(plans, 2)?;
    let master = Csp2dMasterProblem::new(assignment, problem.master_demands())?;
    let solved = solver.solve_master(&master)?;
    require_deliverable(&solved)?;
    if solved.usage.len() != master.assignment.len() || !master.assignment.covers_all(&solved.usage, &master.demands)
        || solved.usage.iter().any(|u| !u.is_finite() || *u < 0.0 || (u.round() - u).abs() > 1e-7) {
        return Err(ospf_rust_framework_csp2d::infrastructure::error::validation_error("Invalid or incomplete integer usage"));
    }
    Ok(solved)
    // #endregion master
}

// #region rule
#[derive(Debug)]
struct NoMixedProducts;
impl PatternGenerator2<f64, Meter> for NoMixedProducts {
    fn name(&self) -> &str { "no-mixed-products" }
    fn generate(&self, request: &PatternGenerationRequest2<f64, Meter>) -> Vec<Pattern2<f64, Meter>> {
        request.products.iter().flat_map(|product| {
            let mut single = request.clone();
            single.products = vec![product.clone()];
            ShelfPatternGenerator2::new().generate(&single)
        }).filter(|p| p.product_amounts().len() <= 1).collect()
    }
}
// #endregion rule

// Domain generation seam; no high-level generator injection is available.
pub fn restricted_plans() -> Ret<Vec<CuttingPlan2<f64, Meter>>> {
    let problem = make_problem(0.0);
    // #region injection
    let generator: Box<dyn PatternGenerator2<f64, Meter>> = Box::new(NoMixedProducts);
    let request = PatternGenerationRequest2::new(problem.materials[0].clone(),
        problem.products.iter().map(|p| (p.clone(), 1)).collect(), problem.kerf).with_process(problem.process);
    request.validate()?;
    Ok(generator.generate(&request).into_iter().map(CuttingPlan2::from_pattern).collect())
    // #endregion injection
}

// #region entry
pub fn run_business() -> Ret<()> {
    let problem = make_problem(0.5).with_configuration(Csp2dConfiguration {
        max_candidates_per_iteration: 24, iteration_limit: 8, ..Default::default() });
    let milp = Csp2dSolvers::new().solve_milp(problem.clone())?;
    let cg = Csp2dSolvers::new().solve_column_generation(problem)?;
    println!("milp={:?}, cg={:?}", milp.termination, cg.termination);
    Ok(())
}
// #endregion entry