25 #include <queso/TransformedScaledCovMatrixTKGroup.h>
26 #include <queso/InvLogitGaussianJointPdf.h>
27 #include <queso/GslVector.h>
28 #include <queso/GslMatrix.h>
32 template<
class V,
class M>
36 const std::vector<double> & scales,
38 :
BaseTKGroup<V, M>(prefix, boxSubset.vectorSpace(), scales),
39 m_boxSubset(boxSubset),
40 m_originalCovMatrix(covMatrix)
49 <<
": m_scales.size() = " <<
m_scales.size()
51 <<
", m_rvs.size() = " <<
m_rvs.size()
65 template<
class V,
class M>
70 template<
class V,
class M>
77 template<
class V,
class M>
83 queso_require_msg(m_rvs[0],
"m_rvs[0] == NULL");
85 queso_require_greater_msg(m_preComputingPositions.size(), stageId,
"m_preComputingPositions.size() <= stageId");
87 queso_require_msg(m_preComputingPositions[stageId],
"m_preComputingPositions[stageId] == NULL");
89 if ((m_env.subDisplayFile() ) &&
90 (m_env.displayVerbosity() >= 10)) {
91 *m_env.subDisplayFile() <<
"In TransformedScaledCovMatrixTKGroup<V,M>::rv1()"
92 <<
", stageId = " << stageId
93 <<
": about to call m_rvs[0]->updateLawExpVector()"
94 <<
", vector = " << *m_preComputingPositions[stageId]
101 V transformedPreComputingPositions(*m_preComputingPositions[stageId]);
102 transformToGaussianSpace(*m_preComputingPositions[stageId],
103 transformedPreComputingPositions);
107 return (*invlogit_gaussian);
110 template<
class V,
class M>
114 queso_require_greater_equal_msg(m_rvs.size(), stageIds.size(),
"m_rvs.size() < stageIds.size()");
116 queso_require_msg(m_rvs[stageIds.size()-1],
"m_rvs[stageIds.size()-1] == NULL");
118 queso_require_greater_msg(m_preComputingPositions.size(), stageIds[0],
"m_preComputingPositions.size() <= stageIds[0]");
120 queso_require_msg(m_preComputingPositions[stageIds[0]],
"m_preComputingPositions[stageIds[0]] == NULL");
122 if ((m_env.subDisplayFile() ) &&
123 (m_env.displayVerbosity() >= 10)) {
124 *m_env.subDisplayFile() <<
"In TransformedScaledCovMatrixTKGroup<V,M>::rv2()"
125 <<
", stageIds.size() = " << stageIds.size()
126 <<
", stageIds[0] = " << stageIds[0]
127 <<
": about to call m_rvs[stageIds.size()-1]->updateLawExpVector()"
128 <<
", vector = " << *m_preComputingPositions[stageIds[0]]
135 V transformedPreComputingPositions(*m_preComputingPositions[stageIds[0]]);
136 transformToGaussianSpace(*m_preComputingPositions[stageIds[0]],
137 transformedPreComputingPositions);
141 return (*invlogit_gaussian);
144 template <
class V,
class M>
149 queso_require_msg(m_rvs[0],
"m_rvs[0] == NULL");
156 V transformedPreComputingPositions(position);
157 transformToGaussianSpace(position, transformedPreComputingPositions);
160 return (*invlogit_gaussian);
164 template<
class V,
class M>
168 for (
unsigned int i = 0; i < m_scales.size(); ++i) {
169 double factor = 1./m_scales[i]/m_scales[i];
170 if ((m_env.subDisplayFile() ) &&
171 (m_env.displayVerbosity() >= 10)) {
172 *m_env.subDisplayFile() <<
"In TransformedScaledCovMatrixTKGroup<V,M>::updateLawCovMatrix()"
173 <<
", m_scales.size() = " << m_scales.size()
175 <<
", m_scales[i] = " << m_scales[i]
176 <<
", factor = " << factor
177 <<
": about to call m_rvs[i]->updateLawCovMatrix()"
178 <<
", covMatrix = \n" << factor*covMatrix
192 template<
class V,
class M>
196 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
197 *m_env.subDisplayFile() <<
"Entering TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
198 <<
": position = " << position
199 <<
", stageId = " << stageId
206 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
207 *m_env.subDisplayFile() <<
"In TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
208 <<
", position = " << position
209 <<
", stageId = " << stageId
210 <<
": preComputingPos = " << *m_preComputingPositions[stageId];
211 if (stageId < m_scales.size()) {
212 *m_env.subDisplayFile() <<
", factor = " << 1./m_scales[stageId]/m_scales[stageId];
214 if (stageId < m_rvs.size()) {
216 *m_env.subDisplayFile() <<
", rvCov = " << pdfPtr->
lawCovMatrix();
218 *m_env.subDisplayFile() << std::endl;
221 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
222 *m_env.subDisplayFile() <<
"Leaving TransformedScaledCovMatrixTKGroup<V,M>::setPreComputingPosition()"
223 <<
": position = " << position
224 <<
", stageId = " << stageId
231 template<
class V,
class M>
239 template <
class V,
class M>
243 unsigned int old_stageId = this->m_stageId;
244 this->m_stageId = stageId;
249 template<
class V,
class M>
257 for (
unsigned int i = 0; i < m_scales.size(); ++i) {
258 double factor = 1./m_scales[i]/m_scales[i];
259 queso_require_msg(!(m_rvs[i]),
"m_rvs[i] != NULL");
261 m_boxSubset, m_vectorSpace->zeroVector(),
262 factor*m_originalCovMatrix);
268 template<
class V,
class M>
276 template<
class V,
class M>
279 const V & physicalPoint, V & transformedPoint)
const
281 V min_domain_bounds(this->m_boxSubset.minValues());
282 V max_domain_bounds(this->m_boxSubset.maxValues());
284 for (
unsigned int i = 0; i < transformedPoint.sizeLocal(); i++) {
285 double min_val = min_domain_bounds[i];
286 double max_val = max_domain_bounds[i];
291 transformedPoint[i] = std::log(physicalPoint[i] - min_val) -
292 std::log(max_val - physicalPoint[i]);
298 transformedPoint[i] = std::log(physicalPoint[i] - min_val);
304 transformedPoint[i] = -std::log(max_val - physicalPoint[i]);
308 transformedPoint[i] = physicalPoint[i];
A class representing a (transformed) Gaussian vector RV with bounds.
const M & lawCovMatrix() const
Returns the covariance matrix; access to protected attribute m_lawCovMatrix.
std::vector< const V * > m_preComputingPositions
virtual unsigned int set_dr_stage(unsigned int stageId)
Does nothing. Subclasses may re-implement. Returns the current stage id.
bool queso_isfinite(T arg)
std::vector< BaseVectorRV< V, M > * > m_rvs
const BaseEnvironment & m_env
virtual void print(std::ostream &os) const
TODO: Prints the transition kernel.
void updateLawCovMatrix(const M &newLawCovMatrix)
Updates the covariance matrix.
void updateLawCovMatrix(const M &covMatrix)
Scales the covariance matrix of the underlying Gaussian distribution.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
virtual void clearPreComputingPositions()
Clears the pre-computing positions m_preComputingPositions[stageId].
void print(std::ostream &os) const
TODO: Prints the transition kernel.
This class represents a transition kernel with a scaled covariance matrix on hybrid bounded/unbounded...
bool symmetric() const
Whether or not the matrix is symmetric. Always 'false'.
bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
Class representing a subset of a vector space shaped like a hypercube.
const InvLogitGaussianVectorRV< V, M > & rv(unsigned int stageId) const
InvLogitGaussian increment property to construct a transition kernel.
void setRVsWithZeroMean()
Sets the mean of the underlying Gaussian RVs to zero.
~TransformedScaledCovMatrixTKGroup()
Destructor.
std::vector< double > m_scales
A class for handling hybrid (transformed) Gaussians with bounds.
This base class allows the representation of a transition kernel.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
TransformedScaledCovMatrixTKGroup(const char *prefix, const BoxSubset< V, M > &boxSubset, const std::vector< double > &scales, const M &covMatrix)
Default constructor.
unsigned int displayVerbosity() const
virtual bool setPreComputingPosition(const V &position, unsigned int stageId)
Sets the pre-computing positions m_preComputingPositions[stageId] with a new vector of size position...
void transformToGaussianSpace(const V &physicalPoint, V &transformedPoint) const
void updateLawExpVector(const V &newLawExpVector)
Updates the vector that contains the mean values for the underlying Gaussian.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).