45 boost::any tmp(std::move(input));
46 ExportJsonType res = std::move(*boost::any_cast<ExportJsonType>(&tmp));
52 std::unordered_set<std::string>
const& auxiliaryVariables = {}) {
70 std::vector<ExportJsonType> elements;
71 elements.push_back(autDecl);
72 compDecl[
"elements"] = elements;
79 std::vector<ExportJsonType> elems;
82 if (subcomp->isAutomatonComposition()) {
83 elemDecl[
"automaton"] = std::static_pointer_cast<AutomatonComposition>(subcomp)->getAutomatonName();
85 STORM_LOG_THROW(allowRecursion, storm::exceptions::InvalidJaniException,
"Nesting composition " << *subcomp <<
" is not supported by JANI.");
86 elemDecl =
anyToJson(subcomp->accept(*
this, data));
88 elems.push_back(elemDecl);
90 compDecl[
"elements"] = elems;
91 std::vector<ExportJsonType> synElems;
94 syncDecl[
"synchronise"] = std::vector<std::string>();
95 for (
auto const& syncIn : syncs.getInput()) {
97 syncDecl[
"synchronise"].push_back(
nullptr);
99 syncDecl[
"synchronise"].push_back(syncIn);
102 syncDecl[
"result"] = syncs.getOutput();
103 synElems.push_back(syncDecl);
105 if (!synElems.empty()) {
106 compDecl[
"syncs"] = synElems;
127 STORM_LOG_THROW(
false, storm::exceptions::IllegalArgumentException,
"Unknown ComparisonType.");
130ExportJsonType FormulaToJaniJson::constructPropertyInterval(boost::optional<storm::expressions::Expression>
const& lower,
131 boost::optional<bool>
const& lowerExclusive,
132 boost::optional<storm::expressions::Expression>
const& upper,
133 boost::optional<bool>
const& upperExclusive)
const {
134 STORM_LOG_THROW((lower.is_initialized() || upper.is_initialized()), storm::exceptions::InvalidJaniException,
135 "PropertyInterval needs either a lower or an upper bound, but none was given.");
136 STORM_LOG_THROW((lower.is_initialized() || !lowerExclusive.is_initialized()), storm::exceptions::InvalidJaniException,
137 "PropertyInterval defines wether the lower bound is exclusive but no lower bound is given.");
138 STORM_LOG_THROW((upper.is_initialized() || !upperExclusive.is_initialized()), storm::exceptions::InvalidJaniException,
139 "PropertyInterval defines wether the upper bound is exclusive but no upper bound is given.");
144 if (lowerExclusive) {
145 iDecl[
"lower-exclusive"] = *lowerExclusive;
149 iDecl[
"upper"] =
buildExpression(*upper, model.getConstants(), model.getGlobalVariables());
150 if (upperExclusive) {
151 iDecl[
"upper-exclusive"] = *upperExclusive;
157ExportJsonType FormulaToJaniJson::constructRewardAccumulation(storm::logic::RewardAccumulation
const& rewardAccumulation,
158 std::string
const& rewardModelName)
const {
159 storm::jani::RewardModelInformation info(model, rewardModelName);
161 bool steps = rewardAccumulation.
isStepsSet() && (info.hasActionRewards() || info.hasTransitionRewards());
162 bool time = rewardAccumulation.
isTimeSet() && !model.isDiscreteTimeModel() && info.hasStateRewards();
163 bool exit = rewardAccumulation.
isExitSet() && info.hasStateRewards();
165 return constructRewardAccumulation(storm::logic::RewardAccumulation(steps, time, exit));
168ExportJsonType FormulaToJaniJson::constructRewardAccumulation(storm::logic::RewardAccumulation
const& rewardAccumulation)
const {
169 std::vector<std::string> res;
171 res.push_back(
"steps");
174 res.push_back(
"time");
177 stateExitRewards =
true;
178 res.push_back(
"exit");
183ExportJsonType FormulaToJaniJson::constructStandardRewardAccumulation(std::string
const& rewardModelName)
const {
184 if (model.isDiscreteTimeModel()) {
185 return constructRewardAccumulation(storm::logic::RewardAccumulation(
true,
false,
true), rewardModelName);
187 return constructRewardAccumulation(storm::logic::RewardAccumulation(
true,
true,
false), rewardModelName);
192 FormulaToJaniJson translator(model);
204 return stateExitRewards;
208 return multiObjectiveProperties;
222 opDecl[
"op"] = op == storm::logic::BinaryBooleanStateFormula::OperatorType::And ?
"∧" :
"∨";
230 opDecl[
"op"] = op == storm::logic::BinaryBooleanPathFormula::OperatorType::And ?
"∧" :
"∨";
241 "Jani export of multi-dimensional bounded until formulas is not supported.");
247 bool hasStepBounds(
false), hasTimeBounds(
false);
248 std::vector<ExportJsonType> rewardBounds;
251 boost::optional<storm::expressions::Expression> lower, upper;
252 boost::optional<bool> lowerExclusive, upperExclusive;
261 ExportJsonType propertyInterval = constructPropertyInterval(lower, lowerExclusive, upper, upperExclusive);
264 if (tbr.isStepBound() || (model.isDiscreteTimeModel() && tbr.isTimeBound())) {
265 STORM_LOG_THROW(!hasStepBounds, storm::exceptions::NotSupportedException,
266 "Jani export of until formulas with multiple step bounds is not supported.");
267 hasStepBounds =
true;
268 opDecl[
"step-bounds"] = propertyInterval;
269 }
else if (tbr.isRewardBound()) {
271 rewbound[
"exp"] =
buildExpression(model.getRewardModelExpression(tbr.getRewardName()), model.getConstants(), model.getGlobalVariables());
272 if (tbr.hasRewardAccumulation()) {
273 rewbound[
"accumulate"] = constructRewardAccumulation(tbr.getRewardAccumulation(), tbr.getRewardName());
275 rewbound[
"accumulate"] = constructStandardRewardAccumulation(tbr.getRewardName());
277 rewbound[
"bounds"] = propertyInterval;
278 rewardBounds.push_back(std::move(rewbound));
280 STORM_LOG_THROW(!hasTimeBounds, storm::exceptions::NotSupportedException,
281 "Jani export of until formulas with multiple time bounds is not supported.");
282 hasTimeBounds =
true;
283 opDecl[
"time-bounds"] = propertyInterval;
286 if (!rewardBounds.empty()) {
293 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Jani currently does not support conditional formulae.");
297 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Storm currently does not support translating cumulative reward formulae.");
316 auto rewAccJson = constructRewardAccumulation(rewAcc);
322 opDecl[
"left"][
"op"] = f.
getOptimalityType() == storm::solver::OptimizationDirection::Minimize ?
"Emin" :
"Emax";
326 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Unsupported subformula for time operator formula " << f <<
".");
329 opDecl[
"left"][
"op"] =
335 opDecl[
"left"][
"accumulate"] = rewAccJson;
336 opDecl[
"right"] =
buildExpression(bound.threshold, model.getConstants(), model.getGlobalVariables());
339 opDecl[
"op"] = f.
getOptimalityType() == storm::solver::OptimizationDirection::Minimize ?
"Emin" :
"Emax";
343 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Unsupported subformula for time operator formula " << f <<
".");
347 opDecl[
"op"] =
"Emin";
351 opDecl[
"accumulate"] = rewAccJson;
364 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Conversion of game formulas to Jani is not supported.");
368 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Jani currently does not support conversion of an instanteneous reward formula.");
377 opDecl[
"left"][
"op"] = f.
getOptimalityType() == storm::solver::OptimizationDirection::Minimize ?
"Smin" :
"Smax";
380 opDecl[
"left"][
"op"] =
385 opDecl[
"right"] =
buildExpression(bound.threshold, model.getConstants(), model.getGlobalVariables());
388 opDecl[
"op"] = f.
getOptimalityType() == storm::solver::OptimizationDirection::Minimize ?
"Smin" :
"Smax";
393 opDecl[
"op"] =
"Smin";
427 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Jani currently does not support conversion of an LRA reward formula.");
431 multiObjectiveProperties =
true;
433 opDecl[
"op"] =
"Multi";
435 opDecl[
"type"] = f.
isTradeoff() ?
"tradeoff" :
"lexicographic";
436 opDecl[
"properties"] = ExportJsonType::array();
438 auto p = ExportJsonType::object();
439 auto subFormulaCopy = subformula->clone();
440 if (subFormulaCopy->isOperatorFormula()) {
441 auto& operatorFormula = subFormulaCopy->asOperatorFormula();
442 if (operatorFormula.hasBound()) {
443 if (!operatorFormula.hasOptimalityType()) {
446 ? storm::solver::OptimizationDirection::Maximize
447 : storm::solver::OptimizationDirection::Minimize;
448 operatorFormula.setOptimalityType(derivedOptimalityType);
452 operatorFormula.hasOptimalityType(), storm::exceptions::NotSupportedException,
453 "Unable to export a multi-objective formula since the optimization direction for subformula " << *subFormulaCopy <<
" can not be derived.");
458 subFormulaCopy->hasQualitativeResult(), storm::exceptions::NotSupportedException,
459 "Unable to export a multi-objective formula since the optimization direction for subformula " << *subFormulaCopy <<
" can not be derived.");
461 p[
"exp"] =
anyToJson(subFormulaCopy->accept(*
this, data));
462 opDecl[
"properties"].push_back(std::move(p));
468 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Jani currently does not support conversion of a Quantile formula.");
476 auto intervalExpressionManager = std::make_shared<storm::expressions::ExpressionManager>();
477 opDecl[
"step-bounds"] = constructPropertyInterval(intervalExpressionManager->integer(1),
false, intervalExpressionManager->integer(1),
false);
488 opDecl[
"left"][
"op"] = f.
getOptimalityType() == storm::solver::OptimizationDirection::Minimize ?
"Pmin" :
"Pmax";
491 opDecl[
"left"][
"op"] =
496 opDecl[
"right"] =
buildExpression(bound.threshold, model.getConstants(), model.getGlobalVariables());
499 opDecl[
"op"] = f.
getOptimalityType() == storm::solver::OptimizationDirection::Minimize ?
"Pmin" :
"Pmax";
504 opDecl[
"op"] =
"Pmin";
513 std::string rewardModelName;
517 if (model.getGlobalVariables().getNumberOfRealTransientVariables() == 1) {
518 for (
auto const& variable : model.getGlobalVariables().getRealVariables()) {
519 if (variable.isTransient()) {
520 rewardModelName = variable.getName();
521 STORM_LOG_WARN(
"Reward model name was not given, assuming the only global real transient variable '" << rewardModelName
522 <<
"' to measure the reward.");
528 STORM_LOG_THROW(!rewardModelName.empty(), storm::exceptions::NotSupportedException,
"Reward name has to be specified for Jani-conversion.");
530 std::string opString =
"";
544 opDecl[
"op"] = opString;
545 auto setRewardAccumulation = [&opDecl, &rewardModelName,
this](
auto const& subformula) {
546 opDecl[
"accumulate"] = subformula.hasRewardAccumulation() ? constructRewardAccumulation(subformula.getRewardAccumulation(), rewardModelName)
547 : constructStandardRewardAccumulation(rewardModelName);
555 setRewardAccumulation(subf);
556 auto isStepInstant = [
this, &subf](uint64_t i) {
557 return subf.getTimeBoundReference(i).isStepBound() || (model.isDiscreteTimeModel() && subf.getTimeBoundReference(i).isTimeBound());
559 auto getInstantExpression = [&subf, &isStepInstant](uint64_t i) {
560 auto instantExpr = subf.getBound(i);
562 if (subf.isBoundStrict(i)) {
564 STORM_LOG_THROW(isStepInstant(i), storm::exceptions::NotSupportedException,
565 "Jani export of cumulative reward formula " << subf <<
" with strict time or reward bound is not supported.");
566 instantExpr = instantExpr - subf.getBound(i).getManager().integer(1);
569 if (isStepInstant(i) && !instantExpr.getType().isIntegerType()) {
574 if (subf.isMultiDimensional() || subf.getTimeBoundReference().isRewardBound()) {
575 opDecl[
"reward-instants"] = ExportJsonType::array();
576 for (uint64_t i = 0; i < subf.getDimension(); ++i) {
578 auto const& tbr = subf.getTimeBoundReference(i);
580 tbr.isRewardBound() ?
buildExpression(model.getRewardModelExpression(tbr.getRewardName()), model.getConstants(), model.getGlobalVariables())
582 if (tbr.isRewardBound()) {
583 if (tbr.hasRewardAccumulation()) {
584 instantDecl[
"accumulate"] = constructRewardAccumulation(tbr.getRewardAccumulation(), tbr.getRewardName());
586 instantDecl[
"accumulate"] = constructStandardRewardAccumulation(tbr.getRewardName());
588 }
else if (isStepInstant(i)) {
593 instantDecl[
"instant"] =
buildExpression(getInstantExpression(i), model.getConstants(), model.getGlobalVariables());
594 opDecl[
"reward-instants"].push_back(std::move(instantDecl));
597 opDecl[isStepInstant(0) ?
"step-instant" :
"time-instant"] =
598 buildExpression(getInstantExpression(0), model.getConstants(), model.getGlobalVariables());
603 opDecl[model.isDiscreteTimeModel() ?
"step-instant" :
"time-instant"] =
610 opDecl[
"exp"] =
buildExpression(model.getRewardModelExpression(rewardModelName), model.getConstants(), model.getGlobalVariables());
616 compDecl[
"left"] = std::move(opDecl);
617 compDecl[
"right"] =
buildExpression(bound.threshold, model.getConstants(), model.getGlobalVariables());
625 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Jani currently does not support a total reward formula.");
669 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Jani currently does not support HOA path formulae.");
673 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Jani currently does not support discounted cumulative reward formulae.");
677 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Jani currently does not support discounted total reward formulae.");
689 case OpType::Implies:
709 case OpType::Logarithm:
713 case OpType::NotEqual:
717 case OpType::LessOrEqual:
719 case OpType::Greater:
721 case OpType::GreaterOrEqual:
736 STORM_LOG_THROW(
false, storm::exceptions::InvalidJaniException,
"Operator not supported by Jani.");
742 std::unordered_set<std::string>
const& auxiliaryVariables) {
746 ExpressionToJson visitor(constants, globalVariables, localVariables, auxiliaryVariables);
747 return anyToJson(simplifiedExpr.accept(visitor, boost::none));
752 opDecl[
"op"] =
"ite";
774 trc[
"exp"] = std::move(opDecl);
791 }
else if (globalVariables.hasVariable(expression.
getVariable())) {
793 }
else if (localVariables.hasVariable(expression.
getVariable())) {
796 for (
auto const& constant : constants) {
797 if (constant.getExpressionVariable() == expression.
getVariable()) {
803 "Expression variable '" << expression.
getVariableName() <<
"' not known in Jani data structures.");
835 auto const& value = expression.
getValue();
843 val[
"left"] = std::move(numJson);
844 val[
"right"] = std::move(denJson);
854 std::vector<ExportJsonType> elements;
855 uint64_t size = expression.
size()->evaluateAsInt();
856 for (uint64_t i = 0; i < size; ++i) {
857 elements.push_back(
anyToJson(expression.
at(i)->accept(*
this, data)));
859 opDecl[
"elements"] = std::move(elements);
867 opDecl[
"length"] =
anyToJson(expression.
size()->accept(*
this, data));
886 opDecl[
"op"] =
"call";
888 std::vector<ExportJsonType> arguments;
892 opDecl[
"args"] = std::move(arguments);
898 constantDecl[
"constant"] = expression.
asString();
904 std::ofstream stream;
906 toStream(janiModel, formulas, stream, checkValid, compact);
917 exporter.convertModel(janiModel, !compact);
919 exporter.convertProperties(formulas, janiModel);
926 std::vector<ExportJsonType> actionReprs;
927 uint64_t actIndex = 0;
928 for (
auto const& act : actions) {
935 actEntry[
"name"] = act.getName();
936 actionReprs.push_back(actEntry);
951 typeDescr[
"kind"] =
"array";
954 STORM_LOG_THROW(
false, storm::exceptions::IllegalArgumentException,
"Unknown expression type.");
960 std::vector<storm::jani::Constant>
const& constants) {
968 std::vector<bool> varOps(2,
false);
969 for (
int i : {0, 1}) {
973 if ((leq && varOps[0]) || (geq && varOps[1])) {
975 }
else if ((leq && varOps[1]) || (geq && varOps[0])) {
978 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Jani Export for constant constraint " << constraint <<
" is not supported.");
981 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Jani Export for constant constraint " << constraint <<
" is not supported.");
986 std::vector<ExportJsonType> constantDeclarations;
987 for (
auto const& constant : constants) {
989 constantEntry[
"name"] = constant.getName();
991 if (constant.hasConstraint()) {
992 typeDesc[
"kind"] =
"bounded";
994 getBoundsFromConstraints(typeDesc, constant.getExpressionVariable(), constant.getConstraintExpression(), constants);
998 constantEntry[
"type"] = typeDesc;
999 if (constant.isDefined()) {
1000 constantEntry[
"value"] =
buildExpression(constant.getExpression(), constants);
1002 constantDeclarations.push_back(constantEntry);
1013 typeDesc[
"kind"] =
"bounded";
1015 switch (bndType.getBaseType()) {
1017 typeDesc[
"base"] =
"int";
1020 typeDesc[
"base"] =
"real";
1023 if (bndType.hasLowerBound()) {
1024 typeDesc[
"lower-bound"] =
buildExpression(bndType.getLowerBound(), constants, globalVariables, localVariables);
1026 if (bndType.hasUpperBound()) {
1027 typeDesc[
"upper-bound"] =
buildExpression(bndType.getUpperBound(), constants, globalVariables, localVariables);
1030 typeDesc[
"kind"] =
"array";
1033 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"Variable type not recognized in JSONExporter.");
1040 ExportJsonType variableDeclarations = std::vector<ExportJsonType>();
1041 for (
auto const& variable : varSet) {
1043 varEntry[
"name"] = variable.getName();
1044 if (variable.isTransient()) {
1045 varEntry[
"transient"] = variable.isTransient();
1047 varEntry[
"type"] =
buildType(variable.getType(), constants, globalVariables, localVariables);
1048 if (variable.hasInitExpression()) {
1049 varEntry[
"initial-value"] =
buildExpression(variable.getInitExpression(), constants, globalVariables, localVariables);
1051 variableDeclarations.push_back(std::move(varEntry));
1053 return variableDeclarations;
1057 std::vector<storm::jani::Constant>
const& constants,
VariableSet const& globalVariables,
1059 ExportJsonType functionDeclarations = std::vector<ExportJsonType>();
1060 for (
auto const& nameFunDef : functionDefinitions) {
1063 funDefJson[
"name"] = nameFunDef.first;
1065 std::vector<ExportJsonType> parameterDeclarations;
1066 std::unordered_set<std::string> parameterNames;
1069 parDefJson[
"name"] = p.getName();
1070 parameterNames.insert(p.getName());
1072 parameterDeclarations.push_back(parDefJson);
1074 funDefJson[
"parameters"] = parameterDeclarations;
1076 functionDeclarations.push_back(std::move(funDefJson));
1078 return functionDeclarations;
1090 newResult[
"op"] =
"aa";
1091 newResult[
"exp"] = std::move(result);
1092 newResult[
"index"] =
buildExpression(indexExpr, constants, globalVariables, localVariables);
1093 result = std::move(newResult);
1101 ExportJsonType assignmentDeclarations = std::vector<ExportJsonType>();
1103 for (
auto const& assignment : orderedAssignments) {
1105 assignmentEntry[
"ref"] =
buildLValue(assignment.getLValue(), constants, globalVariables, localVariables);
1106 assignmentEntry[
"value"] =
buildExpression(assignment.getAssignedExpression(), constants, globalVariables, localVariables);
1108 assignmentEntry[
"index"] = assignment.getLevel();
1110 if (commentExpressions) {
1111 assignmentEntry[
"comment"] = assignment.getLValue().getName() +
" <- " + assignment.getAssignedExpression().toString();
1113 assignmentDeclarations.push_back(std::move(assignmentEntry));
1115 return assignmentDeclarations;
1120 ExportJsonType locationDeclarations = std::vector<ExportJsonType>();
1121 for (
auto const& location : locations) {
1123 locEntry[
"name"] = location.getName();
1124 if (location.hasTimeProgressInvariant()) {
1126 timeProg[
"exp"] =
buildExpression(location.getTimeProgressInvariant(), constants, globalVariables, localVariables);
1127 if (commentExpressions) {
1128 timeProg[
"comment"] = location.getTimeProgressInvariant().toString();
1130 locEntry[
"time-progress"] = std::move(timeProg);
1132 if (!location.getAssignments().empty()) {
1133 locEntry[
"transient-values"] =
buildAssignmentArray(location.getAssignments(), constants, globalVariables, localVariables, commentExpressions);
1135 locationDeclarations.push_back(std::move(locEntry));
1137 return locationDeclarations;
1141 std::vector<std::string> names;
1149 std::vector<storm::jani::Constant>
const& constants,
VariableSet const& globalVariables,
VariableSet const& localVariables,
1150 bool commentExpressions) {
1151 STORM_LOG_ASSERT(destinations.size() > 0,
"Expected at least one destination.");
1153 for (
auto const& destination : destinations) {
1155 destEntry[
"location"] = locationNames.at(destination.getLocationIndex());
1157 if (destination.getProbability().isLiteral()) {
1163 destEntry[
"probability"][
"exp"] =
buildExpression(destination.getProbability(), constants, globalVariables, localVariables);
1164 if (commentExpressions) {
1165 destEntry[
"probability"][
"comment"] = destination.getProbability().toString();
1168 if (!destination.getOrderedAssignments().empty()) {
1169 destEntry[
"assignments"] =
1170 buildAssignmentArray(destination.getOrderedAssignments(), constants, globalVariables, localVariables, commentExpressions);
1172 destDeclarations.push_back(std::move(destEntry));
1174 return destDeclarations;
1178 std::vector<storm::jani::Constant>
const& constants,
VariableSet const& globalVariables,
VariableSet const& localVariables,
1179 bool commentExpressions) {
1188 if (commentExpressions) {
1194 if (commentExpressions) {
1206 std::map<uint64_t, std::string>
const& locationNames, std::vector<storm::jani::Constant>
const& constants,
1209 for (
auto const& edge : edges) {
1210 if (edge.getGuard().isFalse()) {
1213 edgeDeclarations.push_back(
buildEdge(edge, actionNames, locationNames, constants, globalVariables, localVariables, commentExpressions));
1215 return edgeDeclarations;
1219 std::vector<storm::jani::Constant>
const& constants,
VariableSet const& globalVariables,
bool commentExpressions) {
1220 ExportJsonType automataDeclarations = std::vector<ExportJsonType>();
1221 for (
auto const& automaton :
automata) {
1223 autoEntry[
"name"] = automaton.getName();
1224 autoEntry[
"variables"] =
buildVariablesArray(automaton.getVariables(), constants, globalVariables, automaton.getVariables());
1225 if (!automaton.getFunctionDefinitions().empty()) {
1226 autoEntry[
"functions"] =
buildFunctionsArray(automaton.getFunctionDefinitions(), constants, globalVariables, automaton.getVariables());
1228 if (automaton.hasRestrictedInitialStates()) {
1229 autoEntry[
"restrict-initial"][
"exp"] =
1230 buildExpression(automaton.getInitialStatesRestriction(), constants, globalVariables, automaton.getVariables());
1232 autoEntry[
"locations"] =
buildLocationsArray(automaton.getLocations(), constants, globalVariables, automaton.getVariables(), commentExpressions);
1234 autoEntry[
"edges"] =
buildEdges(automaton.getEdges(), actionNames, automaton.buildIdToLocationNameMap(), constants, globalVariables,
1235 automaton.getVariables(), commentExpressions);
1236 automataDeclarations.push_back(std::move(autoEntry));
1238 return automataDeclarations;
1241void JsonExporter::convertModel(
storm::jani::Model const& janiModel,
bool commentExpressions) {
1244 jsonStruct[
"name"] = janiModel.
getName();
1259 auto const& automaton = janiModel.
getAutomaton(automatonIndex);
1287 STORM_LOG_THROW(
false, storm::exceptions::IllegalArgumentException,
"Unknown FilterType.");
1292 propDecl[
"states"][
"op"] =
"initial";
1293 propDecl[
"op"] =
"filter";
1299void JsonExporter::convertProperties(std::vector<storm::jani::Property>
const& formulas,
storm::jani::Model const& model) {
1306 if (formulas.empty()) {
1307 jsonStruct[
"properties"] =
ExportJsonType(ExportJsonType::value_t::array);
1311 for (
auto const& f : formulas) {
1313 propDecl[
"name"] = f.getName();
1315 properties.push_back(std::move(propDecl));
1317 jsonStruct[
"properties"] = std::move(properties);
1321 jsonStruct[
"features"] = ExportJsonType::parse(modelFeatures.toString());
Represents an access to an array.
virtual bool isBinaryRelationExpression() const
virtual bool isBinaryBooleanFunctionExpression() const
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const
Retrieves the given operand from the expression.
VariableExpression const & asVariableExpression() const
Type const & getType() const
Retrieves the type of the expression.
virtual OperatorType getOperator() const
Retrieves the operator of a function application.
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
bool getValue() const
Retrieves the value of the boolean literal.
Represents an array of the given size, where the i'th entry is determined by the elementExpression,...
virtual std::shared_ptr< BaseExpression const > size() const override
std::shared_ptr< BaseExpression const > const & getElementExpression() const
storm::expressions::Variable const & getIndexVar() const
Expression simplify() const
Simplifies the expression according to some basic rules.
bool isVariable() const
Retrieves whether the expression is a variable.
Expression getOperand(uint_fast64_t operandIndex) const
Retrieves the given operand from the expression.
BaseExpression const & getBaseExpression() const
Retrieves the base expression underlying this expression object.
std::string toString() const
Converts the expression into a string.
bool isTrue() const
Checks if the expression is equal to the boolean literal true.
Represents an array with a given list of elements.
uint64_t getNumberOfArguments() const
std::shared_ptr< BaseExpression const > getArgument(uint64_t i) const
std::string const & getFunctionIdentifier() const
std::shared_ptr< BaseExpression const > getElseExpression() const
Retrieves the else expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getCondition() const
Retrieves the condition expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getThenExpression() const
Retrieves the then expression of the if-then-else expression.
int_fast64_t getValue() const
Retrieves the value of the integer literal.
storm::RationalNumber getValue() const
Retrieves the value of the double literal.
std::string asString() const
Get the Transcendental number as string, like in the Jani file (single character).
Type getElementType() const
Retrieves the element type of the type, provided that it is an Array type.
bool isBooleanType() const
Checks whether this type is a boolean type.
bool isIntegerType() const
Checks whether this type is an integral type.
bool isArrayType() const
Checks whether this type is an array type.
bool isRationalType() const
Checks whether this type is a rational type.
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
virtual storm::expressions::OperatorType getOperator() const override
Retrieves the operator of a function application.
Represents an array with a given list of elements.
virtual std::shared_ptr< BaseExpression const > size() const override
virtual std::shared_ptr< BaseExpression const > at(uint64_t i) const override
Variable const & getVariable() const
Retrieves the variable associated with this expression.
std::string const & getVariableName() const
Retrieves the name of the variable associated with this expression.
std::string const & getName() const
Retrieves the name of the variable.
std::string const & getAutomatonName() const
Retrieves the name of the automaton this composition element refers to.
Location const & getLocation(uint64_t index) const
Retrieves the location with the given index.
std::set< uint64_t > const & getInitialLocationIndices() const
Retrieves the indices of the initial locations.
virtual boost::any accept(CompositionVisitor &visitor, boost::any const &data) const =0
virtual boost::any visit(ParallelComposition const &composition, boost::any const &data)
virtual boost::any visit(AutomatonComposition const &composition, boost::any const &)
static ExportJsonType translate(storm::jani::Composition const &comp, bool allowRecursion=true)
CompositionJsonExporter(bool allowRecursion)
bool hasSilentAction() const
Returns whether it contains the silent action.
uint64_t getActionIndex() const
Retrieves the id of the action with which this edge is labeled.
std::vector< EdgeDestination > const & getDestinations() const
Retrieves the destinations of this edge.
bool hasRate() const
Retrieves whether this edge has an associated rate.
uint64_t getSourceLocationIndex() const
Retrieves the index of the source location.
OrderedAssignments const & getAssignments() const
Retrieves the assignments of this edge.
storm::expressions::Expression const & getRate() const
Retrieves the rate of this edge.
storm::expressions::Expression const & getGuard() const
Retrieves the guard of this edge.
virtual boost::any visit(storm::expressions::IfThenElseExpression const &expression, boost::any const &data)
static ExportJsonType translate(storm::expressions::Expression const &expr, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables, std::unordered_set< std::string > const &auxiliaryVariables)
std::shared_ptr< storm::logic::Formula const > const & getFormula() const
storm::modelchecker::FilterType getFilterType() const
storm::expressions::Expression const & getFunctionBody() const
Retrieves the expression that defines the function.
std::vector< storm::expressions::Variable > const & getParameters() const
Retrieves the parameters of the function.
storm::expressions::Type const & getType() const
Retrieves the type of the function.
ArrayType const & asArrayType() const
virtual bool isContinuousType() const
virtual std::string getStringRepresentation() const =0
Retrieves a string representation of the type.
virtual bool isArrayType() const
virtual bool isBoundedType() const
virtual bool isBasicType() const
BoundedType const & asBoundedType() const
virtual bool isClockType() const
static ExportJsonType getEdgeAsJson(storm::jani::Model const &janiModel, uint64_t automatonIndex, uint64_t edgeIndex, bool commentExpressions=true)
static void toFile(storm::jani::Model const &janiModel, std::vector< storm::jani::Property > const &formulas, std::string const &filepath, bool checkValid=true, bool compact=false)
static void toStream(storm::jani::Model const &janiModel, std::vector< storm::jani::Property > const &formulas, std::ostream &ostream, bool checkValid=false, bool compact=false)
std::vector< storm::expressions::Expression > & getArrayIndexVector()
Returns the referred variable. In case of an array access, this is the referred array variable.
bool isArrayAccess() const
Returns true if the lValue refers either to an array variable or to an array access.
storm::jani::Variable const & getVariable() const
To check if the array is fully accessed, so result will be of the most inner child Type....
std::string const & getName() const
Retrieves the name of the location.
ModelFeatures & add(ModelFeature const &modelFeature)
void remove(ModelFeature const &modelFeature)
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
Composition const & getSystemComposition() const
Retrieves the system composition expression.
storm::expressions::Expression const & getInitialStatesRestriction() const
Gets the expression restricting the legal initial values of the global variables.
static const uint64_t SILENT_ACTION_INDEX
The index of the silent action.
std::vector< Automaton > & getAutomata()
Retrieves the automata of the model.
ModelType const & getModelType() const
Retrieves the type of the model.
std::vector< Constant > const & getConstants() const
Retrieves the constants of the model.
std::vector< Action > const & getActions() const
Retrieves the actions of the model.
uint64_t getJaniVersion() const
Retrieves the JANI-version of the model.
void checkValid() const
Checks if the model is valid JANI, which should be verified before any further operations are applied...
std::string const & getName() const
Retrieves the name of the model.
ModelFeatures const & getModelFeatures() const
Retrieves the enabled model features.
Automaton & getAutomaton(std::string const &name)
Retrieves the automaton with the given name.
std::map< uint64_t, std::string > getActionIndexToNameMap() const
Builds a map with action indices mapped to their names.
std::unordered_map< std::string, FunctionDefinition > const & getGlobalFunctionDefinitions() const
Retrieves all global function definitions.
bool hasMultipleLevels(bool onlyTransient=false) const
Checks whether the assignments have several levels.
bool empty(bool onlyTransient=false) const
Retrieves whether this set of assignments is empty.
std::vector< SynchronizationVector > const & getSynchronizationVectors() const
Retrieves the synchronization vectors of the parallel composition.
std::vector< std::shared_ptr< Composition > > const & getSubcompositions() const
Retrieves the subcompositions of the parallel composition.
static const std::string NO_ACTION_INPUT
std::string const & getName() const
Retrieves the name of the variable.
#define STORM_LOG_INFO(message)
#define STORM_LOG_WARN(message)
#define STORM_LOG_TRACE(message)
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)
Expression floor(Expression const &first)
void closeFile(std::ofstream &stream)
Close the given file after writing.
void openFile(std::string const &filepath, std::ofstream &filestream, bool append=false, bool silent=false)
Open the given file for writing.
ExportJsonType buildAutomataArray(std::vector< storm::jani::Automaton > const &automata, std::map< uint64_t, std::string > const &actionNames, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, bool commentExpressions)
ExportJsonType buildEdge(Edge const &edge, std::map< uint64_t, std::string > const &actionNames, std::map< uint64_t, std::string > const &locationNames, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables, bool commentExpressions)
ExportJsonType buildTypeDescription(storm::expressions::Type const &type)
ExportJsonType buildFunctionsArray(std::unordered_map< std::string, FunctionDefinition > const &functionDefinitions, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables=VariableSet())
ExportJsonType convertFilterExpression(storm::jani::FilterExpression const &fe, storm::jani::Model const &model, storm::jani::ModelFeatures &modelFeatures)
storm::json< storm::RationalNumber > ExportJsonType
ExportJsonType buildDestinations(std::vector< EdgeDestination > const &destinations, std::map< uint64_t, std::string > const &locationNames, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables, bool commentExpressions)
std::string comparisonTypeToJani(storm::logic::ComparisonType ct)
ExportJsonType buildLValue(storm::jani::LValue const &lValue, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables)
ExportJsonType buildAssignmentArray(storm::jani::OrderedAssignments const &orderedAssignments, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables, bool commentExpressions)
ExportJsonType buildInitialLocations(storm::jani::Automaton const &automaton)
ExportJsonType buildActionArray(std::vector< storm::jani::Action > const &actions)
ExportJsonType buildExpression(storm::expressions::Expression const &exp, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables=VariableSet(), VariableSet const &localVariables=VariableSet(), std::unordered_set< std::string > const &auxiliaryVariables={})
ExportJsonType buildType(storm::jani::JaniType const &type, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables=VariableSet())
@ MultiObjectiveProperties
ExportJsonType buildConstantsArray(std::vector< storm::jani::Constant > const &constants)
std::string to_string(ModelType const &type)
std::string janiFilterTypeString(storm::modelchecker::FilterType const &ft)
storm::expressions::Expression reduceNestingInJaniExpression(storm::expressions::Expression const &expression)
ExportJsonType anyToJson(boost::any &&input)
ExportJsonType buildEdges(std::vector< Edge > const &edges, std::map< uint64_t, std::string > const &actionNames, std::map< uint64_t, std::string > const &locationNames, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables, bool commentExpressions)
ExportJsonType buildVariablesArray(storm::jani::VariableSet const &varSet, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables=VariableSet())
ExportJsonType buildLocationsArray(std::vector< storm::jani::Location > const &locations, std::vector< storm::jani::Constant > const &constants, VariableSet const &globalVariables, VariableSet const &localVariables, bool commentExpressions)
std::string operatorTypeToJaniString(storm::expressions::OperatorType optype)
void getBoundsFromConstraints(ExportJsonType &typeDesc, storm::expressions::Variable const &var, storm::expressions::Expression const &constraint, std::vector< storm::jani::Constant > const &constants)
bool isLowerBound(ComparisonType t)
bool constexpr minimize(OptimizationDirection d)
bool isOne(ValueType const &a)
NumberTraits< RationalType >::IntegerType denominator(RationalType const &number)
NumberTraits< RationalType >::IntegerType numerator(RationalType const &number)
TargetType convertNumber(SourceType const &number)
bool isJsonNumberExportAccurate(storm::json< ValueType > const &j)
std::string dumpJson(storm::json< ValueType > const &j, bool compact)
Dumps the given json object, producing a String.
ComparisonType comparisonType