internal override Probability CalculateMinimalProbability(Formula formulaToCheck) { var isFormulaReturningBoolVisitor = new IsFormulaReturningBoolValueVisitor(); isFormulaReturningBoolVisitor.Visit(formulaToCheck); if (!isFormulaReturningBoolVisitor.IsFormulaReturningBoolValue) { throw new Exception("expected formula which returns a bool"); } var transformationVisitor = new PrismTransformer(); transformationVisitor.Visit(formulaToCheck); var formulaToCheckInnerString = transformationVisitor.TransformedFormula; var formulaToCheckString = "Pmin=? [ " + formulaToCheckInnerString + "]"; using (var fileProperties = new TemporaryFile("props")) { File.WriteAllText(fileProperties.FilePath, formulaToCheckString); var prismArguments = _filePrism.FilePath + " " + fileProperties.FilePath; var prismProcess = new PrismProcess(_output); var quantitativeResult = prismProcess.ExecutePrismAndParseResult(prismArguments); return(new Probability(quantitativeResult.ResultingProbability)); } }
/************************************************/ /* PRISM EXECUTION */ /************************************************/ internal override Probability CalculateProbability(Formula formulaToCheck) { ProbabilityChecker.AssertProbabilityMatrixWasCreated(); WriteMarkovChainToDisk(); var isFormulaReturningProbabilityVisitor = new IsFormulaReturningProbabilityVisitor(); isFormulaReturningProbabilityVisitor.Visit(formulaToCheck); if (!isFormulaReturningProbabilityVisitor.IsReturningProbability) { throw new Exception("expected formula which returns a probability"); } var transformationVisitor = new PrismTransformer(); transformationVisitor.Visit(formulaToCheck); var formulaToCheckString = transformationVisitor.TransformedFormula; using (var fileProperties = new TemporaryFile("props")) { File.WriteAllText(fileProperties.FilePath, formulaToCheckString); var prismArguments = _filePrism.FilePath + " " + fileProperties.FilePath; var prism = ExecutePrism(prismArguments); _prismProcessOutput.Clear(); prism.Run(); var result = ParseOutput(_prismProcessOutput); var quantitativeResult = (PrismResultQuantitative)result.Result; return(new Probability(quantitativeResult.Result)); } }