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

Method evaluate

crates/openquant/tests/combinatorial_optimization.rs:16–30  ·  view source on GitHub ↗
(&self, decision: &[i64])

Source from the content-addressed store, hash-verified

14 }
15
16 fn evaluate(&self, decision: &[i64]) -> Result<f64, CombinatorialOptimizationError> {
17 if decision.len() != 2 {
18 return Err(CombinatorialOptimizationError::DecisionLengthMismatch {
19 expected: 2,
20 found: decision.len(),
21 });
22 }
23 let x = decision[0] as f64;
24 let y = decision[1] as f64;
25 let smooth = -((x - 1.0).powi(2) + (y + 1.0).powi(2));
26 let fixed =
27 if decision[0] != 0 { 1.5 } else { 0.0 } + if decision[1] != 0 { 0.5 } else { 0.0 };
28 let discrete_bonus = if decision[0] * decision[1] == -1 { 3.0 } else { 0.0 };
29 Ok(smooth - fixed + discrete_bonus)
30 }
31}
32
33struct ZeroVectorAdapter;

Callers 3

solve_exactFunction · 0.80
solveMethod · 0.80

Calls 2

evaluate_trading_pathFunction · 0.85
lenMethod · 0.80

Tested by

no test coverage detected