| 264 | // ---------------------------------------------------------------------------------------- |
| 265 | |
| 266 | void test_problems() |
| 267 | { |
| 268 | print_spinner(); |
| 269 | { |
| 270 | matrix<double,4,1> ch; |
| 271 | |
| 272 | ch = brown_start(); |
| 273 | |
| 274 | find_min_trust_region(objective_delta_stop_strategy(1e-7, 80), |
| 275 | brown_function_model(), |
| 276 | ch); |
| 277 | |
| 278 | dlog << LINFO << "brown obj: " << brown(ch); |
| 279 | dlog << LINFO << "brown der: " << length(brown_derivative(ch)); |
| 280 | dlog << LINFO << "brown error: " << length(ch - brown_solution()); |
| 281 | |
| 282 | DLIB_TEST(length(ch - brown_solution()) < 1e-5); |
| 283 | |
| 284 | } |
| 285 | print_spinner(); |
| 286 | { |
| 287 | matrix<double,2,1> ch; |
| 288 | |
| 289 | ch = rosen_start<double>(); |
| 290 | |
| 291 | find_min_trust_region(objective_delta_stop_strategy(1e-7, 80), |
| 292 | rosen_function_model<double>(), |
| 293 | ch); |
| 294 | |
| 295 | dlog << LINFO << "rosen obj: " << rosen(ch); |
| 296 | dlog << LINFO << "rosen der: " << length(rosen_derivative(ch)); |
| 297 | dlog << LINFO << "rosen error: " << length(ch - rosen_solution<double>()); |
| 298 | |
| 299 | DLIB_TEST(length(ch - rosen_solution<double>()) < 1e-5); |
| 300 | } |
| 301 | |
| 302 | print_spinner(); |
| 303 | { |
| 304 | matrix<double,0,1> ch; |
| 305 | |
| 306 | ch = chebyquad_start(2); |
| 307 | |
| 308 | find_min_trust_region(objective_delta_stop_strategy(1e-7, 80), |
| 309 | chebyquad_function_model(), |
| 310 | ch); |
| 311 | |
| 312 | dlog << LINFO << "chebyquad 2 obj: " << chebyquad(ch); |
| 313 | dlog << LINFO << "chebyquad 2 der: " << length(chebyquad_derivative(ch)); |
| 314 | dlog << LINFO << "chebyquad 2 error: " << length(ch - chebyquad_solution(2)); |
| 315 | |
| 316 | DLIB_TEST(length(ch - chebyquad_solution(2)) < 1e-5); |
| 317 | |
| 318 | } |
| 319 | print_spinner(); |
| 320 | { |
| 321 | matrix<double,0,1> ch; |
| 322 | |
| 323 | ch = chebyquad_start(4); |
no test coverage detected