Coordinate ascent and C ++ Programming

Source: Internet
Author: User
Coordinate riseAlgorithm(Coordinate ascent) and c ++ programming implementation


Programming implementation:
 # include 
  
    using namespace STD; # define F (x1, x2, X3) (-X1 * x1-2 * X2 * x2-3 * X3 * X3 + 2 * X1 * X2 + 2 * X1 * x3-4 * X2 * X3 + 6) int main () {double X1 = 1; double X2 = 1; double X3 = 1; double f0 = f (x1, x2, X3); double err = 1.0e-10; while (true) {x1 = x2 + X3; x2 = 0.5 * x1-x3; X3 = 1.0/3 * x1-2.0/3 * X2; double Ft = f (x1, x2, X3 ); if (ABS (ft-f0) 
   
  

Experiment results:
Note: The method for solving the minimum value of a function is basically the same as this method. In addition, this algorithm is not very sensitive to the selection of initial values. It is very suitable for solving some problems.Source code download: http://download.csdn.net/detail/nuptboyzhb/4909729Discussion:
First, this algorithm cannot compute functions without the maximum and minimum values. However, in practice, if there is no maximum value or minimum value, the model is incorrect.
Second:ProgramIt is indeed impossible to know whether it is the maximum value or the minimum value. Because the maximum and minimum solutions are the same, they are obtained through partial guidance. However, the goal of solving many practical problems is clear.
Third: When a function has multiple maximum values and multiple minimum values, or a local minimum value (maximum value), the calculation result of the algorithm has a great relationship with the selection of the initial value, when the initial value is near the local optimal value, the result is the local optimal value. To find the global optimal value as much as possible,
You can randomly select multiple groups of initial values for iteration, and then select the optimal solution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.