Skip to content

Commit

Permalink
Merge branch 'develop' into release_1_1_0
Browse files Browse the repository at this point in the history
  • Loading branch information
teubert committed Jun 18, 2018
2 parents b407cde + 33219fc commit 9df9a30
Show file tree
Hide file tree
Showing 41 changed files with 1,262 additions and 899 deletions.
24 changes: 21 additions & 3 deletions CMakeLists.txt
Expand Up @@ -70,9 +70,9 @@ elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion -Wswitch-default -Wno-unknown-pragmas")

if(Coverage)
# If coverage option enabled, set compiler and linker flags to gather coverage data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "-lgcov")
# If coverage option enabled, set compiler and linker flags to gather coverage data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "-lgcov")
endif()

set(CMAKE_CXX_FLAGS_DEBUG "-g -Og -Winline")
Expand All @@ -99,6 +99,24 @@ else()
message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} is not recognized.")
endif()

# Check command line to see if OpenMP is to be used.
option(UseOpenMP "UseOpenMP" FALSE)

# Build with OpenMP if desired, and package can be found.
if (UseOpenMP)
message(STATUS "Attempting to find OpenMP package...")
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D USING_OPENMP")
message(STATUS "Added OpenMP to buildsystem")
else()
message(FATAL_ERROR "Command line asked for OpenMP, but package couldn't be found!")
endif()
endif()

#Libraries
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/support/)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/framework/)
Expand Down
19 changes: 12 additions & 7 deletions Test/BenchmarkPrognoser/BenchmarkPrognoser.cpp
Expand Up @@ -17,18 +17,17 @@
* All Rights Reserved.
*/

#include <stdio.h>
#include <iostream>

#include "BenchmarkTimer.h"
#include "BenchmarkPrognoser.h"
#include "BenchmarkTimer.h"
#include "GSAPConfigMap.h"

namespace PCOE {
// Configuration Keys

BenchmarkPrognoser::BenchmarkPrognoser(GSAPConfigMap & configMap) : ModelBasedPrognoser(configMap) {

}
BenchmarkPrognoser::BenchmarkPrognoser(GSAPConfigMap& configMap)
: ModelBasedPrognoser(configMap) {}

void BenchmarkPrognoser::step() {
benchmark1.start();
Expand All @@ -38,6 +37,12 @@ namespace PCOE {

// destructor
BenchmarkPrognoser::~BenchmarkPrognoser() {
printf("Runtime: [%lld, %lld, %lld] ns\n", benchmark1.getMinStepTime()/nanoseconds(1), benchmark1.getAveStepTime()/nanoseconds(1), benchmark1.getMaxStepTime()/nanoseconds(1));
std::cout << "Runtime: [";
std::cout << benchmark1.getMinStepTime().count();
std::cout << ", ";
std::cout << benchmark1.getAveStepTime().count();
std::cout << ", ";
std::cout << benchmark1.getMaxStepTime().count();
std::cout << "] ns" << std::endl;
}
} // namespace PCOE
} // namespace PCOE
30 changes: 0 additions & 30 deletions Test/BenchmarkPrognoser/main.cpp
Expand Up @@ -11,18 +11,7 @@
#include "PrognoserFactory.h"
#include "BenchmarkPrognoser.h"

#include "CommunicatorFactory.h"
#include "RandomCommunicator.h"
#include "RecorderCommunicator.h"
#include "PlaybackCommunicator.h"
#include "ConfigMap.h"
#include "ModelFactory.h"
#include "PrognosticsModelFactory.h"
#include "ObserverFactory.h"
#include "PredictorFactory.h"
#include "UnscentedKalmanFilter.h"
#include "MonteCarloPredictor.h"
#include "Battery.h"
#include <ctime>
#include <fstream>
#include <iostream>
Expand All @@ -37,25 +26,6 @@ int main() {
PrognoserFactory & prognoserFactory = PrognoserFactory::instance();
prognoserFactory.Register("BenchmarkPrognoser", PrognoserFactory::Create<BenchmarkPrognoser>);

// Specify Communicators
CommunicatorFactory & commFactory = CommunicatorFactory::instance();
commFactory.Register("recorder", CommunicatorFactory::Create<RecorderCommunicator>);
commFactory.Register("playback", CommunicatorFactory::Create<PlaybackCommunicator>);

// Register battery model
ModelFactory & pModelFactory = ModelFactory::instance();
PrognosticsModelFactory & pProgModelFactory = PrognosticsModelFactory::instance();
pModelFactory.Register("Battery", ModelFactory::Create<Battery>);
pProgModelFactory.Register("Battery", PrognosticsModelFactory::Create<Battery>);

// Register UKF
ObserverFactory & pObserverFactory = ObserverFactory::instance();
pObserverFactory.Register("UKF", ObserverFactory::Create<UnscentedKalmanFilter>);

// Register MonteCarloPredictor
PredictorFactory & pPredictorFactory = PredictorFactory::instance();
pPredictorFactory.Register("MC", PredictorFactory::Create<MonteCarloPredictor>);

ProgManager PM = ProgManager("bench.cfg");

printf("Benchmarking\n");
Expand Down
6 changes: 3 additions & 3 deletions Test/supportTests/ConfigMapTests.cpp
Expand Up @@ -69,17 +69,17 @@ void configMapLoadNonexistent()
theMap = ConfigMap("Nonexistent.cfg"); // File doesn't exist
Assert::Fail("Found file that should not exist.");
}
catch (std::ios_base::failure &e) {}
catch (std::ios_base::failure) {}
}

