Upload first version
This commit is contained in:
parent
f95d5a63b0
commit
3bdf2003ec
898 changed files with 1405811 additions and 1 deletions
60
dependency/opencv/opencv-linux-aarch64/include/opencv2/ml/ml.inl.hpp
Executable file
60
dependency/opencv/opencv-linux-aarch64/include/opencv2/ml/ml.inl.hpp
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_ML_INL_HPP
|
||||
#define OPENCV_ML_INL_HPP
|
||||
|
||||
namespace cv { namespace ml {
|
||||
|
||||
// declared in ml.hpp
|
||||
template<class SimulatedAnnealingSolverSystem>
|
||||
int simulatedAnnealingSolver(SimulatedAnnealingSolverSystem& solverSystem,
|
||||
double initialTemperature, double finalTemperature, double coolingRatio,
|
||||
size_t iterationsPerStep,
|
||||
CV_OUT double* lastTemperature,
|
||||
cv::RNG& rngEnergy
|
||||
)
|
||||
{
|
||||
CV_Assert(finalTemperature > 0);
|
||||
CV_Assert(initialTemperature > finalTemperature);
|
||||
CV_Assert(iterationsPerStep > 0);
|
||||
CV_Assert(coolingRatio < 1.0f);
|
||||
double Ti = initialTemperature;
|
||||
double previousEnergy = solverSystem.energy();
|
||||
int exchange = 0;
|
||||
while (Ti > finalTemperature)
|
||||
{
|
||||
for (size_t i = 0; i < iterationsPerStep; i++)
|
||||
{
|
||||
solverSystem.changeState();
|
||||
double newEnergy = solverSystem.energy();
|
||||
if (newEnergy < previousEnergy)
|
||||
{
|
||||
previousEnergy = newEnergy;
|
||||
exchange++;
|
||||
}
|
||||
else
|
||||
{
|
||||
double r = rngEnergy.uniform(0.0, 1.0);
|
||||
if (r < std::exp(-(newEnergy - previousEnergy) / Ti))
|
||||
{
|
||||
previousEnergy = newEnergy;
|
||||
exchange++;
|
||||
}
|
||||
else
|
||||
{
|
||||
solverSystem.reverseState();
|
||||
}
|
||||
}
|
||||
}
|
||||
Ti *= coolingRatio;
|
||||
}
|
||||
if (lastTemperature)
|
||||
*lastTemperature = Ti;
|
||||
return exchange;
|
||||
}
|
||||
|
||||
}} //namespace
|
||||
|
||||
#endif // OPENCV_ML_INL_HPP
|
||||
Loading…
Add table
Add a link
Reference in a new issue