Skip to content

Commit fa4f2fa

Browse files
committed
Preliminar implementation of new Tearing algorithm
1 parent a77b662 commit fa4f2fa

2 files changed

Lines changed: 29 additions & 27 deletions

File tree

algorithms/tearing/tearing.cpp

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -231,38 +231,39 @@ void Tearing::restoreSBG()
231231
mapB_ = dsbg_.mapB();
232232
mapD_ = dsbg_.mapD();
233233
}
234-
234+
PWMap Tearing::calculateSCC()
235+
{
236+
PWMap rmap = sccStep();
237+
do {
238+
rmap = sccStep();
239+
} while (Ediff() != fact_.createSet());
240+
return rmap.compact();
241+
}
235242
PWMap Tearing::calculate()
236243
{
237244
if (debug()) Util::SBG_LOG << "Tearing dsbg: \n" << dsbg() << "\n\n";
238245

239246
auto begin = std::chrono::high_resolution_clock::now();
240-
PWMap rmap = sccStep();
241247
Set vrem = fact_.createSet();
242-
Set e_scc = fact_.createSet();
243-
do {
244-
// SCC
245-
do {
246-
rmap = sccStep();
247-
} while (Ediff() != fact_.createSet());
248-
//
249-
e_scc = E();
250-
if (E() != fact_.createSet()) {
251-
Set erem_b = mapB().preImage(rmap.image());
252-
Set erem_d = mapD().preImage(rmap.image());
253-
vrem = vrem.cup(mapB().image(erem_b)).cup(mapD().image(erem_d));
254-
E_ = E().difference(erem_b.cup(erem_d));
255-
}
256-
rmap_ = rmap.compact();
257-
} while (E() != fact_.createSet());
258-
restoreSBG();
259-
Set e_notscc = E().difference(e_scc);
260-
Set e_to_R = mapD().preImage(rmap.image());
261-
PWMap mapD_notscc = mapD().restrict(e_to_R);
262-
263-
Set erem = e_scc.intersection(mapB().preImage(vrem));
264-
Set mapD_aux = mapD().image(erem);
265-
248+
Set e_notscc = dsbg().E();
249+
MD_NAT maxOffset = V().maxElem();
250+
PWMap rmap = calculateSCC();
251+
PWMap tearIOMap_ = fact_.createPWMap();
252+
rmap_ = rmap;
253+
254+
while (!E().isEmpty()) {
255+
Set e_scc = E();
256+
Set e_noscc = e_notscc.difference(e_scc);
257+
Set v_tear = rmap.image();
258+
PWMap tearIOMap = fact_.createPWMap(v_tear).offsetImage(maxOffset);
259+
tearIOMap_ = tearIOMap.combine(tearIOMap_);
260+
PWMap mapB_scc = mapB().restrict(e_scc).composition(rmap);
261+
PWMap mapB_noscc = mapB().restrict(e_noscc).composition(rmap).composition(tearIOMap);
262+
PWMap mapD_scc = mapD().restrict(e_scc).composition(rmap).composition(tearIOMap);
263+
PWMap mapD_noscc = mapD().restrict(e_noscc).composition(rmap);
264+
// combine wit mapB and mapD
265+
rmap = calculateSCC();
266+
}
266267
auto end = std::chrono::high_resolution_clock::now();
267268

268269
auto total = std::chrono::duration_cast<std::chrono::microseconds>(end - begin);
@@ -275,7 +276,7 @@ PWMap Tearing::calculate()
275276
E().print(std::cout);
276277
}
277278

278-
return rmap.compact();
279+
return rmap_;
279280
}
280281

281282
const PWMapAF &Tearing::fact() const { return fact_; }

algorithms/tearing/tearing.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct Tearing {
6868
private:
6969
PWMap sccMinReach(const DSBG &dg) const;
7070
PWMap sccStep();
71+
PWMap calculateSCC();
7172
void restoreSBG();
7273
};
7374

0 commit comments

Comments
 (0)