hslt: new mutator interface with last succeeded mutation record.

metadata
johannes hanika 2014-11-03 17:52:09 +01:00 committed by Wenzel Jakob
parent ef48c84915
commit d9d567bc42
13 changed files with 23 additions and 17 deletions

View File

@ -64,7 +64,7 @@ public:
EMutationType getType() const;
Float suitability(const Path &path) const;
bool sampleMutation(Path &source, Path &proposal, MutationRecord &muRec);
bool sampleMutation(Path &source, Path &proposal, MutationRecord &muRec, const MutationRecord& sourceMuRec);
Float Q(const Path &source, const Path &proposal,
const MutationRecord &muRec) const;
void accept(const MutationRecord &muRec);

View File

@ -63,7 +63,7 @@ public:
EMutationType getType() const;
Float suitability(const Path &path) const;
bool sampleMutation(Path &source, Path &proposal,
MutationRecord &muRec);
MutationRecord &muRec, const MutationRecord& sourceMuRec);
Float Q(const Path &source, const Path &proposal,
const MutationRecord &muRec) const;
void accept(const MutationRecord &muRec);

View File

@ -63,7 +63,7 @@ public:
EMutationType getType() const;
Float suitability(const Path &path) const;
bool sampleMutation(Path &source, Path &proposal,
MutationRecord &muRec);
MutationRecord &muRec, const MutationRecord& sourceMuRec);
Float Q(const Path &source, const Path &proposal,
const MutationRecord &muRec) const;
void accept(const MutationRecord &muRec);

View File

@ -61,7 +61,7 @@ public:
EMutationType getType() const;
Float suitability(const Path &path) const;
bool sampleMutation(Path &source, Path &proposal,
MutationRecord &muRec);
MutationRecord &muRec, const MutationRecord& sourceMuRec);
Float Q(const Path &source, const Path &proposal,
const MutationRecord &muRec) const;
void accept(const MutationRecord &muRec);

View File

@ -63,7 +63,7 @@ public:
EMutationType getType() const;
Float suitability(const Path &path) const;
bool sampleMutation(Path &source, Path &proposal,
MutationRecord &muRec);
MutationRecord &muRec, const MutationRecord& sourceMuRec);
Float Q(const Path &source, const Path &proposal,
const MutationRecord &muRec) const;
void accept(const MutationRecord &muRec);

View File

@ -64,13 +64,17 @@ public:
* \param muRec
* Data record that describes the sampled mutation strategy
*
* \param sourceMuRec
* Data record that describes the last successful mutation strategy
* (for the source path)
*
* \return \a true upon success. When the sampling step is
* unsuccessful (this could happen due to various
* reasons), the function returns <tt>false</tt>.
*/
virtual bool sampleMutation(Path &source, Path &proposal,
MutationRecord &muRec) = 0;
MutationRecord &muRec, const MutationRecord& sourceMuRec) = 0;
/**
* \brief For a pair of paths, this function computes the inverse

View File

@ -174,7 +174,7 @@ public:
std::ostringstream oss;
Spectrum relWeight(0.0f);
Float accumulatedWeight = 0;
MutationRecord muRec;
MutationRecord muRec, currentMuRec(Mutator::EMutationTypeCount, 0, 0, 0, Spectrum(0.f));
Path *current = new Path(),
*proposed = new Path();
size_t mutations = 0;
@ -211,7 +211,7 @@ public:
mutator = m_mutators[mutatorIdx].get();
/* Sample a mutated path */
success = mutator->sampleMutation(*current, *proposed, muRec);
success = mutator->sampleMutation(*current, *proposed, muRec, currentMuRec);
statsAccepted.incrementBase(1);
if (success) {
@ -258,6 +258,7 @@ public:
std::swap(current, proposed);
relWeight = current->getRelativeWeight();
mutator->accept(muRec);
currentMuRec = muRec;
accumulatedWeight = a;
++statsAccepted;
++mutations;

View File

@ -127,7 +127,7 @@ public:
BDAssert(!relWeight.isZero());
DiscreteDistribution suitabilities(m_mutators.size());
MutationRecord muRec;
MutationRecord muRec, currentMuRec(Mutator::EMutationTypeCount,0,0,0,Spectrum(0.f));
ref<Timer> timer = new Timer();
size_t consecRejections = 0;
@ -171,7 +171,7 @@ public:
mutator = m_mutators[mutatorIdx].get();
/* Sample a mutated path */
success = mutator->sampleMutation(*current, *proposed, muRec);
success = mutator->sampleMutation(*current, *proposed, muRec, currentMuRec);
#if defined(MTS_BD_DEBUG_HEAVY)
if (backup != *current)
@ -263,6 +263,7 @@ public:
std::swap(current, proposed);
relWeight = current->getRelativeWeight();
mutator->accept(muRec);
currentMuRec = muRec;
accumulatedWeight = a;
consecRejections = 0;
++statsAccepted;

View File

@ -44,7 +44,7 @@ Float BidirectionalMutator::suitability(const Path &path) const {
}
bool BidirectionalMutator::sampleMutation(
Path &source, Path &proposal, MutationRecord &muRec) {
Path &source, Path &proposal, MutationRecord &muRec, const MutationRecord& sourceMuRec) {
TwoTailedGeoDistr desiredLength(2), deletionLength(2);
int k = source.length();

View File

@ -73,7 +73,7 @@ Float CausticPerturbation::suitability(const Path &path) const {
}
bool CausticPerturbation::sampleMutation(
Path &source, Path &proposal, MutationRecord &muRec) {
Path &source, Path &proposal, MutationRecord &muRec, const MutationRecord& sourceMuRec) {
int k = source.length(), m = k - 1, l = m - 1;
if (k < 4 || !source.vertex(l)->isConnectable())

View File

@ -70,7 +70,7 @@ Float LensPerturbation::suitability(const Path &path) const {
}
bool LensPerturbation::sampleMutation(
Path &source, Path &proposal, MutationRecord &muRec) {
Path &source, Path &proposal, MutationRecord &muRec, const MutationRecord& sourceMuRec) {
int k = source.length(), m = k-1, l = m-1;
while (!source.vertex(l)->isConnectable() && l >= 0)
--l;

View File

@ -230,7 +230,7 @@ bool ManifoldPerturbation::sampleMutationRecord(
}
bool ManifoldPerturbation::sampleMutation(
Path &source, Path &proposal, MutationRecord &muRec) {
Path &source, Path &proposal, MutationRecord &muRec, const MutationRecord& sourceMuRec) {
int k = source.length();
int a, b, c, step, tries = 0;

View File

@ -66,7 +66,7 @@ Float MultiChainPerturbation::suitability(const Path &path) const {
}
bool MultiChainPerturbation::sampleMutation(
Path &source, Path &proposal, MutationRecord &muRec) {
Path &source, Path &proposal, MutationRecord &muRec, const MutationRecord& sourceMuRec) {
int k = source.length(), m = k - 1, l = m-1, nChains = 1;
while (l-1 >= 0 && (!source.vertex(l)->isConnectable()