pub struct SimpleScore { /* private fields */ }Expand description
A simple score with a single integer value.
This is the simplest score type, useful when there’s only one type of constraint to optimize.
§Examples
use solverforge_core::{SimpleScore, Score};
let score1 = SimpleScore::of(-5);
let score2 = SimpleScore::of(-3);
assert!(score2 > score1); // -3 is better than -5
assert!(!score1.is_feasible()); // Negative scores are not feasibleImplementations§
Source§impl SimpleScore
impl SimpleScore
Sourcepub const ZERO: SimpleScore
pub const ZERO: SimpleScore
The zero score.
Sourcepub const ONE: SimpleScore
pub const ONE: SimpleScore
A score of 1 (useful for incrementing).
Sourcepub const fn of(score: i64) -> SimpleScore
pub const fn of(score: i64) -> SimpleScore
Creates a new SimpleScore with the given value.
Trait Implementations§
Source§impl Add for SimpleScore
impl Add for SimpleScore
Source§type Output = SimpleScore
type Output = SimpleScore
The resulting type after applying the
+ operator.Source§fn add(self, other: SimpleScore) -> SimpleScore
fn add(self, other: SimpleScore) -> SimpleScore
Performs the
+ operation. Read moreSource§impl Clone for SimpleScore
impl Clone for SimpleScore
Source§fn clone(&self) -> SimpleScore
fn clone(&self) -> SimpleScore
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 SimpleScore
impl Debug for SimpleScore
Source§impl Default for SimpleScore
impl Default for SimpleScore
Source§fn default() -> SimpleScore
fn default() -> SimpleScore
Returns the “default value” for a type. Read more
Source§impl Display for SimpleScore
impl Display for SimpleScore
Source§impl From<i64> for SimpleScore
impl From<i64> for SimpleScore
Source§fn from(score: i64) -> SimpleScore
fn from(score: i64) -> SimpleScore
Converts to this type from the input type.
Source§impl Hash for SimpleScore
impl Hash for SimpleScore
Source§impl Neg for SimpleScore
impl Neg for SimpleScore
Source§type Output = SimpleScore
type Output = SimpleScore
The resulting type after applying the
- operator.Source§fn neg(self) -> SimpleScore
fn neg(self) -> SimpleScore
Performs the unary
- operation. Read moreSource§impl Ord for SimpleScore
impl Ord for SimpleScore
Source§fn cmp(&self, other: &SimpleScore) -> Ordering
fn cmp(&self, other: &SimpleScore) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl ParseableScore for SimpleScore
impl ParseableScore for SimpleScore
Source§fn parse(s: &str) -> Result<SimpleScore, ScoreParseError>
fn parse(s: &str) -> Result<SimpleScore, ScoreParseError>
Parses a score from a string representation. Read more
Source§fn to_string_repr(&self) -> String
fn to_string_repr(&self) -> String
Returns the string representation of this score.
Source§impl PartialEq for SimpleScore
impl PartialEq for SimpleScore
Source§impl PartialOrd for SimpleScore
impl PartialOrd for SimpleScore
Source§impl Score for SimpleScore
impl Score for SimpleScore
Source§fn is_feasible(&self) -> bool
fn is_feasible(&self) -> bool
Returns true if this score represents a feasible solution. Read more
Source§fn zero() -> SimpleScore
fn zero() -> SimpleScore
Returns the zero score (identity element for addition).
Source§fn levels_count() -> usize
fn levels_count() -> usize
Returns the number of score levels. Read more
Source§fn from_level_numbers(levels: &[i64]) -> SimpleScore
fn from_level_numbers(levels: &[i64]) -> SimpleScore
Creates a score from level numbers. Read more
Source§fn multiply(&self, multiplicand: f64) -> SimpleScore
fn multiply(&self, multiplicand: f64) -> SimpleScore
Multiplies this score by a scalar.
Source§fn divide(&self, divisor: f64) -> SimpleScore
fn divide(&self, divisor: f64) -> SimpleScore
Divides this score by a scalar.
Source§fn abs(&self) -> SimpleScore
fn abs(&self) -> SimpleScore
Returns the absolute value of this score.
Source§fn level_label(index: usize) -> ScoreLevel
fn level_label(index: usize) -> ScoreLevel
Returns the semantic label for the score level at the given index. 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 SimpleScore
impl Sub for SimpleScore
Source§type Output = SimpleScore
type Output = SimpleScore
The resulting type after applying the
- operator.Source§fn sub(self, other: SimpleScore) -> SimpleScore
fn sub(self, other: SimpleScore) -> SimpleScore
Performs the
- operation. Read moreimpl Copy for SimpleScore
impl Eq for SimpleScore
impl StructuralPartialEq for SimpleScore
Auto Trait Implementations§
impl Freeze for SimpleScore
impl RefUnwindSafe for SimpleScore
impl Send for SimpleScore
impl Sync for SimpleScore
impl Unpin for SimpleScore
impl UnsafeUnpin for SimpleScore
impl UnwindSafe for SimpleScore
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more