tStart method
Returns the temperature at which the expectation value
of the acceptance probability of up-hill transitions
approaches gamma
.
Note: The algorithm converges only for gamma
in
the range: 0 < gamma < 1
.
Implementation
Future<num> tStart(
num gamma, {
List<num> deltaPosition = const <num>[],
int sampleSize = 200,
}) async {
if (gamma <= 0 || gamma >= 1) {
throw ErrorOf<EnergyField>(
message: 'Error in function optimalTemperature',
invalidState: 'Found \'gamma\': $gamma.',
expectedState: 'Expected: 0 < gamma < 1.');
}
if (deltaPosition.isEmpty) {
deltaPosition = size / 4;
}
final transitions = this.transitions(
deltaPosition,
sampleSize: sampleSize,
);
final deltaE = transitions.last - transitions.first;
/// First estimate of the initial temperature.
var optTemperature = deltaE.stdDev() / (-log(gamma));
num gammaEstimate = 0;
var counter = 0;
// Rescaling transition energies
final transitionsGS = transitions.first.min();
for (var i = 0; i < sampleSize; ++i) {
transitions.first[i] -= transitionsGS;
transitions.last[i] -= transitionsGS;
}
do {
gammaEstimate = _gammaStart(transitions, optTemperature);
optTemperature = optTemperature *
pow(
log(gammaEstimate) / log(gamma),
0.2,
);
++counter;
//print('gamma: $gammaEstimate temperature: $optTemperature');
} while ((gammaEstimate - gamma).abs() > gamma * 1e-3 && counter < 100);
return optTemperature;
}