void configMapAddBadSearchPath()
{
ConfigMap theMap;
try {
theMap.addSearchPath("../badPath");
Assert::Fail("Added bad search path");
Assert::Fail("ConfigMap added invalid search path.");
}
catch (std::domain_error &e) {}
catch (std::domain_error) {}
}

void configMapTrim()
Expand Down
19 changes: 13 additions & 6 deletions Test/supportTests/MatrixTests.cpp
Expand Up @@ -378,7 +378,10 @@ namespace TestMatrix {
m2.col(n + 1);
Assert::Fail("Got column that doesn't exist.");
}
catch (std::out_of_range &e) {}
catch (std::out_of_range) {}
catch (...) {
Assert::Fail("Unknown exception thrown with col.");
}
}

void col_setmatrix() {
Expand Down Expand Up @@ -523,7 +526,7 @@ namespace TestMatrix {
m3.row(m + 1, r1);
Assert::Fail("Set row that doesn't exist.");
}
catch (std::out_of_range &e) {
catch (std::out_of_range) {
}
try {
m3.row(0, r2);
Expand Down Expand Up @@ -1172,8 +1175,7 @@ namespace TestMatrix {
matrix.weightedMean(w3);
Assert::Fail("Calculated weighted mean with wrong number of weights");
}
catch (std::domain_error &e) {
}
catch (std::domain_error) {}
}

void weightedcovariance() {
Expand All @@ -1200,8 +1202,13 @@ namespace TestMatrix {
Matrix m1(3, 2, {1, 2, 3, 4, 5, 6});

Matrix m2;
std::cout << m1 << std::endl;
std::cout << m2 << std::endl;
try {
std::cout << m1 << std::endl;
std::cout << m2 << std::endl;
}
catch (...) {
Assert::Fail("Exception occurred in left bitwise shift.");
}
}


Expand Down
12 changes: 6 additions & 6 deletions Test/supportTests/ParticleFilterTests.cpp
Expand Up @@ -32,7 +32,7 @@ void ctor() {
ParticleFilter pf = ParticleFilter(&test, N, processNoise, sensorNoise);
Assert::Fail("Constructor did not catch empty processNoise/sensorNoise vectors");
}
catch (std::range_error &e) {}
catch (std::range_error) {}
}

void ctorWithNonemptyVectors() {
Expand Down Expand Up @@ -69,7 +69,7 @@ void ctorWithNonemptyVectors() {
ParticleFilter pf2 = ParticleFilter(&test, N, processNoise, emptySensorNoise);
Assert::Fail("Constructor did not catch empty sensorNoise vector");
}
catch (std::range_error &e) {}
catch (std::range_error) {}
}

void GSAPConfigMapCtor() {
Expand Down Expand Up @@ -123,7 +123,7 @@ void PFinitialize() {
pf2.initialize(t0, x, u);
Assert::Fail("initialize() didn't catch null model.");
}
catch (ConfigurationError &e) {}
catch (std::runtime_error) {}
}

void step() {
Expand Down Expand Up @@ -166,7 +166,7 @@ void step() {
pf.step(t1, u, z);
Assert::Fail("step() did not catch uninitialized ParticleFilter.");
}
catch (std::domain_error &e) {}
catch (std::domain_error) {}

pf.initialize(t0, x, u);

Expand All @@ -175,7 +175,7 @@ void step() {
pf.step(t0, u, z);
Assert::Fail("step() did not catch unchanged time.");
}
catch (std::domain_error &e) {}
catch (std::domain_error) {}

pf.setMinNEffective(2000);
Assert::AreEqual(2000, pf.getMinNEffective());
Expand Down Expand Up @@ -206,4 +206,4 @@ void getStateEstimate() {
ParticleFilter pf = ParticleFilter(&test, N, processNoise, sensorNoise);
std::vector<UData> stateEstimate = pf.getStateEstimate();
Assert::AreEqual(3, stateEstimate.size());
}
}
6 changes: 1 addition & 5 deletions Test/supportTests/PredictorTests.cpp
Expand Up @@ -50,8 +50,6 @@ void testMonteCarloBatteryPredict() {
GSAPConfigMap configMap;
configMap.set("Predictor.numSamples", "10");
configMap.set("Predictor.horizon", "5000");
configMap.set("Model.event", "EOD");
configMap.set("Model.predictedOutputs", "SOC");
std::vector<std::string> processNoise;
for (unsigned int i = 0; i < 8; i++) {
processNoise.push_back("1e-5");
Expand Down Expand Up @@ -103,9 +101,9 @@ void testMonteCarloBatteryPredict() {

// Create progdata
ProgData data;
data.setUncertainty(UType::Samples);
data.addEvent("EOD");
data.addSystemTrajectory("SOC");
data.setUncertainty(UType::Samples);
data.sysTrajectories.setNSamples(
10); // numSamples @todo(MD): Is this right? No basic setup function?
data.setPredictions(1, 5000); // interval, number of predictions
Expand Down Expand Up @@ -135,8 +133,6 @@ void testMonteCarloBatteryConfig() {
GSAPConfigMap configMap;
configMap.set("Predictor.numSamples", "100");
configMap.set("Predictor.horizon", "5000");
configMap.set("Model.event", "EOD");
configMap.set("Model.predictedOutputs", "SOC");
std::vector<std::string> processNoise;
for (unsigned int i = 0; i < 8; i++) {
processNoise.push_back("1e-5");
Expand Down

0 comments on commit 9df9a30

Please sign in to comment.