Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double epsilon = 1e-3, a = 5.0;
- int Nmax = 1000;
- matrix x0(2, 1);
- matrix x1(2, 1);
- random_device rd;
- ofstream f1("wyniki.txt");
- for (int i = 0; i < 100; i++) {
- do {
- x0(0) = 4.0 * rd() / rd.max() + 1;
- x0(1) = 4.0 * rd() / rd.max() + 1;
- } while (sqrt(pow(x0(0), 2) + pow(x0(1), 2)) - a > 0);
- solution::f_calls = 0;
- solution opt = pen(x0, 1, 5, epsilon, Nmax, true);
- f1 <<
- x0(0, 0) << "; " << x0(1, 0) << "; " <<
- opt.x(0, 0) << "; " << opt.x(1, 0) << "; " <<
- sqrt(pow(opt.x(0), 2) + pow(opt.x(1), 2)) << "; " <<
- opt.y << " " << solution::f_calls << "; ";
- solution::f_calls = 0;
- opt = pen(x0, 1, 5, epsilon, Nmax, false);
- f1 <<
- opt.x(0, 0) << "; " << opt.x(1, 0) << "; " <<
- sqrt(pow(opt.x(0), 2) + pow(opt.x(1), 2)) << "; " <<
- opt.y << " " << solution::f_calls << endl;
- }
- f1.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement