Enum ProblemInstance

Source
pub enum ProblemInstance {
    Qap(usize, Vec<Vec<usize>>, Vec<Vec<usize>>),
    Pfsp(usize, usize, Vec<Vec<usize>>),
    Lop(usize, Vec<Vec<usize>>),
}
Expand description

This enum contains problem definitions.

Variants§

§

Qap(usize, Vec<Vec<usize>>, Vec<Vec<usize>>)

Quadratic Assignment Problem (QAP)

§

Pfsp(usize, usize, Vec<Vec<usize>>)

Permutation Flowshop Scheduling Problem (PFSP)

§

Lop(usize, Vec<Vec<usize>>)

Linear Ordering Problem (LOP)

Implementations§

Source§

impl ProblemInstance

Source

pub fn size(&self) -> usize

Returns the size of the instance. All soltions must be of the length of the problem’s size.

Source

pub fn load(path: &str) -> Result<Self, Error>

Loads a ProblemInstance from a file given as a path.

§Errors

Returns an Error::Io error if an error occurs loading the problem instance from the given path.

Source

pub fn evaluate<T>( &self, solutions: &PermuPopulation<T>, fitness_vec: &mut Vec<usize>, ) -> Result<(), Error>

Evaluates each solution of a given PermuPopulation and stores the fitness values inside a given fitness vector.

§Example
use permu_rs::permutation::PermuPopulation;
use permu_rs::problems::ProblemInstance;

let paths = ["PFSP/tai100_20_0.fsp", 
             "QAP/tai100a.dat",
             "/LOP/N-be75eec_150.lop"];
for name in paths.iter() {
    let path = format!("instances/{}", name);
    let instance = ProblemInstance::load(&path).unwrap();
     
    let pop = PermuPopulation::<u16>::random(100, instance.size());
    let mut fitness = vec![0; 100];

    instance.evaluate(&pop, &mut fitness).unwrap();
}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.