void __hdiff_private__create_diff(const TByte* newData,const TByte* newData_end,const TByte* oldData,const TByte* oldData_end, std::vector<TByte>& out_diff,const void* _kDiffParams,const TSuffixString* sstring=0){ const THDiffPrivateParams& kDiffParams=*(const THDiffPrivateParams*)_kDiffParams; TSuffixString _sstring_default(0,0); if (sstring==0){ _sstring_default.resetSuffixString((const char*)oldData,(const char*)oldData_end); sstring=&_sstring_default; } TDiffData diff; diff.newData=newData; diff.newData_end=newData_end; diff.oldData=oldData; diff.oldData_end=oldData_end; search_cover(diff,*sstring,kDiffParams.kMinMatchLength); extend_cover(diff);//先尝试扩展. select_cover(diff,kDiffParams.kMinSingleMatchLength); extend_cover(diff);//select_cover会删除一些覆盖线,所以重新扩展. sub_cover(diff); serialize_diff(diff,out_diff); }
static int add_row(CONSTRAINT *con,double *rhs,char *sense,int *rmatind,double *rmatval) { //int card,j; int card; int l = 0; VARIABLE **stack; double *coef; if( con->lp != -1 ){ std::cout << "ERROR: constraints already in the LP (" << con->lp << ")" << std::endl; CSPexit(EXIT_ERROR); //exit(1); } con->lp = mar; *sense = con->sense; *rhs = con->rhs; rind[mar++] = con; switch( con->type ){ case CAPACITY: case BRIDGE: case BRANCHCUT: case GOMORY: stack = con->stack; coef = con->coef; card = con->card; break; case COVER: stack = (VARIABLE **)malloc( ncols*sizeof(VARIABLE *) ); coef = (double *)malloc( ncols*sizeof(double) ); card = extend_cover(con,stack,coef); break; default: std::cout << "ERROR: unknown type " << con->type << " of constraint" << std::endl; CSPexit(EXIT_ERROR); //exit(1); } while(card--){ switch( stack[card]->stat ){ case WAITING: break; case FIX_LB: break; case FIX_UB: *rhs -= coef[card]; break; default: rmatind[l] = stack[card]->lp; rmatval[l] = coef[card]; l++; } } #ifdef STAMP if(l==0){ std::cout << "WARNING: empty left-hand-side constraint" << std::endl; if(( *rhs>ZERO && *sense!='L' )||( *rhs<-ZERO && *sense!='G' )) std::cout << " (probably infeasible LP)" << std::endl; else if ((*rhs< ZERO && *rhs>-ZERO ) || (*rhs> ZERO && *sense=='L') || (*rhs<-ZERO && *sense=='G') ) std::cout << " (probably not useful cut)" << std::endl; else{ std::cout << " ERROR: bad cut" << std::endl; /* print_row(con); */ CSPexit(EXIT_ERROR); //exit(1); } } #endif rmatind[l] = 0; rmatval[l] = *rhs; l++; #ifdef STAMP control_constraint( con ); #endif switch( con->type ){ case COVER: free(stack); stack = NULL; /*PWOF*/ free(coef); coef = NULL; /*PWOF*/ break; case GOMORY: case CAPACITY: case BRIDGE: case BRANCHCUT: break; default: std::cout << "ERROR: unknown type " << con->type << " of constraint" << std::endl; CSPexit(EXIT_ERROR); //exit(1); } return(l); }