Go to the documentation of this file. 1 #ifndef HOPS_BALLWALKPROPOSAL_HPP
2 #define HOPS_BALLWALKPROPOSAL_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 = ((A * m_proposal - b).array() < 0).all();
40 if (!isProposalInteriorPoint) {
41 return -std::numeric_limits<typename MatrixType::Scalar>::infinity();
54 typename MatrixType::Scalar stepSize;
56 std::uniform_real_distribution<typename MatrixType::Scalar> uniform;
57 std::normal_distribution<typename MatrixType::Scalar> normal;
60 template<
typename MatrixType,
typename VectorType>
64 typename MatrixType::Scalar stepSize_) :
67 state(std::move(currentState_)),
68 m_proposal(this->state),
73 template<
typename MatrixType,
typename VectorType>
77 for (
long i = 0; i < m_proposal.rows(); ++i) {
78 m_proposal(i) = normal(randomNumberGenerator);
80 m_proposal.normalize();
83 m_proposal.noalias() = stepSize*m_proposal;
86 m_proposal.noalias() = std::pow(uniform(randomNumberGenerator), 1. / m_proposal.rows()) * m_proposal;
88 m_proposal.noalias() += state;
91 template<
typename MatrixType,
typename VectorType>
94 state.swap(m_proposal);
97 template<
typename MatrixType,
typename VectorType>
103 template<
typename MatrixType,
typename VectorType>
109 template<
typename MatrixType,
typename VectorType>
111 BallWalkProposal::state = std::move(newState);
114 template<
typename MatrixType,
typename VectorType>
116 typename MatrixType::Scalar newStepSize) {
117 stepSize = newStepSize;
120 template<
typename MatrixType,
typename VectorType>
121 typename MatrixType::Scalar
126 template<
typename MatrixType,
typename VectorType>
132 #endif //HOPS_BALLWALKPROPOSAL_HPP
Eigen::MatrixXd MatrixType
Definition: MatrixType.hpp:7
BallWalkProposal(MatrixType A, VectorType b, StateType currentState, typename MatrixType::Scalar stepSize=1)
Constructs Ballwalk m_proposal mechanism on polytope defined as Ax<b.
Definition: BallWalkProposal.hpp:61
void setState(StateType newState)
Definition: BallWalkProposal.hpp:110
std::string getName()
Definition: BallWalkProposal.hpp:127
Definition: pcg_random.hpp:364
StateType getProposal() const
Definition: BallWalkProposal.hpp:105
void acceptProposal()
Definition: BallWalkProposal.hpp:93
void setStepSize(typename MatrixType::Scalar stepSize)
Definition: BallWalkProposal.hpp:115
MatrixType::Scalar getStepSize() const
Definition: BallWalkProposal.hpp:122
VectorType StateType
Definition: BallWalkProposal.hpp:13
void propose(RandomNumberGenerator &randomNumberGenerator)
Definition: BallWalkProposal.hpp:74
Definition: BallWalkProposal.hpp:11
Definition: CsvReader.hpp:8
StateType getState() const
Definition: BallWalkProposal.hpp:99
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
MatrixType::Scalar computeLogAcceptanceProbability()
Definition: BallWalkProposal.hpp:38