hops
Run.hpp
Go to the documentation of this file.
1 #ifndef HOPS_RUN_HPP
2 #define HOPS_RUN_HPP
3 
14 #include <hops/Utility/Data.hpp>
16 #include <hops/Utility/Problem.hpp>
17 
18 #include <Eigen/Core>
19 
20 #include <memory>
21 #include <random>
22 #include <stdexcept>
23 #include <chrono>
24 
25 #ifdef _OPENMP
26 #include <omp.h>
27 #endif
28 
29 namespace hops {
30  struct NoProposal {
31  void setState(Eigen::VectorXd) {
32  throw std::runtime_error("NoProposal.setState was called, but this class is not actually supposed to be used.");
33  }
34  };
35 
36  template<typename Model, typename Proposal>
37  class RunBase;
38 
39 
40  template<typename Model, typename Proposal>
41  void tune(RunBase<Model, Proposal>& run, AcceptanceRateTuner::param_type& parameters);
42 
43  template<typename Model, typename Proposal>
44  void tune(RunBase<Model, Proposal>& run, ExpectedSquaredJumpDistanceTuner::param_type& parameters);
45 
46  template<typename Model, typename Proposal>
47  void tune(RunBase<Model, Proposal>& run, SimpleExpectedSquaredJumpDistanceTuner::param_type& parameters);
48 
49 
50  template<typename Model, typename Proposal>
51  class RunBase {
52  public:
53  RunBase (MarkovChainType markovChainType,
54  unsigned long numberOfSamples = 1000,
55  unsigned long numberOfChains = 1) :
56  markovChainType(markovChainType),
57  numberOfChains(numberOfChains),
58  numberOfSamples(numberOfSamples) {
59  //
60  }
61 
62  RunBase (const Problem<Model>& problem,
64  unsigned long numberOfSamples = 1000,
65  unsigned long numberOfChains = 1) :
66  problem(problem),
67  markovChainType(markovChainType),
68  numberOfChains(numberOfChains),
69  numberOfSamples(numberOfSamples) {
70  //
71  }
72 
73  RunBase (Proposal m_proposal,
74  unsigned long numberOfSamples = 1000,
75  unsigned long numberOfChains = 1) :
76  m_proposal(m_proposal),
77  numberOfChains(numberOfChains),
78  numberOfSamples(numberOfSamples) {
79  //
80  }
81 
82  RunBase (const Problem<Model>& problem,
83  Proposal m_proposal,
84  unsigned long numberOfSamples = 1000,
85  unsigned long numberOfChains = 1) :
86  problem(problem),
87  m_proposal(m_proposal),
88  numberOfChains(numberOfChains),
89  numberOfSamples(numberOfSamples) {
90  //
91  }
92 
93  RunBase() = default;
94 
95  void setProblem(const Problem<Model>& problem);
96  const Problem<Model>& getProblem();
97 
98  void setStartingPoints(const std::vector<Eigen::VectorXd>& startingPoints);
99  const std::vector<Eigen::VectorXd>& getStartingPoints();
100 
101  void setMarkovChainType(MarkovChainType markovChainType);
103 
104  void setNumberOfChains(unsigned long numberOfChains);
105  unsigned long getNumberOfChains();
106 
107  void setNumberOfSamples(unsigned long numberOfSamples);
108  unsigned long getNumberOfSamples();
109 
110  void setThinning(unsigned long thinning);
111  unsigned long getThinning();
112 
113  void setUseRounding(bool useRounding);
114  bool getUseRounding();
115 
116  void setStepSize(double stepSize);
117  double getStepSize();
118 
119  void setFisherWeight(double fisherWeight);
120  double getFisherWeight();
121 
122  void setRandomSeed(double randomSeed);
123  double getRandomSeed();
124 
125  void setSamplingUntilConvergence(bool sampleUntilConvergence);
127 
128  void setConvergenceThreshold(double convergenceThreshold);
129  double getConvergenceThreshold();
130 
131  void setMaxRepetitions(double maxRepetitions);
132  double getMaxRepetitions();
133 
134  Data& getData();
135 
139  void init() {
140  // create new data object to not mix up possible previous data
141  data = std::make_shared<Data>(problem.dimension);
142 
143  if (!isRandomGeneratorInitialized) {
144  isRandomGeneratorInitialized = true;
145  // initialize random number generator for each chain
146  for (unsigned long i = 0; i < numberOfChains; ++i) {
147  randomNumberGenerators.push_back(RandomNumberGenerator(randomSeed, i));
148  }
149  }
150 
151  // initialize missing starting points with the chebyshev center or the starting point passed
152  // by the problem.
153  if (startingPoints.size() < numberOfChains) {
154  Eigen::VectorXd defaultStartingPoint;
155  if (!problem.useStartingPoint && startingPoints.size() == 0) {
156 #if defined(HOPS_GUROBI_FOUND) || defined(HOPS_CLP_FOUND)
157  try {
158  LinearProgramGurobiImpl linearProgram(problem.A, problem.b);
159  defaultStartingPoint = linearProgram.computeChebyshevCenter().optimalParameters;
160 
161  // either std::runtime_error, if Gurobi wasn't found or GRBException if no license
162  } catch (...) {
163  LinearProgramClpImpl linearProgram(problem.A, problem.b);
164  defaultStartingPoint = linearProgram.computeChebyshevCenter().optimalParameters;
165  }
166 #else
168  "No default starting point was provided in problem and no "
169  "LP solver is available for computing the Chebyshev center, "
170  "can thus not intialize missing starting points.");
171 #endif
172  } if (problem.useStartingPoint) {
173  defaultStartingPoint = problem.startingPoint;
174  } else {
175  defaultStartingPoint = startingPoints.back();
176  }
177 
178  // initialize all missing starting points
179  for (unsigned long i = startingPoints.size(); i < numberOfChains; ++i) {
180  startingPoints.push_back(defaultStartingPoint);
181  }
182  }
183 
184  // if rounding was specified, then compute the round transformation
185  Eigen::MatrixXd roundingTransformation;
186  if (useRounding) {
187  roundingTransformation =
188  hops::MaximumVolumeEllipsoid<double>::construct(problem.A, problem.b, 10000)
190  // next transform of startingPoint assumes roundingTransformation is lower triangular
191  if (!roundingTransformation.isLowerTriangular()) {
192  throw std::runtime_error("Error while rounding starting point, check code.");
193  }
194  }
195 
196  // set up the chains with the problem specifications
197  m_markovChains.resize(numberOfChains);
198  for (unsigned long i = 0; i < numberOfChains; ++i) {
199  if (problem.unround) {
200  if constexpr(std::is_same<Proposal, NoProposal>::value) {
201  m_markovChains[i] = std::move(MarkovChainFactory::createMarkovChain(markovChainType,
202  problem.A,
203  problem.b,
204  startingPoints[i],
205  problem.unroundingTransformation,
206  problem.unroundingShift,
207  problem.model));
208  } else {
209  m_proposal.setState(startingPoints[i]);
210  m_markovChains[i] = std::move(MarkovChainFactory::createMarkovChain(m_proposal,
211  problem.unroundingTransformation,
212  problem.unroundingShift,
213  problem.model));
214  }
215  } else if (useRounding) {
216  Eigen::VectorXd roundedStartingPoint = roundingTransformation.triangularView<Eigen::Lower>().solve(startingPoints[i]);
217  if constexpr(std::is_same<Proposal, NoProposal>::value) {
218  m_markovChains[i] = std::move(MarkovChainFactory::createMarkovChain(markovChainType,
219  Eigen::MatrixXd(problem.A * roundingTransformation),
220  problem.b,
221  roundedStartingPoint,
222  roundingTransformation,
223  Eigen::VectorXd(Eigen::VectorXd::Zero(problem.dimension)),
224  problem.model));
225  } else {
226  m_proposal.setState(roundedStartingPoint);
227  m_markovChains[i] = std::move(MarkovChainFactory::createMarkovChain(m_proposal,
228  roundingTransformation,
229  Eigen::VectorXd(Eigen::VectorXd::Zero(problem.dimension)),
230  problem.model));
231  }
232  } else {
233  if constexpr(std::is_same<Proposal, NoProposal>::value) {
234  m_markovChains[i] = std::move(MarkovChainFactory::createMarkovChain(markovChainType,
235  problem.A,
236  problem.b,
237  startingPoints[i],
238  problem.model));
239  } else {
240  m_proposal.setState(startingPoints[i]);
241  m_markovChains[i] = std::move(
242  MarkovChainFactory::createMarkovChain<Eigen::MatrixXd, Eigen::VectorXd, Model, Proposal>(m_proposal,
243  problem.model));
244  }
245  }
246 
247  // preallocate records vector to avoid reallocation
248  m_markovChains[i]->clearHistory();
249  m_markovChains[i]->reserveStateRecords(maxRepetitions * numberOfSamples);
250 
251  try {
252  m_markovChains[i]->setAttribute(hops::MarkovChainAttribute::STEP_SIZE, stepSize);
253  } catch (...) {
254  //
255  }
256 
257  try {
258  m_markovChains[i]->setAttribute(hops::MarkovChainAttribute::FISHER_WEIGHT, fisherWeight);
259  } catch (...) {
260  //
261  }
262  }
263 
264  // register data object with chains. this sets the pointers in the data
265  // object to the chain's data vectors, making the data outlive the chain.
266  data->linkWithChains(m_markovChains);
267  data->setDimension(problem.dimension);
268 
269  isInitialized = true;
270  }
271 
275  void sample() {
276  sample(numberOfSamples, thinning);
277  }
278 
282  void sample(unsigned long numberOfSamples, unsigned long thinning = 1) {
283  if (!isInitialized) {
284  init();
285  }
286 
287  unsigned long k = 0;
288  double convergenceStatistics = 0;
289  do {
290  #pragma omp parallel for
291  for (unsigned long i = 0; i < numberOfChains; ++i) {
292  m_markovChains[i]->draw(randomNumberGenerators[i], numberOfSamples, thinning);
293  }
294  // end pragma omp parallel for
295 
296  if (sampleUntilConvergence && numberOfChains >= 2) {
297  convergenceStatistics = computePotentialScaleReductionFactor(*data).maxCoeff();
298  }
299 
300  //numSeen += conf.numSamples;
301  ++k;
302  } while(sampleUntilConvergence &&
303  // if threshold was not met or if psrf is nan, keep going
304  (convergenceStatistics > convergenceThreshold || std::isnan(convergenceStatistics)) &&
305  // though only if we have not yet reached the maximum number of repetitions
306  k < maxRepetitions);
307  }
308 
309  private:
310  Problem<Model> problem;
311  std::shared_ptr<Data> data = nullptr;
312 
313  Proposal m_proposal;
314 
315  bool isInitialized = false;
316  bool isRandomGeneratorInitialized = false;
317 
319 
320  std::vector<std::shared_ptr<hops::MarkovChain>> m_markovChains;
321  std::vector<hops::RandomNumberGenerator> randomNumberGenerators;
322 
323  std::vector<Eigen::VectorXd> startingPoints;
324 
325  unsigned long numberOfChains = 1;
326  unsigned long numberOfSamples = 1000;
327  unsigned long thinning = 1;
328 
329  bool useRounding = false;
330 
331  bool sampleUntilConvergence = false;
332  double convergenceThreshold = 1.05;
333  unsigned long maxRepetitions = 1;
334 
335  double stepSize = 1;
336  double fisherWeight = 0.5;
337 
338  double randomSeed = 0;
339 
340  //friend void tune(RunBase<Model, Proposal>& run, const ExpectedSquaredJumpDistanceTuner::param_type& parameters);
341  friend void tune<>(RunBase& run, AcceptanceRateTuner::param_type& parameters);
342  friend void tune<>(RunBase& run, ExpectedSquaredJumpDistanceTuner::param_type& parameters);
343  friend void tune<>(RunBase& run, SimpleExpectedSquaredJumpDistanceTuner::param_type& parameters);
344  };
345 
346  template <typename Model>
348 
349  template<typename Model, typename Proposal>
351  this->isInitialized = false;
352  this->problem = problem;
353  }
354 
355  template<typename Model, typename Proposal>
357  return problem;
358  }
359 
360 
361  template<typename Model, typename Proposal>
362  void RunBase<Model, Proposal>::setStartingPoints(const std::vector<Eigen::VectorXd>& startingPoints) {
363  this->isInitialized = false;
364  this->startingPoints = startingPoints;
365  }
366 
367  template<typename Model, typename Proposal>
368  const std::vector<Eigen::VectorXd>& RunBase<Model, Proposal>::getStartingPoints() {
369  return startingPoints;
370  }
371 
372 
373  template<typename Model, typename Proposal>
375  this->isInitialized = false;
376  this->markovChainType = markovChainType;
377  }
378 
379  template<typename Model, typename Proposal>
381  return markovChainType;
382  }
383 
384 
385  template<typename Model, typename Proposal>
386  void RunBase<Model, Proposal>::setNumberOfChains(unsigned long numberOfChains) {
387  this->isInitialized = false;
388  this->numberOfChains = numberOfChains;
389  }
390 
391  template<typename Model, typename Proposal>
393  return numberOfChains;
394  }
395 
396 
397  template<typename Model, typename Proposal>
398  void RunBase<Model, Proposal>::setNumberOfSamples(unsigned long numberOfSamples) {
399  this->numberOfSamples = numberOfSamples;
400  }
401 
402  template<typename Model, typename Proposal>
404  return numberOfSamples;
405  }
406 
407 
408  template<typename Model, typename Proposal>
409  void RunBase<Model, Proposal>::setThinning(unsigned long thinning) {
410  this->thinning = thinning;
411  }
412 
413  template<typename Model, typename Proposal>
415  return thinning;
416  }
417 
418 
419  template<typename Model, typename Proposal>
421  this->isInitialized = false;
422  this->useRounding = useRounding;
423  }
424 
425  template<typename Model, typename Proposal>
427  return this->useRounding;
428  }
429 
430 
431  template<typename Model, typename Proposal>
433  this->isInitialized = false;
434  this->stepSize = stepSize;
435  }
436 
437  template<typename Model, typename Proposal>
439  return stepSize;
440  }
441 
442 
443  template<typename Model, typename Proposal>
444  void RunBase<Model, Proposal>::setFisherWeight(double fisherWeight) {
445  this->isInitialized = false;
446  this->fisherWeight = fisherWeight;
447  }
448 
449  template<typename Model, typename Proposal>
451  return fisherWeight;
452  }
453 
454 
455  template<typename Model, typename Proposal>
456  void RunBase<Model, Proposal>::setRandomSeed(double randomSeed) {
457  this->isInitialized = false;
458  this->isRandomGeneratorInitialized = false;
459  this->randomSeed = randomSeed;
460  }
461 
462  template<typename Model, typename Proposal>
464  return randomSeed;
465  }
466 
467 
468  template<typename Model, typename Proposal>
469  void RunBase<Model, Proposal>::setSamplingUntilConvergence(bool sampleUntilConvergence) {
470  this->sampleUntilConvergence = sampleUntilConvergence;
471  }
472 
473  template<typename Model, typename Proposal>
475  return this->sampleUntilConvergence;
476  }
477 
478 
479  template<typename Model, typename Proposal>
480  void RunBase<Model, Proposal>::setConvergenceThreshold(double convergenceThreshold) {
481  this->convergenceThreshold = convergenceThreshold;
482  }
483 
484  template<typename Model, typename Proposal>
486  return convergenceThreshold;
487  }
488 
489 
490  template<typename Model, typename Proposal>
491  void RunBase<Model, Proposal>::setMaxRepetitions(double maxRepetitions) {
492  this->maxRepetitions = maxRepetitions;
493  if (this->isInitialized) {
494  for (unsigned long i = 0; i < numberOfChains; ++i) {
495  m_markovChains[i]->reserveStateRecords(maxRepetitions * numberOfSamples);
496  }
497  }
498  }
499 
500  template<typename Model, typename Proposal>
502  return maxRepetitions;
503  }
504 
505 
506  template<typename Model, typename Proposal>
508  return *data;
509  }
510 
511  template<typename Model, typename Proposal>
513  if (!run.isInitialized) {
514  run.init();
515  }
516 
517  double tunedStepSize, deltaAcceptanceRate;
518  Eigen::MatrixXd data, posterior;
519 
520  // record tuning time
521  double time = std::chrono::duration_cast<std::chrono::milliseconds>(
522  std::chrono::high_resolution_clock::now().time_since_epoch()
523  ).count();
524 
525  AcceptanceRateTuner::tune(tunedStepSize,
526  deltaAcceptanceRate,
527  run.m_markovChains,
528  run.randomNumberGenerators,
529  parameters,
530  data,
531  posterior);
532 
533  time = std::chrono::duration_cast<std::chrono::milliseconds>(
534  std::chrono::high_resolution_clock::now().time_since_epoch()
535  ).count() - time;
536 
537 
538  for (size_t i = 0; i < run.m_markovChains.size(); ++i) {
539  try {
540  run.m_markovChains[i]->setAttribute(hops::MarkovChainAttribute::STEP_SIZE, tunedStepSize);
541  } catch (...) {
542  //
543  }
544  }
545 
546  run.stepSize = tunedStepSize;
547  unsigned long totalNumberOfTuningSamples =
548  run.m_markovChains.size() * parameters.iterationsToTestStepSize * parameters.posteriorUpdateIterationsNeeded * parameters.pureSamplingIterations;
549  // reset stored states
550  run.data->reset();
551 
552  run.data->setTuningMethod("ThompsonSamplingESJD");
553  run.data->setTotalNumberOfTuningSamples(totalNumberOfTuningSamples);
554  run.data->setTunedStepSize(tunedStepSize);
555  run.data->setTunedObjectiveValue(deltaAcceptanceRate);
556  run.data->setTotalTuningTimeTaken(time);
557 
558  run.data->setTuningData(data);
559  run.data->setTuningPosterior(posterior);
560  }
561 
562  template<typename Model, typename Proposal>
564  if (!run.isInitialized) {
565  run.init();
566  }
567 
568  double tunedStepSize, maximumExpectedSquaredJumpDistance;
569  Eigen::MatrixXd data, posterior;
570 
571  // record tuning time
572  double time = std::chrono::duration_cast<std::chrono::milliseconds>(
573  std::chrono::high_resolution_clock::now().time_since_epoch()
574  ).count();
575 
577  maximumExpectedSquaredJumpDistance,
578  run.m_markovChains,
579  run.randomNumberGenerators,
580  parameters,
581  data,
582  posterior);
583 
584  time = std::chrono::duration_cast<std::chrono::milliseconds>(
585  std::chrono::high_resolution_clock::now().time_since_epoch()
586  ).count() - time;
587 
588 
589  for (size_t i = 0; i < run.m_markovChains.size(); ++i) {
590  try {
591  run.m_markovChains[i]->setAttribute(hops::MarkovChainAttribute::STEP_SIZE, tunedStepSize);
592  } catch (...) {
593  //
594  }
595  }
596 
597  run.stepSize = tunedStepSize;
598  unsigned long totalNumberOfTuningSamples =
599  run.m_markovChains.size() * parameters.iterationsToTestStepSize * parameters.posteriorUpdateIterationsNeeded * parameters.pureSamplingIterations;
600  // reset stored states
601  run.data->reset();
602 
603  run.data->setTuningMethod("ThompsonSamplingAcceptanceRate");
604  run.data->setTotalNumberOfTuningSamples(totalNumberOfTuningSamples);
605  run.data->setTunedStepSize(tunedStepSize);
606  run.data->setTunedObjectiveValue(maximumExpectedSquaredJumpDistance);
607  run.data->setTotalTuningTimeTaken(time);
608 
609  run.data->setTuningData(data);
610  run.data->setTuningPosterior(posterior);
611  }
612 
613  template<typename Model, typename Proposal>
615  if (!run.isInitialized) {
616  run.init();
617  }
618 
619  double tunedStepSize, maximumExpectedSquaredJumpDistance;
620  Eigen::MatrixXd data, posterior;
621 
622  // record tuning time
623  double time = std::chrono::duration_cast<std::chrono::milliseconds>(
624  std::chrono::high_resolution_clock::now().time_since_epoch()
625  ).count();
626 
628  maximumExpectedSquaredJumpDistance,
629  run.m_markovChains,
630  run.randomNumberGenerators,
631  parameters);
632 
633  time = std::chrono::duration_cast<std::chrono::milliseconds>(
634  std::chrono::high_resolution_clock::now().time_since_epoch()
635  ).count() - time;
636 
637 
638  for (size_t i = 0; i < run.m_markovChains.size(); ++i) {
639  try {
640  run.m_markovChains[i]->setAttribute(hops::MarkovChainAttribute::STEP_SIZE, tunedStepSize);
641  } catch (...) {
642  //
643  }
644  }
645 
646  run.stepSize = tunedStepSize;
647  unsigned long totalNumberOfTuningSamples =
648  run.m_markovChains.size() * parameters.iterationsToTestStepSize * parameters.stepSizeGridSize;
649  // reset stored states
650  run.data->reset();
651 
652  run.data->setTuningMethod("GridSearchESJD");
653  run.data->setTotalNumberOfTuningSamples(totalNumberOfTuningSamples);
654  run.data->setTunedStepSize(tunedStepSize);
655  run.data->setTunedObjectiveValue(maximumExpectedSquaredJumpDistance);
656  run.data->setTotalTuningTimeTaken(time);
657 
658  run.data->setTuningData(data);
659  run.data->setTuningPosterior(posterior);
660  }
661 }
662 
663 #endif // HOPS_RUN_HPP
hops::RunBase::getUseRounding
bool getUseRounding()
Definition: Run.hpp:426
hops::AcceptanceRateTuner::param_type::iterationsToTestStepSize
size_t iterationsToTestStepSize
Definition: AcceptanceRateTuner.hpp:28
hops::RunBase::sample
void sample(unsigned long numberOfSamples, unsigned long thinning=1)
Definition: Run.hpp:282
hops::Data
Definition: Data.hpp:19
hops::AcceptanceRateTuner::param_type
Definition: AcceptanceRateTuner.hpp:26
hops::RunBase
Definition: Problem.hpp:10
Exceptions.hpp
hops::RunBase::setSamplingUntilConvergence
void setSamplingUntilConvergence(bool sampleUntilConvergence)
Definition: Run.hpp:469
hops::RunBase::setUseRounding
void setUseRounding(bool useRounding)
Definition: Run.hpp:420
hops::SimpleExpectedSquaredJumpDistanceTuner::tune
static bool tune(std::vector< std::shared_ptr< MarkovChain >> &, std::vector< RandomNumberGenerator > &, const param_type &)
tunes markov chain acceptance rate by nested intervals. The chain is not guaranteed to have converged...
MaximumVolumeEllipsoid.hpp
hops::ExpectedSquaredJumpDistanceTuner::param_type::pureSamplingIterations
size_t pureSamplingIterations
Definition: ExpectedSquaredJumpDistanceTuner.hpp:30
RandomNumberGenerator.hpp
AcceptanceRateTuner.hpp
hops::ExpectedSquaredJumpDistanceTuner::param_type::posteriorUpdateIterationsNeeded
size_t posteriorUpdateIterationsNeeded
Definition: ExpectedSquaredJumpDistanceTuner.hpp:32
hops::NoProposal
Definition: Run.hpp:30
hops::Problem
Definition: Problem.hpp:13
hops::RunBase::setNumberOfChains
void setNumberOfChains(unsigned long numberOfChains)
Definition: Run.hpp:386
hops::LinearProgramSolution::optimalParameters
Eigen::VectorXd optimalParameters
Definition: LinearProgramSolution.hpp:24
hops::RunBase::RunBase
RunBase(const Problem< Model > &problem, Proposal m_proposal, unsigned long numberOfSamples=1000, unsigned long numberOfChains=1)
Definition: Run.hpp:82
hops::MarkovChainFactory::createMarkovChain
static std::unique_ptr< MarkovChain > createMarkovChain(Proposal m_proposal)
Creates a Markov chain for uniform sampling of convex polytopes using an arbitrary m_proposal class.
Definition: MarkovChainFactory.hpp:43
LinearProgramClpImpl.hpp
hops::AcceptanceRateTuner::param_type::posteriorUpdateIterationsNeeded
size_t posteriorUpdateIterationsNeeded
Definition: AcceptanceRateTuner.hpp:32
MarkovChainType.hpp
hops::RunBase::getSamplingUntilConvergence
bool getSamplingUntilConvergence()
Definition: Run.hpp:474
hops::RunBase::setStartingPoints
void setStartingPoints(const std::vector< Eigen::VectorXd > &startingPoints)
Definition: Run.hpp:362
hops::RunBase::getRandomSeed
double getRandomSeed()
Definition: Run.hpp:463
hops::MissingStartingPointsException
Definition: Exceptions.hpp:33
LinearProgramGurobiImpl.hpp
hops::RunBase::getStepSize
double getStepSize()
Definition: Run.hpp:438
hops::RunBase::getConvergenceThreshold
double getConvergenceThreshold()
Definition: Run.hpp:485
hops::RunBase::setNumberOfSamples
void setNumberOfSamples(unsigned long numberOfSamples)
Definition: Run.hpp:398
SimpleExpectedSquaredJumpDistanceTuner.hpp
hops::RunBase::setMaxRepetitions
void setMaxRepetitions(double maxRepetitions)
Definition: Run.hpp:491
hops::ExpectedSquaredJumpDistanceTuner::tune
static bool tune(std::vector< std::shared_ptr< MarkovChain >> &, std::vector< RandomNumberGenerator > &, param_type &)
tunes markov chain acceptance rate by nested intervals. The chain is not guaranteed to have converged...
hops::SimpleExpectedSquaredJumpDistanceTuner::param_type::iterationsToTestStepSize
size_t iterationsToTestStepSize
Definition: SimpleExpectedSquaredJumpDistanceTuner.hpp:21
hops::MaximumVolumeEllipsoid::construct
static MaximumVolumeEllipsoid construct(const Eigen::Matrix< RealType, Eigen::Dynamic, Eigen::Dynamic > &A, const Eigen::Matrix< RealType, Eigen::Dynamic, 1 > &b, size_t maximumNumberOfIterationsToRun, const Eigen::Matrix< RealType, Eigen::Dynamic, 1 > &startingPoint, RealType tolerance=1e-6)
Definition: MaximumVolumeEllipsoid.cpp:84
hops::RunBase::getFisherWeight
double getFisherWeight()
Definition: Run.hpp:450
Problem.hpp
hops::RunBase::setThinning
void setThinning(unsigned long thinning)
Definition: Run.hpp:409
hops::RunBase::getNumberOfChains
unsigned long getNumberOfChains()
Definition: Run.hpp:392
hops::RunBase::getProblem
const Problem< Model > & getProblem()
Definition: Run.hpp:356
hops::LinearProgramClpImpl::computeChebyshevCenter
LinearProgramSolution computeChebyshevCenter() const override
Definition: LinearProgramClpImpl.hpp:53
hops::RunBase::getNumberOfSamples
unsigned long getNumberOfSamples()
Definition: Run.hpp:403
hops::LinearProgramClpImpl
Definition: LinearProgramClpImpl.hpp:39
hops::RunBase::RunBase
RunBase(const Problem< Model > &problem, MarkovChainType markovChainType=MarkovChainType::HitAndRun, unsigned long numberOfSamples=1000, unsigned long numberOfChains=1)
Definition: Run.hpp:62
hops::RunBase::setConvergenceThreshold
void setConvergenceThreshold(double convergenceThreshold)
Definition: Run.hpp:480
hops::RunBase::getData
Data & getData()
Definition: Run.hpp:507
hops::MarkovChainAttribute::FISHER_WEIGHT
@ FISHER_WEIGHT
hops::RunBase::sample
void sample()
Definition: Run.hpp:275
hops::RunBase::setFisherWeight
void setFisherWeight(double fisherWeight)
Definition: Run.hpp:444
hops::LinearProgramGurobiImpl::computeChebyshevCenter
LinearProgramSolution computeChebyshevCenter() const override
Definition: LinearProgramGurobiImpl.hpp:55
hops::RunBase::getStartingPoints
const std::vector< Eigen::VectorXd > & getStartingPoints()
Definition: Run.hpp:368
hops::MaximumVolumeEllipsoid::getRoundingTransformation
const Eigen::Matrix< RealType, Eigen::Dynamic, Eigen::Dynamic > & getRoundingTransformation() const
Definition: MaximumVolumeEllipsoid.cpp:48
hops::RunBase::setStepSize
void setStepSize(double stepSize)
Definition: Run.hpp:432
hops::SimpleExpectedSquaredJumpDistanceTuner::param_type
Definition: SimpleExpectedSquaredJumpDistanceTuner.hpp:20
hops::ExpectedSquaredJumpDistanceTuner::param_type
Definition: ExpectedSquaredJumpDistanceTuner.hpp:27
hops::RandomNumberGenerator
pcg64 RandomNumberGenerator
Definition: RandomNumberGenerator.hpp:7
Data.hpp
hops::ExpectedSquaredJumpDistanceTuner::param_type::iterationsToTestStepSize
size_t iterationsToTestStepSize
Definition: ExpectedSquaredJumpDistanceTuner.hpp:28
hops::MarkovChainType::HitAndRun
@ HitAndRun
hops
Definition: CsvReader.hpp:8
hops::SimpleExpectedSquaredJumpDistanceTuner::param_type::stepSizeGridSize
size_t stepSizeGridSize
Definition: SimpleExpectedSquaredJumpDistanceTuner.hpp:23
MarkovChain.hpp
hops::RunBase::setMarkovChainType
void setMarkovChainType(MarkovChainType markovChainType)
Definition: Run.hpp:374
hops::tune
void tune(RunBase< Model, Proposal > &run, AcceptanceRateTuner::param_type &parameters)
Definition: Run.hpp:512
MarkovChainFactory.hpp
hops::AcceptanceRateTuner::param_type::pureSamplingIterations
size_t pureSamplingIterations
Definition: AcceptanceRateTuner.hpp:30
hops::RunBase::RunBase
RunBase(Proposal m_proposal, unsigned long numberOfSamples=1000, unsigned long numberOfChains=1)
Definition: Run.hpp:73
hops::computePotentialScaleReductionFactor
double computePotentialScaleReductionFactor(const std::vector< const std::vector< StateType > * > &chains, unsigned long dimension, unsigned long numUnseen, std::vector< double > &sampleVariancesSeen, std::vector< double > &intraChainExpectationsSeen, double &interChainExpectationSeen, unsigned long &numSeen)
Definition: PotentialScaleReductionFactor.hpp:20
hops::RunBase::getThinning
unsigned long getThinning()
Definition: Run.hpp:414
hops::RunBase::setRandomSeed
void setRandomSeed(double randomSeed)
Definition: Run.hpp:456
hops::RunBase::getMaxRepetitions
double getMaxRepetitions()
Definition: Run.hpp:501
hops::MarkovChainAttribute::STEP_SIZE
@ STEP_SIZE
hops::RunBase::RunBase
RunBase()=default
hops::RunBase::getMarkovChainType
MarkovChainType getMarkovChainType()
Definition: Run.hpp:380
hops::RunBase::init
void init()
Definition: Run.hpp:139
ExpectedSquaredJumpDistanceTuner.hpp
hops::MarkovChainType
MarkovChainType
Definition: MarkovChainType.hpp:5
hops::RunBase::RunBase
RunBase(MarkovChainType markovChainType, unsigned long numberOfSamples=1000, unsigned long numberOfChains=1)
Definition: Run.hpp:53
hops::NoProposal::setState
void setState(Eigen::VectorXd)
Definition: Run.hpp:31
hops::AcceptanceRateTuner::tune
static bool tune(std::vector< std::shared_ptr< MarkovChain >> &markovChain, std::vector< RandomNumberGenerator > &randomNumberGenerator, param_type &parameters)
tunes markov chain acceptance rate by nested intervals. The chain is not guaranteed to have converged...
hops::RunBase::setProblem
void setProblem(const Problem< Model > &problem)
Definition: Run.hpp:350
hops::LinearProgramGurobiImpl
Definition: LinearProgramGurobiImpl.hpp:41