1 /* Copyright 2017-2021 PaGMO development team
2 
3 This file is part of the PaGMO library.
4 
5 The PaGMO library is free software; you can redistribute it and/or modify
6 it under the terms of either:
7 
8   * the GNU Lesser General Public License as published by the Free
9     Software Foundation; either version 3 of the License, or (at your
10     option) any later version.
11 
12 or
13 
14   * the GNU General Public License as published by the Free Software
15     Foundation; either version 3 of the License, or (at your option) any
16     later version.
17 
18 or both in parallel, as here.
19 
20 The PaGMO library is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23 for more details.
24 
25 You should have received copies of the GNU General Public License and the
26 GNU Lesser General Public License along with the PaGMO library.  If not,
27 see https://www.gnu.org/licenses/. */
28 
29 #define BOOST_TEST_MODULE archipelago_torture_test
30 #define BOOST_TEST_DYN_LINK
31 #include <boost/test/unit_test.hpp>
32 
33 #include <sstream>
34 
35 #include <pagmo/algorithms/de.hpp>
36 #include <pagmo/archipelago.hpp>
37 #include <pagmo/problems/rosenbrock.hpp>
38 
39 using namespace pagmo;
40 
41 // A small test for poking at an archipelago while it is evolving.
BOOST_AUTO_TEST_CASE(archipelago_torture_00)42 BOOST_AUTO_TEST_CASE(archipelago_torture_00)
43 {
44     archipelago archi{10, de{50}, rosenbrock{100}, 100u};
45     for (auto i = 0; i < 50; ++i) {
46         archi.evolve();
47     }
48     auto nadd = 0;
49     while (archi.status() == evolve_status::busy) {
50         if (nadd < 50) {
51             archi.push_back(de{50}, rosenbrock{100}, 100u);
52             ++nadd;
53         }
54         for (auto &isl : archi) {
55             auto algo = isl.get_algorithm();
56             auto pop = isl.get_population();
57             isl.set_algorithm(algo);
58             isl.set_population(pop);
59             auto isl_copy(isl);
60             auto name = isl.get_name();
61             auto einfo = isl.get_extra_info();
62         }
63         auto s = archi.size();
64         (void)s;
65         auto cf = archi.get_champions_f();
66         auto cx = archi.get_champions_x();
67         std::ostringstream oss;
68         oss << archi;
69         BOOST_CHECK(!oss.str().empty());
70     }
71     BOOST_CHECK_NO_THROW(archi.wait_check());
72 }
73