@@ -5,12 +5,13 @@ use core::marker::PhantomData;
55
66use crate :: cogs:: {
77 ActiveLineageSampler , CoalescenceSampler , DispersalSampler , EventSampler , Habitat ,
8- LineageReference , LineageStore ,
8+ LineageReference , LineageStore , RngCore ,
99} ;
1010
1111#[ derive( TypedBuilder , Debug ) ]
1212#[ cfg_attr( feature = "cuda" , derive( RustToCuda , LendToCuda ) ) ]
1313#[ cfg_attr( feature = "cuda" , r2cBound( H : rust_cuda:: common:: RustToCuda ) ) ]
14+ #[ cfg_attr( feature = "cuda" , r2cBound( G : rust_cuda:: common:: RustToCuda ) ) ]
1415#[ cfg_attr( feature = "cuda" , r2cBound( D : rust_cuda:: common:: RustToCuda ) ) ]
1516#[ cfg_attr( feature = "cuda" , r2cBound( R : rustacuda_core:: DeviceCopy ) ) ]
1617#[ cfg_attr( feature = "cuda" , r2cBound( S : rust_cuda:: common:: RustToCuda ) ) ]
@@ -19,19 +20,22 @@ use crate::cogs::{
1920#[ cfg_attr( feature = "cuda" , r2cBound( A : rust_cuda:: common:: RustToCuda ) ) ]
2021pub struct Simulation <
2122 H : Habitat ,
22- D : DispersalSampler < H > ,
23+ G : RngCore ,
24+ D : DispersalSampler < H , G > ,
2325 R : LineageReference < H > ,
2426 S : LineageStore < H , R > ,
25- C : CoalescenceSampler < H , R , S > ,
26- E : EventSampler < H , D , R , S , C > ,
27- A : ActiveLineageSampler < H , D , R , S , C , E > ,
27+ C : CoalescenceSampler < H , G , R , S > ,
28+ E : EventSampler < H , G , D , R , S , C > ,
29+ A : ActiveLineageSampler < H , G , D , R , S , C , E > ,
2830> {
2931 #[ builder( default = 0.0_f64 , setter( skip) ) ]
3032 pub ( super ) time : f64 ,
3133 pub ( super ) speciation_probability_per_generation : f64 ,
3234 #[ cfg_attr( feature = "cuda" , r2cEmbed) ]
3335 pub ( super ) habitat : H ,
3436 #[ cfg_attr( feature = "cuda" , r2cEmbed) ]
37+ pub ( super ) rng : G ,
38+ #[ cfg_attr( feature = "cuda" , r2cEmbed) ]
3539 pub ( super ) dispersal_sampler : D ,
3640 pub ( super ) lineage_reference : PhantomData < R > ,
3741 #[ cfg_attr( feature = "cuda" , r2cEmbed) ]
@@ -46,20 +50,22 @@ pub struct Simulation<
4650
4751impl <
4852 H : Habitat ,
49- D : DispersalSampler < H > ,
53+ G : RngCore ,
54+ D : DispersalSampler < H , G > ,
5055 R : LineageReference < H > ,
5156 S : LineageStore < H , R > ,
52- C : CoalescenceSampler < H , R , S > ,
53- E : EventSampler < H , D , R , S , C > ,
54- A : ActiveLineageSampler < H , D , R , S , C , E > ,
55- > Simulation < H , D , R , S , C , E , A >
57+ C : CoalescenceSampler < H , G , R , S > ,
58+ E : EventSampler < H , G , D , R , S , C > ,
59+ A : ActiveLineageSampler < H , G , D , R , S , C , E > ,
60+ > Simulation < H , G , D , R , S , C , E , A >
5661{
57- pub fn with_mut_split_active_lineage_sampler <
62+ pub fn with_mut_split_active_lineage_sampler_and_rng <
5863 ' s ,
5964 Q ,
6065 F : FnOnce (
6166 & ' s mut A ,
62- & mut super :: partial:: active_lineager_sampler:: PartialSimulation < ' s , H , D , R , S , C , E > ,
67+ & mut super :: partial:: active_lineager_sampler:: PartialSimulation < ' s , H , G , D , R , S , C , E > ,
68+ & ' s mut G ,
6369 ) -> Q ,
6470 > (
6571 & ' s mut self ,
@@ -68,14 +74,23 @@ impl<
6874 let mut simulation = super :: partial:: active_lineager_sampler:: PartialSimulation {
6975 speciation_probability_per_generation : & self . speciation_probability_per_generation ,
7076 habitat : & self . habitat ,
77+ rng : PhantomData :: < G > ,
7178 dispersal_sampler : & self . dispersal_sampler ,
7279 lineage_reference : & self . lineage_reference ,
7380 lineage_store : & mut self . lineage_store ,
7481 coalescence_sampler : & self . coalescence_sampler ,
7582 event_sampler : & self . event_sampler ,
7683 } ;
7784
78- func ( & mut self . active_lineage_sampler , & mut simulation)
85+ func (
86+ & mut self . active_lineage_sampler ,
87+ & mut simulation,
88+ & mut self . rng ,
89+ )
90+ }
91+
92+ pub fn rng_mut ( & mut self ) -> & mut G {
93+ & mut self . rng
7994 }
8095
8196 pub fn active_lineage_sampler ( & self ) -> & A {
0 commit comments