2023-2-24 pagmo2安装测试

安装必要依赖

安装boost

依赖boost版本大于1.68
boost官网下载

安装boost
安装包解压缩后

./bootstrap --buildtype=complete install
安装TBB

Intel TBB库+CMake+Ubuntu配置流程

安装pagmo

参考pagmo并行全局多目标优化算法库的安装编译与使用

官方教程
install pagmo2

cmake工程测试
CMakeLists.txt:

# The name of our project.
project(sample_project)

# Look for an installation of pagmo in the system.
find_package(Pagmo REQUIRED)

# Create an executable, and link it to the Pagmo::pagmo imported target.
# This ensures that, in the compilation of 'getting_started', pagmo's include
# dirs are added to the include path of the compiler and that pagmo's
# dependencies are transitively linked to 'getting_started'.
add_executable(getting_started getting_started.cpp)
target_link_libraries(getting_started Pagmo::pagmo)

getting_started.cpp:

#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] << '\n';
    }
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值