-
Notifications
You must be signed in to change notification settings - Fork 0
/
sub_ideal.cpp
67 lines (53 loc) · 1.06 KB
/
sub_ideal.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <array>
#include <random>
#include <ostream>
#include <fstream>
using namespace std;
namespace {
ofstream take_log("sub_ideal.log");
}
int time_end = 100000;
double time_bunkai = 0.001;
random_device rdom;
double rd(void)
{
double get;
get = (double)(rdom() % 1000) * 0.001;
return get;
}
double rand_normal(double mu, double sigma)
{
double z = sqrt(- 2.0 * log(rd())) * sin(2.0 * M_PI * rd());
return mu + sigma * z;
}
double get_rand_normal(double size)
{
double get;
get = rand_normal(size, size * 0.1);
return get;
}
int main(void)
{
double a, b, c, d, e, f;
a = 1.2;
b = 0.1;
c = 1.0;
d = 0.1;
e = 0.1;
f = 0.1;
double prev_x = 10;
double prev_y = 20;
double x, y;
for (int t = 0; t < time_end; t++) {
cout << prev_x << " " << prev_y << endl;
take_log << prev_x << " " << prev_y << endl;
x = prev_x + time_bunkai * (a - e * prev_x - b * prev_y);
y = prev_y + time_bunkai * (- c + d * prev_x - f * prev_y);
prev_x = x;
prev_y = y;
if (prev_x < 0) prev_x = 0;
if (prev_y < 0) prev_y = 0;
}
return 0;
}