@@ -39,6 +39,10 @@ impl Strategy {
39
39
position : & [ f64 ] ,
40
40
rng : & mut R ,
41
41
) -> Result < ( ) , NutsError > {
42
+ if let Some ( step_size) = self . options . fixed_step_size {
43
+ * hamiltonian. step_size_mut ( ) = step_size;
44
+ return Ok ( ( ) ) ;
45
+ }
42
46
let mut state = hamiltonian. init_state ( math, position) ?;
43
47
hamiltonian. initialize_trajectory ( math, & mut state, rng) ?;
44
48
@@ -118,13 +122,17 @@ impl Strategy {
118
122
119
123
pub fn update_stepsize < M : Math > (
120
124
& mut self ,
121
- potential : & mut impl Hamiltonian < M > ,
125
+ hamiltonian : & mut impl Hamiltonian < M > ,
122
126
use_best_guess : bool ,
123
127
) {
128
+ if let Some ( step_size) = self . options . fixed_step_size {
129
+ * hamiltonian. step_size_mut ( ) = step_size;
130
+ return ;
131
+ }
124
132
if use_best_guess {
125
- * potential . step_size_mut ( ) = self . step_size_adapt . current_step_size_adapted ( ) ;
133
+ * hamiltonian . step_size_mut ( ) = self . step_size_adapt . current_step_size_adapted ( ) ;
126
134
} else {
127
- * potential . step_size_mut ( ) = self . step_size_adapt . current_step_size ( ) ;
135
+ * hamiltonian . step_size_mut ( ) = self . step_size_adapt . current_step_size ( ) ;
128
136
}
129
137
}
130
138
@@ -226,6 +234,7 @@ pub struct DualAverageSettings {
226
234
pub target_accept : f64 ,
227
235
pub initial_step : f64 ,
228
236
pub params : DualAverageOptions ,
237
+ pub fixed_step_size : Option < f64 > ,
229
238
}
230
239
231
240
impl Default for DualAverageSettings {
@@ -234,6 +243,7 @@ impl Default for DualAverageSettings {
234
243
target_accept : 0.8 ,
235
244
initial_step : 0.1 ,
236
245
params : DualAverageOptions :: default ( ) ,
246
+ fixed_step_size : None ,
237
247
}
238
248
}
239
249
}
0 commit comments