-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptCurve.m
47 lines (34 loc) · 1.29 KB
/
optCurve.m
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
clear all
clc
%% Start Parallelization
par = 0; % 1; % Use parallel
if par
if max(size(gcp)) == 0 % Parallel pool needed
parpool(6) % Create the parallel pool
end
pool = gcp;
poolSize = pool.NumWorkers;
else
poolSize = 1;
end
%% Initialize Shared Folders
csvwrite('sync/current.dat',1);
csvwrite('results/results.txt',zeros(1,26));
%% Parameters and Options
LB = [-0.5, 0,-30,0,0.02];
UB = [ 0.3,40, 80,1,0.0386];
%options = gaoptimset('PopulationSize',40,'Generations',50,'Display','iter','TolFun',0.005,'StallGenLimit',10,'UseParallel',false);
%multiopt = gaoptimset(@gamultiobj);
%options = gaoptimset(multiopt,'TimeLimit',32000,'PopulationSize',40,'Generations',300,'Display','final','TolFun',0.001,'StallGenLimit',10,'UseParallel',false);
%% Optimization
[XminP,SminP] = patternsearch(@(x)funCurve(x,poolSize),[-0.269,0.331,6.735,0.615,0.0386],[],[],[],[],LB,UB);
save('curveResult.mat')
[XminG,SminG] = ga(@(x)funCurve(x,poolSize),5,[],[],[],[],LB,UB,[]);
save('curveResult.mat')
[XminGP,SminGP] = patternsearch(@(x)funCurve(x,poolSize),XminG,[],[],[],[],LB,UB);
save('curveResult.mat')
[Xpar,Fpar] = gamultiobj(@(x)funCurve(x,poolSize,1),3,[],[],[],[],LB,UB,[],option);
save('curveResult.mat')
if par
delete(gcp)
end