class Pagmo < Formula desc "Scientific library for massively parallel optimization" homepage "https://esa.github.io/pagmo2/" url "https://github.com/esa/pagmo2/archive/v2.11.1.tar.gz" sha256 "a87fc77efe3db9daa4426ed129eafd3a2db1c140e3a73216dcbf3aa7fb1dbb98" bottle do cellar :any sha256 "02fe68f7d8a12007da8332ff1f330f15351ebd420378dab3e045a9e9528e81a7" => :mojave sha256 "164b46f53de3be68ade6060eaf5725181c6aea20434922f2cfa1917e0553a536" => :high_sierra sha256 "03b75c41bc2f08cf8e8afa18390064dbc2c41100ce860d989328e3856956653d" => :sierra end depends_on "cmake" => :build depends_on "boost" depends_on "eigen" depends_on "nlopt" depends_on "tbb" def install ENV.cxx11 system "cmake", ".", "-DPAGMO_WITH_EIGEN3=ON", "-DPAGMO_WITH_NLOPT=ON", *std_cmake_args system "make", "install" end test do (testpath/"test.cpp").write <<~EOS #include #include #include #include #include #include using namespace pagmo; int main() { // 1 - Instantiate a pagmo problem constructing it from a UDP // (user defined problem). problem prob{schwefel(30)}; // 2 - Instantiate a pagmo algorithm algorithm algo{sade(100)}; // 3 - Instantiate an archipelago with 16 islands having each 20 individuals archipelago archi{16, algo, prob, 20}; // 4 - Run the evolution in parallel on the 16 separate islands 10 times. archi.evolve(10); // 5 - Wait for the evolutions to be finished archi.wait_check(); // 6 - Print the fitness of the best solution in each island for (const auto &isl : archi) { std::cout << isl.get_population().champion_f()[0] << std::endl; } return 0; } EOS system ENV.cxx, "test.cpp", "-I#{include}", "-L#{lib}", "-lpagmo", "-std=c++11", "-o", "test" system "./test" end end