#include "VISQErrorApproximator.h"
#include <fstream>
+#include <json.h>
using namespace mpqsolver::bisection;
{
// read file
std::ifstream file(visq_data_path);
- if (!init(file))
- {
- throw std::runtime_error("Invalid visq file " + visq_data_path);
- }
+ init(file);
}
-bool VISQErrorApproximator::init(std::istream &)
+void VISQErrorApproximator::init(std::istream &visq_data)
{
- // TODO
- return true;
+ Json::Reader reader;
+ Json::Value completeJsonData;
+ if (!reader.parse(visq_data, completeJsonData))
+ {
+ throw std::runtime_error("Invalid visq stream");
+ }
+
+ if (!completeJsonData.isMember("error"))
+ {
+ throw std::runtime_error("No 'error' section in visq stream");
+ }
+
+ auto layers = completeJsonData["error"][0];
+ auto names = layers.getMemberNames();
+ for (auto name : names)
+ {
+ auto value = layers[name].asFloat();
+ _layer_errors[name] = value;
+ }
}
float VISQErrorApproximator::approximate(const std::string &node_name) const