treeNode *setStages(int varId1,int varId2){ char *var1 = getStringSym(varId1); char *var2 = getStringSym(varId2); int v1 = atoi(var1); int v2 = atoi(var2); nodeStages *stages = Malloc(sizeof(nodeStages)); stages->start = v1; stages->end = v2; treeNode *node = Malloc(sizeof(treeNode)); node->data = stages; return node; }
void printOptVar(FILE *file,int *ov){ fprintf(file,"Opt-%s-%i-DesObj-%s-Stage%i", getStringSym(ov[1]),ov[2],getStringSym(ov[3]),ov[4]); }
void printNegateVar(FILE *file,int *nv){ fprintf(file,"Negate-%s-%i-%s-%i-Stage-%i-%i", getStringSym(nv[1]),nv[2],getStringSym(nv[3]),nv[4],nv[5],nv[6]); }
void printUsedVar(FILE *file,int *uv){ fprintf(file,"%sUsedStage%i=>%i", getStringSym(uv[1]),uv[4],uv[4]+1); }
void printTransVar(FILE *file,int *td){ fprintf(file,"Trans-%s-%s-Stage%i=>%i", getStringSym(td[1]),getStringSym(td[2]),td[3],td[3]+1); }
void printSymCellVar(FILE *file,int *sv){ fprintf(file,"%sIs%sStage%i", getStringSym(sv[2]),getStringSym(sv[1]),sv[5]); }
// read in from dimout.out // convert output from minisat to human readable int createSatOut(char *inFileStr,char *outFileStr,rootData *rdata,indexList *varList,linkedList fullTransNodes){ FILE *inFile = fopen(inFileStr,"r"); FILE *outFile = fopen(outFileStr,"w"); char word[10]; int res = fscanf(inFile,"%s",word); checkRes(res); if(strcmp(word,"UNSAT") == 0){ fprintf(outFile,"UNSATISFIABLE"); fclose(inFile); fclose(outFile); return -1; } if(strcmp(word,"SAT") != 0){ printf("Error: Sat File Parsing Error."); endError(); } indexList *outVars = createVarIndex(); int ret; res = fscanf(inFile,"%i",&ret); checkRes(res); while(ret != 0){ // generally if not true, then not important // get varData of this variable in out sat varData *vdata = getVarByValue(varList,ret); res = fscanf(inFile,"%i",&ret); checkRes(res); if(!vdata) continue; // only care about adding Trans, SymCell if(vdata->type == symCellVarType || vdata->type == transVarType) addSomeVar(outVars,vdata); } // trans array int transWidth = sizeLinked(fullTransNodes); tempTransVar **transArray = toArrayLinked(fullTransNodes); treeNode *boardNode = rdata->boardNode; setData *bs = boardNode->data; int boardWidth = bs->width; int boardHeight = bs->height; cellData **boardSet = bs->setVars; // print board stage n // print transition n=>n+1 // repeat int n,x,y,i,j; int spaceIter; int foundTrans = 1; for(n=0;n<numStagesGlobal;n++){ if(foundTrans){ for(y=0;y<boardHeight;y++){ for(x=0;x<boardWidth;x++){ cellData *cell = boardSet[y*boardWidth+x]; if(!cell) continue; int numSpace = cell->numSpaceBef; for(spaceIter=0;spaceIter<numSpace;spaceIter++) fprintf(outFile,"."); if(numSpace) fprintf(outFile," "); linkedList symList = cell->symList; int symWidth = sizeLinked(symList); int **symArray = toArrayLinked(symList); for(i=0;i<symWidth;i++){ //x, y, id, stage varData *vdata = getSymCellVar(outVars,x,y,*symArray[i],n); if(vdata){ int *sc = vdata->data; char *symIdWord = getStringSym(sc[1]); fprintf(outFile,"%s ",symIdWord); } } } fprintf(outFile,"\n"); } fprintf(outFile,"\n"); } foundTrans = 0; for(j=0;j<transWidth;j++){ tempTransVar *trans = transArray[j]; int transId = trans->transId; int desObjId = trans->desObjId; // only need to check it exists varData *vdata = getTransVar(outVars,transId,desObjId,n); if(vdata){ char *id = getStringSym(trans->transId); char *desObj = getStringSym(trans->desObjId); fprintf(outFile,"%s %s\n",id,desObj); foundTrans = 1; } } if(foundTrans) fprintf(outFile,"\n"); } fclose(inFile); fclose(outFile); destroyVarIndex(outVars); return 0; }