Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include<random>
  2. #include<chrono>
  3. #include<fstream>
  4. #include"opt_alg.h"
  5. #include"ode_solver.h"
  6.  
  7. int main()
  8. {
  9. try
  10. {
  11. matrix x0(2), limits(2, 2);
  12. double epsilon = 1e-3;
  13. double h0;
  14. int Nmax = 5000;
  15. random_device R;
  16.  
  17. limits(0, 0) = limits(1, 0) = -10;
  18. limits(1, 1) = limits(0, 1) = 10;
  19.  
  20. x0(0) = (limits(0, 1) - limits(0, 0)) * R() / R.max() + limits(0, 0);
  21. x0(1) = (limits(1, 1) - limits(1, 0)) * R() / R.max() + limits(1, 0);
  22.  
  23. h0 = 0.05;
  24.  
  25. cout << "H0: " << h0 << endl << endl;
  26. solution opt_SD = SD(x0, h0, epsilon, Nmax, limits);
  27. cout << "opt_SD:" << opt_SD << endl;
  28. solution::clear_calls();
  29.  
  30. solution opt_CG = CG(x0, h0, epsilon, Nmax, limits);
  31. cout << "opt_CG:" << opt_CG << endl;
  32. solution::clear_calls();
  33.  
  34. solution opt_N = Newton(x0, h0, epsilon, Nmax, limits);
  35. cout << "opt_N:" << opt_N << endl;
  36. solution::clear_calls();
  37. }
  38. catch (char * EX_INFO)
  39. {
  40. cout << EX_INFO << endl;
  41. }
  42. system("pause");
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement