9
9
#include < chrono>
10
10
#include < cmath>
11
11
#include < iostream>
12
+ #include < limits>
12
13
#include < random>
13
14
#include < string>
14
15
#include < vector>
@@ -176,19 +177,19 @@ Vector initialize(DynamicStanModel& model, RNG& rng, double init_range,
176
177
int main (int argc, char ** argv) {
177
178
srand (std::chrono::system_clock::now ().time_since_epoch ().count ());
178
179
unsigned int seed = rand ();
179
- int64_t warmup = 1000 ;
180
- int64_t samples = 1000 ;
180
+ int64_t warmup = 128 ;
181
+ int64_t samples = 128 ;
181
182
int64_t max_nuts_depth = 10 ;
182
183
int64_t max_step_depth = 8 ;
183
184
double max_error = 0.5 ;
184
185
double init = 2.0 ;
185
186
double init_count = 1.1 ;
186
187
double mass_iteration_offset = 1.1 ;
187
- double additive_smoothing = 0.1 ;
188
- double step_size_init = 0.5 ;
189
- double accept_rate_target = 2.0 / 3.0 ;
190
- double step_iteration_offset = 2 .0 ;
191
- double learning_rate = 0.95 ;
188
+ double additive_smoothing = 1e-5 ;
189
+ double step_size_init = 1.0 ;
190
+ double accept_rate_target = 0.8 ;
191
+ double step_iteration_offset = 5 .0 ;
192
+ double learning_rate = 1.5 ;
192
193
double decay_rate = 0.05 ;
193
194
194
195
std::string lib;
@@ -202,58 +203,72 @@ int main(int argc, char** argv) {
202
203
app.add_option (" --seed" , seed, " Random seed" )->default_val (seed);
203
204
204
205
app.add_option (" --warmup" , warmup, " Number of warmup iterations" )
205
- ->default_val (warmup);
206
+ ->default_val (warmup)
207
+ ->check (CLI::NonNegativeNumber);
206
208
207
209
app.add_option (" --samples" , samples, " Number of samples to draw" )
208
- ->default_val (samples);
210
+ ->default_val (samples)
211
+ ->check (CLI::PositiveNumber);
209
212
210
213
app.add_option (" --max-depth" , max_nuts_depth,
211
214
" Maximum depth for NUTS trajectory doublings" )
212
- ->default_val (max_nuts_depth);
215
+ ->default_val (max_nuts_depth)
216
+ ->check (CLI::PositiveNumber);
213
217
214
218
app.add_option (" --max-step-depth" , max_step_depth,
215
219
" Maximum depth for the step size adaptation" )
216
- ->default_val (max_step_depth);
220
+ ->default_val (max_step_depth)
221
+ ->check (CLI::PositiveNumber);
217
222
218
223
app.add_option (" --max-error" , max_error,
219
224
" Maximum error allowed in joint densities" )
220
- ->default_val (max_error);
225
+ ->default_val (max_error)
226
+ ->check (CLI::PositiveNumber);
221
227
222
228
app.add_option (" --init" , init,
223
229
" Range [-init,init] for the parameters initial values" )
224
- ->default_val (init);
230
+ ->default_val (init)
231
+ ->check (CLI::NonNegativeNumber);
225
232
226
233
app.add_option (" --mass-init-count" , init_count,
227
234
" Initial count for the mass matrix adaptation" )
228
- ->default_val (init_count);
235
+ ->default_val (init_count)
236
+ ->check (CLI::Range (1.0 , std::numeric_limits<double >::max ()));
229
237
230
238
app.add_option (" --mass-iteration-offset" , mass_iteration_offset,
231
239
" Offset for the mass matrix adaptation iterations" )
232
- ->default_val (mass_iteration_offset);
240
+ ->default_val (mass_iteration_offset)
241
+ ->check (CLI::Range (1.0 , std::numeric_limits<double >::max ()));
233
242
234
243
app.add_option (" --mass-additive-smoothing" , additive_smoothing,
235
244
" Additive smoothing for the mass matrix adaptation" )
236
- ->default_val (additive_smoothing);
245
+ ->default_val (additive_smoothing)
246
+ ->check (CLI::PositiveNumber);
237
247
238
248
app.add_option (" --step-size-init" , step_size_init,
239
249
" Initial step size for the step size adaptation" )
240
- ->default_val (step_size_init);
250
+ ->default_val (step_size_init)
251
+ ->check (CLI::PositiveNumber);
241
252
242
253
app.add_option (" --step-accept-rate-target" , accept_rate_target,
243
254
" Target acceptance rate for the step size adaptation" )
244
- ->default_val (accept_rate_target);
255
+ ->default_val (accept_rate_target)
256
+ ->check (CLI::Range (std::numeric_limits<double >::min (), 1.0 ));
245
257
246
258
app.add_option (" --step-iteration-offset" , step_iteration_offset,
247
259
" Offset for the step size adaptation iterations" )
248
- ->default_val (step_iteration_offset);
260
+ ->default_val (step_iteration_offset)
261
+ ->check (CLI::Range (1.0 , std::numeric_limits<double >::max ()));
249
262
250
263
app.add_option (" --step-learning-rate" , learning_rate,
251
264
" Learning rate for the step size adaptation" )
252
- ->default_val (learning_rate);
265
+ ->default_val (learning_rate)
266
+ ->check (CLI::PositiveNumber);
253
267
254
268
app.add_option (" --step-decay-rate" , decay_rate,
255
269
" Decay rate for the step size adaptation" )
256
- ->default_val (decay_rate);
270
+ ->default_val (decay_rate)
271
+ ->check (CLI::PositiveNumber);
257
272
258
273
app.add_option (" model" , lib, " Path to the Stan model library" )
259
274
->required ()
0 commit comments