Page MenuHomec4science

ncp_functions.cpp
No OneTemporary

File Metadata

Created
Fri, Nov 1, 22:00

ncp_functions.cpp

#include "catch.hpp"
#include "micpsolver/ncp_function.hpp"
using specmicp::micpsolver::fisher_burmeister;
using specmicp::micpsolver::penalized_fisher_burmeister;
TEST_CASE("NCP functions") {
SECTION("fisher Burmeister") {
CHECK(fisher_burmeister(0.0, 0.0) == 0.0);
CHECK(fisher_burmeister(0.0, 1.0) == 0.0);
CHECK(fisher_burmeister(0.0, 3.4) == 0.0);
CHECK(std::abs(fisher_burmeister(1.0, 1.0)-std::sqrt(2)+2) == Approx(0.0));
CHECK(std::abs(fisher_burmeister(2.0, 1.0)-std::sqrt(5)+3) == Approx(0.0));
}
SECTION("Penalized Fischer Burmeister") {
CHECK(penalized_fisher_burmeister(0.0, 0.0, 0.5) == 0.0);
CHECK(penalized_fisher_burmeister(0.0, 1.0, 0.3) == 0.0);
CHECK(penalized_fisher_burmeister(0.0, 3.4, 0.5) == 0.0);
CHECK(penalized_fisher_burmeister(8.4, 0.0, 0.2) == 0.0);
CHECK(std::abs(fisher_burmeister(1.0, 1.0)-penalized_fisher_burmeister(1.0, 1.0, 1.0)) == Approx(0.0));
CHECK(std::abs(penalized_fisher_burmeister(2.0, 1.0, 0.5)-0.5*(std::sqrt(5)-3)+0.5*2.0) == Approx(0.0));
}
}

Event Timeline