Class CostOptimization.Builder

java.lang.Object
software.amazon.smithy.rulesengine.logic.bdd.CostOptimization.Builder
All Implemented Interfaces:
SmithyBuilder<CostOptimization>
Enclosing class:
CostOptimization

public static final class CostOptimization.Builder extends Object implements SmithyBuilder<CostOptimization>
Builder for CostOptimization.
  • Method Details

    • cfg

      public CostOptimization.Builder cfg(Cfg cfg)
      Sets the control flow graph (required).
      Parameters:
      cfg - the CFG
      Returns:
      the builder
    • costModel

      public CostOptimization.Builder costModel(ConditionCostModel costModel)
      Sets the cost model for conditions.
      Parameters:
      costModel - the cost model
      Returns:
      the builder
    • trueProbability

      public CostOptimization.Builder trueProbability(ToDoubleFunction<Condition> trueProbability)
      Sets the function that returns the probability a condition evaluates to true.
      Parameters:
      trueProbability - function returning probability in [0.0, 1.0] (null for uniform 0.5)
      Returns:
      the builder
    • maxAllowedGrowth

      public CostOptimization.Builder maxAllowedGrowth(double maxAllowedGrowth)
      Sets the maximum allowed node growth as a fraction (default 0.08 or 8%).
      Parameters:
      maxAllowedGrowth - maximum growth (0.0 = no growth, 0.1 = 10% growth)
      Returns:
      the builder
    • maxRounds

      public CostOptimization.Builder maxRounds(int maxRounds)
      Sets the maximum number of optimization rounds (default 30).
      Parameters:
      maxRounds - maximum rounds
      Returns:
      the builder
    • topK

      public CostOptimization.Builder topK(int topK)
      Sets the number of hot positions to probe per round (default 50).

      "Hot" positions are conditions ranked by reachProbability × cost. These are conditions that are both frequently evaluated and expensive, making them the best candidates for reordering to reduce expected cost.

      Parameters:
      topK - number of hot positions to consider moving each round
      Returns:
      the builder
    • build

      public CostOptimization build()
      Description copied from interface: SmithyBuilder
      Creates an immutable object that is created from the properties that have been set on the builder.
      Specified by:
      build in interface SmithyBuilder<CostOptimization>
      Returns:
      an instance of T