Finally this works! I seem to be successfully doing "constant jiggling" on my
three classes of "ranged Doubles". I tried two version of where this new mutate
method should go. First I tried putting it on the ephemeral constant class
(like EphemeralDouble), decided the modularity was messy, and moved it to the
wrapped number class (like Double, "T" in the code below). I modified just a
portion of Beagle::GP::MutationJiggleEphemeralOpT<T>::mutate. Where it used to
say:
// Mutate parameter value.
GP::Primitive::Handle lSelectedPrimit =
(*lSelectedTree)[lPotentialParam[lSelectedParam].second].mPrimitive;
typename GP::EphemeralT<T>::Handle lSelectedEphemeral =
castHandleT<typename GP::EphemeralT<T> >(lSelectedPrimit);
GP::Primitive::Handle lGeneratedPrimit =
lSelectedEphemeral->generate(mEphemeralName->getWrappedValue(), lContext);
(*lSelectedTree)[lPotentialParam[lSelectedParam].second].mPrimitive =
lGeneratedPrimit;
Beagle_LogVerboseM(
ioContext.getSystem().getLogger(),
"mutation", "Beagle::GP::MutationJiggleEphemeralOpT",
string("Changing the ephemeral from ")+lSelectedPrimit->serialize()+
string(" to ")+lGeneratedPrimit->serialize()
);
it now says:
// Mutate parameter value.
GP::Primitive::Handle lSelectedPrimit =
(*lSelectedTree)[lPotentialParam[lSelectedParam].second].mPrimitive;
typename GP::EphemeralT<T>::Handle lSelectedEphemeral =
castHandleT<typename GP::EphemeralT<T> >(lSelectedPrimit);
std::cout << "Jiggle mutation -- before: " << lSelectedEphemeral->serialize();
T temp;
lSelectedEphemeral->getValue (temp);
temp.setWrappedValue(temp.mutate(lContext));
lSelectedEphemeral->setValue (temp);
std::cout << " after: " << lSelectedEphemeral->serialize() << std::endl;
// Beagle_LogVerboseM(
// ioContext.getSystem().getLogger(),
// "mutation", "Beagle::GP::MutationJiggleEphemeralOpT",
// string("Changing the ephemeral from ")+lSelectedPrimit->serialize()+
// string(" to ")+lGeneratedPrimit->serialize()
// );
those print outs convince me that it is working correctly, but I am easily
fooled:
Jiggle mutation -- before: <SmallFloat value="-0.644849"/> after: <SmallFloat
value="-0.418695"/>
Jiggle mutation -- before: <Fraction value="0.0677889"/> after: <Fraction
value="0.111499"/>
Jiggle mutation -- before: <Fraction value="0.0910494"/> after: <Fraction
value="0.0992486"/>
Jiggle mutation -- before: <Fraction value="0.655258"/> after: <Fraction
value="0.628954"/>
Jiggle mutation -- before: <SmallFloat value="1.27035"/> after: <SmallFloat
value="1.28836"/>
Jiggle mutation -- before: <SmallPosFloat value="3.10858"/> after:
<SmallPosFloat value="2.83929"/>
My only problem at this point is that I broke the Beagle_LogVerboseM at the end
of that code fragment. I would appreciate suggestions on how to repair it. I
would also appreciate a review of my code for doing things "the OB way"
Thanks for all the help,
Craig