Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F81369654
test_ncp_function.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Sep 5, 14:28
Size
1 KB
Mime Type
text/x-c++
Expires
Sat, Sep 7, 14:28 (2 d)
Engine
blob
Format
Raw Data
Handle
20315190
Attached To
rSPECMICP SpecMiCP / ReactMiCP
test_ncp_function.hpp
View Options
/*-------------------------------------------------------
- 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
Log In to Comment