Tomographer  v5.4
Tomographer C++ Framework Documentation
mhrw.h
Go to the documentation of this file.
1 /* This file is part of the Tomographer project, which is distributed under the
2  * terms of the MIT license.
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2016 ETH Zurich, Institute for Theoretical Physics, Philippe Faist
7  * Copyright (c) 2017 Caltech, Institute for Quantum Information and Matter, Philippe Faist
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to deal
11  * in the Software without restriction, including without limitation the rights
12  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25  * SOFTWARE.
26  */
27 
28 #ifndef _TOMOGRAPHER_MHRW_H
29 #define _TOMOGRAPHER_MHRW_H
30 
31 #include <cstddef>
32 #include <cmath>
33 
34 #include <limits>
35 #include <random>
36 #include <sstream>
37 #include <iomanip>
38 #include <type_traits>
39 
40 #include <boost/serialization/serialization.hpp>
41 
43 #include <tomographer/tools/fmt.h>
45 #include <tomographer/tools/statusprovider.h>
46 #include <tomographer/multiproc.h>
49 
50 
51 
58 namespace Tomographer {
59 
60 
61 
62 
63 
64 enum {
78 };
79 
80 
81 
82 // note: const implies static linkage, see http://stackoverflow.com/q/2268749/1694896
83 //
85 constexpr const double MHRWAcceptanceRatioRecommendedMin = 0.2;
87 constexpr const double MHRWAcceptanceRatioRecommendedMax = 0.4;
88 
89 
96 template<typename StepRealType_ = double>
97 struct TOMOGRAPHER_EXPORT MHWalkerParamsStepSize
98 {
99  typedef StepRealType_ StepRealType;
100 
101  MHWalkerParamsStepSize() : step_size() { }
102  MHWalkerParamsStepSize(StepRealType step_size_) : step_size(step_size_) { }
103 
104  StepRealType step_size;
105 
106 private:
107  friend boost::serialization::access;
108  template<typename Archive>
109  void serialize(Archive & a, unsigned int /* version */)
110  {
111  a & step_size;
112  }
113 };
114 
115 template<typename StepRealType>
116 inline std::ostream & operator<<(std::ostream & stream, MHWalkerParamsStepSize<StepRealType> p)
117 {
118  return stream << "step_size=" << p.step_size;
119 }
120 
121 
134 template<typename MHWalkerParams_ = MHWalkerParamsStepSize<double>, typename CountIntType_ = int >
135 struct TOMOGRAPHER_EXPORT MHRWParams
136 {
137  typedef MHWalkerParams_ MHWalkerParams;
138  typedef CountIntType_ CountIntType;
139 
144  : mhwalker_params(), n_sweep(0), n_therm(0), n_run(0)
145  {
146  }
147 
153  template<typename MHWalkerParamsInit>
154  MHRWParams(MHWalkerParamsInit && mhwalker_params_,
155  CountIntType n_sweep_, CountIntType n_therm_, CountIntType n_run_)
156  : mhwalker_params(std::forward<MHWalkerParamsInit>(mhwalker_params_)),
157  n_sweep(n_sweep_), n_therm(n_therm_), n_run(n_run_)
158  {
159  }
160 
163  template<typename MHWalkerParamsOtherType, typename CountIntOtherType>
165  : mhwalker_params(copy.mhwalker_params),
166  n_sweep(copy.n_sweep), n_therm(copy.n_therm), n_run(copy.n_run)
167  {
168  }
169 
172  MHWalkerParams mhwalker_params;
173 
176  CountIntType n_sweep;
177 
180  CountIntType n_therm;
181 
184  CountIntType n_run;
185 
186 private:
187  friend boost::serialization::access;
188  template<typename Archive,
189  // this way, if MHWalkerParams is not serializable with boost, this declaration
190  // will fail only when it is explicitly requested:
191  typename MHWalkerParams2 = MHWalkerParams>
192  void serialize(Archive & a, unsigned int /* version */)
193  {
194  MHWalkerParams2 & mhwalker_params_ref = mhwalker_params;
195  a & mhwalker_params_ref;
196  a & n_sweep;
197  a & n_therm;
198  a & n_run;
199  }
200 };
201 
202 
203 
204 template<typename CountIntType, typename MHWalkerParams>
205 inline std::ostream & operator<<(std::ostream & str, const MHRWParams<MHWalkerParams,CountIntType> & p)
206 {
207  str << "MHRWParams(" << p.mhwalker_params << ";n_sweep=" << p.n_sweep
208  << ",n_therm=" << p.n_therm << ",n_run=" << p.n_run << ")";
209  return str;
210 }
211 
212 
213 
232 
240 
245 
250 
255 
256 
260 
264 };
265 
266 
267 
268 
273 template<typename MHRWControllerType_>
275 {
276  typedef MHRWControllerType_ MHRWControllerType;
277  enum { AdjustmentStrategy = MHRWControllerType::AdjustmentStrategy };
278 
279 private:
280  constexpr static bool _enabled_callback(bool IsThermalizing, bool IsAfterSample)
281  {
282  return
283  ( ((AdjustmentStrategy & MHRWControllerAdjustWhileThermalizing) && IsThermalizing) ||
284  ((AdjustmentStrategy & MHRWControllerAdjustWhileRunning) && !IsThermalizing) )
285  &&
286  ( ((AdjustmentStrategy & MHRWControllerAdjustEverySample) && IsAfterSample) ||
287  ((AdjustmentStrategy & MHRWControllerAdjustEveryIteration) && !IsAfterSample) )
288  ;
289  }
290 
291 public:
292 
293  template<typename... Args>
294  static inline void invokeInit(MHRWControllerType & x, Args && ... args) {
295  x.init(std::forward<Args>(args)...) ;
296  }
297 
298  template<typename MHRWParamsType, typename MHWalker, typename CountIntType, typename MHRandomWalkType>
299  static inline bool invokeAllowDoneThermalization(MHRWControllerType & x,
300  const MHRWParamsType & params, // ensure this is const
301  const MHWalker & mhwalker,
302  CountIntType iter_k,
303  const MHRandomWalkType & mhrw)
304  {
305  return x.allowDoneThermalization(params, mhwalker, iter_k, mhrw);
306  }
307 
308  template<typename MHRWParamsType, typename MHWalker, typename CountIntType, typename MHRandomWalkType>
309  static inline bool invokeAllowDoneRuns(MHRWControllerType & x,
310  const MHRWParamsType & params, // ensure this is const
311  const MHWalker & mhwalker,
312  CountIntType iter_k,
313  const MHRandomWalkType & mhrw)
314  {
315  return x.allowDoneRuns(params, mhwalker, iter_k, mhrw);
316  }
317 
318 
319  template<bool IsThermalizing, bool IsAfterSample, typename ... Args>
320  static inline
322  invokeAdjustParams(MHRWControllerType & x, Args && ... args)
323  {
324  x.template adjustParams<IsThermalizing, IsAfterSample>(std::forward<Args>(args)...);
325  }
326  template<bool IsThermalizing, bool IsAfterSample, typename ... Args>
327  static inline
329  invokeAdjustParams(MHRWControllerType & , Args && ... )
330  {
331  // callback disabled
332  }
333 
334 };
335 
336 
337 
338 
339 namespace tomo_internal {
340 
341 template<unsigned int AdjustmentStrategy, unsigned int OtherAdjustmentStrategy>
342 struct controller_flags_compatible {
343  static constexpr bool value =
344  // adjustments are done on different stages of the random walk
345  ((AdjustmentStrategy & OtherAdjustmentStrategy & MHRWControllerAdjustRWStageMASK) == 0) ;
346 };
347 
348 
349 template<bool RestOk, unsigned int ProcessedAdjustmentStrategyFlags,
350  typename... MHRWControllerTypes>
351 struct controllers_compatible_helper;
352 
353 template<bool RestOk, unsigned int ProcessedAdjustmentStrategyFlags, typename MHRWControllerAType,
354  typename... MHRWControllerRestTypes>
355 struct controllers_compatible_helper<RestOk, ProcessedAdjustmentStrategyFlags, MHRWControllerAType,
356  MHRWControllerRestTypes...>
357  : controllers_compatible_helper<
358  RestOk && controller_flags_compatible<MHRWControllerAType::AdjustmentStrategy,
359  ProcessedAdjustmentStrategyFlags>::value ,
360  ProcessedAdjustmentStrategyFlags | MHRWControllerAType::AdjustmentStrategy,
361  MHRWControllerRestTypes...
362  > { };
363 
364 template<bool RestOk, unsigned int ProcessedAdjustmentStrategyFlags>
365 struct controllers_compatible_helper<RestOk, ProcessedAdjustmentStrategyFlags> {
366  static constexpr bool value = RestOk;
367  static constexpr unsigned int CombinedAdjustmentStrategy = ProcessedAdjustmentStrategyFlags;
368 };
369 
370 
371 template<typename... MHRWControllerTypes>
372 struct controllers_compatible : controllers_compatible_helper<true, 0, MHRWControllerTypes...> { };
373 
374 } // namespace tomo_internal
375 
376 
377 
378 
379 
380 
381 
397 template<typename ... MHRWControllerTypes>
398 class TOMOGRAPHER_EXPORT MHRWMultipleControllers
399 {
400 public:
401 
402  typedef std::tuple<MHRWControllerTypes...> TupleType;
403  typedef std::tuple<MHRWControllerTypes&...> TupleRefType;
404 
405  static constexpr int NumControllers = sizeof...(MHRWControllerTypes) ;
406 
408 
409 private:
410  TupleRefType controllers;
411 
412 public:
413  enum {
414  AdjustmentStrategy =
415  tomo_internal::controllers_compatible<MHRWControllerTypes...>::CombinedAdjustmentStrategy
416  };
417 
418 
419  MHRWMultipleControllers(MHRWControllerTypes&... controllers_)
420  : controllers(controllers_...)
421  {
422  }
423 
424 
425  template<int I>
426  inline const typename std::tuple_element<I, TupleRefType>::type getController() const
427  {
428  return std::get<I>(controllers) ;
429  }
430 
431 
432  template<typename MHRWParamsType, typename MHWalker, typename MHRandomWalkType,
433  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I < NumControllers)>
434  inline void init(MHRWParamsType & params, const MHWalker & mhwalker,
435  const MHRandomWalkType & mhrw)
436  {
437  std::get<I>(controllers).init(params, mhwalker, mhrw);
438  init<MHRWParamsType, MHWalker, MHRandomWalkType, I+1>(params, mhwalker, mhrw);
439  }
440  template<typename MHRWParamsType, typename MHWalker, typename MHRandomWalkType,
441  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I == NumControllers)>
442  inline void init(const MHRWParamsType &, const MHWalker &, const MHRandomWalkType &) const
443  {
444  }
445 
446  template<typename MHRWParamsType, typename MHWalker, typename MHRandomWalkType,
447  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I < NumControllers)>
448  inline void thermalizingDone(MHRWParamsType & params, const MHWalker & mhwalker,
449  const MHRandomWalkType & mhrw)
450  {
451  std::get<I>(controllers).thermalizingDone(params, mhwalker, mhrw);
452  thermalizingDone<MHRWParamsType, MHWalker, MHRandomWalkType, I+1>(params, mhwalker, mhrw);
453  }
454  template<typename MHRWParamsType, typename MHWalker, typename MHRandomWalkType,
455  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I == NumControllers)>
456  inline void thermalizingDone(const MHRWParamsType & , const MHWalker & ,
457  const MHRandomWalkType & ) const
458  {
459  }
460 
461  template<typename MHRWParamsType, typename MHWalker, typename MHRandomWalkType,
462  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I < NumControllers)>
463  inline void done(MHRWParamsType & params, const MHWalker & mhwalker,
464  const MHRandomWalkType & mhrw)
465  {
466  std::get<I>(controllers).done(params, mhwalker, mhrw);
467  done<MHRWParamsType, MHWalker, MHRandomWalkType, I+1>(params, mhwalker, mhrw);
468  }
469  template<typename MHRWParamsType, typename MHWalker, typename MHRandomWalkType,
470  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I == NumControllers)>
471  inline void done(const MHRWParamsType & , const MHWalker & ,
472  const MHRandomWalkType & ) const
473  {
474  }
475 
476  template<bool IsThermalizing, bool IsAfterSample,
477  typename MHRWParamsType, typename CountIntType,
478  typename MHWalker, typename MHRandomWalkType,
479  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I < NumControllers)>
480  inline void adjustParams(MHRWParamsType & params, const MHWalker & mhwalker,
481  CountIntType iter_k, const MHRandomWalkType & mhrw)
482  {
483  // only one of the calls to adjustParmas() should actually go through; we've checked
484  // this above with a static_assert
486  ::template invokeAdjustParams<IsThermalizing,IsAfterSample>(
487  std::get<I>(controllers), params, mhwalker, iter_k, mhrw
488  );
489  adjustParams<IsThermalizing,IsAfterSample,MHRWParamsType,CountIntType,MHWalker,MHRandomWalkType,I+1>(
490  params, mhwalker, iter_k, mhrw
491  );
492  }
493  template<bool IsThermalizing, bool IsAfterSample,
494  typename MHRWParamsType, typename CountIntType,
495  typename MHWalker, typename MHRandomWalkType,
496  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I == NumControllers)>
497  inline void adjustParams(const MHRWParamsType &, const MHWalker &,
498  CountIntType , const MHRandomWalkType &) const
499  {
500  }
501 
502  template<typename MHRWParamsType, typename MHWalker, typename CountIntType, typename MHRandomWalkType,
503  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I < NumControllers)>
504  inline bool allowDoneThermalization(const MHRWParamsType & params, const MHWalker & mhwalker,
505  CountIntType iter_k, const MHRandomWalkType & mhrw)
506  {
507  return std::get<I>(controllers).allowDoneThermalization(params, mhwalker, iter_k, mhrw) &&
508  allowDoneThermalization<MHRWParamsType,MHWalker,CountIntType,MHRandomWalkType,I+1>(
509  params, mhwalker, iter_k, mhrw
510  ) ;
511  }
512  template<typename MHRWParamsType, typename MHWalker, typename CountIntType, typename MHRandomWalkType,
513  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I == NumControllers)>
514  inline bool allowDoneThermalization(const MHRWParamsType & , const MHWalker & ,
515  CountIntType , const MHRandomWalkType & ) const
516  {
517  return true;
518  }
519 
520  template<typename MHRWParamsType, typename MHWalker, typename CountIntType, typename MHRandomWalkType,
521  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I < NumControllers)>
522  inline bool allowDoneRuns(const MHRWParamsType & params, const MHWalker & mhwalker,
523  CountIntType iter_k, const MHRandomWalkType & mhrw)
524  {
525  return std::get<I>(controllers).allowDoneRuns(params, mhwalker, iter_k, mhrw) &&
526  allowDoneRuns<MHRWParamsType,MHWalker,CountIntType,MHRandomWalkType,I+1>(
527  params, mhwalker, iter_k, mhrw
528  ) ;
529  }
530  template<typename MHRWParamsType, typename MHWalker, typename CountIntType, typename MHRandomWalkType,
531  int I = 0, TOMOGRAPHER_ENABLED_IF_TMPL(I == NumControllers)>
532  inline bool allowDoneRuns(const MHRWParamsType & , const MHWalker & ,
533  CountIntType , const MHRandomWalkType & ) const
534  {
535  return true;
536  }
537 };
538 template<typename ... MHRWControllerTypes>
539 constexpr int MHRWMultipleControllers<MHRWControllerTypes...>::NumControllers;
540 
541 
547 template<typename... MHRWControllerTypes>
548 inline MHRWMultipleControllers<MHRWControllerTypes...>
549 mkMHRWMultipleControllers(MHRWControllerTypes & ... controllers)
550 {
551  return MHRWMultipleControllers<MHRWControllerTypes...>( controllers ... ) ;
552 }
553 
554 
555 
563 
564 
565 
566 
567 
568 
569 
570 namespace tomo_internal {
571 // const_type_helper: a single typedef member, 'type', which is declared as 'T' or 'const
572 // T' depending on whether use_const=false or true
573 template<typename T, bool use_const>
574 struct const_type_helper {
575  typedef T type;
576 };
577 template<typename T>
578 struct const_type_helper<T, true> {
579  typedef const T type;
580 };
581 
582 template<typename MHWalker, bool has_FnValueType>
583 struct helper_FnValueType_or_dummy {
584  typedef typename MHWalker::FnValueType type;
585 };
586 template<typename MHWalker>
587 struct helper_FnValueType_or_dummy<MHWalker,false> {
588  typedef int type; // dummy
589 };
590 } // namespace tomo_internal
591 
592 
639 template<typename Rng_, typename MHWalker_, typename MHRWStatsCollector_,
640  typename MHRWController_ = MHRWNoController,
641  typename LoggerType_ = Logger::VacuumLogger,
642  typename CountIntType_ = int>
643 class TOMOGRAPHER_EXPORT MHRandomWalk
644  : public virtual Tools::NeedOwnOperatorNew<typename MHWalker_::PointType>::ProviderType
645 {
646 public:
648  typedef Rng_ Rng;
650  typedef MHWalker_ MHWalker;
652  typedef MHRWStatsCollector_ MHRWStatsCollector;
654  typedef LoggerType_ LoggerType;
657  typedef CountIntType_ CountIntType;
658 
660  typedef typename MHWalker::PointType PointType;
662  typedef typename MHWalker::WalkerParams MHWalkerParams;
663 
666 
668  typedef MHRWController_ MHRWController;
669  enum { MHRWControllerStrategy = MHRWController::AdjustmentStrategy };
670 
673 
675 #ifndef TOMOGRAPHER_PARSED_BY_DOXYGEN
676  typedef typename tomo_internal::helper_FnValueType_or_dummy<
677  MHWalker,(int)MHWalker::UseFnSyntaxType!=(int)MHUseFnRelativeValue
678  >::type FnValueType;
679 #else
680  typedef _FnValueType FnValueType;
681 #endif
682 
683  enum {
685  UseFnSyntaxType = MHWalker::UseFnSyntaxType
686  };
687 
688 private:
689  // declare const if no adjustments are to be made. This expands to "MHRWParamsType _n;"
690  // or "const MHRWParamsType _n;"
691  typename tomo_internal::const_type_helper<
692  MHRWParamsType,
693  (int)MHRWControllerStrategy==(int)MHRWControllerDoNotAdjust
694  >::type _n;
695 
696  Rng & _rng;
697  MHWalker & _mhwalker;
698  MHRWStatsCollector & _stats;
699  MHRWController & _mhrw_controller;
700 
702 
704  PointType curpt;
708  FnValueType curptval;
709 
714  CountIntType num_accepted;
718  CountIntType num_live_points;
719 
720 
721 public:
722 
724  MHRandomWalk(MHWalkerParams mhwalker_params, CountIntType n_sweep, CountIntType n_therm, CountIntType n_run,
725  MHWalker & mhwalker, MHRWStatsCollector & stats, MHRWController & mhrw_controller,
726  Rng & rng, LoggerType & logger_)
727  : _n(mhwalker_params, n_sweep, n_therm, n_run),
728  _rng(rng),
729  _mhwalker(mhwalker),
730  _stats(stats),
731  _mhrw_controller(mhrw_controller),
732  _logger(TOMO_ORIGIN, logger_),
733  curpt(),
734  curptval(),
735  num_accepted(0),
736  num_live_points(0)
737  {
738  _logger.debug([&](std::ostream & stream) {
739  stream << "constructor(). n_sweep=" << n_sweep << ", mhwalker_params=" << mhwalker_params
740  << "n_therm=" << n_therm << ", n_run=" << n_run;
741  });
742  }
744  template<typename MHRWParamsTypeInit>
745  MHRandomWalk(MHRWParamsTypeInit&& n_rw,
746  MHWalker & mhwalker, MHRWStatsCollector & stats, MHRWController & mhrw_controller,
747  Rng & rng, LoggerType & logger_)
748  : _n(std::forward<MHRWParamsTypeInit>(n_rw)),
749  _rng(rng),
750  _mhwalker(mhwalker),
751  _stats(stats),
752  _mhrw_controller(mhrw_controller),
753  _logger(TOMO_ORIGIN, logger_),
754  curpt(),
755  curptval(),
756  num_accepted(0),
757  num_live_points(0)
758  {
759  _logger.debug([&](std::ostream & s) { s << "constructor(). mhrw parameters = " << _n; });
760  }
761 
762  MHRandomWalk(const MHRandomWalk & other) = delete;
763 
764 
766  inline const MHRWStatsCollector & statsCollector() const { return _stats; }
767 
769  inline const MHRWController & mhrwController() const { return _mhrw_controller; }
770 
771 
773  inline MHRWParamsType mhrwParams() const { return _n; }
774 
776  inline MHWalkerParams mhWalkerParams() const { return _n.mhwalker_params; }
777 
779  inline CountIntType nSweep() const { return _n.n_sweep; }
781  inline CountIntType nTherm() const { return _n.n_therm; }
783  inline CountIntType nRun() const { return _n.n_run; }
784 
785 
789  inline bool hasAcceptanceRatio() const
790  {
791  return (num_live_points > 0);
792  }
795  template<typename RatioType = double>
796  inline RatioType acceptanceRatio() const
797  {
798  return RatioType(num_accepted) / RatioType(num_live_points);
799  }
800 
801 
806  inline const PointType & getCurrentPoint() const
807  {
808  return curpt;
809  }
810 
818  inline const FnValueType & getCurrentPointValue() const
819  {
820  return curptval;
821  }
822 
828  inline void setCurrentPoint(const PointType& pt)
829  {
830  curpt = pt;
831  curptval = _get_ptval(curpt);
832  _logger.longdebug([&](std::ostream & s) {
833  s << "setCurrentPoint: set internal state. Value = " << curptval << "; Point =\n" << pt << "\n";
834  });
835  }
836 
837 
838 private:
839 
842  inline void _init()
843  {
844  num_accepted = 0;
845  num_live_points = 0;
846 
847  // starting point
848  curpt = _mhwalker.startPoint();
849  curptval = _get_ptval(curpt);
850 
851  _mhwalker.init();
852  _stats.init();
853 
854  _mhrw_controller.init(_n, _mhwalker, *this);
855 
856  _logger.longdebug("_init() done.");
857  }
860  inline void _thermalizing_done()
861  {
862  _mhwalker.thermalizingDone();
863  _stats.thermalizingDone();
864 
865  _mhrw_controller.thermalizingDone(_n, _mhwalker, *this);
866 
867  _logger.longdebug("_thermalizing_done() done.");
868  }
871  inline void _done()
872  {
873  _mhwalker.done();
874  _stats.done();
875 
876  _mhrw_controller.done(_n, _mhwalker, *this);
877 
878  _logger.longdebug("_done() done.");
879  }
880 
888  template<bool IsThermalizing>
889  inline void _move(CountIntType k, bool is_live_iter)
890  {
891  _logger.longdebug("_move()");
892  // The reason `mhwalker_params` is passed to jump_fn instead of leaving jump_fn itself
893  // handle the step size, is that we might in the future want to dynamically adapt the
894  // step size according to the acceptance ratio. That would have to be done in this
895  // class.
896  const PointType newpt = _mhwalker.jumpFn(curpt, _n.mhwalker_params);
897 
898  const FnValueType newptval = _get_ptval(newpt);
899 
900  const double a = _get_a_value(newpt, newptval, curpt, curptval);
901 
902  // accept move?
903  bool accept = ( a >= 1.0 ? true : bool( _rng()-_rng.min() <= a*(_rng.max()-_rng.min()) ) ) ;
904 
905  // track acceptance ratio, except if we are thermalizing
906  if (!IsThermalizing) {
907  num_accepted += accept ? 1 : 0;
908  ++num_live_points;
909  }
910 
911  _stats.rawMove(k, IsThermalizing, is_live_iter, accept, a, newpt, newptval, curpt, curptval, *this);
912 
913  _logger.longdebug([&](std::ostream & stream) {
914  stream << (IsThermalizing?"T":"#") << std::setw(3) << k << ": " << (accept?"AC":"RJ") << " "
915  << std::setprecision(4)
916  << "a=" << std::setw(5) << a << ", newptval=" << std::setw(5) << newptval
917  << ", curptval=" << std::setw(5) << curptval << ", accept_ratio="
918  << (!IsThermalizing ? Tools::fmts("%.2g", this->acceptanceRatio()) : std::string("N/A"))
919  << Tools::streamIfPossible(curpt, "\ncurpt = ", "", "");
920  });
921 
922  if (accept) {
923  // update the internal state of the random walk
924  curpt = newpt;
925  curptval = newptval;
926  }
927  _logger.longdebug("_move() done.");
928  }
929 
934  inline void _process_sample(CountIntType k, CountIntType n)
935  {
936  _stats.processSample(k, n, curpt, curptval, *this);
937  _logger.longdebug("_process_sample() done.");
938  }
939 
940 
941  //
942  // utilities for getting the fn value at a specific point, and comparing & getting the
943  // "a"-value for the jump
944  //
945 
946 #ifdef TOMOGRAPHER_PARSED_BY_DOXYGEN
947 
953  inline FnValueType _get_ptval(PointType curpt) const { }
967  inline double _get_a_value(PointType newpt, FnValueType newptval,
968  PointType curpt, FnValueType curptval) const { }
969 #else
970  // the actual implementation:
971 
972  // Case UseFnSyntaxType==MHUseFnValue
973  template<typename PtType, TOMOGRAPHER_ENABLED_IF_TMPL(UseFnSyntaxType == MHUseFnValue)>
974  inline FnValueType _get_ptval(PtType && curpt) const
975  {
976  return _mhwalker.fnVal(curpt);
977  }
978  template<typename PtType1, typename PtType2, TOMOGRAPHER_ENABLED_IF_TMPL(UseFnSyntaxType == MHUseFnValue)>
979  inline double _get_a_value(PtType1 && /*newpt*/, FnValueType newptval,
980  PtType2 && /*curpt*/, FnValueType curptval) const
981  {
982  return ((double)newptval) / curptval;
983  }
984 
985  // Case UseFnSyntaxType==MHUseFnLogValue
986  template<typename PtType, TOMOGRAPHER_ENABLED_IF_TMPL(UseFnSyntaxType == MHUseFnLogValue)>
987  inline FnValueType _get_ptval(PtType && curpt) const
988  {
989  return _mhwalker.fnLogVal(curpt);
990  }
991  template<typename PtType1, typename PtType2, TOMOGRAPHER_ENABLED_IF_TMPL(UseFnSyntaxType == MHUseFnLogValue)>
992  inline double _get_a_value(PtType1 && /*newpt*/, FnValueType newptval,
993  PtType2 && /*curpt*/, FnValueType curptval) const
994  {
995  using namespace std;
996  return (newptval > curptval) ? 1.0 : exp(double(newptval - curptval));
997  }
998 
999  // case UseFnSyntaxType==MHUseFnRelativeValue
1000  template<typename PtType, TOMOGRAPHER_ENABLED_IF_TMPL(UseFnSyntaxType == MHUseFnRelativeValue)>
1001  inline FnValueType _get_ptval(PtType && /*curpt*/) const
1002  {
1003  return 0;
1004  }
1005  template<typename PtType1, typename PtType2, TOMOGRAPHER_ENABLED_IF_TMPL(UseFnSyntaxType == MHUseFnRelativeValue)>
1006  inline double _get_a_value(PtType1 && newpt, FnValueType /*newptval*/,
1007  PtType2 && curpt, FnValueType /*curptval*/) const
1008  {
1009  using namespace std;
1010  return _mhwalker.fnRelVal(std::forward<PtType1>(newpt), std::forward<PtType2>(curpt));
1011  }
1012 
1013 #endif
1014 
1015 
1016  // adjustments
1017  template<bool IsThermalizing>
1018  inline void _controller_adjust_afteriter(CountIntType iter_k)
1019  {
1020  MHRWControllerInvokerType::template invokeAdjustParams<IsThermalizing, false>(
1021  _mhrw_controller, _n, _mhwalker, iter_k, *this
1022  );
1023  }
1024  inline void _controller_adjust_aftersample(CountIntType iter_k)
1025  {
1026  MHRWControllerInvokerType::template invokeAdjustParams<false, true>(
1027  _mhrw_controller, _n, _mhwalker, iter_k, *this
1028  );
1029  }
1030  inline bool _controller_allow_therm_done(CountIntType iter_k)
1031  {
1032  return (iter_k % _n.n_sweep == 0) &&
1033  MHRWControllerInvokerType::template invokeAllowDoneThermalization(
1034  _mhrw_controller, _n, _mhwalker, iter_k, *this
1035  );
1036  }
1037  inline bool _controller_allow_runs_done(CountIntType iter_k)
1038  {
1039  return (iter_k % _n.n_sweep == 0) &&
1040  MHRWControllerInvokerType::template invokeAllowDoneRuns(
1041  _mhrw_controller, _n, _mhwalker, iter_k, *this
1042  );
1043  }
1044 
1045 public:
1046 
1053  void run()
1054  {
1055  _init();
1056 
1057  // make sure that the iteration counter will not overflow.
1058  if (Tomographer::Tools::multiplicationWillOverflow(_n.n_sweep, _n.n_therm) ||
1059  Tomographer::Tools::multiplicationWillOverflow(_n.n_sweep, _n.n_run)) {
1060  std::string msg = streamstr(
1061  "Error: integer type " << boost::core::demangle(typeid(CountIntType).name())
1062  << " cannot be used to represent number of iterations, will overflow with given params "
1063  << _n
1064  );
1065  _logger.error([&](std::ostream & stream) {
1066  stream << msg;
1067  });
1068  // this is an error, cannot continue.
1069  throw std::runtime_error(msg);
1070  }
1071 
1072  CountIntType k;
1073 
1074  _logger.longdebug([&](std::ostream & s) {
1075  s << "Starting random walk, parameters are = " << _n;
1076  });
1077 
1078  // keep the this expression explicit in the condition, because it may be updated by
1079  // the controller. (The compiler should optimize the const value anyway if no
1080  // controller is set because _n is declared const in that case.)
1081  for ( k = 0 ; (k < (_n.n_sweep * _n.n_therm)) || !_controller_allow_therm_done(k) ; ++k ) {
1082  _move<true>(k, false);
1083  _controller_adjust_afteriter<true>(k);
1084  }
1085 
1086  _thermalizing_done();
1087 
1088  _logger.longdebug("Thermalizing done, starting live runs.");
1089 
1090  CountIntType n = 0; // number of live samples
1091 
1092  // keep the this expression explicit in the condition, because it may be updated by
1093  // the controller. (The compiler should optimize the const value anyway if no
1094  // controller is set because _n is declared const in that case.)
1095  for (k = 0 ; (k < (_n.n_sweep * _n.n_run)) || !_controller_allow_runs_done(k) ; ++k) {
1096 
1097  bool is_live_iter = ((k+1) % _n.n_sweep == 0);
1098 
1099  // calculate a candidate jump point and see if we accept the move
1100  _move<false>(k, is_live_iter);
1101  _controller_adjust_afteriter<false>(k);
1102 
1103  if (is_live_iter) {
1104  _process_sample(k, n);
1105  ++n;
1106  _controller_adjust_aftersample(k);
1107  }
1108 
1109  }
1110 
1111  _done();
1112 
1113  _logger.longdebug("Random walk completed.");
1114 
1115  return;
1116  }
1117 };
1118 
1119 
1120 
1121 
1122 
1123 
1124 
1125 
1126 
1127 
1128 
1129 
1130 
1131 
1141 template<typename MHRWParamsType>
1142 struct TOMOGRAPHER_EXPORT MHRWStatusReport : public MultiProc::TaskStatusReport
1143 {
1144  typedef typename MHRWParamsType::CountIntType IterCountIntType;
1145 
1147  MHRWStatusReport(double fdone = 0.0, const std::string & msg = std::string(),
1148  IterCountIntType kstep_ = 0, MHRWParamsType mhrw_params_ = MHRWParamsType(),
1149  double acceptance_ratio_ = 0.0)
1150  : MultiProc::TaskStatusReport(fdone, msg),
1151  kstep(kstep_),
1152  mhrw_params(mhrw_params_),
1153  acceptance_ratio(acceptance_ratio_),
1154  n_total_iters(mhrw_params.n_sweep*(mhrw_params.n_therm + mhrw_params.n_run))
1155  {
1156  }
1157 
1159  IterCountIntType kstep;
1160 
1169  MHRWParamsType mhrw_params;
1170 
1175 
1182  IterCountIntType n_total_iters;
1183 
1184  template<typename MHRandomWalkType, typename MHRWStatsCollectorType, typename MHRWControllerType>
1185  static inline MHRWStatusReport
1186  createFromRandWalkStatInfo(IterCountIntType k, bool is_thermalizing,
1187  const MHRandomWalkType & rw,
1188  const MHRWStatsCollectorType & stats_collector,
1189  const MHRWControllerType & mhrw_controller) {
1190  // prepare & provide status report
1191  IterCountIntType totiters = rw.nSweep()*(rw.nTherm()+rw.nRun());
1192  // k restarts at zero after thermalization, so account for that:
1193  IterCountIntType kreal = is_thermalizing ? k : k + rw.nSweep()*rw.nTherm();
1194  double fdone = ( is_thermalizing ? (double)k : (double)k + rw.nSweep()*rw.nTherm() ) / (double)totiters;
1195  double accept_ratio = std::numeric_limits<double>::quiet_NaN();
1196  bool warn_accept_ratio = false;
1197  std::string accept_ratio_msg;
1198  if (rw.hasAcceptanceRatio()) {
1199  accept_ratio = rw.acceptanceRatio();
1200  warn_accept_ratio = (accept_ratio > MHRWAcceptanceRatioRecommendedMax ||
1201  accept_ratio < MHRWAcceptanceRatioRecommendedMin);
1202  accept_ratio_msg = std::string(" [") + (warn_accept_ratio ? "!!** " : "") +
1203  std::string("accept ratio=") + Tools::fmts("%.2f", accept_ratio) +
1204  (warn_accept_ratio ? " **!!" : "") + "]";
1205  }
1206 
1207  //
1208  // "therm. sweep NNN/NNN [+rn:NNN]: XX.XX% done"
1209  // "run sweep NNN/NNN [+th:NNN]: XX.XX% done [accept ratio=0.25]"
1210  //
1211  std::stringstream msgstr;
1212 
1213  // number of digits needed to represent n_run and n_therm
1214  int ndigrw = (int)(std::ceil(std::log10(std::max(rw.nTherm(), rw.nRun())))+0.01) ;
1215  if (is_thermalizing) {
1216  msgstr << "therm. sweep " << std::setw(ndigrw) << (k / rw.nSweep()) << "/"
1217  << std::setw(ndigrw) << rw.nTherm()
1218  << " [+rn:" << rw.nRun() << "]";
1219  } else {
1220  msgstr << "run sweep " << std::setw(ndigrw) << (k / rw.nSweep()) << "/"
1221  << std::setw(ndigrw) << rw.nRun()
1222  << " [+th:" << rw.nTherm() << "]";
1223  }
1224  msgstr << " : " << Tools::fmts("%5.2f", fdone*100.0) << "% done";
1225  if (accept_ratio_msg.size()) {
1226  msgstr << accept_ratio_msg;
1227  }
1228 
1229  std::string msg = msgstr.str();
1230 
1231  const std::string nlindent = "\n ";
1234  if (s.size()) {
1235  msg += nlindent;
1236  for (std::size_t j = 0; j < s.size(); ++j) {
1237  if (s[j] == '\n') {
1238  msg += nlindent;
1239  } else {
1240  msg += s[j];
1241  }
1242  }
1243  }
1244  }
1247  if (s.size()) {
1248  msg += nlindent;
1249  for (std::size_t j = 0; j < s.size(); ++j) {
1250  if (s[j] == '\n') {
1251  msg += nlindent;
1252  } else {
1253  msg += s[j];
1254  }
1255  }
1256  }
1257  }
1258  return MHRWStatusReport(fdone, msg, kreal, rw.mhrwParams(), accept_ratio);
1259  }
1260 
1261 };
1262 
1263 
1264 
1265 
1266 
1267 
1268 
1269 
1270 
1271 
1272 //
1273 // Specialize Tomographer::Tools::StatusProvider for our MHRWMultipleControllers
1274 //
1275 
1276 
1277 namespace Tools {
1278 
1282 template<typename... Args>
1283 struct TOMOGRAPHER_EXPORT StatusProvider<MHRWMultipleControllers<Args... > >
1284 {
1285  typedef MHRWMultipleControllers<Args... > MHRWControllerType;
1287 
1288  static constexpr int NumControllers = MHRWControllerType::NumControllers;
1289 
1290  static constexpr bool CanProvideStatusLine = true;
1291 
1292  template<int I = 0, typename std::enable_if<(I < NumControllers), bool>::type dummy = true>
1293  static inline std::string getStatusLine(const MHRWControllerType * ctrl)
1294  {
1295  typedef typename std::tuple_element<I, typename MHRWControllerType::TupleType>::type
1296  ThisController;
1297  return
1299  ? StatusQuery<ThisController>::getStatusLine(& ctrl->template getController<I>())
1300  : std::string()),
1301  getStatusLine<I+1>(ctrl) );
1302  };
1303 
1304  template<int I = 0, typename std::enable_if<(I == NumControllers), bool>::type dummy = true>
1305  static inline std::string getStatusLine(const MHRWControllerType * )
1306  {
1307  return std::string();
1308  }
1309 
1310 private:
1311  static inline std::string _joinnl(std::string a, std::string b) {
1312  if (a.size() && b.size()) {
1313  return std::move(a) + "\n" + std::move(b);
1314  }
1315  return std::move(a) + std::move(b); // one of these guys is empty
1316  }
1317 };
1318 // static members:
1319 template<typename... Args>
1320 constexpr int StatusProvider<MHRWMultipleControllers<Args... > >::NumControllers;
1321 template<typename... Args>
1322 constexpr bool StatusProvider<MHRWMultipleControllers<Args... > >::CanProvideStatusLine;
1323 
1324 
1325 } // namespace Tools
1326 
1327 
1328 
1329 
1330 
1331 
1332 
1333 
1334 } // namespace Tomographer
1335 
1336 
1337 
1338 
1339 #endif
A Metropolis-Hastings Random Walk.
Definition: mhrw.h:643
Utilities for formatting strings.
MHRWMultipleControllers MHRWNoController
A MHRWController Interface which does not adjust anything.
Definition: mhrw.h:562
MHRWMultipleControllers< MHRWControllerTypes... > mkMHRWMultipleControllers(MHRWControllerTypes &... controllers)
Convenience function to create a MHRWMultipleControllers (using template argument deduction) ...
Definition: mhrw.h:549
Mask out bits which decide at which random walk stage (thermalizing and/or running) adjustments are p...
Definition: mhrw.h:244
Adjustments are enabled during both thermalization and live (running) sweeps.
Definition: mhrw.h:238
IterCountIntType kstep
the current iteration number
Definition: mhrw.h:1159
MHRWParams(MHWalkerParamsInit &&mhwalker_params_, CountIntType n_sweep_, CountIntType n_therm_, CountIntType n_run_)
standard constructor – initializes fields to given values
Definition: mhrw.h:154
const MHRWStatsCollector & statsCollector() const
Access the stats collector.
Definition: mhrw.h:766
Adjustemnts should be performed after each individual iteration.
Definition: mhrw.h:247
double acceptance_ratio
the current acceptance ratio of the random walk (see Tomographer::MHRandomWalk::acceptanceRatio() ) ...
Definition: mhrw.h:1174
Base namespace for the Tomographer project.
Definition: densellh.h:45
MHRWStatusReport(double fdone=0.0, const std::string &msg=std::string(), IterCountIntType kstep_=0, MHRWParamsType mhrw_params_=MHRWParamsType(), double acceptance_ratio_=0.0)
Constructor which initializes all fields.
Definition: mhrw.h:1147
CountIntType nTherm() const
Number of thermalizing sweeps.
Definition: mhrw.h:781
T ceil(T... args)
CountIntType_ CountIntType
The type used for counting numbers of iterations (see, e.g. nSweep() or MHRWParams) ...
Definition: mhrw.h:657
void error(const char *fmt,...)
Generate a log message with level Logger::ERROR (printf-like syntax)
Definition: loggers.h:1904
MHWalker::PointType PointType
The type of a point in the random walk.
Definition: mhrw.h:660
T exp(T... args)
Adjustments are enabled during thermalization sweeps.
Definition: mhrw.h:234
An MHWalkerParams type which just stores a step size.
Definition: mhrw.h:97
const FnValueType & getCurrentPointValue() const
Access the current function value of the random walk.
Definition: mhrw.h:818
Provide appropriate operator new() definitions for a structure which has a member of the given stored...
CountIntType n_run
Number of live sweeps.
Definition: mhrw.h:184
Logger that discards all messages.
Definition: loggers.h:1149
STL namespace.
constexpr const double MHRWAcceptanceRatioRecommendedMax
Maximal recommended acceptance ratio.
Definition: mhrw.h:87
MHRWStatsCollector_ MHRWStatsCollector
The stats collector type (see MHRWStatsCollector Interface)
Definition: mhrw.h:652
MHWalker::WalkerParams MHWalkerParams
The parameters type of the MHWalker implememtation, typically just a double storing the step size of ...
Definition: mhrw.h:662
constexpr bool multiplicationWillOverflow(IntType a, IntType b)
Test whether a multiplication of two integers will cause an overflow/underflow for that integer type...
Definition: cxxutil.h:453
MHWalker_ MHWalker
The random walker type which knows about the state space and jump function.
Definition: mhrw.h:650
CountIntType n_therm
Number of thermalization sweeps.
Definition: mhrw.h:180
MHRandomWalk(MHWalkerParams mhwalker_params, CountIntType n_sweep, CountIntType n_therm, CountIntType n_run, MHWalker &mhwalker, MHRWStatsCollector &stats, MHRWController &mhrw_controller, Rng &rng, LoggerType &logger_)
Simple constructor, initializes the given fields.
Definition: mhrw.h:724
constexpr const double MHRWAcceptanceRatioRecommendedMin
Minimal recommended acceptance ratio.
Definition: mhrw.h:85
T log10(T... args)
#define TOMO_ORIGIN
Use this as argument for a Tomographer::Logger::LocalLogger constructor .
Definition: loggers.h:1608
MHRandomWalk(MHRWParamsTypeInit &&n_rw, MHWalker &mhwalker, MHRWStatsCollector &stats, MHRWController &mhrw_controller, Rng &rng, LoggerType &logger_)
Simple constructor, initializes the given fields.
Definition: mhrw.h:745
const MHRWController & mhrwController() const
Access the random walk controller.
Definition: mhrw.h:769
Adjustemnts should be performed only while thermalizing, after each individual iteration.
Definition: mhrw.h:258
MHWalkerParams mhWalkerParams() const
Get the MHWalker parameters.
Definition: mhrw.h:776
T setw(T... args)
Query status from different objects.
STL class.
void debug(const char *fmt,...)
Generate a log message with level Logger::DEBUG (printf-like syntax)
Definition: loggers.h:1883
IterCountIntType n_total_iters
the total number of iterations required for this random walk
Definition: mhrw.h:1182
Provides the logarithm MH function value at each point (see Role of UseFnSyntaxType) ...
Definition: mhrw.h:72
CountIntType n_sweep
The number of individual updates to collect together in a "sweep".
Definition: mhrw.h:176
#define TOMO_STATIC_ASSERT_EXPR(...)
Tool for static assertions without message.
Definition: cxxdefs.h:77
MHRWParamsType mhrwParams() const
The parameters of the random walk.
Definition: mhrw.h:773
Never adjust the parameters of the random walk.
Definition: mhrw.h:231
MHRWParams(const MHRWParams< MHWalkerParamsOtherType, CountIntOtherType > &copy)
copy constructor
Definition: mhrw.h:164
MHRWController_ MHRWController
The type which will take care of dynamically adjusting the parameters of the random walk...
Definition: mhrw.h:668
MHRWControllerAdjustmentStrategy
Describe how frequently the parameters of the random walk should be dynamically adjusted.
Definition: mhrw.h:229
Provides the MH function value at each point (see Role of UseFnSyntaxType)
Definition: mhrw.h:68
MHRWControllerInvoker< MHRWController > MHRWControllerInvokerType
The MHRWControllerInvoker for our random walk controller, for convenience.
Definition: mhrw.h:672
Mask out bits which decide at which frequency (after each iteration and/or after each sample) adjustm...
Definition: mhrw.h:254
_Unspecified streamIfPossible(const T &obj)
Utility to stream an object, but only if "<<" overload exists.
Definition: fmt.h:311
A MHRWController Interface which combines several independent random walk controllers.
Definition: mhrw.h:398
T str(T... args)
bool hasAcceptanceRatio() const
Query whether we have any statistics about acceptance ratio. This is false, for example, during the thermalizing runs.
Definition: mhrw.h:789
_FnValueType FnValueType
The type of the Metropolis-Hastings function value. (See class documentation)
Definition: mhrw.h:680
Some C++ utilities, with a tad of C++11 tricks.
Basic status report class.
Definition: multiproc.h:69
T max(T... args)
void setCurrentPoint(const PointType &pt)
Force manual state of random walk.
Definition: mhrw.h:828
T move(T... args)
CountIntType nRun() const
Number of live run sweeps.
Definition: mhrw.h:783
CountIntType nSweep() const
Number of iterations in a sweep.
Definition: mhrw.h:779
void longdebug(const char *fmt,...)
Generate a log message with level Logger::LONGDEBUG (printf-like syntax)
Definition: loggers.h:1876
Managing the need for specific overrides to operator new() for some types (especially Eigen types) ...
T size(T... args)
Status Report structure representing the status of a MHRandomWalk.
Definition: mhrw.h:1142
std::string fmts(const char *fmt,...)
printf- format to a std::string
Definition: fmt.h:128
Template, specializable class to provide status reports for different objects.
const PointType & getCurrentPoint() const
Access the current state of the random walk.
Definition: mhrw.h:806
Some common definitions for multiprocessing interfaces.
Specify the parameters of a Metropolis-Hastings random walk.
Definition: mhrw.h:135
LoggerType_ LoggerType
The logger type which will be provided by user to constructor (see Logging and Loggers) ...
Definition: mhrw.h:654
Adjustemnts should be performed after a sample is taken (during live runs only)
Definition: mhrw.h:249
void run()
Run the random walk. (pun intended)
Definition: mhrw.h:1053
MHRWParams< MHWalkerParams, CountIntType > MHRWParamsType
The struct which can hold the parameters of this random walk.
Definition: mhrw.h:665
Adjustments are enabled during live (running) sweeps.
Definition: mhrw.h:236
VarValueDecoder< T >::RetType value(const Var &var)
Access the value of the given variable, as a C++ type.
Definition: ezmatio.h:878
Adjustemnts should be performed all the time, after each individual iteration.
Definition: mhrw.h:262
Provides directly the ratio of the function values for two consecutive points of the MH random walk (...
Definition: mhrw.h:77
T quiet_NaN(T... args)
RatioType acceptanceRatio() const
Return the acceptance ratio so far.
Definition: mhrw.h:796
#define streamstr(tokens)
Utility macro to format stream tokens to a std::string.
Definition: fmt.h:149
Helper class to invoke a MHRWController Interface &#39;s callbacks.
Definition: mhrw.h:274
T setprecision(T... args)
MHRWParams()
default constructor – sets values to zero and default-initializes the mhwalker_params ...
Definition: mhrw.h:143
Rng_ Rng
Random number generator type (see C++ std::random)
Definition: mhrw.h:648
MHRWParamsType mhrw_params
the parameters of the random walk
Definition: mhrw.h:1169
Binning Analysis in a Metropolis-Hastings random walk.
STL class.
MHWalkerParams mhwalker_params
The parameters of the mh-walker, typically just the step size of the random walk. ...
Definition: mhrw.h:172
Utilities for logging messages.