Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. double epsilon = 1e-3, a = 5.0;
  2. int Nmax = 1000;
  3. matrix x0(2, 1);
  4. matrix x1(2, 1);
  5. random_device rd;
  6. ofstream f1("wyniki.txt");
  7.  
  8. for (int i = 0; i < 100; i++) {
  9. do {
  10.  
  11. x0(0) = 4.0 * rd() / rd.max() + 1;
  12. x0(1) = 4.0 * rd() / rd.max() + 1;
  13. } while (sqrt(pow(x0(0), 2) + pow(x0(1), 2)) - a > 0);
  14.  
  15. solution::f_calls = 0;
  16. solution opt = pen(x0, 1, 5, epsilon, Nmax, true);
  17. f1 <<
  18. x0(0, 0) << "; " << x0(1, 0) << "; " <<
  19. opt.x(0, 0) << "; " << opt.x(1, 0) << "; " <<
  20. sqrt(pow(opt.x(0), 2) + pow(opt.x(1), 2)) << "; " <<
  21. opt.y << " " << solution::f_calls << "; ";
  22.  
  23. solution::f_calls = 0;
  24. opt = pen(x0, 1, 5, epsilon, Nmax, false);
  25. f1 <<
  26. opt.x(0, 0) << "; " << opt.x(1, 0) << "; " <<
  27. sqrt(pow(opt.x(0), 2) + pow(opt.x(1), 2)) << "; " <<
  28. opt.y << " " << solution::f_calls << endl;
  29. }
  30. f1.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement