Skip to content

Commit

Permalink
Migrated lowdiscrepancysequences.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsky committed Nov 7, 2023
1 parent 7ef6b4a commit 120170f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 143 deletions.
5 changes: 2 additions & 3 deletions test-suite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ set(QL_TEST_SOURCES
)

set(QL_TEST_HEADERS
lowdiscrepancysequences.hpp
margrabeoption.hpp
marketmodel.hpp
marketmodel_cms.hpp
Expand Down Expand Up @@ -269,8 +268,8 @@ set(QL_BENCHMARK_SOURCES
fdheston.cpp
hestonmodel.cpp
interpolations.cpp
jumpdiffusion.cpp
lowdiscrepancysequences.cpp lowdiscrepancysequences.hpp
jumpdiffusion.cpp
lowdiscrepancysequences.cpp
marketmodel_cms.cpp marketmodel_cms.hpp
marketmodel_smm.cpp marketmodel_smm.hpp
quantooption.cpp quantooption.hpp
Expand Down
2 changes: 0 additions & 2 deletions test-suite/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ QL_TEST_SRCS = \
zerocouponswap.cpp

QL_TEST_HDRS = \
lowdiscrepancysequences.hpp \
margrabeoption.hpp \
marketmodel.hpp \
marketmodel_cms.hpp \
Expand Down Expand Up @@ -281,7 +280,6 @@ QL_BENCHMARK_SRCS = \
utilities.cpp

QL_BENCHMARK_HDRS = \
lowdiscrepancysequences.hpp \
marketmodel_cms.hpp \
marketmodel_smm.hpp \
quantlibglobalfixture.hpp \
Expand Down
90 changes: 24 additions & 66 deletions test-suite/lowdiscrepancysequences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

#include "lowdiscrepancysequences.hpp"
#include "toplevelfixture.hpp"
#include "utilities.hpp"
#include <ql/math/statistics/discrepancystatistics.hpp>
#include <ql/math/statistics/sequencestatistics.hpp>
Expand All @@ -44,12 +44,16 @@ using namespace boost::unit_test_framework;

using std::fabs;

void LowDiscrepancyTest::testSeedGenerator() {
BOOST_FIXTURE_TEST_SUITE(QuantLibTest, TopLevelFixture)

BOOST_AUTO_TEST_SUITE(LowDiscrepancyTest)

BOOST_AUTO_TEST_CASE(testSeedGenerator) {
BOOST_TEST_MESSAGE("Testing random-seed generator...");
SeedGenerator::instance().get();
}

void LowDiscrepancyTest::testPolynomialsModuloTwo() {
BOOST_AUTO_TEST_CASE(testPolynomialsModuloTwo) {

BOOST_TEST_MESSAGE("Testing " << PPMT_MAX_DIM <<
" primitive polynomials modulo two...");
Expand Down Expand Up @@ -82,7 +86,7 @@ void LowDiscrepancyTest::testPolynomialsModuloTwo() {

}

void LowDiscrepancyTest::testRandomizedLowDiscrepancySequence() {
BOOST_AUTO_TEST_CASE(testRandomizedLowDiscrepancySequence) {

BOOST_TEST_MESSAGE("Testing randomized low-discrepancy sequences up to "
"dimension " << PPMT_MAX_DIM << "...");
Expand Down Expand Up @@ -165,18 +169,15 @@ namespace
}
}

BOOST_AUTO_TEST_CASE(testRandomizedLattices){

void LowDiscrepancyTest::testRandomizedLattices()
{
testRandomizedLatticeRule(LatticeRule::A, "A");
testRandomizedLatticeRule(LatticeRule::B, "B");
testRandomizedLatticeRule(LatticeRule::C, "C");
testRandomizedLatticeRule(LatticeRule::D, "D");

}


void LowDiscrepancyTest::testSobol() {
BOOST_AUTO_TEST_CASE(testSobol) {

BOOST_TEST_MESSAGE("Testing Sobol sequences up to dimension "
<< PPMT_MAX_DIM << "...");
Expand Down Expand Up @@ -260,7 +261,7 @@ void LowDiscrepancyTest::testSobol() {
}
}

void LowDiscrepancyTest::testFaure() {
BOOST_AUTO_TEST_CASE(testFaure) {

BOOST_TEST_MESSAGE("Testing Faure sequences...");

Expand Down Expand Up @@ -409,7 +410,7 @@ void LowDiscrepancyTest::testFaure() {
}
}

void LowDiscrepancyTest::testHalton() {
BOOST_AUTO_TEST_CASE(testHalton) {

BOOST_TEST_MESSAGE("Testing Halton sequences...");

Expand Down Expand Up @@ -883,8 +884,7 @@ namespace {

}


void LowDiscrepancyTest::testMersenneTwisterDiscrepancy() {
BOOST_AUTO_TEST_CASE(testMersenneTwisterDiscrepancy) {

BOOST_TEST_MESSAGE("Testing Mersenne-twister discrepancy...");

Expand All @@ -901,7 +901,7 @@ void LowDiscrepancyTest::testMersenneTwisterDiscrepancy() {
"DiscrMersenneTwis");
}

void LowDiscrepancyTest::testPlainHaltonDiscrepancy() {
BOOST_AUTO_TEST_CASE(testPlainHaltonDiscrepancy) {

BOOST_TEST_MESSAGE("Testing plain Halton discrepancy...");

Expand All @@ -917,7 +917,7 @@ void LowDiscrepancyTest::testPlainHaltonDiscrepancy() {
"DiscrPlain_Halton");
}

void LowDiscrepancyTest::testRandomStartHaltonDiscrepancy() {
BOOST_AUTO_TEST_CASE(testRandomStartHaltonDiscrepancy) {

BOOST_TEST_MESSAGE("Testing random-start Halton discrepancy...");

Expand All @@ -933,7 +933,7 @@ void LowDiscrepancyTest::testRandomStartHaltonDiscrepancy() {
"DiscrRStartHalton");
}

void LowDiscrepancyTest::testRandomShiftHaltonDiscrepancy() {
BOOST_AUTO_TEST_CASE(testRandomShiftHaltonDiscrepancy) {

BOOST_TEST_MESSAGE("Testing random-shift Halton discrepancy...");

Expand All @@ -949,7 +949,7 @@ void LowDiscrepancyTest::testRandomShiftHaltonDiscrepancy() {
"DiscrRShiftHalton");
}

void LowDiscrepancyTest::testRandomStartRandomShiftHaltonDiscrepancy() {
BOOST_AUTO_TEST_CASE(testRandomStartRandomShiftHaltonDiscrepancy) {

BOOST_TEST_MESSAGE("Testing random-start, random-shift Halton discrepancy...");

Expand All @@ -965,7 +965,7 @@ void LowDiscrepancyTest::testRandomStartRandomShiftHaltonDiscrepancy() {
"DiscrRStRShHalton");
}

void LowDiscrepancyTest::testJackelSobolDiscrepancy() {
BOOST_AUTO_TEST_CASE(testJackelSobolDiscrepancy) {

BOOST_TEST_MESSAGE("Testing Jaeckel-Sobol discrepancy...");

Expand All @@ -981,7 +981,7 @@ void LowDiscrepancyTest::testJackelSobolDiscrepancy() {
"DiscrJackel_Sobol");
}

void LowDiscrepancyTest::testSobolLevitanSobolDiscrepancy() {
BOOST_AUTO_TEST_CASE(testSobolLevitanSobolDiscrepancy) {

BOOST_TEST_MESSAGE("Testing Levitan-Sobol discrepancy...");

Expand All @@ -997,7 +997,7 @@ void LowDiscrepancyTest::testSobolLevitanSobolDiscrepancy() {
"DiscrSobLev_Sobol");
}

void LowDiscrepancyTest::testSobolLevitanLemieuxSobolDiscrepancy() {
BOOST_AUTO_TEST_CASE(testSobolLevitanLemieuxSobolDiscrepancy) {

BOOST_TEST_MESSAGE("Testing Levitan-Lemieux-Sobol discrepancy...");

Expand All @@ -1013,7 +1013,7 @@ void LowDiscrepancyTest::testSobolLevitanLemieuxSobolDiscrepancy() {
"DiscrSobLevLem_Sobol");
}

void LowDiscrepancyTest::testUnitSobolDiscrepancy() {
BOOST_AUTO_TEST_CASE(testUnitSobolDiscrepancy) {

BOOST_TEST_MESSAGE("Testing unit Sobol discrepancy...");

Expand All @@ -1026,8 +1026,7 @@ void LowDiscrepancyTest::testUnitSobolDiscrepancy() {
"Discr__Unit_Sobol");
}


void LowDiscrepancyTest::testSobolSkipping() {
BOOST_AUTO_TEST_CASE(testSobolSkipping) {

BOOST_TEST_MESSAGE("Testing Sobol sequence skipping...");

Expand Down Expand Up @@ -1070,47 +1069,6 @@ void LowDiscrepancyTest::testSobolSkipping() {
}
}

BOOST_AUTO_TEST_SUITE_END()

test_suite* LowDiscrepancyTest::suite() {
auto* suite = BOOST_TEST_SUITE("Low-discrepancy sequence tests");

suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testRandomizedLattices));


suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testSeedGenerator));

suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testPolynomialsModuloTwo));

suite->add(QUANTLIB_TEST_CASE(&LowDiscrepancyTest::testSobol));
suite->add(QUANTLIB_TEST_CASE(&LowDiscrepancyTest::testHalton));
suite->add(QUANTLIB_TEST_CASE(&LowDiscrepancyTest::testFaure));

suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testMersenneTwisterDiscrepancy));
suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testPlainHaltonDiscrepancy));
suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testRandomStartHaltonDiscrepancy));
suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testRandomShiftHaltonDiscrepancy));
suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testRandomStartRandomShiftHaltonDiscrepancy));
suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testUnitSobolDiscrepancy));
suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testJackelSobolDiscrepancy));
suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testSobolLevitanSobolDiscrepancy));
suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testSobolLevitanLemieuxSobolDiscrepancy));

