Interface CostModel

All Known Implementing Classes:
RateCardCostModel
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CostModel
Prices a portfolio. The one place cost comes from: the cost objective, the budget constraint, the reports and the deployment plan all read the same PortfolioCost, so they cannot disagree. Implementations may call rate cards, and should cache: a solver prices many portfolios that share metros.
  • Method Details

    • price

      PortfolioCost price(MetroPortfolio portfolio, DesignContext context)
      Parameters:
      portfolio - the candidate design
      context - the facts of this run
      Returns:
      every priced line with its source and range, and what could not be priced
    • prepare

      default void prepare(Collection<MetroPortfolio> portfolios, DesignContext context)
      Prices ahead of time what price(MetroPortfolio, DesignContext) will need for these portfolios, so later calls answer from memory. A solver calls it once per run with every portfolio it is about to price (never one a constraint has already rejected). It must not change any result: an implementation may batch or parallelise independent lookups, but price(MetroPortfolio, DesignContext) must return what it would have returned without it. The default does nothing.
      Parameters:
      portfolios - the portfolios about to be priced, in a deterministic order
      context - the facts of this run