EntropySolveSettings

Struct EntropySolveSettings 

Source
pub struct EntropySolveSettings {
    pub attempts: u64,
    pub noise: f64,
    pub final_attempt: Option<Option<u64>>,
}
Expand description

Stores settings for entropy solver.

Fields§

§attempts: u64

The number of solve attempts.

§noise: f64

Whether to sample randomly (1) or converge (0).

§final_attempt: Option<Option<u64>>

Make one final attempt with maximum iterations setting.

Implementations§

Source§

impl EntropySolveSettings

Source

pub fn new() -> EntropySolveSettings

Creates new entropy settings.

Examples found in repository?
examples/adinkra1.rs (line 21)
6fn main() {
7    let mut g = Graph::new();
8    let a = Node {
9        color: 0,
10        self_connected: false,
11        edges: vec![Constraint {edge: RED, node: 1}]
12    };
13    let b = Node {
14        color: 1,
15        self_connected: false,
16        edges: vec![Constraint {edge: RED, node: 0}]
17    };
18    g.push(a);
19    g.push(b);
20
21    let entropy_solve_settings = EntropySolveSettings::new()
22        .attempts(1000)
23        .noise(0.5)
24        .final_attempt(Some(None));
25    let solve_settings = SolveSettings::new();
26    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
27        solution.puzzle.print();
28    }
29}
More examples
Hide additional examples
examples/pentagon.rs (line 21)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![
14            Constraint {edge: EDGE, node: 0},
15            Constraint {edge: EDGE, node: 0},
16        ]
17    };
18
19    for _ in 0..5 {g.push(a.clone())}
20
21    let entropy_solve_settings = EntropySolveSettings::new()
22        .attempts(1000)
23        .noise(0.5)
24        .final_attempt(Some(None));
25    let solve_settings = SolveSettings::new();
26    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
27        // solution.puzzle.print();
28        println!("{}", solution.puzzle.graphviz(
29            "sfdp",
30            &["black"],
31            &["black"]
32        ));
33    }
34}
examples/cube.rs (line 30)
16fn main() {
17    let mut g = Graph::new();
18
19    // Create a node pattern with 3 edges.
20    let a = Node {
21        color: 0,
22        self_connected: false,
23        edges: vec![Constraint {edge: EDGE, node: 0}; 3]
24    };
25
26    // Add 8 vertices.
27    for _ in 0..8 {g.push(a.clone())}
28    g.no_triangles = true;
29
30    let entropy_solve_settings = EntropySolveSettings::new()
31        .attempts(1000)
32        .noise(0.5)
33        .final_attempt(Some(None));
34    let solve_settings = SolveSettings::new();
35    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
36        println!("{}", solution.puzzle.graphviz(
37            "sfdp",
38            &["black"],
39            &["black"]
40        ));
41    } else {
42        eprintln!("<no solution>");
43    }
44}
examples/square2.rs (line 19)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![Constraint {edge: SOLID, node: 0}; 2]
14    };
15
16    // Add 4 nodes.
17    for _ in 0..4 {g.push(a.clone())}
18
19    let entropy_solve_settings = EntropySolveSettings::new()
20        .attempts(1000)
21        .noise(0.5)
22        .final_attempt(Some(None));
23    let solve_settings = SolveSettings::new()
24        .debug(true).sleep_ms(2000);
25    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
26        // Prints:
27        // 0 0 0 0
28        // ========================================
29        // 0 2 1 0
30        // 2 0 0 1
31        // 1 0 0 2
32        // 0 1 2 0
33        solution.puzzle.print();
34    }
35}
examples/hexagon.rs (line 22)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![
14            Constraint {edge: EDGE, node: 0},
15            Constraint {edge: EDGE, node: 0},
16        ]
17    };
18
19    for _ in 0..6 {g.push(a.clone())}
20    g.push_pair((2, 3));
21
22    let entropy_solve_settings = EntropySolveSettings::new()
23        .attempts(1000)
24        .noise(0.5)
25        .final_attempt(Some(None));
26    let solve_settings = SolveSettings::new();
27    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
28        // solution.puzzle.print();
29        println!("{}", solution.puzzle.graphviz(
30            "sfdp",
31            &["black,fontcolor=white"],
32            &["black"]
33        ));
34    }
35}
examples/triangle.rs (line 18)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![Constraint {edge: EDGE, node: 0}; 2]
14    };
15
16    for _ in 0..3 {g.push(a.clone())}
17
18    let entropy_solve_settings = EntropySolveSettings::new()
19        .attempts(1000)
20        .noise(0.5)
21        .final_attempt(Some(None));
22    let solve_settings = SolveSettings::new();
23    if let (_n, Some(solution)) = g.solve(
24        entropy_solve_settings,
25        solve_settings,
26    ) {
27        // println!("Attempts: {}", n);
28        // solution.puzzle.print();
29        println!("{}", solution.puzzle.graphviz(
30            "sfdp",
31            &["black"],
32            &["black"]
33        ));
34    } else {
35        println!("<no solution>");
36    }
37}
Source

