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
use necsim_core::{
    cogs::{LocallyCoherentLineageStore, MathsCore, SplittableRng},
    reporter::Reporter,
};
use necsim_impls_no_std::cogs::{
    lineage_store::coherent::locally::classical::ClassicalLineageStore,
    maths::intrinsics::IntrinsicsMathsCore,
};
use necsim_impls_std::cogs::rng::pcg::Pcg;

use necsim_partitioning_core::{partition::PartitionSize, LocalPartition, Partitioning};
use rustcoalescence_algorithms::{AlgorithmDefaults, AlgorithmDispatch, AlgorithmParamters};
use rustcoalescence_scenarios::Scenario;

use crate::arguments::{get_gillespie_logical_partition_size, GillespieArguments};

mod classical;
mod turnover;

#[allow(clippy::module_name_repetitions, clippy::empty_enum)]
pub enum GillespieAlgorithm {}

impl AlgorithmParamters for GillespieAlgorithm {
    type Arguments = GillespieArguments;
    type Error = !;
}

impl AlgorithmDefaults for GillespieAlgorithm {
    type MathsCore = IntrinsicsMathsCore;
    type Rng<M: MathsCore> = Pcg<M>;
}

impl<M: MathsCore, G: SplittableRng<M>, O: Scenario<M, G>, R: Reporter>
    AlgorithmDispatch<M, G, O, R> for GillespieAlgorithm
where
    O::LineageStore<ClassicalLineageStore<M, O::Habitat>>:
        LocallyCoherentLineageStore<M, O::Habitat>,
{
    type Algorithm<'p, P: LocalPartition<'p, R>> = Self;

    fn get_logical_partition_size<P: Partitioning>(
        args: &Self::Arguments,
        partitioning: &P,
    ) -> PartitionSize {
        get_gillespie_logical_partition_size(args, partitioning)
    }
}