Skip to content

Commit

Permalink
Fix test build of nlopt algo
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave-Poissant committed Mar 7, 2024
1 parent 86e7bc1 commit aa99ac9
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions tests/nlopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,34 +381,3 @@ BOOST_AUTO_TEST_CASE(nlopt_loc_opt)
algo.evolve(pop);
BOOST_CHECK(algo.extract<nlopt>()->get_last_opt_result() >= 0);
}

BOOST_AUTO_TEST_CASE(nlopt_initial_population_not_respecting_bounds_throw_test)
{
// We test that the algorithm throws if the initial population does not respect the bounds
auto pop = population{hs71{}, 1};
auto a = nlopt{"slsqp"};
auto dv = pop.get_x()[0];
dv[0] = prob.get_bounds().first[0] - 1.;
pop.set_x(0, dv);
BOOST_CHECK_THROW(nlopt.evolve(pop), std::invalid_argument);

dv = pop.get_x()[0];
dv[0] = prob.get_bounds().second[0] + 2.;
pop.set_x(0, dv);
BOOST_CHECK_THROW(nlopt.evolve(pop), std::invalid_argument);

dv = pop.get_x()[0];
dv[0] = std::numeric_limits<double>::quiet_NaN();
pop.set_x(0, dv);
BOOST_CHECK_THROW(nlopt.evolve(pop), std::invalid_argument);

dv = pop.get_x()[0];
dv[0] = std::numeric_limits<double>::infinity();
pop.set_x(0, dv);
BOOST_CHECK_THROW(nlopt.evolve(pop), std::invalid_argument);

dv = pop.get_x()[0];
dv[0] = prob.get_bounds().first[0] + prob.get_bounds().second[0] / 2.0;
pop.set_x(0, dv);
BOOST_CHECK_NO_THROW(nlopt.evolve(pop));
}

0 comments on commit aa99ac9

Please sign in to comment.