Transcript ppt
ECE 465
Petrick’s Algorithm for 2-level
Minimization
Shantanu Dutt
University of Illinois at Chicago
Acknowledgement: Transcribed to Powerpoint by Huan Ren from
Prof. Shantanu Dutt’s handwritten notes
Petrick’s Algorithm for Choosing
Minimal Cost cover
The PIT portion of Q-M can get optimal in most
cases and near-optimal cost coverings, but will
not be optimal in all cases.
Can use an algebraic method called Petrick’s
algorithm.
Petrick’s Algorithm
1. Obtain all PIs using Q-M.
2. Create a PIT and remove all EPIs and corresponding columns (MTs).
3. Write a POS expr. representing all possible covers of remaining MTs
a) For each MT mi write an expr. C(mi) that is the sum/OR of all PIs
that cover it --- the PIs are the variables in this expression.
b) Form a POS expression C that is the product/AND of all C(mi)’s --this indicates that all MTs need to be covered.
4. Convert the POS expr. to SOP using the distr. law. Use involution and
absorption to simplify ((a*a=a, a+a=a) (a+ab=a))—note that these
minimization rules come about in this problem from concepts of nonreplication and lower cost soln. than strictly from Boolean algebra.
Each product term in the SOP expr. represents one possible cover
(Note: correct functional expression = sum of the PIs in the product term).
5. Select the cover with the lowest cost.
total # of literals + # of PIs
Petrick’s Algorithm (Contd.)
Example 1
Cost PIs
2+1
PI1
3+1
PI2
3+1
PI3
3+1
PI4
3+1
PI5
3+1
PI6
1
2
3
4
5
6
9
11
Note: Actual Soln. = sum of Pis in
the chosen min-cost product term in
C = PI1 + PI3 + PI5
Minimal solution
Cost=8 +3
PI1 PI2 PI1 PI4 PI5 PI3
+ + + + + +
PI6 PI3 PI2 PI5 PI6 PI4
Cost=9 +3
Absorb
X’s
C=(PI1+PI2PI6)(PI5+PI4PI6)(PI3+PI2PI4)
=(PI1PI5+PI1PI4PI6+PI2PI5PI6+PI2PI4PI6)(PI3+PI2 PI4)
PI1PI3PI5+PI2PI4PI6+PI1PI3PI4PI6
+PI2PI3PI5PI6+PI1PI2PI4PI5+
PI2PI3PI4PI6+PI1PI2PI4PI6+
PI2PI4 PI5PI6
Petrick’s Algorithm (Contd.)
Exercise: Use this algorithm to obtain the least
cost cover for the example in which we used the
max. MT covering heuristic to get the minimal
solution.
Petrick’s Algorithm (Contd.)
Computational complexity of Petrick’s algorithm is very high
If m =# of MTs n = # of vars,
pi = # of PIs covering MTi,
pav = avg # of PIs covering a MT
pi O(2n )
Since MTi=an-1…..a0, a PI covering MTi will have X
some positions j. Can choose, say, n/2 X’s with in
n
n 1
2 ways, w/ each way not covering any other
n / 2
way, i.e., each way is a PI covering MTi
The time complexity T for generating product terms in C = Pi=1m pi
T = O(2nm = O(2n*2**n))
Or T = O((pav)m ) = O((pav)2**n))
For n=8, let us choose pav = 2n-3, m=2n-3, which are reasonable values T = O((pav)2**n-3)) =
O(2160) worst-case # of basic operations to gen. the reqd. product terms in C
1 trillion=240 T= trillion trillion trillion trillion operations (in the worst case)
If each oper takes 1 ns, time taken can be 2130 ~ 1k trillion trillion trillion secs ~ 317k trillion
trillion centuries! (in the worst case)
QM PIT (Covering Stage) Complexity
If m =# of MTs n = # of vars, pi = # of PIs covering MTi,
pav = avg # of PIs covering a MT, p = total # of PIs
• The time taken to determine row covering is O(mp2) (look at all PI pairs—naïve
method, and each pair takes O(m) time to determine if there is covering betw. them)
• Similarly, O(m2p) for determining column covering relations
• If after every row covering, we detect an EPI, or if we detect a col. covering, we
reduce # of MTs by at least 1; so we would require m iterations, and thus O(max(m2p2,
m3p) time until all MTs are covered.
• Or, we do not get any EPIs or col. covering until we do lots of row coverings until
finally 1 PI is left that covers all MTs (worst case). This will take p iterations, and thus a
total time of O(max(mp3, m2p2)).
• So overall complexity (using no appropriate data structures) is O(max(p3m, mp3))
(m2p2 < p3m or m2p2 < m3p).
• Compare this to O((pav)m) ~ O((p/m)m) for Petrick’s, and we see that QM is much less
complex (m appears as an exponent in Petrick’s as opposed to as the base of a loworder polynomial in QM).
Graphical comparison of Petrick’s and QM’s time complexities
• As can be seen, Petrick’s run-time quickly becomes huge and impractical for n > 7, while QM’s is much more
reasonable and thus could potentially be used in a CAD tool.
• Further, as we have seen, besides the cyclic PIT scenario, QM’s non-optimality stems from the infrequent
case of “bad” row covering (cost(covering PI) > cost(covered PI), which is partly alleviated by QM+ (has same
complexity as QM) Thus on the average, QM/QM+ produces good (near-optimal) solutions.
• Thus overall, QM /QM+ is a very good and practical algorithm to use for, say, n > 5.