74 lines
2.5 KiB
Ruby
74 lines
2.5 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.17.0.tar.gz"
|
|
sha256 "1b95b036f75e6fa0b21082ab228dbd63cd18ca10d9622ac53629245e0f95c35c"
|
|
license any_of: ["LGPL-3.0-or-later", "GPL-3.0-or-later"]
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_big_sur: "4153aa315f2174b1228b4646dbe18711b2a274704e8b9b58cd855f32142c78a2"
|
|
sha256 cellar: :any, big_sur: "77cebfa5caa6276de184eb32922c673b6437c1653324bcbdef854a2fec4c917d"
|
|
sha256 cellar: :any, catalina: "98e39c1e554b73519443529099df2b1e93cb3e0b755a814be45e8490cc7a739f"
|
|
sha256 cellar: :any, mojave: "54089fee37bb382596312ed8664bbc5764c18d925ea75e56351caecdfe2916bd"
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "boost"
|
|
depends_on "eigen"
|
|
depends_on "nlopt"
|
|
depends_on "tbb"
|
|
|
|
def install
|
|
system "cmake", ".", "-DPAGMO_WITH_EIGEN3=ON", "-DPAGMO_WITH_NLOPT=ON",
|
|
*std_cmake_args,
|
|
"-DCMAKE_CXX_STANDARD=17"
|
|
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
|
|
// (i.e., a user-defined problem, in this case the 30-dimensional
|
|
// generalised Schwefel test function).
|
|
problem prob{schwefel(30)};
|
|
|
|
// 2 - Instantiate a pagmo algorithm (self-adaptive differential
|
|
// evolution, 100 generations).
|
|
algorithm algo{sade(100)};
|
|
|
|
// 3 - Instantiate an archipelago with 16 islands having each 20 individuals.
|
|
archipelago archi{16u, algo, prob, 20u};
|
|
|
|
// 4 - Run the evolution in parallel on the 16 separate islands 10 times.
|
|
archi.evolve(10);
|
|
|
|
// 5 - Wait for the evolutions to finish.
|
|
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++17", "-o", "test"
|
|
system "./test"
|
|
end
|
|
end
|