Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92563017
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, Nov 21, 12:25
Size
2 KB
Mime Type
text/x-c++
Expires
Sat, Nov 23, 12:25 (1 d, 1 h)
Engine
blob
Format
Raw Data
Handle
22429744
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 <fabieng@princeton.edu>, Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Princeton University nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------*/
#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