STORM_LOG_THROW(parsedStructure.at("restrict-initial").count("exp")==1,storm::exceptions::InvalidJaniException,"Model needs an expression inside the initial restricion");
initialValueRestriction=parseExpression(parsedStructure.at("restrict-initial").at("exp"),"Initial value restriction for automaton "+name);
initialValueRestriction=parseExpression(parsedStructure.at("restrict-initial").at("exp"),"Initial value restriction for automaton "+name,globalVars,constants);
pi.lowerBound=parseExpression(piStructure.at("lower"),"Lower bound for property interval");
pi.lowerBound=parseExpression(piStructure.at("lower"),"Lower bound for property interval",{},{});
// TODO substitute constants.
STORM_LOG_THROW(!pi.lowerBound.containsVariables(),storm::exceptions::NotSupportedException,"Only constant expressions are supported as lower bounds");
@ -177,7 +183,7 @@ namespace storm {
}
if(piStructure.count("upper")>0){
pi.upperBound=parseExpression(piStructure.at("upper"),"Upper bound for property interval");
pi.upperBound=parseExpression(piStructure.at("upper"),"Upper bound for property interval",{},{});
// TODO substitute constants.
STORM_LOG_THROW(!pi.upperBound.containsVariables(),storm::exceptions::NotSupportedException,"Only constant expressions are supported as upper bounds");
STORM_LOG_THROW(propertyStructure.count("exp")==1,storm::exceptions::InvalidJaniException,"Expecting reward-expression for operator "<<opString<<" in "<<context);
storm::expressions::ExpressionrewExpr=parseExpression(propertyStructure.at("exp"),"Reward expression in "+context);
storm::expressions::ExpressionrewExpr=parseExpression(propertyStructure.at("exp"),"Reward expression in "+context,{},{});
if(rewExpr.isVariable()){
time=false;
}else{
@ -257,7 +263,7 @@ namespace storm {
if(propertyStructure.count("step-instant")>0){
storm::expressions::ExpressionstepInstantExpr=parseExpression(propertyStructure.at("step-instant"),"Step instant in "+context);
storm::expressions::ExpressionstepInstantExpr=parseExpression(propertyStructure.at("step-instant"),"Step instant in "+context,{},{});
STORM_LOG_THROW(!stepInstantExpr.containsVariables(),storm::exceptions::NotSupportedException,"storm only allows constant step-instants");
STORM_LOG_THROW(constantStructure.count("name")==1,storm::exceptions::InvalidJaniException,"Variable (scope: "+scopeDescription+") must have a name");
std::stringname=getString(constantStructure.at("name"),"variable-name in "+scopeDescription+"-scope");
// TODO check existance of name.
@ -500,7 +506,7 @@ namespace storm {
STORM_LOG_THROW(valueCount<2,storm::exceptions::InvalidJaniException,"Value for constant '"+name+"' (scope: "+scopeDescription+") must be given at most once.");
if(valueCount==1){
// Read initial value before; that makes creation later on a bit easier, and has as an additional benefit that we do not need to check whether the variable occurs also on the assignment.
initExpr=parseExpression(constantStructure.at("value"),"Value of constant "+name+" (scope: "+scopeDescription+")");
initExpr=parseExpression(constantStructure.at("value"),"Value of constant "+name+" (scope: "+scopeDescription+")",{},constants);
assert(initExpr.isInitialized());
}
@ -557,7 +563,7 @@ namespace storm {
STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Unknown type description, "<<constantStructure.at("type").dump()<<" for Variable '"<<name<<"' (scope: "<<scopeDescription<<")");
initVal=parseExpression(variableStructure.at("initial-value"),"Initial value for variable "+name+" (scope: "+scopeDescription+") ");
initVal=parseExpression(variableStructure.at("initial-value"),"Initial value for variable "+name+" (scope: "+scopeDescription+") ",globalVars,constants,localVars);
STORM_LOG_THROW(initVal.get().hasRationalType(),storm::exceptions::InvalidJaniException,"Initial value for integer variable "+name+"(scope "+scopeDescription+") should be a rational");
initVal=parseExpression(variableStructure.at("initial-value"),"Initial value for variable "+name+" (scope: "+scopeDescription+") ");
initVal=parseExpression(variableStructure.at("initial-value"),"Initial value for variable "+name+" (scope: "+scopeDescription+") ",globalVars,constants,localVars);
STORM_LOG_THROW(initVal.get().hasBooleanType(),storm::exceptions::InvalidJaniException,"Initial value for integer variable "+name+"(scope "+scopeDescription+") should be a Boolean");
initVal=parseExpression(variableStructure.at("initial-value"),"Initial value for variable "+name+" (scope: "+scopeDescription+") ");
initVal=parseExpression(variableStructure.at("initial-value"),"Initial value for variable "+name+" (scope: "+scopeDescription+") ",globalVars,constants,localVars);
STORM_LOG_THROW(initVal.get().hasIntegerType(),storm::exceptions::InvalidJaniException,"Initial value for integer variable "+name+"(scope "+scopeDescription+") should be an integer");
// First do the bounds, that makes the code a bit more streamlined
STORM_LOG_THROW(variableStructure.at("type").count("lower-bound")==1,storm::exceptions::InvalidJaniException,"For bounded type as in variable "<<name<<"(scope: "<<scopeDescription<<") lower-bound must be given");
storm::expressions::ExpressionlowerboundExpr=parseExpression(variableStructure.at("type").at("lower-bound"),"Lower bound for variable "+name+" (scope: "+scopeDescription+")");
storm::expressions::ExpressionlowerboundExpr=parseExpression(variableStructure.at("type").at("lower-bound"),"Lower bound for variable "+name+" (scope: "+scopeDescription+")",globalVars,constants,localVars);
assert(lowerboundExpr.isInitialized());
STORM_LOG_THROW(variableStructure.at("type").count("upper-bound")==1,storm::exceptions::InvalidJaniException,"For bounded type as in variable "<<name<<"(scope: "<<scopeDescription<<") upper-bound must be given");
storm::expressions::ExpressionupperboundExpr=parseExpression(variableStructure.at("type").at("upper-bound"),"Upper bound for variable "+name+" (scope: "+scopeDescription+")");
storm::expressions::ExpressionupperboundExpr=parseExpression(variableStructure.at("type").at("upper-bound"),"Upper bound for variable "+name+" (scope: "+scopeDescription+")",globalVars,constants,localVars);
assert(upperboundExpr.isInitialized());
STORM_LOG_THROW(variableStructure.at("type").count("base")==1,storm::exceptions::InvalidJaniException,"For bounded type as in variable "<<name<<"(scope: "<<scopeDescription<<") base must be given");
// TODO as soon as we support half-open intervals, we have to change this.
}else{
initVal=parseExpression(variableStructure.at("initial-value"),"Initial value for variable "+name+" (scope: "+scopeDescription+") ");
initVal=parseExpression(variableStructure.at("initial-value"),"Initial value for variable "+name+" (scope: "+scopeDescription+") ",globalVars,constants,localVars);
}
}
std::stringbasictype=getString(variableStructure.at("type").at("base"),"base for bounded type as in variable "+name+"(scope: "+scopeDescription+") ");
@ -672,14 +678,14 @@ namespace storm {
STORM_LOG_THROW(expected==actual,storm::exceptions::InvalidJaniException,"Operator "<<opstring<<" expects "<<expected<<" arguments, but got "<<actual<<" in "<<errorInfo<<".");
storm::expressions::Expressionleft=parseExpression(expressionDecl.at("exp"),"Argument of operator "+opstring+" in "+scopeDescription,localVars,returnNoneInitializedOnUnknownOperator);
storm::expressions::Expressionleft=parseExpression(expressionDecl.at("exp"),"Argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator);
storm::expressions::Expressionleft=parseExpression(expressionDecl.at("left"),"Left argument of operator "+opstring+" in "+scopeDescription,localVars,returnNoneInitializedOnUnknownOperator);
storm::expressions::Expressionright=parseExpression(expressionDecl.at("right"),"Right argument of operator "+opstring+" in "+scopeDescription,localVars,returnNoneInitializedOnUnknownOperator);
storm::expressions::Expressionleft=parseExpression(expressionDecl.at("left"),"Left argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator);
storm::expressions::Expressionright=parseExpression(expressionDecl.at("right"),"Right argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator);
STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Distributions are not supported by storm expressions, cannot import "<<expressionStructure.dump()<<" in "<<scopeDescription<<".");
arguments.push_back(parseExpression(expressionStructure.at("if"),"if-formula in "+scopeDescription,localVars,returnNoneInitializedOnUnknownOperator));
arguments.push_back(parseExpression(expressionStructure.at("then"),"then-formula in "+scopeDescription,localVars,returnNoneInitializedOnUnknownOperator));
arguments.push_back(parseExpression(expressionStructure.at("else"),"else-formula in "+scopeDescription,localVars,returnNoneInitializedOnUnknownOperator));
arguments.push_back(parseExpression(expressionStructure.at("if"),"if-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator));
arguments.push_back(parseExpression(expressionStructure.at("then"),"then-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator));
arguments.push_back(parseExpression(expressionStructure.at("else"),"else-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator));
STORM_LOG_THROW(transientValueEntry.count("value")==1,storm::exceptions::InvalidJaniException,"Transient values in location "<<locName<<" need exactly one assigned value");
storm::jani::Variableconst&lhs=getLValue(transientValueEntry.at("ref"),parentModel.getGlobalVariables(),automaton.getVariables(),"LHS of assignment in location "+locName+" (automaton '"+name+"')");
STORM_LOG_THROW(lhs.isTransient(),storm::exceptions::InvalidJaniException,"Assigned non-transient variable "+lhs.getName()+" in location "+locName+" (automaton: '"+name+"')");
storm::expressions::Expressionrhs=parseExpression(transientValueEntry.at("value"),"Assignment of variable "+lhs.getName()+" in location "+locName+" (automaton: '"+name+"')");
storm::expressions::Expressionrhs=parseExpression(transientValueEntry.at("value"),"Assignment of variable "+lhs.getName()+" in location "+locName+" (automaton: '"+name+"')",globalVars,constants,localVars);
STORM_LOG_THROW(automatonStructure.at("restrict-initial").count("exp")==1,storm::exceptions::InvalidJaniException,"Automaton '"<<name<<"' needs an expression inside the initial restricion");
initialValueRestriction=parseExpression(automatonStructure.at("restrict-initial").at("exp"),"Initial value restriction for automaton "+name);
initialValueRestriction=parseExpression(automatonStructure.at("restrict-initial").at("exp"),"Initial value restriction for automaton "+name,globalVars,constants,localVars);
STORM_LOG_THROW(automatonStructure.count("edges")>0,storm::exceptions::InvalidJaniException,"Automaton '"<<name<<"' must have a list of edges");
@ -1034,7 +1047,7 @@ namespace storm {
storm::expressions::ExpressionrateExpr;
if(edgeEntry.count("rate")>0){
STORM_LOG_THROW(edgeEntry.at("rate").count("exp")==1,storm::exceptions::InvalidJaniException,"Rate in edge from '"<<sourceLoc<<"' in automaton '"<<name<<"' must have a defing expression.");
rateExpr=parseExpression(edgeEntry.at("rate").at("exp"),"rate expression in edge from '"+sourceLoc+"' in automaton '"+name+"'");
rateExpr=parseExpression(edgeEntry.at("rate").at("exp"),"rate expression in edge from '"+sourceLoc+"' in automaton '"+name+"'",globalVars,constants,localVars);
STORM_LOG_THROW(rateExpr.hasNumericalType(),storm::exceptions::InvalidJaniException,"Rate '"<<rateExpr<<"' has not a numerical type");
STORM_LOG_THROW(edgeEntry.at("guard").count("exp")==1,storm::exceptions::InvalidJaniException,"Guard in edge from '"+sourceLoc+"' in automaton '"+name+"' must have one expression");
guardExpr=parseExpression(edgeEntry.at("guard").at("exp"),"guard expression in edge from '"+sourceLoc+"' in automaton '"+name+"'",localVars);
guardExpr=parseExpression(edgeEntry.at("guard").at("exp"),"guard expression in edge from '"+sourceLoc+"' in automaton '"+name+"'",globalVars,constants,localVars);
STORM_LOG_THROW(guardExpr.hasBooleanType(),storm::exceptions::InvalidJaniException,"Guard "<<guardExpr<<" does not have Boolean type.");
}
assert(guardExpr.isInitialized());
@ -1064,7 +1077,7 @@ namespace storm {
probExpr=expressionManager->rational(1.0);
}else{
STORM_LOG_THROW(destEntry.at("probability").count("exp")==1,storm::exceptions::InvalidJaniException,"Destination in edge from '"<<sourceLoc<<"' to '"<<targetLoc<<"' in automaton '"<<name<<"' must have a probability expression.");
probExpr=parseExpression(destEntry.at("probability").at("exp"),"probability expression in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'",localVars);
probExpr=parseExpression(destEntry.at("probability").at("exp"),"probability expression in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'",globalVars,constants,localVars);
}
assert(probExpr.isInitialized());
STORM_LOG_THROW(probExpr.hasNumericalType(),storm::exceptions::InvalidJaniException,"Probability expression "<<probExpr<<" does not have a numerical type.");
@ -1080,7 +1093,7 @@ namespace storm {
storm::jani::Variableconst&lhs=getLValue(refstring,parentModel.getGlobalVariables(),automaton.getVariables(),"Assignment variable in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'");
// value
STORM_LOG_THROW(assignmentEntry.count("value")==1,storm::exceptions::InvalidJaniException,"Assignment in edge from '"<<sourceLoc<<"' to '"<<targetLoc<<"' in automaton '"<<name<<"' must have one value field");
storm::expressions::ExpressionassignmentExpr=parseExpression(assignmentEntry.at("value"),"assignment in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'",localVars);
storm::expressions::ExpressionassignmentExpr=parseExpression(assignmentEntry.at("value"),"assignment in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'",globalVars,constants,localVars);