@@ -36,7 +36,6 @@ use rand::SeedableRng;
36
36
use rand_distr:: Distribution ;
37
37
use rayon:: prelude:: ParallelIterator ;
38
38
use rayon:: prelude:: * ;
39
- use std:: f64;
40
39
use std:: fmt;
41
40
use std:: sync:: mpsc:: channel;
42
41
use std:: sync:: Arc ;
@@ -47,10 +46,7 @@ use std::time::Instant as StdInstant;
47
46
/// One caveat of the design is that the trajectory is used for post processing, not each individual state. This may prevent some event switching from being shown in GNC simulations.
48
47
pub struct MonteCarlo < S : Interpolatable , Distr : Distribution < DispersedState < S > > >
49
48
where
50
- DefaultAllocator : Allocator < f64 , S :: Size >
51
- + Allocator < f64 , S :: Size , S :: Size >
52
- + Allocator < f64 , S :: VecLength >
53
- + Allocator < usize , S :: Size , S :: Size > ,
49
+ DefaultAllocator : Allocator < S :: Size > + Allocator < S :: Size , S :: Size > + Allocator < S :: VecLength > ,
54
50
{
55
51
/// Seed of the [64bit PCG random number generator](https://www.pcg-random.org/index.html)
56
52
pub seed : Option < u128 > ,
63
59
64
60
impl < S : Interpolatable , Distr : Distribution < DispersedState < S > > > MonteCarlo < S , Distr >
65
61
where
66
- DefaultAllocator : Allocator < f64 , S :: Size >
67
- + Allocator < f64 , S :: Size , S :: Size >
68
- + Allocator < f64 , S :: VecLength >
69
- + Allocator < usize , S :: Size , S :: Size > ,
62
+ DefaultAllocator : Allocator < S :: Size > + Allocator < S :: Size , S :: Size > + Allocator < S :: VecLength > ,
70
63
{
71
64
pub fn new (
72
65
nominal_state : S ,
@@ -109,11 +102,10 @@ where
109
102
D : Dynamics < StateType = S > ,
110
103
E : ErrorCtrl ,
111
104
F : EventEvaluator < S > ,
112
- DefaultAllocator : Allocator < f64 , <D :: StateType as State >:: Size >
113
- + Allocator < f64 , <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
114
- + Allocator < usize , <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
115
- + Allocator < f64 , <D :: StateType as State >:: VecLength > ,
116
- <DefaultAllocator as Allocator < f64 , <D :: StateType as State >:: VecLength > >:: Buffer : Send ,
105
+ DefaultAllocator : Allocator < <D :: StateType as State >:: Size >
106
+ + Allocator < <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
107
+ + Allocator < <D :: StateType as State >:: VecLength > ,
108
+ <DefaultAllocator as Allocator < <D :: StateType as State >:: VecLength > >:: Buffer < f64 > : Send ,
117
109
{
118
110
self . resume_run_until_nth_event ( prop, almanac, 0 , max_duration, event, trigger, num_runs)
119
111
}
@@ -135,11 +127,10 @@ where
135
127
D : Dynamics < StateType = S > ,
136
128
E : ErrorCtrl ,
137
129
F : EventEvaluator < S > ,
138
- DefaultAllocator : Allocator < f64 , <D :: StateType as State >:: Size >
139
- + Allocator < f64 , <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
140
- + Allocator < usize , <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
141
- + Allocator < f64 , <D :: StateType as State >:: VecLength > ,
142
- <DefaultAllocator as Allocator < f64 , <D :: StateType as State >:: VecLength > >:: Buffer : Send ,
130
+ DefaultAllocator : Allocator < <D :: StateType as State >:: Size >
131
+ + Allocator < <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
132
+ + Allocator < <D :: StateType as State >:: VecLength > ,
133
+ <DefaultAllocator as Allocator < <D :: StateType as State >:: VecLength > >:: Buffer < f64 > : Send ,
143
134
{
144
135
// Generate the initial states
145
136
let init_states = self . generate_states ( skip, num_runs, self . seed ) ;
@@ -207,11 +198,10 @@ where
207
198
where
208
199
D : Dynamics < StateType = S > ,
209
200
E : ErrorCtrl ,
210
- DefaultAllocator : Allocator < f64 , <D :: StateType as State >:: Size >
211
- + Allocator < f64 , <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
212
- + Allocator < usize , <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
213
- + Allocator < f64 , <D :: StateType as State >:: VecLength > ,
214
- <DefaultAllocator as Allocator < f64 , <D :: StateType as State >:: VecLength > >:: Buffer : Send ,
201
+ DefaultAllocator : Allocator < <D :: StateType as State >:: Size >
202
+ + Allocator < <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
203
+ + Allocator < <D :: StateType as State >:: VecLength > ,
204
+ <DefaultAllocator as Allocator < <D :: StateType as State >:: VecLength > >:: Buffer < f64 > : Send ,
215
205
{
216
206
self . resume_run_until_epoch ( prop, almanac, 0 , end_epoch, num_runs)
217
207
}
@@ -230,11 +220,10 @@ where
230
220
where
231
221
D : Dynamics < StateType = S > ,
232
222
E : ErrorCtrl ,
233
- DefaultAllocator : Allocator < f64 , <D :: StateType as State >:: Size >
234
- + Allocator < f64 , <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
235
- + Allocator < usize , <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
236
- + Allocator < f64 , <D :: StateType as State >:: VecLength > ,
237
- <DefaultAllocator as Allocator < f64 , <D :: StateType as State >:: VecLength > >:: Buffer : Send ,
223
+ DefaultAllocator : Allocator < <D :: StateType as State >:: Size >
224
+ + Allocator < <D :: StateType as State >:: Size , <D :: StateType as State >:: Size >
225
+ + Allocator < <D :: StateType as State >:: VecLength > ,
226
+ <DefaultAllocator as Allocator < <D :: StateType as State >:: VecLength > >:: Buffer < f64 > : Send ,
238
227
{
239
228
// Generate the initial states
240
229
let init_states = self . generate_states ( skip, num_runs, self . seed ) ;
@@ -315,10 +304,7 @@ where
315
304
impl < S : Interpolatable , Distr : Distribution < DispersedState < S > > > fmt:: Display
316
305
for MonteCarlo < S , Distr >
317
306
where
318
- DefaultAllocator : Allocator < f64 , S :: Size >
319
- + Allocator < f64 , S :: Size , S :: Size >
320
- + Allocator < f64 , S :: VecLength >
321
- + Allocator < usize , S :: Size , S :: Size > ,
307
+ DefaultAllocator : Allocator < S :: Size > + Allocator < S :: Size , S :: Size > + Allocator < S :: VecLength > ,
322
308
{
323
309
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
324
310
write ! (
@@ -332,10 +318,7 @@ where
332
318
impl < S : Interpolatable , Distr : Distribution < DispersedState < S > > > fmt:: LowerHex
333
319
for MonteCarlo < S , Distr >
334
320
where
335
- DefaultAllocator : Allocator < f64 , S :: Size >
336
- + Allocator < f64 , S :: Size , S :: Size >
337
- + Allocator < f64 , S :: VecLength >
338
- + Allocator < usize , S :: Size , S :: Size > ,
321
+ DefaultAllocator : Allocator < S :: Size > + Allocator < S :: Size , S :: Size > + Allocator < S :: VecLength > ,
339
322
{
340
323
/// Returns a filename friendly name
341
324
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
0 commit comments