diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..37f6a80 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,14 @@ +"""psocpp library for Bazel""" + +load("@rules_cc//cc:defs.bzl", "cc_library") + +licenses(["notice"]) # MIT + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "psocpp", + hdrs = glob(["include/*.h"]), + includes = ["include"], + deps = ["@eigen"], +) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..d4dfd65 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,6 @@ +"""psocpp module""" + +module(name = "psocpp") + +bazel_dep(name = "rules_cc", version = "0.2.14") +bazel_dep(name = "eigen", version = "5.0.1") diff --git a/include/psocpp.h b/include/psocpp.h index 37e9a4f..270c926 100644 --- a/include/psocpp.h +++ b/include/psocpp.h @@ -473,8 +473,9 @@ namespace pso public: - ParticleSwarmOptimization() - : objective_(), callback_(), weightStrategy_(), threads_(1), + template + ParticleSwarmOptimization(Args&&... args) + : objective_(std::forward(args)...), callback_(), weightStrategy_(), threads_(1), maxIt_(0), xeps_(static_cast(1e-6)), feps_(static_cast(1e-6)), phip_(static_cast(2.0)), phig_(static_cast(2.0)), maxVel_(static_cast(0.0)), @@ -577,6 +578,18 @@ namespace pso weightStrategy_ = weightStrategy; } + void setDice(const std::function &dice) + { + dice_ = dice; + } + + template + void setGen(RandomEngine gen) + { + std::uniform_real_distribution distrib(0.0, 1.0); + dice_ = std::bind(distrib, std::forward(gen)); + } + /** Perform minimization with the given bounds and number of particels. * * The swarm of particles will be drawn uniform randomly within the