pub enum CriteriaType {
Cost,
Profit,
}Expand description
Enum to represent the type of each criterion: either Cost or Profit.
Variants§
Cost
Criterion where lower values are preferred (minimization).
Profit
Criterion where higher values are preferred (maximization).
Implementations§
Source§impl CriteriaType
impl CriteriaType
Sourcepub fn from<I>(iter: I) -> Result<Vec<CriteriaType>, ValidationError>where
I: IntoIterator<Item = i8>,
pub fn from<I>(iter: I) -> Result<Vec<CriteriaType>, ValidationError>where
I: IntoIterator<Item = i8>,
Converts an iterator of i8 values (-1 for Cost, 1 for Profit) into a vector of CriteriaType.
§Arguments
iter- An iterator ofi8values. Each value should be either-1(forCost) or1(forProfit).
§Returns
Result<Vec<CriteriaType>, ValidationError>- A vector ofCriteriaTypeif the values are valid, or an error if an invalid value is encountered.
§Errors
ValidationError::InvalidValue- If the iterator contains values other than-1or1.
§Example
use mcdm::errors::ValidationError;
use mcdm::CriteriaType;
use nalgebra::dmatrix;
let criteria_types = vec![-1, 1, 1]; // -1 for Cost, 1 for Profit
let criteria = CriteriaType::from(criteria_types).unwrap();
assert_eq!(criteria, vec![CriteriaType::Cost, CriteriaType::Profit, CriteriaType::Profit]);Sourcepub fn profits(len: usize) -> Vec<CriteriaType>
pub fn profits(len: usize) -> Vec<CriteriaType>
Generate a vector of CriteriaType::Profit of the given length len.
Sourcepub fn costs(len: usize) -> Vec<CriteriaType>
pub fn costs(len: usize) -> Vec<CriteriaType>
Generate a vector of CriteriaType::Cost of the given length len.
Sourcepub fn switch(types: Vec<CriteriaType>) -> Vec<CriteriaType>
pub fn switch(types: Vec<CriteriaType>) -> Vec<CriteriaType>
Trait Implementations§
Source§impl Clone for CriteriaType
impl Clone for CriteriaType
Source§fn clone(&self) -> CriteriaType
fn clone(&self) -> CriteriaType
Returns a copy 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 CriteriaType
impl Debug for CriteriaType
Source§impl PartialEq for CriteriaType
impl PartialEq for CriteriaType
impl Eq for CriteriaType
impl StructuralPartialEq for CriteriaType
Auto Trait Implementations§
impl Freeze for CriteriaType
impl RefUnwindSafe for CriteriaType
impl Send for CriteriaType
impl Sync for CriteriaType
impl Unpin for CriteriaType
impl UnwindSafe for CriteriaType
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.