59 pcube RAISE, FREESET, INIT_LOWER, SUPER_CUBE, OVEREXPANDED_CUBE;
78 for(var = 0; var < cube.num_vars; var++)
80 (void)
set_or(INIT_LOWER, INIT_LOWER, cube.var_mask[var]);
94 expand1(R, F, RAISE, FREESET, OVEREXPANDED_CUBE, SUPER_CUBE,
95 INIT_LOWER, &num_covered, p);
97 printf(
"EXPAND: %s (covered %d)\n",
pc1(p), num_covered);
103 if (num_covered == 0 && !
setp_equal(p, OVEREXPANDED_CUBE)) {
135 void expand1(BB, CC, RAISE, FREESET, OVEREXPANDED_CUBE, SUPER_CUBE,
136 INIT_LOWER, num_covered, c)
141 pcube OVEREXPANDED_CUBE;
150 printf(
"\nEXPAND1: \t%s\n",
pc1(c));
162 (void)
set_diff(FREESET, cube.fullset, RAISE);
166 (void)
set_diff(FREESET, FREESET, INIT_LOWER);
172 (void)
set_or(OVEREXPANDED_CUBE, RAISE, FREESET);
175 if (CC->active_count > 0) {
180 while (CC->active_count > 0) {
189 while (BB->active_count > 0) {
190 mincov(BB, RAISE, FREESET);
194 (void)
set_or(RAISE, RAISE, FREESET);
212 pcube RAISE, FREESET;
214 register pcube p, r = RAISE;
215 pcube lastp, xlower = cube.temp[0];
218 (void)
set_copy(xlower, cube.emptyset);
222 if ((dist =
cdist01(p, r)) > 1)
goto exit_if;
224 {
register int w,last;
register unsigned int x;dist=0;
if((last=cube.inword)!=-1)
225 {x=p[last]&r[last];
if((x=~(x|x>>1)&cube.inmask))
if((dist=
count_ones(x))>1)
goto
226 exit_if;
for(w=1;w<last;w++){x=p[w]&r[w];
if((x=~(x|x>>1)&
DISJOINT))
if(dist==1||(
228 mask;
for(var=cube.num_binary_vars;var<cube.num_vars;var++){mask=cube.var_mask[
229 var];last=cube.last_word[
var];
for(w=cube.first_word[var];w<=last;w++)
if(p[w]&r[
230 w]&mask[w])
goto nextvar;
if(++dist>1)
goto exit_if;nextvar:;}}
233 fatal(
"ON-set and OFF-set are not orthogonal");
243 (void)
set_diff(FREESET, FREESET, xlower);
248 printf(
"ESSEN_PARTS:\tRAISE=%s FREESET=%s\n",
pc1(RAISE),
pc2(FREESET));
261 pcube RAISE, FREESET;
263 register pcube last,
p, xraise = cube.temp[0];
266 (void)
set_copy(xraise, cube.emptyset);
269 (void)
set_diff(xraise, FREESET, xraise);
271 (void)
set_or(RAISE, RAISE, xraise);
272 (void)
set_diff(FREESET, FREESET, xraise);
275 printf(
"ESSEN_RAISING:\tRAISE=%s FREESET=%s\n",
276 pc1(RAISE),
pc2(FREESET));
290 pcube RAISE, FREESET;
292 register pcube p, r =
set_or(cube.temp[0], RAISE, FREESET);
302 {
register int w,lastw;
register unsigned int x;
if((lastw=cube.inword)!=-1){x=p[
303 lastw]&r[lastw];
if(~(x|x>>1)&cube.inmask)
goto false;
for(w=1;w<lastw;w++){x=p[w]
304 &r[w];
if(~(x|x>>1)&
DISJOINT)
goto false;}}}{
register int w,
var,lastw;
register
305 pcube mask;
for(var=cube.num_binary_vars;var<cube.num_vars;var++){mask=cube.
306 var_mask[
var];lastw=cube.last_word[
var];
for(w=cube.first_word[var];w<=lastw;w++)
307 if(p[w]&r[w]&mask[w])
goto nextvar;
goto false;nextvar:;}}
continue;
false:
316 if (CC != (
pcover) NULL) {
342 register int i, best_part, best_count, *count;
343 register pset p, last;
346 count =
ALLOC(
int, cube.size);
347 for(i = 0; i < cube.size; i++)
354 best_count = best_part = -1;
355 for(i = 0; i < cube.size; i++)
356 if (
is_in_set(FREESET,i) && count[i] > best_count) {
358 best_count = count[i];
363 printf(
"MOST_FREQUENT:\tbest=%d FREESET=%s\n", best_part,
pc2(FREESET));
381 BB->active_count = BB->count;
385 if (CC != (
pcover) NULL) {
386 CC->active_count = CC->count;
406 pcube RAISE, FREESET, SUPER_CUBE;
410 register pcube bestfeas = NULL;
411 register pcube *feas;
413 pcube *feas_new_lower;
414 int bestcount, bestsize, count,
size, numfeas, lastfeas;
426 feas_new_lower =
ALLOC(
pcube, CC->active_count);
428 for(i = 0; i < numfeas; i++)
429 feas_new_lower[i] =
GETSET(new_lower, i);
441 for(i = 0; i < lastfeas; i++) {
453 (void)
set_or(SUPER_CUBE, SUPER_CUBE, p);
465 printf(
"SELECT_FEASIBLE: started with %d pfcc, ended with %d fcc\n",
471 FREE(feas_new_lower);
479 for(i = 0; i < numfeas; i++) {
485 for(j = 0; j < numfeas; j++)
489 for(j = 0; j < numfeas; j++)
493 if (count > bestcount) {
497 }
else if (count == bestcount && size < bestsize) {
504 (void)
set_or(RAISE, RAISE, bestfeas);
505 (void)
set_diff(FREESET, FREESET, RAISE);
507 printf(
"FEASIBLE: \tRAISE=%s FREESET=%s\n",
pc1(RAISE),
pc2(FREESET));
523 pcube c, RAISE, new_lower;
532 if ((dist =
cdist01(p, r)) > 1)
goto exit_if;
534 {
register int w,last;
register unsigned int x;dist=0;
if((last=cube.inword)!=-1)
535 {x=p[last]&r[last];
if((x=~(x|x>>1)&cube.inmask))
if((dist=
count_ones(x))>1)
goto
536 exit_if;
for(w=1;w<last;w++){x=p[w]&r[w];
if((x=~(x|x>>1)&
DISJOINT))
if(dist==1||(
538 mask;
for(var=cube.num_binary_vars;var<cube.num_vars;var++){mask=cube.var_mask[
539 var];last=cube.last_word[
var];
for(w=cube.first_word[var];w<=last;w++)
if(p[w]&r[
540 w]&mask[w])
goto nextvar;
if(++dist>1)
goto exit_if;nextvar:;}}
562 pcube RAISE, FREESET;
564 int expansion, nset,
var, dist;
566 register pcube xraise=cube.temp[0], xlower,
p, last, plower;
569 #if defined(_POSIX_SOURCE) || defined(__SVR4)
570 dist = rand() %
set_ord(FREESET);
574 for(var = 0; var < cube.size && dist >= 0; var++) {
596 for(var = cube.num_binary_vars; var < cube.num_vars; var++) {
597 if ((dist=
set_dist(p, cube.var_mask[var])) > 1) {
599 if (expansion > 500)
goto heuristic_mincov;
603 if (nset > 500)
goto heuristic_mincov;
606 B =
unravel(B, cube.num_binary_vars);
611 (void)
set_copy(FREESET, cube.emptyset);
612 BB->active_count = 0;
614 printf(
"MINCOV: \tRAISE=%s FREESET=%s\n",
pc1(RAISE),
pc2(FREESET));
624 (void)
set_diff(FREESET, FREESET, RAISE);
636 register
pcube RAISE, FREESET;
638 register pset last,
p, plower;
641 if (BB->active_count == 0) {
672 register pcube last,
p, RAISE, FREESET;
685 (void)
set_diff(FREESET, cube.fullset, RAISE);
691 Fall_primes =
sf_append(Fall_primes, B1);
int most_frequent(pcover CC, pcube FREESET)
#define INLINEset_diff(r, a, b)
pset_family sf_rev_contain(INOUT pset_family A)
pcover unravel(IN pcover B, IN int start)
#define INLINEsetp_implies(a, b, when_false)
void essen_parts(pcover BB, pcover CC, pcube RAISE, pcube FREESET)
pset_family exact_minimum_cover()
void essen_raising(pcover BB, pcube RAISE, pcube FREESET)
pcover find_all_primes(pcover BB, pcube RAISE, pcube FREESET)
pcover mini_sort(pcover F, int(*compare)())
#define foreach_set(R, last, p)
pcover random_order(pcover F)
#define INLINEset_or(r, a, b)
pcover all_primes(pcover F, pcover R)
void expand1(pcover BB, pcover CC, pcube RAISE, pcube FREESET, pcube OVEREXPANDED_CUBE, pcube SUPER_CUBE, pcube INIT_LOWER, int *num_covered, pcube c)
void setup_BB_CC(pcover BB, pcover CC)
ABC_NAMESPACE_IMPL_START pcover expand(INOUT pcover F, IN pcover R, IN bool nonsparse)
#define ABC_NAMESPACE_IMPL_END
void elim_lowering(pcover BB, pcover CC, pcube RAISE, pcube FREESET)
#define is_in_set(set, e)
void mincov(pcover BB, pcube RAISE, pcube FREESET)
#define foreach_active_set(R, last, p)
#define ABC_NAMESPACE_IMPL_START
#define set_remove(set, e)
pset do_sm_minimum_cover()
#define set_insert(set, e)
#define GETSET(family, index)
bool feasibly_covered(pcover BB, pcube c, pcube RAISE, pcube new_lower)
void select_feasible(pcover BB, pcover CC, pcube RAISE, pcube FREESET, pcube SUPER_CUBE, int *num_covered)
pset_family sf_inactive()