4 changed files with 59 additions and 43 deletions
			
			
		@ -0,0 +1,14 @@ | 
				
			|||
#include "result.h"
 | 
				
			|||
 | 
				
			|||
// Define python bindings
 | 
				
			|||
void define_result(py::module& m) { | 
				
			|||
 | 
				
			|||
    // PmcResult
 | 
				
			|||
    py::class_<PmcResult, std::shared_ptr<PmcResult>>(m, "PmcResult", "Holds the results after parametric model checking") | 
				
			|||
        .def("__str__", &PmcResult::toString) | 
				
			|||
        .def_property_readonly("result_function", &PmcResult::getResultFunction, "Result as rational function") | 
				
			|||
        .def_property_readonly("constraints_well_formed", &PmcResult::getConstraintsWellFormed, "Constraints ensuring well-formed probabilities") | 
				
			|||
        .def_property_readonly("constraints_graph_preserving", &PmcResult::getConstraintsGraphPreserving, "Constraints ensuring graph preservation") | 
				
			|||
    ; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,42 @@ | 
				
			|||
#ifndef PYTHON_CORE_RESULT_H_ | 
				
			|||
#define PYTHON_CORE_RESULT_H_ | 
				
			|||
 | 
				
			|||
#include "common.h" | 
				
			|||
 | 
				
			|||
// Class holding the parametric model checking result | 
				
			|||
class PmcResult { | 
				
			|||
    public: | 
				
			|||
        storm::RationalFunction resultFunction; | 
				
			|||
        std::unordered_set<storm::ArithConstraint<storm::RationalFunction>> constraintsWellFormed; | 
				
			|||
        std::unordered_set<storm::ArithConstraint<storm::RationalFunction>> constraintsGraphPreserving; | 
				
			|||
 | 
				
			|||
        storm::RationalFunction getResultFunction() const { | 
				
			|||
            return resultFunction; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        std::unordered_set<storm::ArithConstraint<storm::RationalFunction>> getConstraintsWellFormed() const { | 
				
			|||
            return constraintsWellFormed; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        std::unordered_set<storm::ArithConstraint<storm::RationalFunction>> getConstraintsGraphPreserving() const { | 
				
			|||
            return constraintsGraphPreserving; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        std::string toString() { | 
				
			|||
            std::stringstream stream; | 
				
			|||
            stream << resultFunction << std::endl; | 
				
			|||
            stream << "Well formed constraints:" << std::endl; | 
				
			|||
            for (auto constraint : constraintsWellFormed) { | 
				
			|||
                stream << constraint << std::endl; | 
				
			|||
            } | 
				
			|||
            stream << "Graph preserving constraints:" << std::endl; | 
				
			|||
            for (auto constraint : constraintsGraphPreserving) { | 
				
			|||
                stream << constraint << std::endl; | 
				
			|||
            } | 
				
			|||
            return stream.str(); | 
				
			|||
        } | 
				
			|||
}; | 
				
			|||
 | 
				
			|||
void define_result(py::module& m); | 
				
			|||
 | 
				
			|||
#endif /* PYTHON_CORE_RESULT_H_ */ | 
				
			|||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue