Go to the documentation of this file. 1 #ifndef HOPS_GAUSSIANPROPOSAL_HPP
2 #define HOPS_GAUSSIANPROPOSAL_HPP
4 #include "../IsSetStepSizeAvailable.hpp"
5 #include "../../RandomNumberGenerator/RandomNumberGenerator.hpp"
6 #include "../../FileWriter/CsvWriter.hpp"
10 template<
typename MatrixType,
typename VectorType>
34 void setStepSize(
typename MatrixType::Scalar stepSize);
39 bool isProposalInteriorPoint = ((b - A * m_proposal).array() >= 0).all();
40 if (!isProposalInteriorPoint) {
41 return -std::numeric_limits<typename MatrixType::Scalar>::infinity();
54 typename MatrixType::Scalar stepSize;
56 std::normal_distribution<typename MatrixType::Scalar> normal;
59 template<
typename MatrixType,
typename VectorType>
63 typename MatrixType::Scalar stepSize_) :
66 state(std::move(currentState_)),
67 m_proposal(this->state),
69 normal = std::normal_distribution<typename MatrixType::Scalar>(0, stepSize);
72 template<
typename MatrixType,
typename VectorType>
75 for (
long i = 0; i < m_proposal.rows(); ++i) {
76 m_proposal(i) = normal(randomNumberGenerator);
79 m_proposal.noalias() += state;
82 template<
typename MatrixType,
typename VectorType>
85 state.swap(m_proposal);
88 template<
typename MatrixType,
typename VectorType>
94 template<
typename MatrixType,
typename VectorType>
100 template<
typename MatrixType,
typename VectorType>
102 GaussianProposal::state = std::move(newState);
105 template<
typename MatrixType,
typename VectorType>
107 typename MatrixType::Scalar newStepSize) {
108 stepSize = newStepSize;
109 normal = std::normal_distribution<typename MatrixType::Scalar>(0, stepSize);
112 template<
typename MatrixType,
typename VectorType>
113 typename MatrixType::Scalar
118 template<
typename MatrixType,
typename VectorType>
124 #endif //HOPS_GAUSSIANPROPOSAL_HPP
MatrixType::Scalar getStepSize() const
Definition: GaussianProposal.hpp:114
GaussianProposal(MatrixType A, VectorType b, StateType currentState, typename MatrixType::Scalar stepSize=1)
Constructs classical Gaussian random walk m_proposal mechanism on polytope defined as Ax<b.
Definition: GaussianProposal.hpp:60
Eigen::MatrixXd MatrixType
Definition: MatrixType.hpp:7
Definition: pcg_random.hpp:364
void propose(RandomNumberGenerator &randomNumberGenerator)
Definition: GaussianProposal.hpp:73
StateType getProposal() const
Definition: GaussianProposal.hpp:96
StateType getState() const
Definition: GaussianProposal.hpp:90
MatrixType::Scalar computeLogAcceptanceProbability()
Definition: GaussianProposal.hpp:38
Definition: GaussianProposal.hpp:11
VectorType StateType
Definition: GaussianProposal.hpp:13
void acceptProposal()
Definition: GaussianProposal.hpp:84
Definition: CsvReader.hpp:8
std::string getName()
Definition: GaussianProposal.hpp:119
void setState(StateType newState)
Definition: GaussianProposal.hpp:101
NAME string(REPLACE ".cpp" "_bin" example_name ${example_filename}) if($
Definition: hops/Third-party/HighFive/src/examples/CMakeLists.txt:6
Eigen::VectorXd VectorType
Definition: VectorType.hpp:7
void setStepSize(typename MatrixType::Scalar stepSize)
Definition: GaussianProposal.hpp:106