From 51deea2e2aa04bb951f6cbf40b0b7fa9b77f70cc Mon Sep 17 00:00:00 2001 From: Seth Putnam Date: Wed, 24 May 2017 13:06:54 -0600 Subject: [PATCH] Merge develop into release to make a new Release Candidate (#1574) * make conflicts network matcher opt test easier to follow * couple more small tweaks to optimizer * Fix error reporting in ConflateCaseTest.cpp (it was ambiguous before) (#1570) Comment out a few trace statements that were causing a test failure (and appliedd appropriate warnings) * remove warning * Update to latest Oracle release of java (#1572) * Update to latest Oracle jdk * Fixing whitespace * Fixing typo in comment * Updates for JAVA_HOME * Stop jdk from upgrading automatically during provisioning * remove unused var * update copyright headers --- VagrantProvision.sh | 24 +-- .../cpp/hoot/core/test/ConflateCaseTest.cpp | 10 +- .../conflate/network/EdgeMatchSetFinder.cpp | 20 +- ...nflictsNetworkMatcherSettingsOptimizer.cpp | 184 ++++++++++++++---- .../cpp/tgs/Optimization/FitnessFunction.h | 2 +- .../tgs/Optimization/SimulatedAnnealing.cpp | 2 +- .../cpp/tgs/Optimization/SimulatedAnnealing.h | 6 +- .../Optimization/SimulatedAnnealingTest.cpp | 2 +- 8 files changed, 185 insertions(+), 65 deletions(-) diff --git a/VagrantProvision.sh b/VagrantProvision.sh index e4495f8a2d..b8ceee9872 100644 --- a/VagrantProvision.sh +++ b/VagrantProvision.sh @@ -13,6 +13,8 @@ fi echo "Updating OS..." sudo apt-get -qq update > Ubuntu_upgrade.txt 2>&1 +# Don't automatically update the oracle jdk, we need to control the version +sudo apt-mark -qq hold oracle-java8-installer oracle-java8-set-default >> Ubuntu_upgrade.txt 2>&1 sudo apt-get -q -y upgrade >> Ubuntu_upgrade.txt 2>&1 sudo apt-get -q -y dist-upgrade >> Ubuntu_upgrade.txt 2>&1 @@ -22,21 +24,21 @@ sudo service ntp stop sudo ntpd -gq sudo service ntp start -if ! java -version 2>&1 | grep --quiet 1.8.0_112; then +if ! java -version 2>&1 | grep --quiet 1.8.0_131; then echo "### Installing Java 8..." # jdk-8u112-linux-x64.tar.gz's official checksums: - # sha256: 777bd7d5268408a5a94f5e366c2e43e720c6ce4fe8c59d9a71e2961e50d774a5 - # md5: de9b7a90f0f5a13cfcaa3b01451d0337 - echo "de9b7a90f0f5a13cfcaa3b01451d0337 /tmp/jdk-8u112-linux-x64.tar.gz" > /tmp/jdk.md5 - - if [ ! -f /tmp/jdk-8u112-linux-x64.tar.gz ] || ! md5sum -c /tmp/jdk.md5; then - echo "Downloading jdk-8u112-linux-x64.tar.gz ...." - sudo wget --quiet --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jdk-8u112-linux-x64.tar.gz -P /tmp - echo "Finished download of jdk-8u112-linux-x64.tar.gz" + # sha256: 62b215bdfb48bace523723cdbb2157c665e6a25429c73828a32f00e587301236 + # md5: 75b2cb2249710d822a60f83e28860053 + echo "75b2cb2249710d822a60f83e28860053 /tmp/jdk-8u131-linux-x64.tar.gz " > /tmp/jdk.md5 + + if [ ! -f /tmp/jdk-8u131-linux-x64.tar.gz ] || ! md5sum -c /tmp/jdk.md5; then + echo "Downloading jdk-8u131-linux-x64.tar.gz ...." + sudo wget --quiet --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz -P /tmp + echo "Finished download of jdk-8u131-linux-x64.tar.gz" fi - sudo tar -xvzf /tmp/jdk-8u112-linux-x64.tar.gz --directory=/tmp >/dev/null + sudo tar -xvzf /tmp/jdk-8u131-linux-x64.tar.gz --directory=/tmp >/dev/null if [[ ! -e /usr/lib/jvm ]]; then sudo mkdir /usr/lib/jvm @@ -46,7 +48,7 @@ if ! java -version 2>&1 | grep --quiet 1.8.0_112; then fi fi - sudo mv -f /tmp/jdk1.8.0_112 /usr/lib/jvm/oracle_jdk8 + sudo mv -f /tmp/jdk1.8.0_131 /usr/lib/jvm/oracle_jdk8 sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/oracle_jdk8/jre/bin/java 9999 sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/oracle_jdk8/bin/javac 9999 echo "### Done with Java 8 install..." diff --git a/hoot-core-test/src/test/cpp/hoot/core/test/ConflateCaseTest.cpp b/hoot-core-test/src/test/cpp/hoot/core/test/ConflateCaseTest.cpp index c1ccaa6cf4..ba19e30a45 100644 --- a/hoot-core-test/src/test/cpp/hoot/core/test/ConflateCaseTest.cpp +++ b/hoot-core-test/src/test/cpp/hoot/core/test/ConflateCaseTest.cpp @@ -72,14 +72,13 @@ ConflateCaseTest::ConflateCaseTest(QDir d, QStringList confs) : void ConflateCaseTest::runTest() { + TestUtils::resetEnvironment(); LOG_DEBUG("Running conflate case test..."); // configures and cleans up the conf() environment LOG_VART(_confs); SetupTest st(_confs); - bool failed = false; - ConflateCmd cmd; if (QFileInfo(_d, "README.txt").exists() == false) @@ -124,15 +123,10 @@ void ConflateCaseTest::runTest() if (result != 0) { - failed = true; + CPPUNIT_ASSERT_MESSAGE(QString("Conflate command had nonzero exit status").toStdString(), false); } if (!TestUtils::compareMaps(expected.absoluteFilePath(), testOutput)) - { - failed = true; - } - - if (failed) { CPPUNIT_ASSERT_MESSAGE(QString("Maps do not match").toStdString(), false); } diff --git a/hoot-rnd/src/main/cpp/hoot/rnd/conflate/network/EdgeMatchSetFinder.cpp b/hoot-rnd/src/main/cpp/hoot/rnd/conflate/network/EdgeMatchSetFinder.cpp index 89f143095f..4805b84b2e 100644 --- a/hoot-rnd/src/main/cpp/hoot/rnd/conflate/network/EdgeMatchSetFinder.cpp +++ b/hoot-rnd/src/main/cpp/hoot/rnd/conflate/network/EdgeMatchSetFinder.cpp @@ -177,7 +177,10 @@ bool EdgeMatchSetFinder::_addEdgeNeighborsToEnd(ConstEdgeMatchPtr em, { LOG_VART(neighbor1); LOG_VART(em->contains(neighbor1)); - LOG_VART(_details->getPartialEdgeMatchScore(neighbor1, em->getString2()->getLastEdge())); + + // Calling this non-const function can alter the state of the map, and lead to different + // behaviors at different log levels! Beware! + //LOG_VART(_details->getPartialEdgeMatchScore(neighbor1, em->getString2()->getLastEdge())); // if the neighbor pair score is non-zero if (em->contains(neighbor1) == false && @@ -198,7 +201,10 @@ bool EdgeMatchSetFinder::_addEdgeNeighborsToEnd(ConstEdgeMatchPtr em, LOG_VART(neighbor2); LOG_VART(em->contains(neighbor2)); LOG_VART(_details->isStringCandidate(em->getString2()->getLastEdge(), neighbor2)); - LOG_VART(_details->getPartialEdgeMatchScore(neighbor2, em->getString1()->getLastEdge())); + + // Calling this non-const function can alter the state of the map, and lead to different + // behaviors at different log levels! Beware! + //LOG_VART(_details->getPartialEdgeMatchScore(neighbor2, em->getString1()->getLastEdge())); // if the neighbor pair score is non-zero if (em->contains(neighbor2) == false && @@ -230,7 +236,10 @@ bool EdgeMatchSetFinder::_addEdgeNeighborsToStart(ConstEdgeMatchPtr em, { LOG_VART(neighbor1); LOG_VART(em->getString2()->getFirstEdge()); - LOG_VART(_details->getPartialEdgeMatchScore(neighbor1, em->getString2()->getFirstEdge())); + + // Calling this non-const function can alter the state of the map, and lead to different + // behaviors at different log levels! Beware! + //LOG_VART(_details->getPartialEdgeMatchScore(neighbor1, em->getString2()->getFirstEdge())); // if the neighbor pair score is non-zero if (em->contains(neighbor1) == false && @@ -250,7 +259,10 @@ bool EdgeMatchSetFinder::_addEdgeNeighborsToStart(ConstEdgeMatchPtr em, { LOG_VART(neighbor2); LOG_VART(em->getString1()->getFirstEdge()); - LOG_VART(_details->getPartialEdgeMatchScore(neighbor2, em->getString1()->getFirstEdge())); + + // Calling this non-const function can alter the state of the map, and lead to different + // behaviors at different log levels! Beware! + //LOG_VART(_details->getPartialEdgeMatchScore(neighbor2, em->getString1()->getFirstEdge())); // if the neighbor pair score is non-zero if (em->contains(neighbor2) == false && diff --git a/hoot-rnd/src/test/cpp/hoot/rnd/conflate/network/ConflictsNetworkMatcherSettingsOptimizer.cpp b/hoot-rnd/src/test/cpp/hoot/rnd/conflate/network/ConflictsNetworkMatcherSettingsOptimizer.cpp index 9f515900cf..70df472381 100644 --- a/hoot-rnd/src/test/cpp/hoot/rnd/conflate/network/ConflictsNetworkMatcherSettingsOptimizer.cpp +++ b/hoot-rnd/src/test/cpp/hoot/rnd/conflate/network/ConflictsNetworkMatcherSettingsOptimizer.cpp @@ -116,13 +116,14 @@ class ConflictsNetworkMatcherSettingsOptimizer : public CppUnit::TestFixture public: CaseFitnessFunction() : - _testCount(0) + _testCount(0), + _lowestNumFailingTestsPerRun(-1) { _testSuite.reset(new ConflateCaseTestSuite("test-files/cases/hoot-rnd/network/conflicts/")); _testCount = _testSuite->getChildTestCount(); } - virtual double f(const ConstStatePtr& s) const + virtual double f(const ConstStatePtr& s) { LOG_DEBUG("Running fitness function..."); @@ -163,6 +164,26 @@ class ConflictsNetworkMatcherSettingsOptimizer : public CppUnit::TestFixture } } + QString failedTestsStr; + if (failedTests.size() > 0) + { + failedTestsStr = _failedTestsToString(failedTests); + } + if (failedTests.size() < _lowestNumFailingTestsPerRun || _lowestNumFailingTestsPerRun == -1) + { + _lowestNumFailingTestsPerRun = failedTests.size(); + _failingTestsForBestRuns.clear(); + if (!failedTestsStr.isEmpty()) + { + _failingTestsForBestRuns.append(failedTestsStr); + } + } + else if (failedTests.size() == _lowestNumFailingTestsPerRun && + !failedTestsStr.isEmpty() && !_failingTestsForBestRuns.contains(failedTestsStr)) + { + _failingTestsForBestRuns.append(failedTestsStr); + } + if (failedTests.size() == 0) { //This message will actually show if, by chance, the first selected random state @@ -180,6 +201,8 @@ class ConflictsNetworkMatcherSettingsOptimizer : public CppUnit::TestFixture failureMsg += "\t" + failedTests[i] + "\n"; } LOG_ERROR(failureMsg); + LOG_ERROR("Lowest number of tests failed so far: " << _lowestNumFailingTestsPerRun); + LOG_ERROR(""); } return (double)failedTests.size() / (double)_testCount; @@ -187,132 +210,219 @@ class ConflictsNetworkMatcherSettingsOptimizer : public CppUnit::TestFixture int getTestCount() { return _testCount; } + QStringList getFailingTestsForBestRuns() { return _failingTestsForBestRuns; } + private: int _testCount; + int _lowestNumFailingTestsPerRun; + //list members are one or more test names joined by a ';' + QStringList _failingTestsForBestRuns; boost::shared_ptr _testSuite; + + QString _failedTestsToString(const QStringList failedTests) const + { + QString concatTestNames; + for (int i = 0; i < failedTests.size(); i++) + { + concatTestNames += failedTests.at(i) + ";"; + } + concatTestNames.chop(1); + return concatTestNames; + } }; - void optimizeAgainstCaseDataTest() + StateDescriptionPtr initStateDescription() { - StateDescriptionPtr desc(new StateDescription()); - desc->addVariable( + StateDescriptionPtr stateDescription(new StateDescription()); + + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkConflictsAggressionKey(), //VariableDescription::Real, 4.4, 4.4)); //original default //VariableDescription::Real, 8.8, 8.8)); //current default //VariableDescription::Real, 0.0, 10.0)); //min/max VariableDescription::Real, 4.0, 10.0)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkConflictsPartialHandicapKey(), //VariableDescription::Real, 0.2, 0.2)); //original default //VariableDescription::Real, 0.2, 0.2)); //current default //VariableDescription::Real, 0.0, 2.0)); //min/max VariableDescription::Real, 0.1, 0.3)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkConflictsStubHandicapKey(), //VariableDescription::Real, 0.86, 0.86)); //original default //VariableDescription::Real, 1.7, 1.7)); //current default //VariableDescription::Real, 0.0, 2.0)); //min/max VariableDescription::Real, 0.76, 0.96)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkConflictsWeightInfluenceKey(), //VariableDescription::Real, 0.0, 0.0)); //original default //VariableDescription::Real, 0.0, 0.0)); //current default //VariableDescription::Real, 0.0, 2.0)); //min/max VariableDescription::Real, 0.0, 0.1)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkConflictsOutboundWeightingKey(), //VariableDescription::Real, 0.0, 0.0)); //original default //VariableDescription::Real, 0.25, 0.25)); //current default //VariableDescription::Real, 0.0, 2.0)); //min/max VariableDescription::Real, 0.0, 0.1)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkConflictsStubThroughWeightingKey(), //VariableDescription::Real, 0.59, 0.59)); //original default //VariableDescription::Real, 0.5, 0.5)); //current default //VariableDescription::Real, 0.0, 10.0)); //min/max VariableDescription::Real, 0.49, 0.69)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkMaxStubLengthKey(), //VariableDescription::Real, 20.0, 20.0)); //original default //VariableDescription::Real, 20.0, 20.0)); //current default //VariableDescription::Real, 1.0, 100.0)); //min/max?? VariableDescription::Real, 15.0, 25.0)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkMatchThresholdKey(), //VariableDescription::Real, 0.15, 0.15)); //original default //VariableDescription::Real, 0.15, 0.15)); //current default //VariableDescription::Real, 0.01, 0.99)); //min/max VariableDescription::Real, 0.05, 0.25)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkMissThresholdKey(), //VariableDescription::Real, 0.85, 0.85)); //original default //VariableDescription::Real, 0.85, 0.85)); //current default //VariableDescription::Real, 0.01, 0.99)); //min/max VariableDescription::Real, 0.75, 0.95)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkReviewThresholdKey(), //VariableDescription::Real, 0.5, 0.5)); //original default //VariableDescription::Real, 0.5, 0.5)); //current default //VariableDescription::Real, 0.01, 0.99)); //min/max VariableDescription::Real, 0.4, 0.6)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getWayMergerMinSplitSizeKey(), //VariableDescription::Real, 5.0, 5.0)); //original default //VariableDescription::Real, 5.0, 5.0)); //current default //VariableDescription::Real, 0.01, 100.0)); //min/max?? VariableDescription::Real, 4.0, 6.0)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getWayMatcherMaxAngleKey(), //VariableDescription::Real, 60.0, 60.0)); //original default //VariableDescription::Real, 60.0, 60.0)); //current default //VariableDescription::Real, 0.01, 90.0)); //min/max VariableDescription::Real, 50.0, 70.0)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getWayMatcherHeadingDeltaKey(), //VariableDescription::Real, 5.0, 5.0)); //original default //VariableDescription::Real, 5.0, 5.0)); //new default //VariableDescription::Real, 0.01, 100.0)); //min/max?? VariableDescription::Real, 4.0, 6.0)); //test values - desc->addVariable( + stateDescription->addVariable( new VariableDescription(ConfigOptions::getNetworkOptimizationIterationsKey(), //VariableDescription::Real, 10, 10)); //original default - //VariableDescription::Real, 10, 10)); //new default + VariableDescription::Real, 10, 10)); //new default //VariableDescription::Real, 0, 100)); //min/max?? - VariableDescription::Real, 10, 20)); //test values + //VariableDescription::Real, 10, 20)); //test values - boost::shared_ptr fitnessFunction(new CaseFitnessFunction()); - SimulatedAnnealing sa(desc, fitnessFunction); + return stateDescription; + } + + QSet runOptimization(ConstStateDescriptionPtr stateDescription, + boost::shared_ptr fitnessFunction, + double& bestScore, const int numIterations) + { + SimulatedAnnealing sa(stateDescription, fitnessFunction); sa.setPickFromBestScores(true); - const int numIterations = 50; //change your number of test iterations here - const double bestScore = sa.iterate(numIterations); - - LOG_ERROR("Number of test iterations: " << numIterations); - LOG_ERROR("Number of tests in test suite: " << fitnessFunction->getTestCount()); - LOG_ERROR( - "Lowest number of test failures in test iteration: " << - (int)(fitnessFunction->getTestCount() * bestScore)); - LOG_ERROR("Number of best states found: " << sa.getBestStates().size()); + bestScore = sa.iterate(numIterations); + return sa.getBestStates(); + } + + void writeOutput(boost::shared_ptr fitnessFunction, + const QSet& bestStates, const double bestScore, + const int numIterations) + { + QString output = + "Results for Conflicts Network Matcher Configuration Option Optimization with Simulated Annealing\n\n"; + + QString temp = "Number of test iterations: " + QString::number(numIterations); + LOG_ERROR(temp); + output += temp + "\n\n"; + + temp = "Number of tests in test suite: " + QString::number(fitnessFunction->getTestCount()); + LOG_ERROR(temp); + output += temp + "\n\n"; + + temp = + "Lowest number of test failures in test iteration: " + + QString::number((int)(fitnessFunction->getTestCount() * bestScore)); + LOG_ERROR(temp); + output += temp + "\n\n"; + + temp = "Number of best states found: " + QString::number(bestStates.size()); + LOG_ERROR(temp); + output += temp + "\n\n"; + if (bestScore == 0.0) { - LOG_ERROR("***YOU FOUND A SOLUTION! :-)***"); + temp = "***YOU FOUND A SOLUTION! :-)***"; } else { - LOG_ERROR("No solution was found. :-("); + temp = "No solution was found. :-("; } + LOG_ERROR(temp); + output += temp + "\n\n"; QDir().mkdir("test-output/algorithms"); const QString statesOutputPath = "test-output/algorithms/ConflictsNetworkMatcherSettingsOptimizer-states-out"; - LOG_ERROR("Writing best states to: " << statesOutputPath << "..."); - QString output = "\nBest states:\n"; - foreach (ConstStatePtr state, sa.getBestStates()) + LOG_ERROR("Writing best states and failing test groups to: " << statesOutputPath << "..."); + const QStringList failingTestsForBestRuns = fitnessFunction->getFailingTestsForBestRuns(); + output += + "Failing Test Groups For Best States (" + QString::number(failingTestsForBestRuns.size()) + + "):\n\n"; + if (failingTestsForBestRuns.size() == 0) { - output += state->toString() + "\n"; + output += "no failing test groups\n"; + } + else + { + for (int i = 0; i < failingTestsForBestRuns.size(); i++) + { + output += "#" + QString::number(i + 1) + ":\n\n"; + QString failingTestsStr = failingTestsForBestRuns.at(i); + if (failingTestsStr.contains(";")) + { + QStringList failingTests = failingTestsStr.split(";"); + for (int j = 0; j < failingTests.size(); j++) + { + output += failingTests.at(j) + "\n"; + } + } + else + { + output += failingTestsStr + "\n"; + } + output += "\n"; + } + } + output += "Best States (" + QString::number(bestStates.size()) + "):\n\n"; + int statesCtr = 1; + foreach (ConstStatePtr state, bestStates) + { + output += "#" + QString::number(statesCtr) + ":\n\n"; + output += state->toString() + "\n\n"; + statesCtr++; } FileUtils::writeFully(statesOutputPath, output); } + + void optimizeAgainstCaseDataTest() + { + boost::shared_ptr fitnessFunction(new CaseFitnessFunction()); + const int numIterations = 50; + double bestScore = -1.0; + const QSet bestStates = + runOptimization(initStateDescription(), fitnessFunction, bestScore, numIterations); + writeOutput(fitnessFunction, bestStates, bestScore, numIterations); + } }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConflictsNetworkMatcherSettingsOptimizer, "glacial"); diff --git a/tgs/src/main/cpp/tgs/Optimization/FitnessFunction.h b/tgs/src/main/cpp/tgs/Optimization/FitnessFunction.h index 5316dce28f..6cc1c731bb 100644 --- a/tgs/src/main/cpp/tgs/Optimization/FitnessFunction.h +++ b/tgs/src/main/cpp/tgs/Optimization/FitnessFunction.h @@ -40,7 +40,7 @@ class FitnessFunction * * While not required fitness functions that return values from [0, 1] may work better. */ - virtual double f(const ConstStatePtr& s) const = 0; + virtual double f(const ConstStatePtr& s) = 0; }; typedef boost::shared_ptr FitnessFunctionPtr; diff --git a/tgs/src/main/cpp/tgs/Optimization/SimulatedAnnealing.cpp b/tgs/src/main/cpp/tgs/Optimization/SimulatedAnnealing.cpp index 387b530c97..558ecc88b5 100644 --- a/tgs/src/main/cpp/tgs/Optimization/SimulatedAnnealing.cpp +++ b/tgs/src/main/cpp/tgs/Optimization/SimulatedAnnealing.cpp @@ -38,7 +38,7 @@ namespace Tgs using namespace std; SimulatedAnnealing::SimulatedAnnealing(ConstStateDescriptionPtr sd, - ConstFitnessFunctionPtr fitness) : _rand(0) + FitnessFunctionPtr fitness) : _rand(0) { _stateDescription = sd; _fitness = fitness; diff --git a/tgs/src/main/cpp/tgs/Optimization/SimulatedAnnealing.h b/tgs/src/main/cpp/tgs/Optimization/SimulatedAnnealing.h index 3be3ae7554..b5f11d81b0 100644 --- a/tgs/src/main/cpp/tgs/Optimization/SimulatedAnnealing.h +++ b/tgs/src/main/cpp/tgs/Optimization/SimulatedAnnealing.h @@ -42,7 +42,8 @@ namespace Tgs class SimulatedAnnealing { public: - SimulatedAnnealing(ConstStateDescriptionPtr sd, ConstFitnessFunctionPtr fitness); + + SimulatedAnnealing(ConstStateDescriptionPtr sd, FitnessFunctionPtr fitness); QSet getBestStates() const { return _bestStates; } @@ -53,12 +54,13 @@ class SimulatedAnnealing * best states found so far. */ void setPickFromBestScores(bool best) { _pickFromBestScores = best; } + private: mutable Random _rand; double _bestScore; QSet _bestStates; - ConstFitnessFunctionPtr _fitness; + FitnessFunctionPtr _fitness; bool _pickFromBestScores; ConstStateDescriptionPtr _stateDescription; diff --git a/tgs/src/test/cpp/tgs/Optimization/SimulatedAnnealingTest.cpp b/tgs/src/test/cpp/tgs/Optimization/SimulatedAnnealingTest.cpp index 8f6db8be8c..1ab542dd06 100644 --- a/tgs/src/test/cpp/tgs/Optimization/SimulatedAnnealingTest.cpp +++ b/tgs/src/test/cpp/tgs/Optimization/SimulatedAnnealingTest.cpp @@ -49,7 +49,7 @@ class SimulatedAnnealingTest : public CppUnit::TestFixture public: class TestFitnessFunction : public FitnessFunction { - virtual double f(const ConstStatePtr& s) const + virtual double f(const ConstStatePtr& s) { double w = s->get("w"); double x = s->get("x");