61 int i, k, Chow0 = 0, nMints = (1 << nVars);
62 memset(pChow, 0,
sizeof(
int) * nVars);
64 for (i = 0; i < nMints; i++)
65 if (Abc_TtGetBit(t, i))
66 for (Chow0++, k = 0; k < nVars; k++)
70 for (k = 0; k < nVars; k++)
71 pChow[k] = 2 * pChow[k] - Chow0;
72 return Chow0 - (1 << (nVars - 1));
162 int m, Lmin, Lmax, nMints = (1 << nVars);
164 for (pW[2] = 1; pW[2] <= nVars; pW[2]++)
165 for (pW[1] = pW[2]; pW[1] <= nVars; pW[1]++)
166 for (pW[0] = pW[1]; pW[0] <= nVars; pW[0]++) {
169 for (m = 0; m < nMints; m++) {
170 if (Abc_TtGetBit(t, m))
171 Lmin = Abc_MinInt(Lmin,
172 Extra_ThreshWeightedSum(pW, nVars, m));
174 Lmax = Abc_MaxInt(Lmax,
175 Extra_ThreshWeightedSum(pW, nVars, m));
189 int m, Lmin, Lmax, nMints = (1 << nVars);
191 for (pW[3] = 1; pW[3] <= nVars; pW[3]++)
192 for (pW[2] = pW[3]; pW[2] <= nVars; pW[2]++)
193 for (pW[1] = pW[2]; pW[1] <= nVars; pW[1]++)
194 for (pW[0] = pW[1]; pW[0] <= nVars; pW[0]++) {
197 for (m = 0; m < nMints; m++) {
198 if (Abc_TtGetBit(t, m))
199 Lmin = Abc_MinInt(Lmin,
200 Extra_ThreshWeightedSum(pW, nVars, m));
202 Lmax = Abc_MaxInt(Lmax,
203 Extra_ThreshWeightedSum(pW, nVars, m));
215 int m, Lmin, Lmax, nMints = (1 << nVars), Limit = nVars + 0;
217 for (pW[4] = 1; pW[4] <= Limit; pW[4]++)
218 for (pW[3] = pW[4]; pW[3] <= Limit; pW[3]++)
219 for (pW[2] = pW[3]; pW[2] <= Limit; pW[2]++)
220 for (pW[1] = pW[2]; pW[1] <= Limit; pW[1]++)
221 for (pW[0] = pW[1]; pW[0] <= Limit; pW[0]++) {
224 for (m = 0; m < nMints; m++) {
225 if (Abc_TtGetBit(t, m))
226 Lmin = Abc_MinInt(Lmin,
227 Extra_ThreshWeightedSum(pW, nVars, m));
229 Lmax = Abc_MaxInt(Lmax,
230 Extra_ThreshWeightedSum(pW, nVars, m));
242 int m, Lmin, Lmax, nMints = (1 << nVars), Limit = nVars + 3;
244 for (pW[5] = 1; pW[5] <= Limit; pW[5]++)
245 for (pW[4] = pW[5]; pW[4] <= Limit; pW[4]++)
246 for (pW[3] = pW[4]; pW[3] <= Limit; pW[3]++)
247 for (pW[2] = pW[3]; pW[2] <= Limit; pW[2]++)
248 for (pW[1] = pW[2]; pW[1] <= Limit; pW[1]++)
249 for (pW[0] = pW[1]; pW[0] <= Limit; pW[0]++) {
252 for (m = 0; m < nMints; m++) {
253 if (Abc_TtGetBit(t, m))
254 Lmin = Abc_MinInt(Lmin,
255 Extra_ThreshWeightedSum(pW, nVars,
258 Lmax = Abc_MaxInt(Lmax,
259 Extra_ThreshWeightedSum(pW, nVars,
272 int m, Lmin, Lmax, nMints = (1 << nVars), Limit = nVars + 6;
274 for (pW[6] = 1; pW[6] <= Limit; pW[6]++)
275 for (pW[5] = pW[6]; pW[5] <= Limit; pW[5]++)
276 for (pW[4] = pW[5]; pW[4] <= Limit; pW[4]++)
277 for (pW[3] = pW[4]; pW[3] <= Limit; pW[3]++)
278 for (pW[2] = pW[3]; pW[2] <= Limit; pW[2]++)
279 for (pW[1] = pW[2]; pW[1] <= Limit; pW[1]++)
280 for (pW[0] = pW[1]; pW[0] <= Limit; pW[0]++) {
283 for (m = 0; m < nMints; m++) {
284 if (Abc_TtGetBit(t, m))
285 Lmin = Abc_MinInt(Lmin,
286 Extra_ThreshWeightedSum(pW,
289 Lmax = Abc_MaxInt(Lmax,
290 Extra_ThreshWeightedSum(pW,
303 int m, Lmin, Lmax, nMints = (1 << nVars), Limit = nVars + 1;
305 for (pW[7] = 1; pW[7] <= Limit; pW[7]++)
306 for (pW[6] = pW[7]; pW[6] <= Limit; pW[6]++)
307 for (pW[5] = pW[6]; pW[5] <= Limit; pW[5]++)
308 for (pW[4] = pW[5]; pW[4] <= Limit; pW[4]++)
309 for (pW[3] = pW[4]; pW[3] <= Limit; pW[3]++)
310 for (pW[2] = pW[3]; pW[2] <= Limit; pW[2]++)
311 for (pW[1] = pW[2]; pW[1] <= Limit; pW[1]++)
312 for (pW[0] = pW[1]; pW[0] <= Limit; pW[0]++) {
315 for (m = 0; m < nMints; m++) {
316 if (Abc_TtGetBit(t, m))
317 Lmin = Abc_MinInt(Lmin,
318 Extra_ThreshWeightedSum(pW,
321 Lmax = Abc_MaxInt(Lmax,
322 Extra_ThreshWeightedSum(pW,
379 int * pWofChow,
int * pChow,
int nChows,
int nInequalities,
380 unsigned long ** pGreaters,
unsigned long ** pSmallers) {
381 int i = 0, j = 0, k = 0, m = 0;
383 int nCubesIsop =
strlen(pIsop) / (nVars + 3);
384 int nCubesIsopFneg =
strlen(pIsopFneg) / (nVars + 3);
386 for (k = 0; k < nCubesIsop * nCubesIsopFneg; k++)
387 for (i = 0; i < nChows; i++) {
392 for (i = 0; i < (int)
strlen(pIsop); i += (nVars + 3))
393 for (j = 0; j < nCubesIsopFneg; j++) {
394 for (k = 0; k < nVars; k++)
395 if (pIsop[i + k] ==
'1')
396 pGreaters[m][pChow[k]] = pGreaters[m][(pChow[k])] + 1;
401 for (i = 0; i < nCubesIsop; i++)
402 for (j = 0; j < (int)
strlen(pIsopFneg); j += (nVars + 3)) {
403 for (k = 0; k < nVars; k++)
404 if (pIsopFneg[j + k] ==
'-')
405 pSmallers[m][pChow[k]] = pSmallers[m][pChow[k]] + 1;
413 unsigned long ** pGreaters,
unsigned long ** pSmallers) {
416 for (k = 0; k < nInequalities; k++) {
417 for (i = 0; i < nChows; i++) {
418 if ((pGreaters[k][i]) == (pSmallers[k][i])) {
421 }
else if ((pGreaters[k][i]) > (pSmallers[k][i])) {
422 pGreaters[k][i] = pGreaters[k][i] - pSmallers[k][i];
425 pSmallers[k][i] = pSmallers[k][i] - pGreaters[k][i];
435 int nVars,
int * pW,
int * pChow,
int nChows,
int Wmin) {
437 int i = 0, j = 0, Lmin = 1000, Lmax = 0, Limit = nVars * 2, delta = 0,
438 deltaOld = -1000, fIncremented = 0;
440 int * pWofChow =
ABC_ALLOC(
int, nChows );
441 int nCubesIsop =
strlen(pIsop) / (nVars + 3);
442 int nCubesIsopFneg =
strlen(pIsopFneg) / (nVars + 3);
443 int nInequalities = nCubesIsop * nCubesIsopFneg;
444 unsigned long **pGreaters;
445 unsigned long **pSmallers;
447 pGreaters = (
unsigned long **)
malloc(nCubesIsop * nCubesIsopFneg *
sizeof *pGreaters);
448 for (i = 0; i < nCubesIsop * nCubesIsopFneg; i++) {
449 pGreaters[i] = (
unsigned long *)
malloc(nChows *
sizeof *pGreaters[i]);
451 pSmallers = (
unsigned long **)
malloc(nCubesIsop * nCubesIsopFneg *
sizeof *pSmallers);
452 for (i = 0; i < nCubesIsop * nCubesIsopFneg; i++) {
453 pSmallers[i] = (
unsigned long *)
malloc(nChows *
sizeof *pSmallers[i]);
458 nChows, nInequalities, pGreaters, pSmallers);
464 for (i = 1; i < nChows; i++) {
465 pWofChow[i] = pWofChow[i - 1] + 1;
470 while (i < nChows && pWofChow[nChows - 1] <= Limit) {
474 while (j < nInequalities) {
475 if (pGreaters[j][i] != 0) {
476 Lmin = Extra_ThreshCubeWeightedSum3(pWofChow, nChows, pGreaters,
478 Lmax = Extra_ThreshCubeWeightedSum4(pWofChow, nChows, pSmallers,
483 if (fIncremented == 1) {
491 if (delta > deltaOld) {
495 }
else if (fIncremented == 1) {
512 for (i = 0; i < nCubesIsop * nCubesIsopFneg; i++) {
516 for (i = 0; i < nCubesIsop * nCubesIsopFneg; i++) {
527 for (j = 0; j < (int)
strlen(pIsop); j += (nVars + 3))
528 Lmin = Abc_MinInt(Lmin,
529 Extra_ThreshCubeWeightedSum1(pWofChow, pChow, pIsop, nVars, j));
530 for (j = 0; j < (int)
strlen(pIsopFneg); j += (nVars + 3))
531 Lmax = Abc_MaxInt(Lmax,
532 Extra_ThreshCubeWeightedSum2(pWofChow, pChow, pIsopFneg, nVars,
535 for (i = 0; i < nVars; i++) {
536 pW[i] = pWofChow[pChow[i]];
594 extern char * Abc_ConvertBddToSop(
Mem_Flex_t * pMan, DdManager * dd, DdNode * bFuncOn, DdNode * bFuncOnDc,
int nFanins,
int fAllPrimes,
Vec_Str_t * vCube,
int fMode );
595 int Chow0, Chow[16], nChows, i, T = 0;
598 DdNode * ddNode, * ddNodeFneg;
599 char * pIsop, * pIsopFneg;
602 if (!Abc_TtIsUnate(t, nVars))
604 Abc_TtMakePosUnate(t, nVars);
610 vCube = Vec_StrAlloc(nVars);
611 for (i = 0; i < nVars; i++)
612 Cudd_bddIthVar(dd, i);
613 ddNode = Kit_TruthToBdd(dd, (
unsigned *) t, nVars, 0);
615 pIsop = Abc_ConvertBddToSop( NULL, dd, ddNode, ddNode, nVars, 1,
618 Abc_TtNot(t, Abc_TruthWordNum(nVars));
619 ddNodeFneg = Kit_TruthToBdd(dd, (
unsigned *) t, nVars, 0);
620 Cudd_Ref(ddNodeFneg);
622 pIsopFneg = Abc_ConvertBddToSop( NULL, dd, ddNodeFneg, ddNodeFneg,
625 Cudd_RecursiveDeref(dd, ddNode);
626 Cudd_RecursiveDeref(dd, ddNodeFneg);
631 for (i = 2; (i < 4) && (T == 0) && (nVars >= 6); i++)
655 int T, Chow0, Chow[16], Weights[16];
661 word t = (s_Truths6[0] & s_Truths6[1] & s_Truths6[2])| (s_Truths6[0] & s_Truths6[1] & s_Truths6[3]) | (s_Truths6[0] & s_Truths6[1] & s_Truths6[4] & s_Truths6[5]) | (s_Truths6[0] & s_Truths6[2] & s_Truths6[3] & s_Truths6[4] & s_Truths6[5]);
667 for (i = 0; i < nVars; i++)
668 printf(
"%d %d %d\n", i, Abc_TtPosVar(&t, nVars, i),
669 Abc_TtNegVar(&t, nVars, i));
675 printf(
"No threshold\n");
ABC_DLL void * Abc_FrameReadManDd()