-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_func.cpp
More file actions
43 lines (35 loc) · 858 Bytes
/
test_func.cpp
File metadata and controls
43 lines (35 loc) · 858 Bytes
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
#include<math.h>
#include<vector>
#include"test_func.h"
using namespace std;
double booth(vector<double> temp)
{
double x = temp[0];
double y = temp[1];
return ((x+2*y-7)*(x+2*y-7)+(2*x+y-5)*(2*x+y-5));
}
double sphere(vector<double> temp)
{
double x = temp[0];
double y = temp[1];
return (x*x+y*y);
}
double ackley(vector<double> temp)
{
double x = temp[0];
double y = temp[1];
return (-20*exp(-0.2*sqrt(0.5*(x*x+y*y)))-exp(0.5*(cos(2*M_PI*x)+cos(2*M_PI*y))+exp(1)+20));
}
double holder(vector<double> temp)
{
double x = temp[0];
double y = temp[1];
return(-abs(sin(x)*cos(y)*exp(abs(1-(sqrt(x*x+y*y)/M_PI)))));
}
double rosenbrock(vector<double> temp)
{
double x = temp[0];
double y = temp[1];
double z = temp[2];
return(100*(pow(y-x*x,2)+pow(z-y*y,2))+(pow(1-x,2)+pow(1-y,2)));
}