void storeResults(const RendererType& renderer, std::size_t index) {
        FilePath baseName(toString3(index));

        FilePath pngDir = m_ResultPath + "png";
        FilePath exrDir = m_ResultPath + "exr";
        FilePath statsDir = m_ResultPath + "stats";

        storeFramebuffer(index, pngDir, exrDir, baseName, m_fGamma, renderer.getFramebuffer());

        createDirectory(statsDir);

        auto& stats = m_RenderStatistics[index];

        storeArray(statsDir + baseName.addExt(".nrmseFloat"), stats.nrmse);
        storeArray(statsDir + baseName.addExt(".rmseFloat"), stats.rmse);
        storeArray(statsDir + baseName.addExt(".absErrorFloat"), stats.mae);
        storeArray(statsDir + baseName.addExt(".processingTimes"), stats.renderTimes);

        auto reportsPath = m_ResultPath + "reports";
        createDirectory(reportsPath);

        auto reportDocumentPath = reportsPath + (toString3(index) + ".report.bnz.xml");
        tinyxml2::XMLDocument reportDocument;

        auto pReport = reportDocument.NewElement("Result");
        auto pRendererStats = reportDocument.NewElement("RendererStats");
        auto pRendererSettings = reportDocument.NewElement("Renderer");

        renderer.storeSettings(*pRendererSettings);
        renderer.storeStatistics(*pRendererStats);

        reportDocument.InsertEndChild(pReport);

        setAttribute(*pReport, "Index", index);
        setChildAttribute(*pReport, "Gamma", m_fGamma);

        setChildAttribute(*pReport, "RenderTime", stats.renderTimes.back());
        setChildAttribute(*pReport, "NRMSE", stats.nrmse.back());
        setChildAttribute(*pReport, "RMSE", stats.rmse.back());
        setChildAttribute(*pReport, "MAE", stats.mae.back());
        setChildAttribute(*pReport, "IterationCount", stats.getIterationCount());

        pReport->InsertEndChild(pRendererStats);

        pReport->InsertEndChild(pRendererSettings);

        reportDocument.SaveFile(reportDocumentPath.c_str());
    }
Esempio n. 2
0
/**
 * store_model() - store the given model into the given mxStruct structure
 */
void store_model(struct model *model, mxArray *mxOut[] )
{
  int i = 0;
  int numfields;
  int dims[] = { 1,1 };
  mxArray *mxStruct;
  
  const char *fields[] = { "sv_num", "upper_bound", "b", "totwords", 
			   "totdoc", "loo_error", "loo_recall", "loo_precision", 
			   "xa_error","xa_recall", "xa_precision", "maxdiff", 
			   "r_delta_sq", "r_delta_avg", "model_length", "loss", 
			   "vcdim", "alpha", "lin_weights", "index",
			   "supvec" , "kernel_parm","example_length","a" };
  
  numfields = 24;
  mxStruct = mxCreateStructMatrix(1,1, numfields, fields);
  
  storeValue(mxStruct, "sv_num", model->sv_num);
  storeValue(mxStruct, "upper_bound", model->at_upper_bound);
  storeValue(mxStruct, "b", model->b);
  storeValue(mxStruct, "totwords", model->totwords);
  storeValue(mxStruct, "totdoc", model->totdoc);
  storeValue(mxStruct, "loo_error", model->loo_error);
  storeValue(mxStruct, "loo_recall", model->loo_recall);
  storeValue(mxStruct, "loo_precision", model->loo_precision);
  storeValue(mxStruct, "xa_error", model->xa_error);
  storeValue(mxStruct, "xa_recall", model->xa_recall);
  storeValue(mxStruct, "xa_precision", model->xa_precision);
  storeValue(mxStruct, "maxdiff", model->maxdiff);
  storeValue(mxStruct, "r_delta_sq", model->r_delta_sq);
  storeValue(mxStruct, "r_delta_avg", model->r_delta_avg);
  storeValue(mxStruct, "model_length", model->model_length);
  storeValue(mxStruct, "example_length", model->example_length);
  storeValue(mxStruct, "loss", model->loss);
  storeValue(mxStruct, "vcdim", model->vcdim);
  
  storeArray(mxStruct, "alpha", model->alpha, model->totdoc);
  storeArray(mxStruct, "a", model->a, model->totdoc);

  if (model->lin_weights != NULL)
    storeArray(mxStruct, "lin_weights", model->lin_weights, model->totdoc+2);
  else {
  	if (verbosity > 0) 
	  	printf("Skipping lin_weights (array is empty)\n");
    }

  if (model->index != NULL)
    storeArrayLong(mxStruct, "index", model->index, (int) model->totdoc);
  else {
  	if (verbosity > 0)
  	 printf("Skipping model->index (array is empty)\n");
  }

  if (model->supvec != NULL)
     storeDocs(mxStruct,"supvec", model->supvec, model->sv_num, model->totwords);
  else {
  	if (verbosity > 0) printf("Skipping supvec (array is empty)\n");
  }
  
  store_kern_parms(mxStruct, "kernel_parm", &(model->kernel_parm));

  mxOut[0] = mxStruct;


}