suite->add(QUANTLIB_TEST_CASE(&LowDiscrepancyTest::testSobolSkipping));

suite->add(QUANTLIB_TEST_CASE(
&LowDiscrepancyTest::testRandomizedLowDiscrepancySequence));

return suite;
}
BOOST_AUTO_TEST_SUITE_END()
58 changes: 0 additions & 58 deletions test-suite/lowdiscrepancysequences.hpp

This file was deleted.

8 changes: 6 additions & 2 deletions test-suite/quantlibbenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
#include "utilities.hpp"
#include "marketmodel_smm.hpp"
#include "marketmodel_cms.hpp"
#include "lowdiscrepancysequences.hpp"
#include "quantooption.hpp"
#include "riskstats.hpp"
#include "shortratemodels.hpp"
Expand Down Expand Up @@ -224,6 +223,11 @@ namespace QuantLibTest {
struct testGreeks:
public BOOST_AUTO_TEST_CASE_FIXTURE { void test_method(); };
}

namespace LowDiscrepancyTest {
struct testMersenneTwisterDiscrepancy:
public BOOST_AUTO_TEST_CASE_FIXTURE { void test_method(); };
}
}

namespace {
Expand Down Expand Up @@ -276,7 +280,7 @@ namespace {
Benchmark("MarketModelCmsTest::testCmSwapsSwaptions", &MarketModelCmsTest::testMultiStepCmSwapsAndSwaptions, 11497.73),
Benchmark("MarketModelSmmTest::testMultiSmmSwaptions", &MarketModelSmmTest::testMultiStepCoterminalSwapsAndSwaptions, 11244.95),
Benchmark("QuantoOption::ForwardGreeks", &QuantoOptionTest::testForwardGreeks, 90.98),
Benchmark("RandomNumber::MersenneTwisterDescrepancy", &LowDiscrepancyTest::testMersenneTwisterDiscrepancy, 951.98),
Benchmark("RandomNumber::MersenneTwisterDescrepancy", std::bind(&QuantLibTest::LowDiscrepancyTest::testMersenneTwisterDiscrepancy::test_method, QuantLibTest::LowDiscrepancyTest::testMersenneTwisterDiscrepancy()), 951.98),
Benchmark("RiskStatistics::Results", &RiskStatisticsTest::testResults, 300.28),
Benchmark("ShortRateModel::Swaps", &ShortRateModelTest::testSwaps, 454.73)
};
Expand Down
8 changes: 0 additions & 8 deletions test-suite/quantlibtestsuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

#include <ql/types.hpp>
#include <ql/settings.hpp>
#include <ql/utilities/dataparsers.hpp>
#include <ql/version.hpp>

#ifdef QL_ENABLE_PARALLEL_UNIT_TEST_RUNNER
#include "paralleltestrunner.hpp"
Expand All @@ -36,7 +34,6 @@
# include <ql/auto_link.hpp>
#endif

#include "lowdiscrepancysequences.hpp"
#include "margrabeoption.hpp"
#include "marketmodel.hpp"
#include "marketmodel_cms.hpp"
Expand Down Expand Up @@ -101,7 +98,6 @@
#include "twoassetbarrieroption.hpp"
#include "twoassetcorrelationoption.hpp"
#include "ultimateforwardtermstructure.hpp"
#include "utilities.hpp"
#include "variancegamma.hpp"
#include "varianceoption.hpp"
#include "varianceswaps.hpp"
Expand All @@ -110,9 +106,6 @@
#include "xoshiro256starstar.hpp"
#include "zabr.hpp"
#include "zerocouponswap.hpp"
#include <chrono>
#include <iomanip>
#include <iostream>

using namespace boost::unit_test_framework;

Expand Down Expand Up @@ -145,7 +138,6 @@ test_suite* init_unit_test_suite(int, char* []) {

auto* test = BOOST_TEST_SUITE("QuantLib test suite");

test->add(LowDiscrepancyTest::suite());
test->add(MargrabeOptionTest::suite());
test->add(MarketModelTest::suite(speed));
test->add(MarketModelCmsTest::suite(speed));
Expand Down
1 change: 0 additions & 1 deletion test-suite/testsuite.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,6 @@
<ClCompile Include="quantlibtestsuite.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="lowdiscrepancysequences.hpp" />
<ClInclude Include="margrabeoption.hpp" />
<ClInclude Include="marketmodel.hpp" />
<ClInclude Include="marketmodel_cms.hpp" />
Expand Down
Loading

0 comments on commit 120170f

Please sign in to comment.