pub fn set_attempts(&mut self, val: u64)

Sets number of attempts.

Source

pub fn attempts(self, val: u64) -> EntropySolveSettings

The number of attempts.

Examples found in repository?
examples/adinkra1.rs (line 22)
6fn main() {
7    let mut g = Graph::new();
8    let a = Node {
9        color: 0,
10        self_connected: false,
11        edges: vec![Constraint {edge: RED, node: 1}]
12    };
13    let b = Node {
14        color: 1,
15        self_connected: false,
16        edges: vec![Constraint {edge: RED, node: 0}]
17    };
18    g.push(a);
19    g.push(b);
20
21    let entropy_solve_settings = EntropySolveSettings::new()
22        .attempts(1000)
23        .noise(0.5)
24        .final_attempt(Some(None));
25    let solve_settings = SolveSettings::new();
26    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
27        solution.puzzle.print();
28    }
29}
More examples
Hide additional examples
examples/pentagon.rs (line 22)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![
14            Constraint {edge: EDGE, node: 0},
15            Constraint {edge: EDGE, node: 0},
16        ]
17    };
18
19    for _ in 0..5 {g.push(a.clone())}
20
21    let entropy_solve_settings = EntropySolveSettings::new()
22        .attempts(1000)
23        .noise(0.5)
24        .final_attempt(Some(None));
25    let solve_settings = SolveSettings::new();
26    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
27        // solution.puzzle.print();
28        println!("{}", solution.puzzle.graphviz(
29            "sfdp",
30            &["black"],
31            &["black"]
32        ));
33    }
34}
examples/cube.rs (line 31)
16fn main() {
17    let mut g = Graph::new();
18
19    // Create a node pattern with 3 edges.
20    let a = Node {
21        color: 0,
22        self_connected: false,
23        edges: vec![Constraint {edge: EDGE, node: 0}; 3]
24    };
25
26    // Add 8 vertices.
27    for _ in 0..8 {g.push(a.clone())}
28    g.no_triangles = true;
29
30    let entropy_solve_settings = EntropySolveSettings::new()
31        .attempts(1000)
32        .noise(0.5)
33        .final_attempt(Some(None));
34    let solve_settings = SolveSettings::new();
35    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
36        println!("{}", solution.puzzle.graphviz(
37            "sfdp",
38            &["black"],
39            &["black"]
40        ));
41    } else {
42        eprintln!("<no solution>");
43    }
44}
examples/square2.rs (line 20)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![Constraint {edge: SOLID, node: 0}; 2]
14    };
15
16    // Add 4 nodes.
17    for _ in 0..4 {g.push(a.clone())}
18
19    let entropy_solve_settings = EntropySolveSettings::new()
20        .attempts(1000)
21        .noise(0.5)
22        .final_attempt(Some(None));
23    let solve_settings = SolveSettings::new()
24        .debug(true).sleep_ms(2000);
25    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
26        // Prints:
27        // 0 0 0 0
28        // ========================================
29        // 0 2 1 0
30        // 2 0 0 1
31        // 1 0 0 2
32        // 0 1 2 0
33        solution.puzzle.print();
34    }
35}
examples/hexagon.rs (line 23)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![
14            Constraint {edge: EDGE, node: 0},
15            Constraint {edge: EDGE, node: 0},
16        ]
17    };
18
19    for _ in 0..6 {g.push(a.clone())}
20    g.push_pair((2, 3));
21
22    let entropy_solve_settings = EntropySolveSettings::new()
23        .attempts(1000)
24        .noise(0.5)
25        .final_attempt(Some(None));
26    let solve_settings = SolveSettings::new();
27    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
28        // solution.puzzle.print();
29        println!("{}", solution.puzzle.graphviz(
30            "sfdp",
31            &["black,fontcolor=white"],
32            &["black"]
33        ));
34    }
35}
examples/triangle.rs (line 19)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![Constraint {edge: EDGE, node: 0}; 2]
14    };
15
16    for _ in 0..3 {g.push(a.clone())}
17
18    let entropy_solve_settings = EntropySolveSettings::new()
19        .attempts(1000)
20        .noise(0.5)
21        .final_attempt(Some(None));
22    let solve_settings = SolveSettings::new();
23    if let (_n, Some(solution)) = g.solve(
24        entropy_solve_settings,
25        solve_settings,
26    ) {
27        // println!("Attempts: {}", n);
28        // solution.puzzle.print();
29        println!("{}", solution.puzzle.graphviz(
30            "sfdp",
31            &["black"],
32            &["black"]
33        ));
34    } else {
35        println!("<no solution>");
36    }
37}
Source

