hslt: new mutator interface with last succeeded mutation record.
parent
ef48c84915
commit
d9d567bc42
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue