Page MenuHomec4science

test_ncp_function.hpp
No OneTemporary

File Metadata

Created
Sun, Nov 10, 03:01

test_ncp_function.hpp

/*-------------------------------------------------------
- Module : test/micpsolver
- File : test_ncp_function
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget, Princeton University
---------------------------------------------------------*/
#include <cxxtest/TestSuite.h>
#include "micpsolver/ncp_function.hpp"
using specmicp::micpsolver::fisher_burmeister;
using specmicp::micpsolver::penalized_fisher_burmeister;
class TEST_NCP_FUNCTION : public CxxTest::TestSuite
{
public:
void test_fisher_burmeister()
{
TS_ASSERT_EQUALS(fisher_burmeister(0.0, 0.0), 0.0);
TS_ASSERT_EQUALS(fisher_burmeister(0.0, 1.0), 0.0);
TS_ASSERT_EQUALS(fisher_burmeister(0.0, 3.4), 0.0);
TS_ASSERT_LESS_THAN_EQUALS(std::abs(fisher_burmeister(1.0, 1.0)-std::sqrt(2)+2), 1e-12);
TS_ASSERT_LESS_THAN_EQUALS(std::abs(fisher_burmeister(2.0, 1.0)-std::sqrt(5)+3), 1e-12);
}
void test_PenalisedBurmeister()
{
TS_ASSERT_EQUALS(penalized_fisher_burmeister(0.0, 0.0, 0.5), 0.0);
TS_ASSERT_EQUALS(penalized_fisher_burmeister(0.0, 1.0, 0.3), 0.0);
TS_ASSERT_EQUALS(penalized_fisher_burmeister(0.0, 3.4, 0.5), 0.0);
TS_ASSERT_EQUALS(penalized_fisher_burmeister(8.4, 0.0, 0.2), 0.0);
TS_ASSERT_LESS_THAN_EQUALS(std::abs(fisher_burmeister(1.0, 1.0)-penalized_fisher_burmeister(1.0, 1.0, 1.0)), 1e-12);
TS_ASSERT_LESS_THAN_EQUALS(std::abs(penalized_fisher_burmeister(2.0, 1.0, 0.5)-0.5*(std::sqrt(5)-3)+0.5*2.0), 1e-12);
}
};

Event Timeline