pub fn set_noise(&mut self, val: f64)

Sets the noise (0 = converge, 1 = random sampling).

Source

pub fn noise(self, val: f64) -> EntropySolveSettings

The noise (0 = converge, 1 = random sampling).

Examples found in repository?
examples/adinkra1.rs (line 23)
6fn main() {
7    let mut g = Graph::new();
8    let a = Node {
9        color: 0,
10        self_connected: false,
11        edges: vec![Constraint {edge: RED, node: 1}]
12    };
13    let b = Node {
14        color: 1,
15        self_connected: false,
16        edges: vec![Constraint {edge: RED, node: 0}]
17    };
18    g.push(a);
19    g.push(b);
20
21    let entropy_solve_settings = EntropySolveSettings::new()
22        .attempts(1000)
23        .noise(0.5)
24        .final_attempt(Some(None));
25    let solve_settings = SolveSettings::new();
26    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
27        solution.puzzle.print();
28    }
29}
More examples
Hide additional examples
examples/pentagon.rs (line 23)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![
14            Constraint {edge: EDGE, node: 0},
15            Constraint {edge: EDGE, node: 0},
16        ]
17    };
18
19    for _ in 0..5 {g.push(a.clone())}
20
21    let entropy_solve_settings = EntropySolveSettings::new()
22        .attempts(1000)
23        .noise(0.5)
24        .final_attempt(Some(None));
25    let solve_settings = SolveSettings::new();
26    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
27        // solution.puzzle.print();
28        println!("{}", solution.puzzle.graphviz(
29            "sfdp",
30            &["black"],
31            &["black"]
32        ));
33    }
34}
examples/cube.rs (line 32)
16fn main() {
17    let mut g = Graph::new();
18
19    // Create a node pattern with 3 edges.
20    let a = Node {
21        color: 0,
22        self_connected: false,
23        edges: vec![Constraint {edge: EDGE, node: 0}; 3]
24    };
25
26    // Add 8 vertices.
27    for _ in 0..8 {g.push(a.clone())}
28    g.no_triangles = true;
29
30    let entropy_solve_settings = EntropySolveSettings::new()
31        .attempts(1000)
32        .noise(0.5)
33        .final_attempt(Some(None));
34    let solve_settings = SolveSettings::new();
35    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
36        println!("{}", solution.puzzle.graphviz(
37            "sfdp",
38            &["black"],
39            &["black"]
40        ));
41    } else {
42        eprintln!("<no solution>");
43    }
44}
examples/square2.rs (line 21)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![Constraint {edge: SOLID, node: 0}; 2]
14    };
15
16    // Add 4 nodes.
17    for _ in 0..4 {g.push(a.clone())}
18
19    let entropy_solve_settings = EntropySolveSettings::new()
20        .attempts(1000)
21        .noise(0.5)
22        .final_attempt(Some(None));
23    let solve_settings = SolveSettings::new()
24        .debug(true).sleep_ms(2000);
25    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
26        // Prints:
27        // 0 0 0 0
28        // ========================================
29        // 0 2 1 0
30        // 2 0 0 1
31        // 1 0 0 2
32        // 0 1 2 0
33        solution.puzzle.print();
34    }
35}
examples/hexagon.rs (line 24)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![
14            Constraint {edge: EDGE, node: 0},
15            Constraint {edge: EDGE, node: 0},
16        ]
17    };
18
19    for _ in 0..6 {g.push(a.clone())}
20    g.push_pair((2, 3));
21
22    let entropy_solve_settings = EntropySolveSettings::new()
23        .attempts(1000)
24        .noise(0.5)
25        .final_attempt(Some(None));
26    let solve_settings = SolveSettings::new();
27    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
28        // solution.puzzle.print();
29        println!("{}", solution.puzzle.graphviz(
30            "sfdp",
31            &["black,fontcolor=white"],
32            &["black"]
33        ));
34    }
35}
examples/triangle.rs (line 20)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![Constraint {edge: EDGE, node: 0}; 2]
14    };
15
16    for _ in 0..3 {g.push(a.clone())}
17
18    let entropy_solve_settings = EntropySolveSettings::new()
19        .attempts(1000)
20        .noise(0.5)
21        .final_attempt(Some(None));
22    let solve_settings = SolveSettings::new();
23    if let (_n, Some(solution)) = g.solve(
24        entropy_solve_settings,
25        solve_settings,
26    ) {
27        // println!("Attempts: {}", n);
28        // solution.puzzle.print();
29        println!("{}", solution.puzzle.graphviz(
30            "sfdp",
31            &["black"],
32            &["black"]
33        ));
34    } else {
35        println!("<no solution>");
36    }
37}
Source

pub fn set_final_attempt(&mut self, val: Option<Option<u64>>)

