22template <
typename DecisionVariables>
42template <
typename DecisionVariables>
45 const DecisionVariables& initialGuess)>
47 std::span<const DecisionVariables> initialGuesses) {
49 futures.
reserve(initialGuesses.size());
51 for (
const auto& initialGuess : initialGuesses) {
52 futures.
emplace_back(std::async(std::launch::async, solve, initialGuess));
58 for (
auto& future : futures) {
62 return *std::min_element(
63 results.cbegin(), results.cend(), [](
const auto& a,
const auto& b) {
65 if (a.status.exitCondition == SolverExitCondition::kSuccess &&
66 b.status.exitCondition != SolverExitCondition::kSuccess) {
71 return a.status.cost < b.status.cost;
This file defines the SmallVector class.
An implementation of std::function_ref, a lightweight non-owning reference to a callable.
Definition FunctionRef.hpp:17
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1212
reference emplace_back(ArgTypes &&... Args)
Definition SmallVector.h:953
void reserve(size_type N)
Definition SmallVector.h:679
size_t size() const
Definition SmallVector.h:99
Definition Hessian.hpp:18
MultistartResult< DecisionVariables > Multistart(function_ref< MultistartResult< DecisionVariables >(const DecisionVariables &initialGuess)> solve, std::span< const DecisionVariables > initialGuesses)
Solves an optimization problem from different starting points in parallel, then returns the solution ...
Definition Multistart.hpp:43
The result of a multistart solve.
Definition Multistart.hpp:23
SolverStatus status
Definition Multistart.hpp:24
DecisionVariables variables
Definition Multistart.hpp:25
Return value of OptimizationProblem::Solve() containing the cost function and constraint types and so...
Definition SolverStatus.hpp:15