static pset_family do_minimize(pset_family F, pset_family D, pset_family R, int exact_cover, int weighted) { pset_family newF, E, Rt, Rp; pset p, last; int heur, level, *weights; sm_matrix *table; sm_row *cover; sm_element *pe; int debug_save = debug; if (debug & 0x0400) { debug |= (0x0020 | 0x0800); } if (debug & 0x0800) { setlinebuf((&_iob[1])); } level = (debug & 0x0800) ? 4 : 0; heur = ! exact_cover; {long t=util_cpu_time();F = primes_consensus(cube2list(F, D));if(trace)print_trace( F, "PRIMES ",util_cpu_time()-t);}; {long t=util_cpu_time();irred_split_cover(F, D, &E, &Rt, &Rp);if(trace)print_trace( E, "ESSENTIALS ",util_cpu_time()-t);}; {long t=util_cpu_time();table = irred_derive_table(D, E, Rp);if(trace)print_trace( Rp, "PI-TABLE ",util_cpu_time()-t);}; if (weighted) { weights = ((int *) malloc(sizeof(int) * ( F->count))); for( p=Rp->data, last= p+Rp->count*Rp->wsize; p< last; p+=Rp->wsize) { weights[(p[0] >> 16)] = cube.size - set_ord(p); } } else {
static set_family_t * do_minimize(set_family_t *F, set_family_t *D, set_family_t *R, int exact_cover, int weighted) { set_family_t *newF, *E, *Rt, *Rp; set *p, *last; int heur, level, *weights; sm_matrix *table; sm_row *cover; sm_element *pe; int debug_save = debug; if (debug & EXACT) { debug |= (IRRED | MINCOV); } level = (debug & MINCOV) ? 4 : 0; heur = ! exact_cover; // Generate all prime implicants F = primes_consensus(cube2list(F, D)); // Setup the prime implicant table irred_split_cover(F, D, &E, &Rt, &Rp); table = irred_derive_table(D, E, Rp); // Solve either a weighted or nonweighted covering problem if (weighted) { // correct only for all 2-valued variables weights = ALLOC(int, F->count); foreach_set(Rp, last, p) { weights[SIZE(p)] = CUBE.size - set_ord(p); } }
static pcover do_minimize(pset_family F, pset_family D, pset_family R, int exact_cover, int weighted) { pcover newF, E, Rt, Rp; pset p, last; int heur, level, *weights; sm_matrix *table; sm_row *cover; sm_element *pe; int debug_save = debug; if (debug & EXACT) { debug |= (IRRED | MINCOV); } #if defined(sun) || defined(bsd4_2) /* hack ... */ if (debug & MINCOV) { setlinebuf(stdout); } #endif level = (debug & MINCOV) ? 4 : 0; heur = ! exact_cover; /* Generate all prime implicants */ EXEC(F = primes_consensus(cube2list(F, D)), "PRIMES ", F); /* Setup the prime implicant table */ EXEC(irred_split_cover(F, D, &E, &Rt, &Rp), "ESSENTIALS ", E); EXEC(table = irred_derive_table(D, E, Rp), "PI-TABLE ", Rp); /* Solve either a weighted or nonweighted covering problem */ if (weighted) { /* correct only for all 2-valued variables */ weights = ALLOC(int, F->count); foreach_set(Rp, last, p) { weights[SIZE(p)] = cube.size - set_ord(p); } } else {
/* ** Perform a reduce action and the shift that must immediately ** follow the reduce. */ static void yy_reduce( yyParser *yypParser, /* The parser */ int yyruleno /* Number of the rule by which to reduce */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ ParseARG_FETCH; yymsp = &yypParser->yystack[yypParser->yyidx]; #ifndef NDEBUG if( yyTraceFILE && yyruleno>=0 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, yyRuleName[yyruleno]); } #endif /* NDEBUG */ /* Silence complaints from purify about yygotominor being uninitialized ** in some cases when it is copied into the stack after the following ** switch. yygotominor is uninitialized when a rule reduces that does ** not set the value of its left-hand side nonterminal. Leaving the ** value of the nonterminal uninitialized is utterly harmless as long ** as the value is never used. So really the only thing this code ** accomplishes is to quieten purify. ** ** 2007-01-16: The wireshark project (www.wireshark.org) reports that ** without this code, their parser segfaults. I'm not sure what there ** parser is doing to make this happen. This is the second bug report ** from wireshark this week. Clearly they are stressing Lemon in ways ** that it has not been previously stressed... (SQLite ticket #2172) */ /*memset(&yygotominor, 0, sizeof(yygotominor));*/ yygotominor = yyzerominor; switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ case 4: /* decl ::= REPORT TO STR */ #line 22 "cfg.y" {set_report(ps,yymsp[0].minor.yy0);} #line 739 "cfg.c" break; case 5: /* decl ::= LISTEN ON STR */ #line 23 "cfg.y" {set_listen(ps,yymsp[0].minor.yy0);} #line 744 "cfg.c" break; case 6: /* job ::= JOB LCURLY sbody RCURLY */ #line 24 "cfg.y" {push_job(ps);} #line 749 "cfg.c" break; case 9: /* kv ::= NAME STR */ #line 27 "cfg.y" {set_name(ps,yymsp[0].minor.yy0);} #line 754 "cfg.c" break; case 11: /* kv ::= DIR path */ #line 29 "cfg.y" {set_dir(ps,yymsp[0].minor.yy0);} #line 759 "cfg.c" break; case 12: /* kv ::= OUT path */ #line 30 "cfg.y" {set_out(ps,yymsp[0].minor.yy0);} #line 764 "cfg.c" break; case 13: /* kv ::= IN path */ #line 31 "cfg.y" {set_in(ps,yymsp[0].minor.yy0);} #line 769 "cfg.c" break; case 14: /* kv ::= ERR path */ #line 32 "cfg.y" {set_err(ps,yymsp[0].minor.yy0);} #line 774 "cfg.c" break; case 15: /* kv ::= USER STR */ #line 33 "cfg.y" {set_user(ps,yymsp[0].minor.yy0);} #line 779 "cfg.c" break; case 16: /* kv ::= ORDER STR */ #line 34 "cfg.y" {set_ord(ps,yymsp[0].minor.yy0);} #line 784 "cfg.c" break; case 17: /* kv ::= ENV STR */ #line 35 "cfg.y" {set_env(ps,yymsp[0].minor.yy0);} #line 789 "cfg.c" break; case 18: /* kv ::= ULIMIT STR STR */ case 34: /* pairs ::= pairs STR STR */ yytestcase(yyruleno==34); #line 36 "cfg.y" {set_ulimit(ps,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);} #line 795 "cfg.c" break; case 20: /* kv ::= DISABLED */ #line 38 "cfg.y" {set_dis(ps); } #line 800 "cfg.c" break; case 21: /* kv ::= WAIT */ #line 39 "cfg.y" {set_wait(ps); } #line 805 "cfg.c" break; case 22: /* kv ::= ONCE */ #line 40 "cfg.y" {set_once(ps); } #line 810 "cfg.c" break; case 23: /* kv ::= BOUNCE EVERY STR */ #line 41 "cfg.y" {set_bounce(ps,yymsp[0].minor.yy0);} #line 815 "cfg.c" break; case 25: /* cmd ::= path */ #line 43 "cfg.y" {set_cmd(ps,yymsp[0].minor.yy0);} #line 820 "cfg.c" break; case 26: /* cmd ::= path args */ #line 44 "cfg.y" {set_cmd(ps,yymsp[-1].minor.yy0);} #line 825 "cfg.c" break; case 27: /* path ::= STR */ case 30: /* arg ::= STR */ yytestcase(yyruleno==30); #line 45 "cfg.y" {yygotominor.yy0=yymsp[0].minor.yy0;} #line 831 "cfg.c" break; case 28: /* args ::= args arg */ case 29: /* args ::= arg */ yytestcase(yyruleno==29); #line 46 "cfg.y" {utarray_push_back(&ps->job->cmdv,&yymsp[0].minor.yy0);} #line 837 "cfg.c" break; case 31: /* arg ::= QUOTEDSTR */ #line 49 "cfg.y" {yygotominor.yy0=unquote(yymsp[0].minor.yy0);} #line 842 "cfg.c" break; case 32: /* paths ::= paths path */ case 33: /* paths ::= path */ yytestcase(yyruleno==33); #line 50 "cfg.y" {utarray_push_back(&ps->job->depv,&yymsp[0].minor.yy0);} #line 848 "cfg.c" break; default: /* (0) file ::= decls */ yytestcase(yyruleno==0); /* (1) decls ::= decls job */ yytestcase(yyruleno==1); /* (2) decls ::= decls decl */ yytestcase(yyruleno==2); /* (3) decls ::= */ yytestcase(yyruleno==3); /* (7) sbody ::= sbody kv */ yytestcase(yyruleno==7); /* (8) sbody ::= kv */ yytestcase(yyruleno==8); /* (10) kv ::= CMD cmd */ yytestcase(yyruleno==10); /* (19) kv ::= ULIMIT LCURLY pairs RCURLY */ yytestcase(yyruleno==19); /* (24) kv ::= DEPENDS LCURLY paths RCURLY */ yytestcase(yyruleno==24); /* (35) pairs ::= */ yytestcase(yyruleno==35); break; }; yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yypParser->yyidx -= yysize; yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); if( yyact < YYNSTATE ){ #ifdef NDEBUG /* If we are not debugging and the reduce action popped at least ** one element off the stack, then we can push the new element back ** onto the stack here, and skip the stack overflow test in yy_shift(). ** That gives a significant speed improvement. */ if( yysize ){ yypParser->yyidx++; yymsp -= yysize-1; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yymsp->minor = yygotominor; }else #endif { yy_shift(yypParser,yyact,yygoto,&yygotominor); } }else{ assert( yyact == YYNSTATE + YYNRULE + 1 ); yy_accept(yypParser); } }