// Function definitions for class L-BFGS-B Program. // ----------------------------------------------------------------- lbfgsb_program::lbfgsb_program (user_function_data *fun, user_function_data *grad, iter_fun_data *iterF, size_t ndec, double *in_lb, double *in_ub, double *in_x0, double *xfinal, double *fval, double *iter, int printLevel, int maxIter, int maxFeval, double maxtime, double ftol, int m, double pgtol) : Program((int)ndec,0,0,0,0,m,maxIter,maxFeval,maxtime,ftol/mxGetEps(),pgtol) //Program Constructor { //Create local copies of input args (we will change them) x = new double[ndec]; lb = new double[ndec]; ub = new double[ndec]; for(int i = 0; i < ndec; i++) { lb[i] = in_lb[i]; ub[i] = in_ub[i]; x[i] = in_x0[i]; } //Solver bound types btype = new int[ndec]; // Set the bound types. for (int i = 0; i < ndec; i++) btype[i] = getBoundType(lb[i],ub[i]); //Save size this->ndec = ndec; //Save print stuff this->printLevel = printLevel; //Save Function Information this->fun = fun; this->grad = grad; this->iterF = iterF; //Assign Output Variables this->xfinal = xfinal; this->noFevals = 0; }
inline unsigned int FMPWPartTmpl<GainTmpl>:: doPartitionInternal(vector<unsigned char>& part) { typedef FMPartTmpl<FMBiPartCore, GainTmpl> PWPartMgrType; typedef FMPartTmpl4<FMKWayPartCore4, FMKWayGainMgr2> RefineType; unsigned int cost1 = _initCost; unsigned int cost = _initCost; RefineType rfMgr(getParam()); rfMgr.setBalanceTol(getBalanceTol()); rfMgr.setPValue(1); rfMgr.setQValue(10); rfMgr.setVerbosity(getVerbosity()); rfMgr.setBoundType(getBoundType()); rfMgr.noNeedSetHighFanoutNets(); while (1) { initGrouping2(); getNetlist().pairWisePhase1(part, _groupMap, _sGVec); //xxx int cost3 = cost; cost = cost1; for (unsigned int j=0; j<_numGroups; ++j) { const FMParam param(*_sGVec[j]); PWPartMgrType PWMgr(param); //xxx PWMgr.setBalanceTol(getBalanceTol()); PWMgr.setUpperBound(getUpperBound()); PWMgr.setLowerBound(getLowerBound()); // PWMgr.setPValue(_pvalue); // PWMgr.setQValue(_qvalue); PWMgr.setVerbosity(getVerbosity()); //xxx PWMgr.setBoundType(getBoundType()); PWMgr.noNeedSetHighFanoutNets(); PWMgr.setNoInit(cost); vector<unsigned char> pw_part; projectUp(part, pw_part, j); // cost = PWMgr.doPartitionOne(pw_part); boost::array<int, 64>& diff = getDiff(); const unsigned int part0 = _groupInvMap[j]; const unsigned int part1 = _moveTo[part0]; int diff2[2]; diff2[0] = diff[part0]; diff2[1] = diff[part1]; PWMgr.setDiff(diff2); cost = PWMgr.doPartitionOne4(pw_part); // PWMgr.doPartition(pw_part, 1); // cost = PWMgr.getBestCost(); projectDown(part, pw_part, j); int* diff3 = PWMgr.getDiff(); diff[part0] = diff3[0]; diff[part1] = diff3[1]; delete _sGVec[j]; } // printDiff(); // std::cout << "cost = " << cost << std::endl; assert(cost == getNetlist().cutCost(part, getNumPartitions())); //xxx initDiff(part); rfMgr.setNoInit(cost); // only refine the solution rfMgr.setDiff(getDiff()); cost1 = rfMgr.doPartitionOne4(part); // rfMgr.doPartition(part, 1); // cost1 = rfMgr.getBestCost(); assert(cost1 == getNetlist().cutCost(part, getNumPartitions())); setDiff(rfMgr.getDiff()); // printDiff(); // std::cout << "cost1 = " << cost1 << std::endl; if (cost1 >= cost) break; } return cost1; }