(&self, decision: &[i64])
| 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 | |
| 33 | struct ZeroVectorAdapter; |
no test coverage detected