Browse Source

Export of weight vector in the cdf

tempestpy_adaptions
TimQu 7 years ago
parent
commit
9901995280
  1. 2
      src/storm/modelchecker/multiobjective/pcaa/SparseMdpRewardBoundedPcaaWeightVectorChecker.cpp
  2. 8
      src/storm/modelchecker/multiobjective/pcaa/SparsePcaaQuery.cpp
  3. 20
      src/storm/utility/export.h

2
src/storm/modelchecker/multiobjective/pcaa/SparseMdpRewardBoundedPcaaWeightVectorChecker.cpp

@ -70,7 +70,7 @@ namespace storm {
for (uint64_t i = 0; i < this->objectives.size(); ++i) {
headers.push_back("obj" + std::to_string(i));
}
storm::utility::exportDataToCSVFile("cdf" + std::to_string(numChecks) + ".csv", cdfData, headers);
storm::utility::exportDataToCSVFile<ValueType, ValueType, std::string>("cdf" + std::to_string(numChecks) + ".csv", cdfData, weightVector, headers);
}
auto solution = rewardUnfolding.getInitialStateResult(initEpoch);
// Todo: we currently assume precise results...

8
src/storm/modelchecker/multiobjective/pcaa/SparsePcaaQuery.cpp

@ -228,7 +228,7 @@ namespace storm {
for(auto const& v : underApproxVertices) {
pointsForPlotting.push_back(storm::utility::vector::convertNumericVector<double>(v));
}
storm::utility::exportDataToCSVFile(destinationDir + "underapproximation.csv", pointsForPlotting, columnHeaders);
storm::utility::exportDataToCSVFile<double, std::string>(destinationDir + "underapproximation.csv", pointsForPlotting, columnHeaders);
pointsForPlotting.clear();
overApproxVertices = transformedOverApprox->intersection(boundariesAsPolytope)->getVerticesInClockwiseOrder();
@ -236,14 +236,14 @@ namespace storm {
for(auto const& v : overApproxVertices) {
pointsForPlotting.push_back(storm::utility::vector::convertNumericVector<double>(v));
}
storm::utility::exportDataToCSVFile(destinationDir + "overapproximation.csv", pointsForPlotting, columnHeaders);
storm::utility::exportDataToCSVFile<double, std::string>(destinationDir + "overapproximation.csv", pointsForPlotting, columnHeaders);
pointsForPlotting.clear();
pointsForPlotting.reserve(paretoPoints.size());
for(auto const& v : paretoPoints) {
pointsForPlotting.push_back(storm::utility::vector::convertNumericVector<double>(v));
}
storm::utility::exportDataToCSVFile(destinationDir + "paretopoints.csv", pointsForPlotting, columnHeaders);
storm::utility::exportDataToCSVFile<double, std::string>(destinationDir + "paretopoints.csv", pointsForPlotting, columnHeaders);
pointsForPlotting.clear();
auto boundVertices = boundariesAsPolytope->getVerticesInClockwiseOrder();
@ -251,7 +251,7 @@ namespace storm {
for(auto const& v : boundVertices) {
pointsForPlotting.push_back(storm::utility::vector::convertNumericVector<double>(v));
}
storm::utility::exportDataToCSVFile(destinationDir + "boundaries.csv", pointsForPlotting, columnHeaders);
storm::utility::exportDataToCSVFile<double, std::string>(destinationDir + "boundaries.csv", pointsForPlotting, columnHeaders);
}
#ifdef STORM_HAVE_CARL

20
src/storm/utility/export.h

@ -14,14 +14,24 @@ namespace storm {
template <typename ValueType>
inline void exportDataToCSVFile(std::string filepath, std::vector<std::vector<ValueType>> const& data, boost::optional<std::vector<std::string>> const& columnHeaders) {
template <typename DataType, typename Header1Type = DataType, typename Header2Type = DataType>
inline void exportDataToCSVFile(std::string filepath, std::vector<std::vector<DataType>> const& data, boost::optional<std::vector<Header1Type>> const& header1 = boost::none, boost::optional<std::vector<Header2Type>> const& header2 = boost::none) {
std::ofstream filestream;
storm::utility::openFile(filepath, filestream);
if(columnHeaders) {
for(auto columnIt = columnHeaders->begin(); columnIt != columnHeaders->end(); ++columnIt) {
if(columnIt != columnHeaders->begin()) {
if (header1) {
for(auto columnIt = header1->begin(); columnIt != header1->end(); ++columnIt) {
if(columnIt != header1->begin()) {
filestream << ",";
}
filestream << *columnIt;
}
filestream << std::endl;
}
if (header2) {
for(auto columnIt = header2->begin(); columnIt != header2->end(); ++columnIt) {
if(columnIt != header2->begin()) {
filestream << ",";
}
filestream << *columnIt;

Loading…
Cancel
Save