SA模拟退火求函数极值

include [i]includeincludeincludeusing namespace std;const double b = 0.9;double u = 0;///.....计算函数的值......////double Ifunc(double x, double y, double z){double hsz = 0.0;hsz = 50

include [i]

include

include

include

using namespace std;

const double b = 0.9;

double u = 0;

///.....计算函数的值......////

double Ifunc(double x, double y, double z)

{

    double hsz = 0.0;

    hsz = 50 - pow(5 x - 2 y , 2) - pow(x - 7 y y + 2 z z , 4);

    return hsz;

}

/////..........概率计算.........//////

double glfunc(double w1, double w2, double T)

{

    double p;

    double u = 0;

    double w3 = - 1.00 * abs(w1 - w2);

    u = exp(w3 / (b * T));

    if (u > x >> y >> z;

    cout (NULL))));

        //进行 y = x + z 变换

        x_next = x + -x * (rand() % 10000)/ 10100.00 ;

        y_next = y + -y * (rand() % 10000)/ 10100.00 ;

        z_next = z + -z * (rand() % 10000)/ 10100.00 ;

        cout  hsz_max)

        {

            x_max = x_next;

            y_max = y_next;

            z_max = z_next;

            hsz_max = hsz_next;

            T = T * b;

        }

        

    cout = 0.5);

}
金融工程, 数学算法, CPP, 算法