Record Class CostComparability
java.lang.Object
java.lang.Record
com.eqixiac.equinix.design.cost.CostComparability
- Record Components:
currency- the currency costs must be comparable in (commercial.currency)costWeight- the weight the spec gives the cost objectivemissingRates- the currencies whose rate tocurrencyis missing, across all feasible designsaffected- keys of the feasible designs whose cost is unknown only for want of a ratefeasibleCount- how many feasible designs were examinedcostWithdrawn- whether the rule removed cost from the ranking
public record CostComparability(String currency, double costWeight, SortedSet<String> missingRates, List<String> affected, int feasibleCount, boolean costWithdrawn)
extends Record
Whether the cost of every feasible design can be compared in the spec's currency, and what the
optimiser does when it cannot because an exchange rate is missing. With the built-in
RateCardCostModel every line is converted (CurrencyConverters), so this is a safeguard
for plug-in cost models.
The rule
Why withdraw rather than rank: the weighted score gives an unknown objective no points, so a design priced in GBP (London) loses the whole cost weight to a design priced in USD (Istanbul) however cheap it really is. That is a ranking decided by which metros the price API happens to quote in USD, not by cost. Withdrawing cost for every design keeps the comparison fair until the caller supplies the rates; each design's priced lines are still reported, and the recommendation is stated to be blocked on cost.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaffected()Returns the value of theaffectedrecord component.static CostComparabilityassess(Collection<MetroPortfolio> feasible, DesignContext context, double costWeight) Assesses a set of feasible designs.doubleReturns the value of thecostWeightrecord component.booleanReturns the value of thecostWithdrawnrecord component.currency()Returns the value of thecurrencyrecord component.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of thefeasibleCountrecord component.booleanflags(MetroPortfolio portfolio) final inthashCode()Returns a hash code value for this object.headline()booleanReturns the value of themissingRatesrecord component.missingRates(PortfolioCost cost, String currency) final StringtoString()Returns a string representation of this record class.static booleanunknownOnlyForExchangeRate(PortfolioCost cost, String currency) withdrawCost(List<Objective> objectives) The objectives with cost replaced by a withdrawn stand-in that reports every design's cost as unknown (its explanation keeps the design's own cost statement), so cost neither raises nor lowers any score.
-
Field Details
-
RULE
-
-
Constructor Details
-
CostComparability
-
-
Method Details
-
assess
public static CostComparability assess(Collection<MetroPortfolio> feasible, DesignContext context, double costWeight) Assesses a set of feasible designs.- Parameters:
feasible- every feasible portfoliocontext- the run's facts (spec and cost model)costWeight- the weight of the cost objective- Returns:
- the assessment;
costWithdrawnis true when the rule applies
-
missingRates
- Parameters:
cost- a priced portfoliocurrency- the comparison currency- Returns:
- every line currency other than
currency, sorted
-
unknownOnlyForExchangeRate
- Parameters:
cost- a priced portfoliocurrency- the comparison currency- Returns:
truewhen every item is priced but some line is in another currency, so an exchange rate is the only thing standing between the design and a comparable total
-
incomplete
public boolean incomplete()- Returns:
truewhen some feasible design's cost is unknown only for want of a rate
-
flags
- Parameters:
portfolio- a design- Returns:
- whether it is one of the designs whose cost is unknown only for want of a rate
-
headline
- Returns:
- the BLOCKING finding's text, e.g. "cost comparison is incomplete: supply rates for EUR, GBP"
-
withdrawCost
The objectives with cost replaced by a withdrawn stand-in that reports every design's cost as unknown (its explanation keeps the design's own cost statement), so cost neither raises nor lowers any score.- Parameters:
objectives- the run's objectives- Returns:
- the objectives to rank with
-
toMarkdown
- Returns:
- a Markdown section stating the rule's outcome
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
currency
-
costWeight
public double costWeight()Returns the value of thecostWeightrecord component.- Returns:
- the value of the
costWeightrecord component
-
missingRates
Returns the value of themissingRatesrecord component.- Returns:
- the value of the
missingRatesrecord component
-
affected
-
feasibleCount
public int feasibleCount()Returns the value of thefeasibleCountrecord component.- Returns:
- the value of the
feasibleCountrecord component
-
costWithdrawn
public boolean costWithdrawn()Returns the value of thecostWithdrawnrecord component.- Returns:
- the value of the
costWithdrawnrecord component
-