Interface Constraint

All Known Implementing Classes:
BudgetConstraint, ComplianceZonesConstraint, EveryMetroUsedConstraint, ExcludedMetrosConstraint, ExcludedRegionsConstraint, FailoverGeoZonesConstraint, GeoZonesConstraint, MaxSiteLatencyConstraint, MetroCountConstraint, MinimumRedundancyConstraint, MinSurvivalConstraint, PinnedWorkloadsConstraint, RequiredCloudsConstraint, RequiredMetrosConstraint, RequiredRegionsConstraint, WorkloadLatencyConstraint

public interface Constraint
A hard limit. A portfolio that fails any constraint is never offered, whatever its objectives say. Implementations must be pure functions of their arguments.
  • Method Details

    • id

      String id()
      Returns:
      a stable id, lower_snake_case (for example max_latency)
    • admits

      default boolean admits(MetroFacts metro, DesignContext context)
      Cheap per-metro pruning before portfolios are formed. Return false only when no portfolio containing this metro could ever satisfy the constraint (an excluded metro, a metro outside every allowed zone). The default admits every metro.
      Parameters:
      metro - a candidate metro
      context - the facts of this run
      Returns:
      whether the metro may appear in a portfolio
    • check

      ConstraintVerdict check(MetroPortfolio portfolio, DesignContext context)
      Checks a whole portfolio.
      Parameters:
      portfolio - the candidate design
      context - the facts of this run
      Returns:
      the verdict with its reason
    • usesCost

      default boolean usesCost()
      Whether check(MetroPortfolio, DesignContext) prices the portfolio through DesignContext.costModel(). A solver uses it to price ahead, in one batch, the portfolios that reach a pricing constraint (CostModel.prepare(Collection, DesignContext)); the verdicts are the same either way. The default is false: a pricing constraint that says so is only slower, never wrong.
      Returns:
      true when checking needs prices