22 std::string& rReportStr)
24 FD_DF(
"IsHioConstraintForm("<< rHioConstraint.
Name() <<
",...)");
31 rErrEvSet.
Name(
"rErrEvSet");
34 rErrTrSet.
Name(
"rErrTrSet");
37 rErrStSet.
Name(
"rErrStSet");
46 bool finalResult =
true;
48 bool localResult =
true;
59 EventSet::Iterator evit;
60 StateSet::Iterator sit;
64 rReportStr.append(
"#########################################################\n");
65 rReportStr.append(
"########## IsHioConstraintForm("+rHioConstraint.
Name()+
",...) - test results:\n");
70 rReportStr.append(
"##### fail: generator is not deterministic!\n");
71 if(initStates.
Size()>1) {
72 rErrStSet = initStates;
73 rReportStr.append(
"##### (amongst others, there is more than one initial state)\n");
78 rReportStr.append(
"#####\n");
84 rReportStr.append(
"########## Condition (i):\n");
88 rReportStr.append(
"##### fail: empty Y alphabet.\n");
93 rReportStr.append(
"##### fail: empty U alphabet.\n");
103 rReportStr.append(
"##### Condition (i) passed.\n");
104 rReportStr.append(
"#####\n");
110 rReportStr.append(
"########## Condition (ii):\n");
113 for(sit = accessibleStates.
Begin(); sit != accessibleStates.
End(); ++sit) {
117 bool goodState =
true;
121 if(activeEv.
Empty()) {
128 evit = activeEv.
Begin();
129 isY = rHioConstraint.
IsY(*evit);
130 isU = rHioConstraint.
IsU(*evit);
132 for(; evit != activeEv.
End(); evit++) {
133 if( (isY && !rHioConstraint.
IsY(*evit)) ||
134 (isU && !rHioConstraint.
IsU(*evit))) {
147 if(!goodState)
continue;
152 rHioConstraint.
SetQY(*sit);
156 rHioConstraint.
SetQU(*sit);
161 if(localResult) rReportStr.append(
"##### Condition (ii) passed.\n");
164 rReportStr.append(
"##### fail: found states with undecidable attribute:\n");
165 rReportStr.append(locErrStSet.
ToString()+
"\n");
167 rReportStr.append(
"##### Condition (ii) failed.\n");
168 rReportStr.append(
"########## Termination due to crucial failure. ##########\n");
169 rReportStr.append(
"###################### No success. ######################\n");
170 rReportStr.append(
"#########################################################\n");
173 rReportStr.append(
"#####\n");
179 rReportStr.append(
"########## Condition (iii):\n");
182 if(!(initStates <= rQY)) {
183 rReportStr.append(
"##### fail: some init state(s) is (are) not a QY-state:\n");
184 locErrStSet=initStates-rQY;
185 rReportStr.append(locErrStSet.
ToString()+
"\n");
191 if(localResult) rReportStr.append(
"##### Condition (iii) passed.\n");
192 else rReportStr.append(
"##### Condition (iii) failed.\n");
193 rReportStr.append(
"#####\n");
200 rReportStr.append(
"########## Condition (iv):\n");
203 for(sit = rQY.
Begin(); sit != rQY.
End(); ++sit) {
206 if( (rHioConstraint.
IsY(tit->Ev) && !rQU.
Exists(tit->X2)) ) {
216 if(localResult) rReportStr.append(
"##### Condition (iv) passed.\n");
218 rReportStr.append(
"##### fail: found Y-transitions leading to wrong states:\n");
219 rReportStr.append(locErrTrSet.
ToString()+
"\n");
221 rReportStr.append(
"##### Condition (iv) failed.\n");
223 rReportStr.append(
"#####\n");
229 rReportStr.append(
"########## Condition (v):\n");
232 for(sit = rQU.
Begin(); sit != rQU.
End(); ++sit) {
234 if(!rQY.
Exists(tit->X2)) {
243 if(localResult) rReportStr.append(
"##### Condition (v) passed.\n");
245 rReportStr.append(
"##### fail: found U-transitions leading to wrong states:\n");
246 rReportStr.append(locErrTrSet.
ToString()+
"\n");
248 rReportStr.append(
"##### Condition (v) failed.\n");
250 rReportStr.append(
"#####\n");
256 rReportStr.append(
"########## Condition (vi):\n");
259 for(sit = rQY.
Begin(); sit != rQY.
End(); ++sit) {
269 if(localResult) rReportStr.append(
"##### Condition (vi) passed.\n");
271 rReportStr.append(
"##### fail: found QY-states with inactive Y-events:\n");
272 rReportStr.append(locErrStSet.
ToString()+
"\n");
274 rReportStr.append(
"##### Condition (vi) failed.\n");
276 rReportStr.append(
"#####\n");
282 rReportStr.append(
"########## Condition (vii):\n");
285 if(!deadEnds.
Empty()) {
289 rReportStr.append(
"##### fail: found dead ends:\n");
290 rReportStr.append(deadEnds.
ToString()+
"\n");
292 rReportStr.append(
"##### Condition (vii) failed.\n");
294 rReportStr.append(
"##### Condition (vii) passed.\n");
300 rReportStr.append(
"########## Condition (viii):\n");
303 if(!(accessibleStates<=rHioConstraint.
MarkedStates())) {
308 if(localResult) rReportStr.append(
"##### Condition (viii) passed.\n");
310 rReportStr.append(
"##### fail: not all accessible states are marked:\n");
311 locErrStSet=accessibleStates - rHioConstraint.
MarkedStates();
313 rReportStr.append(locErrStSet.
ToString()+
"\n");
315 rReportStr.append(
"##### Condition (viii) failed.\n");
317 rReportStr.append(
"#####\n");
322 rReportStr.append(
"########## Condition (ix):\n");
327 rReportStr.append(
"##### warning: non-accessible states have been removed.\n");
328 rReportStr.append(
"##### Condition (ix) repaired.\n");
330 else rReportStr.append(
"##### Condition (ix) passed.\n");
337 rReportStr.append(
"##################### Final result: #####################\n");
339 rReportStr.append(
"############ Generator is in HioConstraintForm. ###########\n");
340 rReportStr.append(
"#########################################################\n");
344 rReportStr.append(
"############## Generator is NOT in HioConstraintForm. ##############\n");
345 rReportStr.append(
"#########################################################\n");
359 return IsHioConstraintForm(rHioConstraint, rQY, rQU, rErrEvSet, rErrTrSet, rErrStSet,rReportStr);
368 std::string rReportStr;
370 return IsHioConstraintForm(rHioConstraint, rQY, rQU, rErrEvSet, rErrTrSet, rErrStSet, rReportStr);
#define FD_DF(message)
Debug: optional report on user functions.
Idx Insert(void)
Insert new index to set.
Set of indices with symbolic names.
bool IsU(Idx index) const
Is event U-event(by index)
bool IsY(Idx index) const
Is event Y-event(by index)
EventSet UEvents(void) const
Get EventSet with U-events.
void SetQU(Idx index)
Mark event as QU-state (by index)
void SetQY(Idx index)
Mark event as QY-state (by index)
EventSet YEvents(void) const
Get EventSet with Y-events.
bool Insert(const Transition &rTransition)
Add a Transition.
TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator
Iterator on transition.
std::string ToString(const std::string &rLabel="", const Type *pContext=0) const
Write configuration data to a string.
const StateSet & MarkedStates(void) const
Return const ref of marked states.
EventSet ActiveEventSet(Idx x1) const
Return active event set at state x1.
const StateSet & InitStates(void) const
Const ref to initial states.
TransSet::Iterator TransRelBegin(void) const
Iterator to Begin() of transition relation.
bool Accessible(void)
Make generator accessible.
bool IsAccessible(void) const
Check if generator is accessible.
StateSet AccessibleSet(void) const
Compute set of accessible states.
void Name(const std::string &rName)
Set the generator's name.
TransSet::Iterator TransRelEnd(void) const
Iterator to End() of transition relation.
bool IsDeterministic(void) const
Check if generator is deterministic.
bool Empty(void) const
Test whether if the TBaseSet is Empty.
bool Exists(const T &rElem) const
Test existence of element.
virtual void Clear(void)
Clear all set.
Iterator End(void) const
Iterator to the end of set.
virtual void InsertSet(const TBaseSet &rOtherSet)
Insert elements given by rOtherSet.
Iterator Begin(void) const
Iterator to the begin of set.
const std::string & Name(void) const
Return name of TBaseSet.
Idx Size(void) const
Get Size of TBaseSet.
Generator with I/O-constraint attributes.
libFAUDES resides within the namespace faudes.
bool IsHioConstraintForm(HioConstraint &rHioConstraint, StateSet &rQY, StateSet &rQU, EventSet &rErrEvSet, TransSet &rErrTrSet, StateSet &rErrStSet, std::string &rReportStr)
IsHioConstraintForm: check if rHioConstraint is in I/O-constraint form and assign state attributes.
void HioStatePartition(HioConstraint &rHioConstraint)
Function definition for run-time interface.