homebrew-core/Formula/pagmo.rb
2019-10-11 12:58:43 +02:00

69 lines
2.1 KiB
Ruby

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.4.tar.gz"
sha256 "7756cf4b4a427a856137c40c3fdf27422fcf546249b70f9ba4c213ef1fbee051"
bottle do
cellar :any
sha256 "bf7266791644988179506f3c89dd7f671ea36b2262a1d1daaf9b51f81f28e962" => :catalina
sha256 "fadbf1dddee642198a8e4b0f1ca2c55785137cb7eadda7136e09a7475d8eec75" => :mojave
sha256 "ff1dccd341a12f21c16979dcc1a6fd63eb764997e975d2bd720e4957693a118a" => :high_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 <iostream>
#include <pagmo/algorithm.hpp>
#include <pagmo/algorithms/sade.hpp>
#include <pagmo/archipelago.hpp>
#include <pagmo/problem.hpp>
#include <pagmo/problems/schwefel.hpp>
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