Skip to content

Commit 0f16a3f

Browse files
committed
fixes for IOA
1 parent c22579b commit 0f16a3f

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

include/maxplus/graph/smpls.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ class SMPLSwithEvents : public SMPLS {
153153
*/
154154
void isConsistentUtil(const IOAState &s,
155155
EventList &eventList,
156-
const IOASetOfStates &finalStates,
156+
const ::FSM::Abstract::SetOfStateRefs &finalStates,
157157
MPString &errMsg,
158158
std::map<IOAStateRef, EventList> &visited);
159159

160160
void determinizeUtil(const IOAState &s,
161161
IOASetOfStateRefs &visited,
162-
const IOASetOfStateRefs &finalStates,
162+
const FSM::Abstract::SetOfStateRefs &finalStates,
163163
MPString &errMsg,
164164
std::ofstream &outfile);
165165

src/graph/smpls.cc

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void SMPLSwithEvents::saveDeterminizedIOAtoFile(const MPString &file) {
243243
outfile << "ioautomaton statespace{ \r\n";
244244
const auto &I = this->ioa->getInitialStates();
245245

246-
const auto &finalStates = dynamic_cast<const IOASetOfStateRefs &>(this->ioa->getFinalStates());
246+
const auto &finalStates = this->ioa->getFinalStates();
247247

248248
MPString errMsg = "";
249249
auto i = I.begin();
@@ -269,15 +269,15 @@ bool SMPLSwithEvents::isConsistent() {
269269
}
270270
EventList eventList;
271271

272-
const auto &I = dynamic_cast<const IOASetOfStates &>(this->ioa->getInitialStates());
272+
const auto &I = this->ioa->getInitialStates();
273273

274-
const auto &finalStates = dynamic_cast<const IOASetOfStates &>(this->ioa->getFinalStates());
274+
const auto &finalStates = this->ioa->getFinalStates();
275275

276276
std::map<IOAStateRef, EventList> visited;
277277
MPString errMsg = "";
278278
for (const auto &i : I) {
279279
isConsistentUtil(
280-
(dynamic_cast<IOAState &>(*(i.second))), eventList, finalStates, errMsg, visited);
280+
*dynamic_cast<IOAStateRef>(i), eventList, finalStates, errMsg, visited);
281281
}
282282

283283
if (!errMsg.empty()) {
@@ -302,17 +302,20 @@ std::shared_ptr<MaxPlusAutomaton> SMPLSwithEvents::convertToMaxPlusAutomaton() {
302302
// search
303303
const auto &I = dynamic_cast<const IOASetOfStates &>(this->ioa->getStates());
304304
for (const auto &i : I) {
305-
this->elsFSM.addState(dynamic_cast<ELSState &>(*(i.second)).getLabel());
305+
this->elsFSM.addState(dynamic_cast<IOAState &>(*(i.second)).getLabel());
306306
}
307307

308-
const auto &I2 = dynamic_cast<const IOASetOfStates &>(this->ioa->getInitialStates());
308+
const auto &I2 = this->ioa->getInitialStates();
309309
for (const auto &i : I2) {
310-
prepareMatrices((dynamic_cast<IOAState &>(*(i.second))), eventList, visitedEdges);
311-
this->elsFSM.addInitialState((dynamic_cast<ELSState &>(*(i.second))));
310+
auto s = dynamic_cast<IOAStateRef>(i);
311+
prepareMatrices(*s, eventList, visitedEdges);
312+
auto sr = this->elsFSM.getStateLabeled(s->getLabel());
313+
this->elsFSM.addInitialState(*sr);
312314
}
313-
const auto &I3 = dynamic_cast<const IOASetOfStates &>(this->ioa->getFinalStates());
315+
const auto &I3 = this->ioa->getFinalStates();
314316
for (const auto &i : I3) {
315-
this->elsFSM.addFinalState((dynamic_cast<ELSState &>(*(i.second))));
317+
auto s = dynamic_cast<IOAStateRef>(i);
318+
this->elsFSM.addFinalState(*this->elsFSM.getStateLabeled(s->getLabel()));
316319
}
317320
return SMPLS::convertToMaxPlusAutomaton();
318321
}
@@ -369,7 +372,7 @@ Event SMPLSwithEvents::findEventByMode(const Mode &mode) const {
369372
void SMPLSwithEvents::prepareMatrices(const IOAState &s,
370373
std::multiset<Event> &eventList,
371374
IOASetOfEdgeRefs &visitedEdges) {
372-
const auto &adj = dynamic_cast<const IOASetOfEdgeRefs &>(s.getOutgoingEdges());
375+
const auto &adj = s.getOutgoingEdges();
373376
for (const auto *i : adj) {
374377
const auto *e = dynamic_cast<IOAEdgeRef>(i);
375378
if (visitedEdges.count(e) > 0) {
@@ -551,7 +554,7 @@ SMPLSwithEvents::findDissectedModeMatrix(const MPString &sName) {
551554
*/
552555
void SMPLSwithEvents::isConsistentUtil(const IOAState &s,
553556
EventList &eventList,
554-
const IOASetOfStates &finalStates,
557+
const FSM::Abstract::SetOfStateRefs &finalStates,
555558
MPString &errMsg,
556559
std::map<IOAStateRef, EventList> &visited) {
557560
auto it = visited.find(&s);
@@ -567,15 +570,15 @@ void SMPLSwithEvents::isConsistentUtil(const IOAState &s,
567570
}
568571
visited.emplace(&s, eventList);
569572

570-
if (finalStates.count(s.getLabel()) > 0) {
573+
if (finalStates.count(&s) > 0) {
571574
if (!eventList.empty()) {
572575
errMsg = "Event " + (*eventList.begin())
573576
+ " has not been processed by the end of the word.\r\n";
574577
return;
575578
}
576579
} else // If current state is not final
577580
{
578-
const auto &adj = dynamic_cast<const IOASetOfEdgeRefs &>(s.getOutgoingEdges());
581+
const auto &adj = s.getOutgoingEdges();
579582
for (const auto *i : adj) {
580583
// make a copy so that child node can not modify the parent nodes list
581584
// only adds and removes and passes it to its children
@@ -637,7 +640,7 @@ void SMPLSwithEvents::isConsistentUtil(const IOAState &s,
637640
*/
638641
void SMPLSwithEvents::determinizeUtil(const IOAState &s,
639642
IOASetOfStateRefs &visited,
640-
const IOASetOfStateRefs &finalStates,
643+
const FSM::Abstract::SetOfStateRefs &finalStates,
641644
MPString &errMsg,
642645
std::ofstream &outfile) {
643646
/**

0 commit comments

Comments
 (0)