Struct Cohort

Source
pub struct Cohort<S = Ackley, A = Agent<S>, T = Team<S, A>>
where S: Solution, A: AgentMethods<S>, T: TeamMethods<S, A>,
{ /* private fields */ }
Expand description

This is the Cohort class, a container for multiple teams

The cohort allows you to run a set of teams easily to achieve statistical significance:

use cisat::{Parameters, Cohort, problems::Ackley};
let mut x = Cohort::<Ackley>::new(Parameters::default());
x.solve();

Above, we specify one generic parameters Ackley, which tells the Cohort which problem to solve. However, we can get more complciated than that! For instance, we feed in a struct that implements AgentMethods to specific which type of agent to use:

use cisat::{Parameters, Cohort, problems::Ackley, Agent};
let mut x = Cohort::<Ackley, Agent<Ackley>>::new(Parameters::default());
x.solve();

Here, we just fed in the in-build Agent class which already implements AgentMethods. You can implement the trait yourself to define a new agent though. The same applies for ‘Team’ and ‘TeamMethods’:

use cisat::{Parameters, Cohort, problems::Ackley, Agent, Team};
let mut x = Cohort::<Ackley, Agent<Ackley>, Team<Ackley, Agent<Ackley>>>::new(Parameters::default());
x.solve();

Implementations§

Source§

impl<S, A, T> Cohort<S, A, T>
where S: Solution, A: AgentMethods<S>, T: TeamMethods<S, A>,

Source

pub fn new(parameters: Parameters) -> Cohort<S, A, T>

This generates a new cohort

Examples found in repository?
examples/custom_implementation.rs (line 105)
104fn main() {
105    let mut x = Cohort::<CustomProblem, CustomAgent, CustomTeam>::new(Parameters::default());
106    x.solve();
107}
More examples
Hide additional examples
examples/cohort_of_teams.rs (lines 4-8)
3fn main() {
4    let mut x = Cohort::<Ackley>::new(Parameters {
5        number_of_teams: 1,
6        communication: CommunicationStyle::RegularInterval { interval: 5 },
7        ..Default::default()
8    });
9
10    x.solve();
11
12    println!("{:?}", x);
13}
Source

pub fn solve(&mut self)

This runs the cohort using parallelism

Examples found in repository?
examples/custom_implementation.rs (line 106)
104fn main() {
105    let mut x = Cohort::<CustomProblem, CustomAgent, CustomTeam>::new(Parameters::default());
106    x.solve();
107}
More examples
Hide additional examples
examples/cohort_of_teams.rs (line 10)
3fn main() {
4    let mut x = Cohort::<Ackley>::new(Parameters {
5        number_of_teams: 1,
6        communication: CommunicationStyle::RegularInterval { interval: 5 },
7        ..Default::default()
8    });
9
10    x.solve();
11
12    println!("{:?}", x);
13}
Source

pub fn iterate(&mut self)

This runs a single iteration

Source

pub fn get_best_solution_so_far(&mut self) -> f64

Get the current best solution

Trait Implementations§

Source§

impl<S, A, T> Clone for Cohort<S, A, T>
where S: Solution + Clone, A: AgentMethods<S> + Clone, T: TeamMethods<S, A> + Clone,

Source§

fn clone(&self) -> Cohort<S, A, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S, A, T> Debug for Cohort<S, A, T>
where S: Solution + Debug, A: AgentMethods<S> + Debug, T: TeamMethods<S, A> + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Cohort

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S, A, T> Freeze for Cohort<S, A, T>

§

impl<S, A, T> RefUnwindSafe for Cohort<S, A, T>

§

impl<S, A, T> Send for Cohort<S, A, T>

§

impl<S, A, T> Sync for Cohort<S, A, T>
where S: Sync, A: Sync, T: Sync,

§

impl<S, A, T> Unpin for Cohort<S, A, T>
where S: Unpin, A: Unpin, T: Unpin,

§

impl<S, A, T> UnwindSafe for Cohort<S, A, T>
where S: UnwindSafe, A: UnwindSafe, T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

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

Source§

fn vzip(self) -> V