MCPcopy Create free account
hub / github.com/Open-Quant/openquant / cardinality

Method cardinality

crates/openquant/src/combinatorial_optimization.rs:64–72  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

62 }
63
64 fn cardinality(self) -> Result<usize, CombinatorialOptimizationError> {
65 self.validate()?;
66 let span = i128::from(self.upper) - i128::from(self.lower);
67 let step = i128::from(self.step);
68 let count = span / step + 1;
69 usize::try_from(count).map_err(|_| {
70 CombinatorialOptimizationError::InvalidInput("variable cardinality does not fit usize")
71 })
72 }
73
74 fn values(self) -> Result<Vec<i64>, CombinatorialOptimizationError> {
75 self.validate()?;

Callers 2

valuesMethod · 0.80
decision_space_sizeMethod · 0.80

Calls 1

validateMethod · 0.45

Tested by

no test coverage detected