1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! This is an example problem for designing truss structures
use super::super::utilities::Solution;
use std::{cmp::Ordering, ops::Sub};
use trussx::Truss;

#[derive(Clone, Debug)]
/// This is a structure!
pub struct Structure {
    /// Thie contains the fundamental truss information
    truss: Truss,
    /// This contains a single quality scalar derived from objective function values
    quality_scalar: f64,
    /// This contains direct objective function values
    objective_function_value: Vec<f64>,
}

impl Solution<Structure> for Structure {
    const NUMBER_OF_MOVE_OPERATORS: usize = 1;
    const NUMBER_OF_OBJECTIVES: usize = 1;
    fn generate_initial_solution() -> Structure {
        Structure {
            truss: Truss::new(),
            quality_scalar: 0.0,
            objective_function_value: vec![0.0; Structure::NUMBER_OF_OBJECTIVES],
        }
    }

    fn apply_move_operator(&mut self, move_index: usize, temperature: f64) {
        unimplemented!()
    }

    fn get_quality_scalar(&self) -> f64 {
        unimplemented!()
    }
}

impl PartialEq for Structure {
    fn eq(&self, other: &Self) -> bool {
        self.quality_scalar == other.quality_scalar
    }
}

impl Eq for Structure {}

impl PartialOrd for Structure {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        self.quality_scalar.partial_cmp(&other.quality_scalar)
    }
}

impl Ord for Structure {
    fn cmp(&self, other: &Self) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}

impl Sub for Structure {
    type Output = f64;

    fn sub(self, rhs: Self) -> Self::Output {
        self.quality_scalar - rhs.quality_scalar
    }
}