pub struct BendableScore { /* private fields */ }Expand description
A score with a configurable number of hard and soft levels.
Unlike HardSoftScore, the number of levels is determined at runtime.
This is useful when the constraint structure varies between problem instances.
§Examples
use solverforge_core::score::{BendableScore, Score};
// Create a score with 2 hard levels and 3 soft levels
let score = BendableScore::of(vec![-1, -2], vec![-10, -20, -30]);
assert_eq!(score.hard_levels_count(), 2);
assert_eq!(score.soft_levels_count(), 3);
assert!(!score.is_feasible()); // Negative hard scoresImplementations§
Source§impl BendableScore
impl BendableScore
Sourcepub fn of(hard_scores: Vec<i64>, soft_scores: Vec<i64>) -> Self
pub fn of(hard_scores: Vec<i64>, soft_scores: Vec<i64>) -> Self
Creates a new BendableScore with the given hard and soft score vectors.
Sourcepub fn zero_with_levels(hard_levels: usize, soft_levels: usize) -> Self
pub fn zero_with_levels(hard_levels: usize, soft_levels: usize) -> Self
Creates a zero score with the specified number of levels.
Sourcepub fn hard_levels_count(&self) -> usize
pub fn hard_levels_count(&self) -> usize
Returns the number of hard score levels.
Sourcepub fn soft_levels_count(&self) -> usize
pub fn soft_levels_count(&self) -> usize
Returns the number of soft score levels.
Sourcepub fn hard_score(&self, level: usize) -> i64
pub fn hard_score(&self, level: usize) -> i64
Sourcepub fn soft_score(&self, level: usize) -> i64
pub fn soft_score(&self, level: usize) -> i64
Sourcepub fn hard_scores(&self) -> &[i64]
pub fn hard_scores(&self) -> &[i64]
Returns all hard scores as a slice.
Sourcepub fn soft_scores(&self) -> &[i64]
pub fn soft_scores(&self) -> &[i64]
Returns all soft scores as a slice.
Trait Implementations§
Source§impl Add for BendableScore
impl Add for BendableScore
Source§impl Clone for BendableScore
impl Clone for BendableScore
Source§fn clone(&self) -> BendableScore
fn clone(&self) -> BendableScore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BendableScore
impl Debug for BendableScore
Source§impl Default for BendableScore
impl Default for BendableScore
Source§impl Display for BendableScore
impl Display for BendableScore
Source§impl Hash for BendableScore
impl Hash for BendableScore
Source§impl Neg for BendableScore
impl Neg for BendableScore
Source§impl Ord for BendableScore
impl Ord for BendableScore
Source§impl ParseableScore for BendableScore
impl ParseableScore for BendableScore
Source§impl PartialEq for BendableScore
impl PartialEq for BendableScore
Source§impl PartialOrd for BendableScore
impl PartialOrd for BendableScore
Source§impl Score for BendableScore
impl Score for BendableScore
Source§fn is_feasible(&self) -> bool
fn is_feasible(&self) -> bool
Returns true if this score represents a feasible solution. Read more
Source§fn levels_count() -> usize
fn levels_count() -> usize
Returns the number of score levels. Read more
Source§fn from_level_numbers(levels: &[i64]) -> Self
fn from_level_numbers(levels: &[i64]) -> Self
Creates a score from level numbers. Read more
Source§fn compare(&self, other: &Self) -> Ordering
fn compare(&self, other: &Self) -> Ordering
Compares two scores, returning the ordering. Read more
Source§fn is_better_than(&self, other: &Self) -> bool
fn is_better_than(&self, other: &Self) -> bool
Returns true if this score is better than the other score. Read more
Source§fn is_worse_than(&self, other: &Self) -> bool
fn is_worse_than(&self, other: &Self) -> bool
Returns true if this score is worse than the other score.
Source§fn is_equal_to(&self, other: &Self) -> bool
fn is_equal_to(&self, other: &Self) -> bool
Returns true if this score is equal to the other score.
Source§impl Sub for BendableScore
impl Sub for BendableScore
impl Eq for BendableScore
impl StructuralPartialEq for BendableScore
Auto Trait Implementations§
impl Freeze for BendableScore
impl RefUnwindSafe for BendableScore
impl Send for BendableScore
impl Sync for BendableScore
impl Unpin for BendableScore
impl UnwindSafe for BendableScore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more