MCPcopy Create free account
hub / github.com/davisking/dlib / test_apq

Function test_apq

dlib/test/optimization.cpp:156–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154// ----------------------------------------------------------------------------------------
155
156 void test_apq (
157 const matrix<double,0,1> p
158 )
159 {
160 typedef matrix<double,0,1> T;
161 const double eps = 1e-12;
162 const double minf = -10;
163 matrix<double,0,1> x(p.nr()), opt(p.nr());
164 set_all_elements(opt, 0);
165 double val = 0;
166
167 if (p.size() < 20)
168 dlog << LINFO << "testing with apq and the start point: " << trans(p);
169 else
170 dlog << LINFO << "testing with apq and a big vector with " << p.size() << " components.";
171
172 // don't use bfgs on really large vectors
173 if (p.size() < 20)
174 {
175 total_count = 0;
176 x = p;
177 val = find_min(bfgs_search_strategy(),
178 objective_delta_stop_strategy(eps),
179 wrap_function(apq<T>), wrap_function(der_apq<T>), x, minf);
180 DLIB_TEST_MSG(dlib::equal(x,opt, 1e-5),opt-x);
181 DLIB_TEST(approx_equal(val , apq(x)));
182 dlog << LINFO << "find_min() bgfs: got apq in " << total_count;
183
184 total_count = 0;
185 x = p;
186 find_min(bfgs_search_strategy(),
187 gradient_norm_stop_strategy(),
188 wrap_function(apq<T>), wrap_function(der_apq<T>), x, minf);
189 DLIB_TEST_MSG(dlib::equal(x,opt, 1e-5),opt-x);
190 dlog << LINFO << "find_min() bgfs(gn): got apq in " << total_count;
191 }
192
193
194 if (p.size() < 100)
195 {
196 total_count = 0;
197 x = p;
198 val=find_min_bobyqa(wrap_function(apq<T>), x, 2*x.size()+1,
199 uniform_matrix<double>(x.size(),1,-1e100),
200 uniform_matrix<double>(x.size(),1,1e100),
201 (max(abs(x))+1)/10,
202 1e-6,
203 10000);
204 DLIB_TEST_MSG(dlib::equal(x,opt, 1e-5),opt-x);
205 DLIB_TEST(approx_equal(val , apq(x)));
206 dlog << LINFO << "find_min_bobyqa(): got apq in " << total_count;
207 }
208
209 total_count = 0;
210 x = p;
211 val=find_min(lbfgs_search_strategy(10),
212 objective_delta_stop_strategy(eps),
213 wrap_function(apq<T>), wrap_function(der_apq<T>), x, minf);

Callers 1

optimization_testFunction · 0.85

Calls 15

set_all_elementsFunction · 0.85
find_minFunction · 0.85
wrap_functionFunction · 0.85
apqFunction · 0.85
find_min_bobyqaFunction · 0.85
absFunction · 0.85
approx_equalFunction · 0.70
transFunction · 0.50
equalFunction · 0.50

Tested by

no test coverage detected