Sets one final attempt with maximum iterations setting.

Source

pub fn final_attempt(self, val: Option<Option<u64>>) -> EntropySolveSettings

The final attempt with maximum iterations setting.

Examples found in repository?
examples/adinkra1.rs (line 24)
6fn main() {
7    let mut g = Graph::new();
8    let a = Node {
9        color: 0,
10        self_connected: false,
11        edges: vec![Constraint {edge: RED, node: 1}]
12    };
13    let b = Node {
14        color: 1,
15        self_connected: false,
16        edges: vec![Constraint {edge: RED, node: 0}]
17    };
18    g.push(a);
19    g.push(b);
20
21    let entropy_solve_settings = EntropySolveSettings::new()
22        .attempts(1000)
23        .noise(0.5)
24        .final_attempt(Some(None));
25    let solve_settings = SolveSettings::new();
26    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
27        solution.puzzle.print();
28    }
29}
More examples
Hide additional examples
examples/pentagon.rs (line 24)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![
14            Constraint {edge: EDGE, node: 0},
15            Constraint {edge: EDGE, node: 0},
16        ]
17    };
18
19    for _ in 0..5 {g.push(a.clone())}
20
21    let entropy_solve_settings = EntropySolveSettings::new()
22        .attempts(1000)
23        .noise(0.5)
24        .final_attempt(Some(None));
25    let solve_settings = SolveSettings::new();
26    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
27        // solution.puzzle.print();
28        println!("{}", solution.puzzle.graphviz(
29            "sfdp",
30            &["black"],
31            &["black"]
32        ));
33    }
34}
examples/cube.rs (line 33)
16fn main() {
17    let mut g = Graph::new();
18
19    // Create a node pattern with 3 edges.
20    let a = Node {
21        color: 0,
22        self_connected: false,
23        edges: vec![Constraint {edge: EDGE, node: 0}; 3]
24    };
25
26    // Add 8 vertices.
27    for _ in 0..8 {g.push(a.clone())}
28    g.no_triangles = true;
29
30    let entropy_solve_settings = EntropySolveSettings::new()
31        .attempts(1000)
32        .noise(0.5)
33        .final_attempt(Some(None));
34    let solve_settings = SolveSettings::new();
35    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
36        println!("{}", solution.puzzle.graphviz(
37            "sfdp",
38            &["black"],
39            &["black"]
40        ));
41    } else {
42        eprintln!("<no solution>");
43    }
44}
examples/square2.rs (line 22)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![Constraint {edge: SOLID, node: 0}; 2]
14    };
15
16    // Add 4 nodes.
17    for _ in 0..4 {g.push(a.clone())}
18
19    let entropy_solve_settings = EntropySolveSettings::new()
20        .attempts(1000)
21        .noise(0.5)
22        .final_attempt(Some(None));
23    let solve_settings = SolveSettings::new()
24        .debug(true).sleep_ms(2000);
25    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
26        // Prints:
27        // 0 0 0 0
28        // ========================================
29        // 0 2 1 0
30        // 2 0 0 1
31        // 1 0 0 2
32        // 0 1 2 0
33        solution.puzzle.print();
34    }
35}
examples/hexagon.rs (line 25)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![
14            Constraint {edge: EDGE, node: 0},
15            Constraint {edge: EDGE, node: 0},
16        ]
17    };
18
19    for _ in 0..6 {g.push(a.clone())}
20    g.push_pair((2, 3));
21
22    let entropy_solve_settings = EntropySolveSettings::new()
23        .attempts(1000)
24        .noise(0.5)
25        .final_attempt(Some(None));
26    let solve_settings = SolveSettings::new();
27    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
28        // solution.puzzle.print();
29        println!("{}", solution.puzzle.graphviz(
30            "sfdp",
31            &["black,fontcolor=white"],
32            &["black"]
33        ));
34    }
35}
examples/triangle.rs (line 21)
6fn main() {
7    let mut g = Graph::new();
8
9    // Create a node pattern.
10    let a = Node {
11        color: 0,
12        self_connected: false,
13        edges: vec![Constraint {edge: EDGE, node: 0}; 2]
14    };
15
16    for _ in 0..3 {g.push(a.clone())}
17
18    let entropy_solve_settings = EntropySolveSettings::new()
19        .attempts(1000)
20        .noise(0.5)
21        .final_attempt(Some(None));
22    let solve_settings = SolveSettings::new();
23    if let (_n, Some(solution)) = g.solve(
24        entropy_solve_settings,
25        solve_settings,
26    ) {
27        // println!("Attempts: {}", n);
28        // solution.puzzle.print();
29        println!("{}", solution.puzzle.graphviz(
30            "sfdp",
31            &["black"],
32            &["black"]
33        ));
34    } else {
35        println!("<no solution>");
36    }
37}

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V