30 std::map< std::pair<Idx,Idx>,
Idx> cmap;
33 if(&rResGen== &rGen1 || &rResGen== &rGen2) {
34 pResGen= rResGen.
New();
37 Parallel(rGen1, rGen2, cmap, *pResGen);
39 if(pResGen != &rResGen) {
40 pResGen->
Move(rResGen);
58 if(&rResGen== &rGen1 || &rResGen== &rGen2) {
59 pResGen= rResGen.
New();
72 if(pResGen != &rResGen) {
73 pResGen->
Move(rResGen);
90 if(!rGenVec.
At(i).Alphabet().EqualAttributes(rGenVec.
At(j).Alphabet()))
94 if(rGenVec.
Size()==0) {
99 if(rGenVec.
Size()==1) {
100 rResGen=rGenVec.
At(0);
130 if(&rResGen== &rGen1 || &rResGen== &rGen2) {
131 pResGen= rResGen.
New();
144 if(pResGen != &rResGen) {
145 pResGen->
Move(rResGen);
172 Parallel(rGen1,rGen2,rCompositionMap,rResGen);
195 StateSet::Iterator sit;
208 std::map< std::pair<Idx,Idx>,
Idx>& rCompositionMap,
211 FD_DF(
"Parallel(" << &rGen1 <<
"," << &rGen2 <<
")");
243 if(&rResGen== &rGen1 || &rResGen== &rGen2) {
244 pResGen= rResGen.
New();
248 rCompositionMap.clear();
251 EventSet::Iterator eit;
258 FD_DF(
"Parallel: inserted indices in rResGen.alphabet( "
263 FD_DF(
"Parallel: shared events: " << sharedalphabet.ToString());
266 std::stack< std::pair<Idx,Idx> > todo;
268 std::pair<Idx,Idx> currentstates, newstates;
271 StateSet::Iterator lit1, lit2;
273 std::map< std::pair<Idx,Idx>,
Idx>::iterator rcit;
276 FD_DF(
"Parallel: adding all combinations of initial states to todo:");
279 currentstates = std::make_pair(*lit1, *lit2);
280 todo.push(currentstates);
282 rCompositionMap[currentstates] = tmpstate;
283 FD_DF(
"Parallel: (" << *lit1 <<
"|" << *lit2 <<
") -> "
284 << rCompositionMap[currentstates]);
289 FD_DF(
"Parallel: processing reachable states:");
290 while (! todo.empty()) {
294 FD_WPC(rCompositionMap.size(),rCompositionMap.size()+todo.size(),
"Parallel(): processing");
296 currentstates = todo.top();
298 FD_DF(
"Parallel: processing (" << currentstates.first <<
"|"
299 << currentstates.second <<
") -> "
300 << rCompositionMap[currentstates]);
305 for (; tit1 != tit1_end; ++tit1) {
307 if (! sharedalphabet.Exists(tit1->Ev)) {
308 FD_DF(
"Parallel: exists only in rGen1");
309 newstates = std::make_pair(tit1->X2, currentstates.second);
311 rcit = rCompositionMap.find(newstates);
312 if (rcit == rCompositionMap.end()) {
313 todo.push(newstates);
315 rCompositionMap[newstates] = tmpstate;
316 FD_DF(
"Parallel: todo push: (" << newstates.first <<
"|"
317 << newstates.second <<
") -> "
318 << rCompositionMap[newstates]);
321 tmpstate = rcit->second;
323 pResGen->
SetTransition(rCompositionMap[currentstates], tit1->Ev, tmpstate);
324 FD_DF(
"Parallel: add transition to new generator: "
325 << rCompositionMap[currentstates] <<
"-" << tit1->Ev <<
"-"
330 FD_DF(
"Parallel: common event");
333 tit2_end = rGen2.
TransRelEnd(currentstates.second, tit1->Ev);
334 for (; tit2 != tit2_end; ++tit2) {
335 newstates = std::make_pair(tit1->X2, tit2->X2);
337 rcit = rCompositionMap.find(newstates);
338 if (rcit == rCompositionMap.end()) {
339 todo.push(newstates);
341 rCompositionMap[newstates] = tmpstate;
342 FD_DF(
"Parallel: todo push: (" << newstates.first <<
"|"
343 << newstates.second <<
") -> "
344 << rCompositionMap[newstates]);
347 tmpstate = rcit->second;
351 FD_DF(
"Parallel: add transition to new generator: "
352 << rCompositionMap[currentstates] <<
"-"
353 << tit1->Ev <<
"-" << tmpstate);
360 tit2_end = rGen2.
TransRelEnd(currentstates.second);
361 for (; tit2 != tit2_end; ++tit2) {
362 if (! sharedalphabet.Exists(tit2->Ev)) {
363 FD_DF(
"Parallel: exists only in rGen2");
364 newstates = std::make_pair(currentstates.first, tit2->X2);
366 rcit = rCompositionMap.find(newstates);
367 if (rcit == rCompositionMap.end()) {
368 todo.push(newstates);
370 rCompositionMap[newstates] = tmpstate;
371 FD_DF(
"Parallel: todo push: (" << newstates.first <<
"|"
372 << newstates.second <<
") -> "
373 << rCompositionMap[newstates]);
376 tmpstate = rcit->second;
380 FD_DF(
"Parallel: add transition to new generator: "
381 << rCompositionMap[currentstates] <<
"-"
382 << tit2->Ev <<
"-" << tmpstate);
392 currentstates = std::make_pair(*lit1, *lit2);
393 rcit = rCompositionMap.find(currentstates);
394 if (rcit != rCompositionMap.end()) {
399 FD_DF(
"Parallel: marked states: "
402 if(pResGen != &rResGen) {
416 std::map< std::pair<Idx,Idx>,
Idx> cmap;
418 Product(rGen1, rGen2, cmap, rResGen);
434 if(&rResGen== &rGen1 || &rResGen== &rGen2) {
435 pResGen= rResGen.
New();
448 if(pResGen != &rResGen) {
449 pResGen->
Move(rResGen);
468 if(&rResGen== &rGen1 || &rResGen== &rGen2) {
469 pResGen= rResGen.
New();
482 if(pResGen != &rResGen) {
483 pResGen->
Move(rResGen);
492 std::map< std::pair<Idx,Idx>,
Idx>& rCompositionMap,
499 Product(rGen1,rGen2,rCompositionMap,rResGen);
506 std::map< std::pair<Idx,Idx>,
Idx>::iterator rit;
507 for(rit=rCompositionMap.begin(); rit!=rCompositionMap.end(); ++rit){
517 std::map< std::pair<Idx,Idx>,
Idx>& rCompositionMap,
520 FD_DF(
"Product(" << &rGen1 <<
"," << &rGen2 <<
")");
524 if(&rResGen== &rGen1 || &rResGen== &rGen2) {
525 pResGen= rResGen.
New();
528 rCompositionMap.clear();
532 FD_DF(
"Product: shared alphabet: "
536 std::stack< std::pair<Idx,Idx> > todo;
538 std::pair<Idx,Idx> currentstates, newstates;
542 StateSet::Iterator lit1, lit2;
544 std::map< std::pair<Idx,Idx>,
Idx>::iterator rcit;
547 FD_DF(
"Product: adding all combinations of initial states to todo:");
552 currentstates = std::make_pair(*lit1, *lit2);
553 todo.push(currentstates);
554 rCompositionMap[currentstates] = pResGen->
InsInitState();
555 FD_DF(
"Product: (" << *lit1 <<
"|" << *lit2 <<
") -> "
556 << rCompositionMap[currentstates]);
561 FD_DF(
"Product: processing reachable states:");
562 while (! todo.empty()) {
566 FD_WPC(rCompositionMap.size(),rCompositionMap.size()+todo.size(),
"Product(): processing");
568 currentstates = todo.top();
570 FD_DF(
"Product: processing (" << currentstates.first <<
"|"
571 << currentstates.second <<
") -> " << rCompositionMap[currentstates]);
576 tit2_end = rGen2.
TransRelEnd(currentstates.second);
577 while((tit1 != tit1_end) && (tit2 != tit2_end)) {
579 if(tit1->Ev < tit2->Ev) {
584 if(tit1->Ev > tit2->Ev) {
590 while(tit2 != tit2_end) {
592 if(tit1->Ev != tit2->Ev)
break;
594 newstates = std::make_pair(tit1->X2, tit2->X2);
596 rcit = rCompositionMap.find(newstates);
597 if(rcit == rCompositionMap.end()) {
598 todo.push(newstates);
600 rCompositionMap[newstates] = tmpstate;
601 FD_DF(
"Product: todo push: (" << newstates.first <<
"|"
602 << newstates.second <<
") -> " << rCompositionMap[newstates]);
604 tmpstate = rcit->second;
607 pResGen->
SetTransition(rCompositionMap[currentstates], tit1->Ev, tmpstate);
608 FD_DF(
"Product: add transition to new generator: "
609 << rCompositionMap[currentstates] <<
"-" << tit1->Ev <<
"-" << tmpstate);
616 if(tit1->Ev == tit2_begin->Ev)
626 currentstates = std::make_pair(*lit1, *lit2);
627 rcit = rCompositionMap.find(currentstates);
628 if (rcit != rCompositionMap.end()) {
636 if(pResGen != &rResGen) {
653 const std::map< std::pair<Idx,Idx>,
Idx>& rCompositionMap,
656 std::map< std::pair<Idx,Idx>,
Idx>::const_iterator rcit;
657 for(rcit=rCompositionMap.begin(); rcit!=rCompositionMap.end(); rcit++) {
658 Idx x1=rcit->first.first;
659 Idx x2=rcit->first.second;
660 Idx x12=rcit->second;
666 std::string name12= name1 +
"|" + name2;
675 const std::map< std::pair<Idx,Idx>,
Idx>& rCompositionMap,
676 std::map<Idx,Idx>& rCompositionMap1)
678 rCompositionMap1.clear();
679 std::map< std::pair<Idx,Idx>,
Idx>::const_iterator rcit;
680 for(rcit=rCompositionMap.begin(); rcit!=rCompositionMap.end(); rcit++)
681 rCompositionMap1.insert(std::pair<Idx,Idx>(rcit->second,rcit->first.first));
687 const std::map< std::pair<Idx,Idx>,
Idx>& rCompositionMap,
688 std::map<Idx,Idx>& rCompositionMap2)
690 rCompositionMap2.clear();
691 std::map< std::pair<Idx,Idx>,
Idx>::const_iterator rcit;
692 for(rcit=rCompositionMap.begin(); rcit!=rCompositionMap.end(); rcit++)
693 rCompositionMap2.insert(std::pair<Idx,Idx>(rcit->second,rcit->first.second));
758 std::pair<Idx,Idx> x12(x1,x2);
761 return x12it->second;
769 std::map< std::pair<Idx,Idx>,
Idx>::const_iterator rcit;
771 mArg1Map.insert(std::pair<Idx,Idx>(rcit->second,rcit->first.first));
772 mArg2Map.insert(std::pair<Idx,Idx>(rcit->second,rcit->first.second));
776 std::map< Idx , Idx >::const_iterator x1it=
mArg1Map.find(x1);
786 std::map< std::pair<Idx,Idx>,
Idx>::const_iterator rcit;
788 mArg1Map.insert(std::pair<Idx,Idx>(rcit->second,rcit->first.first));
789 mArg2Map.insert(std::pair<Idx,Idx>(rcit->second,rcit->first.second));
793 std::map< Idx , Idx >::const_iterator x2it=
mArg2Map.find(x2);