Browse Source
Refactoring of extraction of info from P/R/S operators (in explicit engine).
Refactoring of extraction of info from P/R/S operators (in explicit engine).
git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@9458 bbc10eb1-c90d-0410-af57-cb519fbb1720master
5 changed files with 147 additions and 83 deletions
-
97prism/src/explicit/ProbModelChecker.java
-
20prism/src/parser/ast/ExpressionProb.java
-
20prism/src/parser/ast/ExpressionReward.java
-
24prism/src/parser/ast/ExpressionSS.java
-
69prism/src/prism/OpRelOpBound.java
@ -0,0 +1,69 @@ |
|||
package prism; |
|||
|
|||
import parser.ast.RelOp; |
|||
import explicit.MinMax; |
|||
|
|||
/** |
|||
* Class to represent info (operator, relational operator, bound, etc.) found in a P/R/S operator. |
|||
*/ |
|||
public class OpRelOpBound |
|||
{ |
|||
protected String op; |
|||
protected RelOp relOp; |
|||
protected boolean numeric; |
|||
protected double bound; |
|||
|
|||
public OpRelOpBound(String op, RelOp relOp, Double boundObject) |
|||
{ |
|||
this.op = op; |
|||
this.relOp = relOp; |
|||
numeric = (boundObject == null); |
|||
if (boundObject != null) |
|||
bound = boundObject.doubleValue(); |
|||
} |
|||
|
|||
public RelOp getRelOp() |
|||
{ |
|||
return relOp; |
|||
} |
|||
|
|||
public boolean isNumeric() |
|||
{ |
|||
return numeric; |
|||
} |
|||
|
|||
public double getBound() |
|||
{ |
|||
return bound; |
|||
} |
|||
|
|||
public MinMax getMinMax(ModelType modelType) throws PrismException |
|||
{ |
|||
MinMax minMax = MinMax.blank(); |
|||
if (modelType.nondeterministic()) { |
|||
if (relOp == RelOp.EQ && isNumeric()) { |
|||
throw new PrismException("Can't use \""+op+"=?\" for nondeterministic models; use e.g. \""+op+"min=?\" or \""+op+"max=?\""); |
|||
} |
|||
if (modelType == ModelType.MDP || modelType == ModelType.CTMDP) { |
|||
minMax = (relOp.isLowerBound() || relOp.isMin()) ? MinMax.min() : MinMax.max(); |
|||
} else { |
|||
throw new PrismException("Don't know how to model check " + getTypeOfOperator() + " properties for " + modelType + "s"); |
|||
} |
|||
} |
|||
return minMax; |
|||
} |
|||
|
|||
public String getTypeOfOperator() |
|||
{ |
|||
String s = ""; |
|||
s += op + relOp; |
|||
s += isNumeric() ? "?" : "p"; // TODO: always "p"? |
|||
return s; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() |
|||
{ |
|||
return relOp.toString() + bound; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue