//============================================================================== // // Copyright (c) 2016- // Authors: // * Joachim Klein (TU Dresden) // //------------------------------------------------------------------------------ // // This file is part of PRISM. // // PRISM is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // PRISM is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with PRISM; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //============================================================================== #ifndef EXPORT_ITERATIONS_H #define EXPORT_ITERATIONS_H #include #include #include #include #include #include "dv.h" #include "prism.h" #include class ExportIterations { private: FILE *fp; std::string filename; public: /** * Constructor, provide filename. */ ExportIterations(const char* title = "", const char* filename = get_export_iterations_filename()) { fp = fopen(filename, "w"); this->filename = filename; fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "%s\n", title); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "\n"); fprintf(fp, "

%s

\n", title); fprintf(fp, "\n"); fprintf(fp, "\n"); } /** * Get the filename used for exporting. */ const std::string& getFileName() { return filename; } /** * Export the given vector, with size n and given type (0 = normal, VI from below, 1 = VI from above) */ void exportVector(double *soln, int n, int type) { fprintf(fp, "\n", type); fflush(fp); } /** * Export the given MTBDD vector, with num_rvars row variables, * odd for reachable state space and type (0= normal, VI from below, 1 = VI from above) */ void exportVector(DdNode *dd, DdNode **rvars, int num_rvars, ODDNode* odd, int type) { double* vec = mtbdd_to_double_vector(ddman, dd, rvars, num_rvars, odd); // get number of states int n = odd->eoff + odd->toff; exportVector(vec, n, type); delete[] vec; } /** Destructor, close file */ ~ExportIterations() { fprintf(fp, "\n"); fclose(fp); } }; #endif