VIS
|
00001 00019 #include "satInt.h" 00020 00021 static char rcsid[] UNUSED = "$Id: satDebug.c,v 1.14 2009/04/11 18:26:37 fabio Exp $"; 00022 00023 /*---------------------------------------------------------------------------*/ 00024 /* Constant declarations */ 00025 /*---------------------------------------------------------------------------*/ 00026 00029 /*---------------------------------------------------------------------------*/ 00030 /* Static function prototypes */ 00031 /*---------------------------------------------------------------------------*/ 00032 static int numCompareInt(const void *x, const void *y); 00033 00034 00038 /*---------------------------------------------------------------------------*/ 00039 /* Definition of exported functions */ 00040 /*---------------------------------------------------------------------------*/ 00041 00042 00054 void 00055 sat_PrintNode( 00056 satManager_t *cm, 00057 long v) 00058 { 00059 int inverted, i, size; 00060 long ante, cur, *fan, *plit; 00061 satVariable_t *var; 00062 satArray_t *wl; 00063 00064 inverted = SATisInverted(v); 00065 v = SATnormalNode(v); 00066 if(SATflags(v) & IsCNFMask) { 00067 size = SATnumLits(v); 00068 fprintf(cm->stdOut, "CNF %6ld (%4ld) U(%ld)", v, SATnumConflict(v), SATconflictUsage(v)); 00069 sat_PrintFlag(cm, v); 00070 fprintf(cm->stdOut, " "); 00071 for(i=0, plit = (long*)SATfirstLit(v); i<size; i++, plit++) { 00072 if(i!=0 && i%5 == 0) 00073 fprintf(cm->stdOut, "\n "); 00074 sat_PrintLiteral(cm, *plit); 00075 } 00076 fprintf(cm->stdOut, "\n"); 00077 } 00078 else if(SATflags(v) & IsBDDMask) { 00079 } 00080 else { 00081 fprintf(cm->stdOut, "AIG "); 00082 sat_PrintFlag(cm, SATnormalNode(v)); 00083 fprintf(cm->stdOut, " "); 00084 sat_PrintNodeAlone(cm, v); 00085 sat_PrintNodeAlone(cm, SATleftChild(v)); 00086 sat_PrintNodeAlone(cm, SATrightChild(v)); 00087 fprintf(cm->stdOut, "\n"); 00088 size = SATnFanout(v); 00089 fprintf(cm->stdOut, "%4d ", size); 00090 for(i=0, fan=SATfanout(v); i<size; i++, fan++) { 00091 cur = (*fan) >>1; 00092 fprintf(cm->stdOut, "%6ld ", cur); 00093 } 00094 fprintf(cm->stdOut, "\n"); 00095 00096 fprintf(cm->stdOut, " canonocal : %ld\n", sat_GetCanonical(cm, v)); 00097 if(cm->variableArray && SATvalue(v) < 2) { 00098 ante = SATante(v); 00099 if(SATflags(ante) & IsCNFMask) { 00100 fprintf(cm->stdOut, " ante CNF : %ld\n", SATante(v)); 00101 } 00102 else{ 00103 fprintf(cm->stdOut, " ante : %ld\n", SATante(v)); 00104 fprintf(cm->stdOut, " ante2 : %ld\n", SATante2(v)); 00105 } 00106 } 00107 00108 if(cm->variableArray) { 00109 var = SATgetVariable(v); 00110 wl = var->wl[0]; 00111 if(wl && wl->num) { 00112 fprintf(cm->stdOut, " 0 wl : "); 00113 for(i=0; i<wl->num; i++) { 00114 plit = (long *)(wl->space[i]); 00115 if(plit == 0) continue; 00116 fprintf(cm->stdOut, "%ld", (*plit)>>2); 00117 while(1) { 00118 plit++; 00119 if(*plit < 0) break; 00120 } 00121 fprintf(cm->stdOut, "(%ld) ", -(*plit)); 00122 } 00123 fprintf(cm->stdOut, "\n"); 00124 } 00125 wl = var->wl[1]; 00126 if(wl && wl->num) { 00127 fprintf(cm->stdOut, " 1 wl : "); 00128 for(i=0; i<wl->num; i++) { 00129 plit = (long *)(wl->space[i]); 00130 if(plit == 0) continue; 00131 fprintf(cm->stdOut, "%ld", (*plit)>>2); 00132 while(1) { 00133 plit++; 00134 if(*plit < 0) break; 00135 } 00136 fprintf(cm->stdOut, "(%ld) ", -(*plit)); 00137 } 00138 fprintf(cm->stdOut, "\n"); 00139 } 00140 } 00141 } 00142 fflush(cm->stdOut); 00143 } 00144 00156 void 00157 sat_PrintFlag(satManager_t *cm, long v) 00158 { 00159 int flag; 00160 00161 flag = SATflags(SATnormalNode(v)); 00162 fprintf(cm->stdOut, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", 00163 (flag & CoiMask) ? 'C' : ' ', 00164 (flag & VisitedMask) ? 'V' : ' ', 00165 (flag & NewMask) ? 'N' : ' ', 00166 (flag & InQueueMask) ? 'Q' : ' ', 00167 (flag & ObjMask) ? 'o' : ' ', 00168 (flag & NonobjMask) ? 'n' : ' ', 00169 (flag & IsSystemMask) ? 'S' : ' ', 00170 (flag & IsConflictMask) ? 'c' : ' ', 00171 (flag & InUseMask) ? 'U' : ' ', 00172 (flag & StaticLearnMask) ? 's' : ' ', 00173 (flag & StateBitMask) ? 'T' : ' ', 00174 (flag & IsBlockingMask) ? 'B' : ' ', 00175 (flag & IsFrontierMask) ? 'F' : ' ', 00176 (flag & LeafNodeMask) ? 'L' : ' '); 00177 00178 } 00179 00191 void 00192 sat_PrintNodeAlone(satManager_t *cm, long v) 00193 { 00194 int value, level, inverted; 00195 00196 inverted = SATisInverted(v); 00197 v = SATnormalNode(v); 00198 value = SATvalue(v); 00199 level = value>1 ? -1 : (cm->variableArray ? SATlevel(v) : -1); 00200 fprintf(cm->stdOut, "%6ld%c@%d=%c%c ", 00201 v, inverted ? '\'' : ' ', level, 00202 SATgetValueChar(value), 00203 (SATflags(v)&ObjMask) ? '*' : ' '); 00204 } 00205 00217 void 00218 sat_PrintLiteral(satManager_t *cm, long lit) 00219 { 00220 int value, level, inverted; 00221 long v; 00222 00223 v = SATgetNode(lit); 00224 inverted = SATisInverted(v); 00225 v = SATnormalNode(v); 00226 value = SATvalue(v); 00227 level = value>1 ? -1 : SATlevel(v); 00228 fprintf(cm->stdOut, "%6ld%c@%d=%c%c ", 00229 v, inverted ? '\'' : ' ', level, SATgetValueChar(value), 00230 SATisWL(lit) ? '*' : ' '); 00231 } 00232 00244 void 00245 sat_PrintImplicationGraph( 00246 satManager_t *cm, 00247 satLevel_t *d) 00248 { 00249 long ante, ante2, v; 00250 int i; 00251 satArray_t *implied; 00252 00253 fprintf(cm->stdOut, "++++++++++++++++++++++++++++++++\n"); 00254 fprintf(cm->stdOut, "* Level %d %ld->%ld\n", 00255 d->level, d->decisionNode, SATvalue(d->decisionNode)); 00256 fprintf(cm->stdOut, "++++++++++++++++++++++++++++++++\n"); 00257 00258 implied = d->implied; 00259 for(i=0; i<implied->num; i++) { 00260 v = implied->space[i]; 00261 ante = SATante(v); 00262 if(SATflags(ante) & IsCNFMask) { 00263 sat_PrintNodeAlone(cm, v); 00264 fprintf(cm->stdOut, "<= %6ld %c(%cCNF)\n", 00265 ante, (SATflags(ante) & ObjMask) ? '*' : ' ', 00266 (SATflags(ante) & IsConflictMask) ? 'c' : ' '); 00267 sat_PrintNode(cm, ante); 00268 } 00269 else if(SATflags(ante) & IsBDDMask) { 00270 } 00271 else { 00272 sat_PrintNodeAlone(cm, v); 00273 fprintf(cm->stdOut, "<= "); 00274 sat_PrintNodeAlone(cm, ante); 00275 ante2 = SATante2(v); 00276 if(ante2) 00277 sat_PrintNodeAlone(cm, ante2); 00278 fprintf(cm->stdOut, "\n"); 00279 } 00280 } 00281 fflush(cm->stdOut); 00282 } 00283 00296 void 00297 sat_CheckFlagsOnConflict(satManager_t *cm) 00298 { 00299 long i; 00300 00301 for(i=satNodeSize; i<cm->nodesArraySize; i+=satNodeSize) { 00302 if(!(SATflags(i) & CoiMask)) 00303 continue; 00304 00305 if(SATflags(i) & VisitedMask || SATflags(i) & NewMask) { 00306 fprintf(cm->stdOut, "%s ERROR : %ld has flag\n", 00307 cm->comment, i); 00308 sat_PrintNode(cm, i); 00309 } 00310 } 00311 } 00312 00324 void 00325 sat_PrintScore(satManager_t *cm) 00326 { 00327 int i; 00328 long v; 00329 satArray_t *ordered; 00330 satVariable_t *var; 00331 00332 fprintf(cm->stdOut, "------------Print Score-----------\n"); 00333 ordered = cm->orderedVariableArray; 00334 for(i=0; i<ordered->num; i++) { 00335 v = ordered->space[i]; 00336 var = SATgetVariable(v); 00337 fprintf(cm->stdOut, "%5ld : %3d %3d\n", v, var->scores[0], var->scores[1]); 00338 } 00339 fflush(cm->stdOut); 00340 } 00341 00342 00354 void 00355 sat_PrintDotForConflict( 00356 satManager_t *cm, 00357 satLevel_t *d, 00358 long conflict, 00359 int includePreviousLevel) 00360 { 00361 satArray_t *root; 00362 long left, right, nv; 00363 int inverted, size, value, i; 00364 long *plit; 00365 satOption_t *option; 00366 00367 root = sat_ArrayAlloc(8); 00368 00369 conflict = d->conflict; 00370 inverted = SATisInverted(conflict); 00371 conflict = SATnormalNode(conflict); 00372 00373 option = cm->option; 00374 if(SATflags(conflict) & IsCNFMask) { 00375 size = SATnumLits(conflict); 00376 for(i=0, plit=(long*)SATfirstLit(conflict); i<size; i++, plit++) { 00377 nv = SATgetNode(*plit); 00378 if(d->level == SATlevel(nv)) 00379 sat_ArrayInsert(root, nv); 00380 } 00381 } 00382 else { 00383 value = SATvalue(conflict); 00384 if(value == 1) { 00385 if(d->level == SATlevel(conflict)) 00386 sat_ArrayInsert(root, conflict); 00387 00388 left = SATleftChild(conflict); 00389 inverted = SATisInverted(left); 00390 left = SATnormalNode(left); 00391 value = SATvalue(left) ^ inverted; 00392 if(value == 0) { 00393 if(d->level == SATlevel(left)) 00394 sat_ArrayInsert(root, left); 00395 } 00396 else { 00397 right = SATrightChild(conflict); 00398 inverted = SATisInverted(right); 00399 right = SATnormalNode(right); 00400 value = SATvalue(right) ^ inverted; 00401 if(value == 0) { 00402 if(d->level == SATlevel(right)) 00403 sat_ArrayInsert(root, right); 00404 } 00405 } 00406 } 00407 else if(value == 0) { 00408 left = SATleftChild(conflict); 00409 right = SATrightChild(conflict); 00410 if(d->level == SATlevel(conflict)) 00411 sat_ArrayInsert(root, conflict); 00412 if(d->level == SATlevel(left)) 00413 sat_ArrayInsert(root, left); 00414 if(d->level == SATlevel(right)) 00415 sat_ArrayInsert(root, right); 00416 } 00417 } 00418 00419 sat_PrintDotForImplicationGraph(cm, d, root, includePreviousLevel); 00420 sat_ArrayFree(root); 00421 } 00422 00434 void 00435 sat_PrintDotForWholeGraph( 00436 satManager_t *cm, 00437 satLevel_t *d, 00438 int includePreviousLevel) 00439 { 00440 satArray_t *root, *implied; 00441 int v, i; 00442 00443 root = sat_ArrayAlloc(8); 00444 implied = d->implied; 00445 for(i=implied->num-1; i>=0; i--) { 00446 v = implied->space[i]; 00447 sat_ArrayInsert(root, v); 00448 } 00449 sat_PrintDotForImplicationGraph(cm, d, root, includePreviousLevel); 00450 sat_ArrayFree(root); 00451 } 00463 void 00464 sat_PrintDotForImplicationGraph( 00465 satManager_t *cm, 00466 satLevel_t *d, 00467 satArray_t *root, 00468 int includePreviousLevel) 00469 { 00470 char name[1024]; 00471 long v, nv, *plit, lit; 00472 int i, j, size; 00473 int inverted; 00474 long ante, ante2; 00475 st_table *table; 00476 FILE *fp; 00477 satArray_t *implied; 00478 00479 00480 for(i=0; i<root->num; i++) { 00481 v = root->space[i]; 00482 v = SATnormalNode(v); 00483 SATflags(v) |= VisitedMask; 00484 } 00485 00486 sprintf(name, "%d_%ld_%d_%d.dot", 00487 d->level, d->decisionNode, cm->each->nDecisions, includePreviousLevel); 00488 fp = fopen(name, "w"); 00489 00490 fprintf(fp, "digraph \"AndInv\" {\n rotate=90;\n"); 00491 fprintf(fp, " margin=0.5;\n label=\"AndInv\";\n"); 00492 fprintf(fp, " size=\"10,7.5\";\n ratio=\"fill\";\n"); 00493 00494 table = st_init_table(st_numcmp, st_numhash); 00495 implied = d->implied; 00496 for(i=implied->num-1; i>=0; i--) { 00497 v = implied->space[i]; 00498 if(!(SATflags(v) & VisitedMask)) continue; 00499 if((SATflags(v) & NewMask)) continue; 00500 00501 st_insert(table, (char *)(long)v, (char *)(long)v); 00502 00503 ante = SATante(v); 00504 if(SATflags(ante) & IsCNFMask) { 00505 size = SATnumLits(ante); 00506 for(j=0, plit=(long *)SATfirstLit(ante); j<size; j++) { 00507 lit = plit[j]; 00508 nv = SATgetNode(lit); 00509 inverted = SATisInverted(nv); 00510 nv = SATnormalNode(nv); 00511 if(nv == v) continue; 00512 00513 st_insert(table, (char *)nv, (char *)nv); 00514 if(SATlevel(nv) == d->level) { 00515 fprintf(fp,"%ld.%d -> %ld.%d [color = red];\n", 00516 nv, SATlevel(nv), v, SATlevel(v)); 00517 SATflags(nv) |= VisitedMask; 00518 } 00519 else if(includePreviousLevel) { 00520 fprintf(fp,"%ld.%d -> %ld.%d [color = black];\n", 00521 nv, SATlevel(nv), v, SATlevel(v)); 00522 } 00523 } 00524 } 00525 else { 00526 fprintf(fp,"%ld.%d [label=\"%ld.%d \"];\n", v, SATlevel(v), v, SATlevel(v)); 00527 ante2 = SATnormalNode(SATante2(v)); 00528 if(ante2) { 00529 st_insert(table, (char *)ante2, (char *)ante2); 00530 if(SATlevel(ante2) == d->level) { 00531 fprintf(fp,"%ld.%d -> %ld.%d [color = red];\n", ante2, SATlevel(ante2), v, SATlevel(v)); 00532 SATflags(ante2) |= VisitedMask; 00533 } 00534 else if(includePreviousLevel && SATlevel(ante2)>=0) { 00535 fprintf(fp,"%ld.%d -> %ld.%d [color = black];\n", ante2, SATlevel(ante2), v, SATlevel(v)); 00536 } 00537 } 00538 00539 if(ante) { 00540 st_insert(table, (char *)ante, (char *)ante); 00541 if(SATlevel(ante) == d->level) { 00542 fprintf(fp,"%ld.%d -> %ld.%d [color = red];\n", ante, SATlevel(ante), v, SATlevel(v)); 00543 SATflags(ante) |= VisitedMask; 00544 } 00545 else if(includePreviousLevel && SATlevel(ante)>=0) { 00546 fprintf(fp,"%ld.%d -> %ld.%d [color = black];\n", ante, SATlevel(ante), v, SATlevel(v)); 00547 } 00548 } 00549 } 00550 SATflags(v) |= NewMask; 00551 } 00552 fprintf(fp, "}\n"); 00553 fclose(fp); 00554 00555 for(i=implied->num-1; i>=0; i--) { 00556 v = implied->space[i]; 00557 SATflags(v) &= ResetNewVisitedMask; 00558 } 00559 for(i=0; i<root->num; i++) { 00560 v = root->space[i]; 00561 SATflags(v) &= ResetVisitedMask; 00562 } 00563 00564 st_free_table(table); 00565 00566 } 00567 00581 void 00582 sat_CheckNonobjConflictClause( 00583 satManager_t *cm, 00584 long v) 00585 { 00586 int i, size, inverted; 00587 long *plit, nv; 00588 satLevel_t *d; 00589 00590 d = 0; 00591 size = SATnumLits(v); 00592 for(i=0, plit = (long*)SATfirstLit(v); i<size; i++, plit++) { 00593 nv = SATgetNode(*plit); 00594 inverted = SATisInverted(nv); 00595 nv = SATnormalNode(nv); 00596 00597 d = sat_AllocLevel(cm); 00598 d->decisionNode = nv; 00599 00600 SATvalue(nv) = inverted; 00601 SATmakeImplied(nv, d); 00602 00603 sat_Enqueue(cm->queue, nv); 00604 SATflags(nv) |= InQueueMask; 00605 00606 sat_ImplicationMain(cm, d); 00607 if(d->conflict) break; 00608 } 00609 00610 if(d->conflict == 0) { 00611 fprintf(cm->stdOut, "%s ERROR : %ld does not result in conflict\n", 00612 cm->comment, v); 00613 sat_PrintNode(cm, v); 00614 } 00615 sat_Backtrack(cm, -1); 00616 } 00617 00631 void 00632 sat_CheckNonobjUnitClause( 00633 satManager_t *cm) 00634 { 00635 int v, i; 00636 int inverted; 00637 satLevel_t *d; 00638 satArray_t *arr; 00639 00640 arr = cm->nonobjUnitLitArray; 00641 00642 for(i=0; i<arr->num; i++) { 00643 v = arr->space[i]; 00644 inverted = SATisInverted(v); 00645 v = SATnormalNode(v); 00646 00647 d = sat_AllocLevel(cm); 00648 d->decisionNode = v; 00649 00650 SATvalue(v) = inverted; 00651 SATmakeImplied(v, d); 00652 00653 sat_Enqueue(cm->queue, v); 00654 SATflags(v) |= InQueueMask; 00655 00656 sat_ImplicationMain(cm, d); 00657 if(d->conflict == 0) { 00658 fprintf(cm->stdOut, "%s ERROR : %d unit literal does not result in conflict\n", 00659 cm->comment, v); 00660 } 00661 sat_Backtrack(cm, -1); 00662 00663 } 00664 } 00665 00677 void 00678 sat_CheckInitialCondition( 00679 satManager_t *cm) 00680 { 00681 long i; 00682 00683 for(i=satNodeSize; i<cm->nodesArraySize; i+=satNodeSize) { 00684 if(!(SATflags(i) & CoiMask)) 00685 continue; 00686 00687 if(SATvalue(i) != 2) { 00688 fprintf(cm->stdOut, "%s ERROR : %ld has value %ld\n", 00689 cm->comment, i, SATvalue(i)); 00690 } 00691 if(SATflags(i) & VisitedMask || SATflags(i) & NewMask) { 00692 fprintf(cm->stdOut, "%s ERROR : %ld has flag\n", 00693 cm->comment, i); 00694 sat_PrintNode(cm, i); 00695 } 00696 } 00697 } 00698 00712 void 00713 sat_CheckConflictClause( 00714 satManager_t *cm, 00715 satArray_t *clauseArray) 00716 { 00717 satArray_t *decisionArray; 00718 satLevel_t *d; 00719 int i, value, inverted; 00720 long v; 00721 int conflictFlag, tvalue; 00722 00723 decisionArray = sat_ArrayAlloc(cm->currentDecision); 00724 for(i=1; i<=cm->currentDecision; i++) { 00725 v = cm->decisionHead[i].decisionNode; 00726 value = SATvalue(v); 00727 sat_ArrayInsert(decisionArray, v^(!value)); 00728 } 00729 00730 sat_Backtrack(cm, 0); 00731 00732 conflictFlag = 0; 00733 for(i=0; i<clauseArray->num; i++) { 00734 v = clauseArray->space[i]; 00735 inverted = SATisInverted(v); 00736 v = SATnormalNode(v); 00737 00738 d = sat_AllocLevel(cm); 00739 d->decisionNode = v; 00740 00741 value = !inverted; 00742 tvalue = SATvalue(v); 00743 if(tvalue < 2 && tvalue != value) { 00744 fprintf(cm->stdOut, "ERROR : Early conflict condition detect\n"); 00745 break; 00746 } 00747 SATvalue(v) = value; 00748 SATmakeImplied(v, d); 00749 00750 sat_Enqueue(cm->queue, v); 00751 SATflags(v) |= InQueueMask; 00752 00753 sat_ImplicationMain(cm, d); 00754 00755 if(d->conflict) { 00756 conflictFlag = 1; 00757 break; 00758 } 00759 } 00760 00761 if(conflictFlag == 0) { 00762 fprintf(cm->stdOut, "ERROR : Wrong conflict clause\n"); 00763 sat_PrintClauseArray(cm, clauseArray); 00764 } 00765 00766 sat_Backtrack(cm, 0); 00767 00768 conflictFlag = 0; 00769 for(i=0; i<decisionArray->num; i++) { 00770 v = decisionArray->space[i]; 00771 inverted = SATisInverted(v); 00772 v = SATnormalNode(v); 00773 00774 d = sat_AllocLevel(cm); 00775 d->decisionNode = v; 00776 00777 value = !inverted; 00778 SATvalue(v) = value; 00779 SATmakeImplied(v, d); 00780 00781 sat_Enqueue(cm->queue, v); 00782 SATflags(v) |= InQueueMask; 00783 00784 sat_ImplicationMain(cm, d); 00785 if(d->conflict) { 00786 conflictFlag = 1; 00787 } 00788 } 00789 if(conflictFlag == 0) { 00790 fprintf(cm->stdOut, "ERROR : Can't produce conflict\n"); 00791 exit(0); 00792 } 00793 } 00794 00806 void 00807 sat_PrintClauseArray( 00808 satManager_t *cm, 00809 satArray_t *clauseArray) 00810 { 00811 int i, inverted; 00812 long v; 00813 00814 fprintf(cm->stdOut, " "); 00815 for(i=0; i<clauseArray->num; i++) { 00816 v = clauseArray->space[i]; 00817 inverted = SATisInverted(v); 00818 v = SATnormalNode(v); 00819 if(i!=0 && i%5 == 0) 00820 fprintf(cm->stdOut, "\n "); 00821 sat_PrintNodeAlone(cm, v); 00822 } 00823 fprintf(cm->stdOut, "\n"); 00824 fflush(cm->stdOut); 00825 } 00826 00838 void 00839 sat_PrintProfileForNumConflict(satManager_t *cm) 00840 { 00841 char filename[1024]; 00842 FILE *fout; 00843 int i, index; 00844 satArray_t *arr; 00845 long count; 00846 long total, part; 00847 long v; 00848 long maxValue; 00849 00850 00851 sprintf(filename, "nConflict.dat"); 00852 fout = fopen(filename, "w"); 00853 index = 1; 00854 maxValue = 0; 00855 arr = sat_ArrayAlloc(1024); 00856 for(v=satNodeSize; v<cm->nodesArraySize; v+=satNodeSize) { 00857 if(!(SATflags(v) & IsCNFMask)) continue; 00858 if(SATnumConflict(v) == 0) continue; 00859 if(SATnumConflict(v) > maxValue) 00860 maxValue = SATnumConflict(v); 00861 sat_ArrayInsert(arr, SATnumConflict(v)); 00862 } 00863 00864 qsort(arr->space, arr->num, sizeof(int), numCompareInt); 00865 total = 0; 00866 part = 0; 00867 for(i=0; i<arr->num; i++) { 00868 count = arr->space[i]; 00869 if(count == 0) continue; 00870 total += count; 00871 if(count > 1) { 00872 part += count; 00873 } 00874 fprintf(fout, "%d %ld\n", i, count); 00875 } 00876 index = i; 00877 sat_ArrayFree(arr); 00878 fclose(fout); 00879 00880 00881 sprintf(filename, "nConflict.gp"); 00882 fout = fopen(filename, "w"); 00883 fprintf(fout, "set xlabel \"Conflict Index\"\n"); 00884 fprintf(fout, "set ylabel \"Number of Conflicting %ld/%ld\"\n", part, total); 00885 fprintf(fout, "set nokey\n"); 00886 fprintf(fout, "set size square 0.8,1\n"); 00887 fprintf(fout, "set xrange [0:%d]\n", index+1); 00888 fprintf(fout, "set yrange [0:%ld]\n", maxValue+1); 00889 fprintf(fout, "set grid\n"); 00890 fprintf(fout, "set border 3 linewidth 0.5\n"); 00891 fprintf(fout, "set xtics nomirror\n"); 00892 fprintf(fout, "set ytics nomirror\n"); 00893 fprintf(fout, "set mxtics 2\n"); 00894 fprintf(fout, "set mytics 2\n"); 00895 fprintf(fout, "set pointsize 2\n"); 00896 fprintf(fout, "set terminal postscript eps enhanced color solid \"Times-Roman\" 24\n"); 00897 fprintf(fout, "set output \"nConflict.eps\"\n"); 00898 fprintf(fout, "plot \"nConflict.dat\" using 1:2 with line linetype 3\n"); 00899 fclose(fout); 00900 } 00901 00913 static int 00914 numCompareInt(const void *x, const void *y) 00915 { 00916 long n1, n2; 00917 00918 n1 = *(int *)x; 00919 n2 = *(int *)y; 00920 return(n1 > n2); 00921 }