-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptimization.hbak
99 lines (65 loc) · 2.06 KB
/
optimization.hbak
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "slmcontrol.h"
/*
#define INTENBUFFSIZE 20
#define SUMSZIE 5
#define SUMARRAYSIZE (INTENBUFFSIZE - AVERSZIE)
*/
//3 point fast search
const double INITSTEP = 1;
const double MINSTEP = 0.05;
//GA
const int ParallelNum = 8;
const int ArrayNum = (ParallelNum+1);
const int CrosNum = ((ParallelNum-2)/2);
const int MutationNum = 2;
const double INIT_SHIFTX = 50;
const double INIT_SHIFTY = 50;
const double INIT_FOCUS = 0;
const double MAXNUMNOTB = 40;
//change the char to double
//256 - 51.2, 0 -- 255 ---->-25.6--- 25.4
const double SCALEXCH = 0.2;
class SlmCom;
class optim_ga{
private :
//parameter array, the last one save the best value
char paracomax[ArrayNum], bestparacomax[CrosNum];
char paracomay[ArrayNum], bestparacomay[CrosNum];
char parastigx[ArrayNum], bestparastigx[CrosNum];
char parastigy[ArrayNum], bestparastigy[CrosNum];
char paraspher[ArrayNum], bestparaspher[CrosNum];
//order number
int order;
//the double type parameters;
double *realpara;
//best intensity value
double finalbestinten;
double aver_inten[ParallelNum];
double best_inten[CrosNum];
unsigned int curpoint; //indicate which of the intense is
unsigned char *phasedata;
char initflag;
SlmCom *slm;
int nfCount;
double tilt_fix_func(double coma);
double focus_fix_func(double spher, double astigx, double astigy);
//private function for data type translation
void DtoI(double * Dbuf, int length);
void generate_buf();
void send_buf();
double round256(double dat);
void crossOverM();
void controlfun();
int stopfun();
void slmcon();
void selectpara();
double parameterExchange(char para);
void find3best();
void getpara();
void exchpara(int i, int j);
public:
optim_ga(int num);
~optim_ga();
int optimization(double aver);
void setpower(bool bPowerstatus);
};