-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
44 lines (33 loc) · 1.04 KB
/
main.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
%////////MAIN FILE - RUN THIS/////////
fclose('all')
close all
clear all
%set iteration file-workaround
filename='iteration.csv';
ifile=fopen(filename,'w');
fprintf(ifile,'1');
fclose(ifile);
%Define x0 - Start Point
%And Upper/Lower Bounds, format:
%Scale Root/mid/tip%
%X mid/tip
%Z mid/tip
alpha = 0;
target_cmtot = -0.01;
alpha_tol = 0.01; % 1% tolerance from target Cm
%x0=[50 30 15 30 40 10 10];
x0=[40 20 10 20 40 40 40];
LB=[20 15 10 0 0 10 10];
UB=[72 72 72 72 72 35 40];
%Write AVL case file and get filename, constraint values
[filename,iter,At]=aeromodule(x0);
%Define Objective Function
objFun=@(x)objective(x);
%Define solver options
options = optimoptions('fmincon','Algorithm','active-set','Display','iter-detailed','FiniteDifferenceStepSize',2,'FunctionTolerance',5e-7,'StepTolerance',1e-7,'PlotFcns',@optimplotfval);
%Run Optimisation
[X,J]=fmincon(objFun,x0,[],[],[],[],LB,UB,@constraints,options)
%Generate Final AVL case file
%[filename, iter]=aeromodule(X)
%AVLcall(filename,'mass_1.avl','w.run',iter);
fclose('all');