21 uint64_t locId = addLocation(mainAutomaton);
22 addEdges(mainAutomaton, locId);
31 for (
auto const& place : gspn.getPlaces()) {
32 std::shared_ptr<storm::jani::Variable> janiVar =
nullptr;
33 if (!place.hasRestrictedCapacity()) {
36 expressionManager->integer(place.getNumberOfInitialTokens()),
false);
38 assert(place.hasRestrictedCapacity());
40 expressionManager->integer(place.getNumberOfInitialTokens()),
false,
41 expressionManager->integer(0), expressionManager->integer(place.getCapacity()));
43 assert(janiVar !=
nullptr);
44 assert(vars.count(place.getID()) == 0);
45 vars[place.getID()] = &model->
addVariable(*janiVar);
56 uint64_t lastPriority = -1;
60 for (
auto const& partition : gspn.getPartitions()) {
63 assert(lastPriority >= partition.priority);
64 if (lastPriority > partition.priority) {
65 priorityGuard = priorityGuard && !lastPriorityGuard;
66 lastPriority = partition.priority;
68 assert(lastPriority == partition.priority);
73 for (
auto const& transId : partition.transitions) {
75 if (trans.noWeightAttached()) {
79 for (
auto const& inPlaceEntry : trans.getInputPlaces()) {
80 destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second);
82 for (
auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
83 destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second);
85 totalWeight = totalWeight +
storm::expressions::ite(destguard, expressionManager->rational(trans.getWeight()), expressionManager->rational(0.0));
87 totalWeight = totalWeight.
simplify();
89 std::vector<storm::jani::OrderedAssignments> oas;
90 std::vector<storm::expressions::Expression> probabilities;
91 std::vector<uint64_t> destinationLocations;
92 for (
auto const& transId : partition.transitions) {
94 if (trans.noWeightAttached()) {
95 std::cout <<
"ERROR -- no weights attached at transition\n";
99 std::vector<storm::jani::Assignment> assignments;
100 for (
auto const& inPlaceEntry : trans.getInputPlaces()) {
101 destguard = destguard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second);
102 if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) {
104 (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second);
107 for (
auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
108 destguard = destguard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second);
110 for (
auto const& outputPlaceEntry : trans.getOutputPlaces()) {
111 if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) {
113 (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second);
115 assignments.emplace_back(
117 (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second - trans.getInputPlaces().at(outputPlaceEntry.first));
121 guard = guard || destguard;
123 oas.emplace_back(assignments);
124 destinationLocations.emplace_back(locId);
125 probabilities.emplace_back(
126 storm::expressions::ite(destguard, (expressionManager->rational(trans.getWeight()) / totalWeight), expressionManager->rational(0.0)));
129 std::shared_ptr<storm::jani::TemplateEdge> templateEdge = std::make_shared<storm::jani::TemplateEdge>((priorityGuard && guard).
simplify());
132 for (
auto const& oa : oas) {
137 lastPriorityGuard = lastPriorityGuard || guard;
139 for (
auto const& trans : gspn.getTimedTransitions()) {
141 STORM_LOG_WARN(
"Transitions with rate zero are not allowed in JANI. Skipping this transition");
146 std::vector<storm::jani::Assignment> assignments;
147 for (
auto const& inPlaceEntry : trans.getInputPlaces()) {
148 guard = guard && (vars[inPlaceEntry.first]->getExpressionVariable() >= inPlaceEntry.second);
149 if (trans.getOutputPlaces().count(inPlaceEntry.first) == 0) {
151 (vars[inPlaceEntry.first])->getExpressionVariable() - inPlaceEntry.second);
154 for (
auto const& inhibPlaceEntry : trans.getInhibitionPlaces()) {
155 guard = guard && (vars[inhibPlaceEntry.first]->getExpressionVariable() < inhibPlaceEntry.second);
157 for (
auto const& outputPlaceEntry : trans.getOutputPlaces()) {
158 if (trans.getInputPlaces().count(outputPlaceEntry.first) == 0) {
160 (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second);
162 assignments.emplace_back(
164 (vars[outputPlaceEntry.first])->getExpressionVariable() + outputPlaceEntry.second - trans.getInputPlaces().at(outputPlaceEntry.first));
168 std::shared_ptr<storm::jani::TemplateEdge> templateEdge = std::make_shared<storm::jani::TemplateEdge>(guard);
172 if (trans.hasInfiniteServerSemantics() || (trans.hasKServerSemantics() && !trans.hasSingleServerSemantics())) {
173 STORM_LOG_THROW(trans.hasKServerSemantics() || !trans.getInputPlaces().empty(), storm::exceptions::InvalidModelException,
174 "Unclear semantics: Found a transition with infinite-server semantics and without input place.");
176 bool firstArgumentOfMinExpression =
true;
177 if (trans.hasKServerSemantics()) {
178 enablingDegree = expressionManager->integer(trans.getNumberOfServers());
179 firstArgumentOfMinExpression =
false;
181 for (
auto const& inPlaceEntry : trans.getInputPlaces()) {
183 vars[inPlaceEntry.first]->getExpressionVariable() / expressionManager->integer(inPlaceEntry.second);
184 if (firstArgumentOfMinExpression ==
true) {
185 enablingDegree = enablingDegreeInPlace;
186 firstArgumentOfMinExpression =
false;
191 rate = rate * enablingDegree;
194 templateEdge->addDestination(assignments);
201 bool ignoreInhibitorArcs,
bool ignoreEmptyPlaces) {
205 std::vector<storm::gspn::Transition const*> transitions;
207 for (
auto const& t : gspn.getImmediateTransitions()) {
208 transitions.push_back(&t);
210 for (
auto const& t : gspn.getTimedTransitions()) {
211 transitions.push_back(&t);
213 bool firstTransition =
true;
214 for (
auto const& transition : transitions) {
217 bool firstPlace =
true;
218 if (!ignoreEmptyPlaces) {
219 for (
auto const& placeIdMult : transition->getInputPlaces()) {
221 (vars.at(placeIdMult.first)->getExpressionVariable() < expressionManager->integer(placeIdMult.second));
223 transitionDisabled = placeBlocksTransition;
226 transitionDisabled = transitionDisabled || placeBlocksTransition;
230 if (!ignoreInhibitorArcs) {
231 for (
auto const& placeIdMult : transition->getInhibitionPlaces()) {
233 (vars.at(placeIdMult.first)->getExpressionVariable() >= expressionManager->integer(placeIdMult.second));
235 transitionDisabled = placeBlocksTransition;
238 transitionDisabled = transitionDisabled || placeBlocksTransition;
242 if (!ignoreCapacities) {
243 for (
auto const& placeIdMult : transition->getOutputPlaces()) {
244 auto const& place = gspn.
getPlace(placeIdMult.first);
245 if (place->hasRestrictedCapacity()) {
247 (vars.at(placeIdMult.first)->getExpressionVariable() + expressionManager->integer(placeIdMult.second) >
248 expressionManager->integer(place->getCapacity()));
250 transitionDisabled = placeBlocksTransition;
253 transitionDisabled = transitionDisabled || placeBlocksTransition;
259 if (firstTransition) {
260 transientValue = transitionDisabled;
261 firstTransition =
false;
263 transientValue = transientValue && transitionDisabled;
271 auto exprVar = expressionManager->declareBooleanVariable(name);
274 model->
getAutomata().front().getLocations().front().addTransientAssignment(assignment);
279 std::string res = name;
280 while (manager.hasVariable(res)) {
287 std::shared_ptr<storm::logic::AtomicExpressionFormula> atomicFormula,
288 std::string name, std::string description,
bool maximal) {
289 std::vector<storm::jani::Property> standardProperties;
290 std::string dirShort = maximal ?
"Max" :
"Min";
291 std::string dirLong = maximal ?
"maximal" :
"minimal";
293 maximal ? storm::solver::OptimizationDirection::Maximize : storm::solver::OptimizationDirection::Minimize;
294 std::set<storm::expressions::Variable> emptySet;
297 auto reachFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(
300 standardProperties.emplace_back(dirShort +
"PrReach" + name, reachFormula, emptySet,
301 "The " + dirLong +
" probability to eventually reach " + description +
".");
305 auto exprTB = expressionManager->declareRationalVariable(
getUniqueVarName(*expressionManager,
"TIME_BOUND"));
311 auto trueFormula = std::make_shared<storm::logic::BooleanLiteralFormula>(
true);
312 auto reachTimeBoundFormula = std::make_shared<storm::logic::ProbabilityOperatorFormula>(
313 std::make_shared<storm::logic::BoundedUntilFormula>(trueFormula, atomicFormula, boost::none, tb, tbr),
315 standardProperties.emplace_back(dirShort +
"PrReach" + name +
"TB", reachTimeBoundFormula, emptySet,
316 "The " + dirLong +
" probability to reach " + description +
" within 'TIME_BOUND' steps.");
319 dirShort = maximal ?
"Min" :
"Max";
320 dirLong = maximal ?
"minimal" :
"maximal";
321 optimizationDirection = maximal ? storm::solver::OptimizationDirection::Minimize : storm::solver::OptimizationDirection::Maximize;
324 auto expTimeFormula = std::make_shared<storm::logic::TimeOperatorFormula>(
327 standardProperties.emplace_back(dirShort +
"ExpTime" + name, expTimeFormula, emptySet,
"The " + dirLong +
" expected time to reach " + description +
".");
328 return standardProperties;
332 auto const& deadlockVar = addDeadlockTransientVariable(model,
getUniqueVarName(*expressionManager,
"deadl"));
333 auto deadlockFormula = std::make_shared<storm::logic::AtomicExpressionFormula>(deadlockVar.getExpressionVariable().getExpression());