source: ThirdParty/levmar/matlab/lmdemo.m@ 7516f6

Action_Thermostats Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChemicalSpaceEvaluator Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Exclude_Hydrogens_annealWithBondGraph Fix_Verbose_Codepatterns ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters Recreated_GuiChecks StoppableMakroAction TremoloParser_IncreasedPrecision
Last change on this file since 7516f6 was 8ce1a9, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '5443b10a06f0c125d0ae0500abb09901fda9666b' as 'ThirdParty/levmar'

  • Property mode set to 100644
File size: 4.0 KB
Line 
1% Demo program for levmar's MEX-file interface
2% Performs minimization of several test problems
3
4format long;
5
6% Unconstrained minimization
7
8% fitting the exponential model x_i=p(1)*exp(-p(2)*i)+p(3) of expfit.c to noisy measurements obtained with (5.0 0.1 1.0)
9p0=[1.0, 0.0, 0.0];
10x=[5.8728, 5.4948, 5.0081, 4.5929, 4.3574, 4.1198, 3.6843, 3.3642, 2.9742, 3.0237, 2.7002, 2.8781,...
11 2.5144, 2.4432, 2.2894, 2.0938, 1.9265, 2.1271, 1.8387, 1.7791, 1.6686, 1.6232, 1.571, 1.6057,...
12 1.3825, 1.5087, 1.3624, 1.4206, 1.2097, 1.3129, 1.131, 1.306, 1.2008, 1.3469, 1.1837, 1.2102,...
13 0.96518, 1.2129, 1.2003, 1.0743];
14
15options=[1E-03, 1E-15, 1E-15, 1E-20, 1E-06];
16% arg demonstrates additional data passing to expfit/jacexpfit
17arg=[40];
18
19[ret, popt, info]=levmar('expfit', 'jacexpfit', p0, x, 200, options, arg);
20disp('Exponential model fitting (see also ../expfit.c)');
21popt
22
23
24% Meyer's (reformulated) problem
25p0=[8.85, 4.0, 2.5];
26
27x=[];
28x(1:4)=[34.780, 28.610, 23.650, 19.630];
29x(5:8)=[16.370, 13.720, 11.540, 9.744];
30x(9:12)=[8.261, 7.030, 6.005, 5.147];
31x(13:16)=[4.427, 3.820, 3.307, 2.872];
32
33options=[1E-03, 1E-15, 1E-15, 1E-20, 1E-06];
34% arg1, arg2 demonstrate additional dummy data passing to meyer/jacmeyer
35arg1=[17];
36arg2=[27];
37
38%[ret, popt, info]=levmar('meyer', 'jacmeyer', p0, x, 200, options, arg1, arg2);
39
40%[ret, popt, info, covar]=levmar('meyer', 'jacmeyer', p0, x, 200, options, arg1, arg2);
41[ret, popt, info, covar]=levmar('meyer', p0, x, 200, options, 'unc', arg1, arg2);
42disp('Meyer''s (reformulated) problem');
43popt
44
45
46% Osborne's problem
47p0=[0.5, 1.5, -1.0, 1.0E-2, 2.0E-2];
48
49x=[8.44E-1, 9.08E-1, 9.32E-1, 9.36E-1, 9.25E-1, 9.08E-1, 8.81E-1,...
508.5E-1, 8.18E-1, 7.84E-1, 7.51E-1, 7.18E-1, 6.85E-1, 6.58E-1,...
516.28E-1, 6.03E-1, 5.8E-1, 5.58E-1, 5.38E-1, 5.22E-1, 5.06E-1,...
524.9E-1, 4.78E-1, 4.67E-1, 4.57E-1, 4.48E-1, 4.38E-1, 4.31E-1,...
534.24E-1, 4.2E-1, 4.14E-1, 4.11E-1, 4.06E-1];
54
55
56options=[1E-03, 1E-15, 1E-15, 1E-20, 1E-06];
57
58[ret, popt, info, covar]=levmar('osborne', 'jacosborne', p0, x, 200, options);
59%[ret, popt, info, covar]=levmar('osborne', p0, x, 200, options, 'unc');
60disp('Osborne''s problem');
61popt
62
63
64% Linear constraints
65
66% Boggs-Tolle problem 3
67p0=[2.0, 2.0, 2.0, 2.0, 2.0];
68x=[0.0, 0.0, 0.0, 0.0, 0.0];
69options=[1E-03, 1E-15, 1E-15, 1E-20];
70adata=[];
71
72A=[1.0, 3.0, 0.0, 0.0, 0.0;
73 0.0, 0.0, 1.0, 1.0, -2.0;
74 0.0, 1.0, 0.0, 0.0, -1.0];
75b=[0.0, 0.0, 0.0]';
76
77[ret, popt, info, covar]=levmar('bt3', 'jacbt3', p0, x, 200, options, 'lec', A, b, adata);
78disp('Boggs-Tolle problem 3');
79popt
80
81
82% Box constraints
83
84% Hock-Schittkowski problem 01
85p0=[-2.0, 1.0];
86x=[0.0, 0.0];
87lb=[-realmax, -1.5];
88ub=[realmax, realmax];
89options=[1E-03, 1E-15, 1E-15, 1E-20];
90
91[ret, popt, info, covar]=levmar('hs01', 'jachs01', p0, x, 200, options, 'bc', lb, ub);
92disp('Hock-Schittkowski problem 01');
93popt
94
95
96% Box and linear constraints
97
98% Hock-Schittkowski modified problem 52 (#1)
99p0=[2.0, 2.0, 2.0, 2.0, 2.0];
100x=[0.0, 0.0, 0.0, 0.0];
101lb=[-0.09, 0.0, -realmax, -0.2, 0.0];
102ub=[realmax, 0.3, 0.25, 0.3, 0.3];
103A=[1.0, 3.0, 0.0, 0.0, 0.0;
104 0.0, 0.0, 1.0, 1.0, -2.0;
105 0.0, 1.0, 0.0, 0.0, -1.0];
106b=[0.0, 0.0, 0.0]';
107options=[1E-03, 1E-15, 1E-15, 1E-20];
108
109[ret, popt, info, covar]=levmar('modhs52', 'jacmodhs52', p0, x, 200, options, 'blec', lb, ub, A, b);
110disp('Hock-Schittkowski modified problem 52 (#1)');
111popt
112
113% Schittkowski modified problem 235
114p0=[-2.0, 3.0, 1.0];
115x=[0.0, 0.0];
116lb=[-realmax, 0.1, 0.7];
117ub=[realmax, 2.9, realmax];
118A=[1.0, 0.0, 1.0;
119 0.0, 1.0, -4.0];
120b=[-1.0, 0.0]';
121options=[1E-03, 1E-15, 1E-15, 1E-20];
122
123[ret, popt, info, covar]=levmar('mods235', p0, x, 200, options, 'blec', lb, ub, A, b);
124disp('Hock-Schittkowski modified problem 235');
125popt
126
127% Box, linear equation & inequality constraints
128p0=[0.5, 0.5, 0.5, 0.5];
129x=[0.0, 0.0, 0.0, 0.0];
130lb=[0.0, 0.0, 0.0, 0.0];
131ub=[realmax, realmax, realmax, realmax];
132A=[0.0, 1.0, 4.0, 0.0];
133b=[1.5]';
134C=[-1.0, -2.0, -1.0, -1.0;
135 -3.0, -1.0, -2.0, 1.0];
136d=[-5.0, -0.4]';
137
138[ret, popt, info, covar]=levmar('modhs76', 'jacmodhs76', p0, x, 200, options, 'bleic', lb, ub, A, b, C, d);
139disp('Hock-Schittkowski modified problem 76');
140popt
Note: See TracBrowser for help on using the repository browser.