当前位置: 首页>>代码示例>>C++>>正文


C++ CoinMin函数代码示例

本文整理汇总了C++中CoinMin函数的典型用法代码示例。如果您正苦于以下问题:C++ CoinMin函数的具体用法?C++ CoinMin怎么用?C++ CoinMin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CoinMin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CoinMax

//-------------------------------------------------------------------
// Generate Stored cuts
//------------------------------------------------------------------- 
void 
CglStoredUser::generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
			     const CglTreeInfo info) const
{
  // Get basic problem information
  const double * solution = si.getColSolution();
  if (info.inTree&&info.pass>numberPasses_) {
    // only continue if integer feasible
    int numberColumns=si.getNumCols(); 
    int i;
    const double * colUpper = si.getColUpper();
    const double * colLower = si.getColLower();
    int numberAway=0;
    for (i=0;i<numberColumns;i++) {
      double value = solution[i];
      // In case slightly away from bounds
      value = CoinMax(colLower[i],value);
      value = CoinMin(colUpper[i],value);
      if (si.isInteger(i)&&fabs(value-fabs(value+0.5))>1.0e-5) 
	numberAway++;
    }
    if (numberAway)
      return; // let code branch
  }
  int numberRowCuts = cuts_.sizeRowCuts();
  for (int i=0;i<numberRowCuts;i++) {
    const OsiRowCut * rowCutPointer = cuts_.rowCutPtr(i);
    double violation = rowCutPointer->violated(solution);
    if (violation>=requiredViolation_)
      cs.insert(*rowCutPointer);
  }
}
开发者ID:Flymir,项目名称:coin-all,代码行数:35,代码来源:allCuts.cpp

示例2: selectFractionalBinaries

void
CglClique::generateCuts(const OsiSolverInterface& si, OsiCuts & cs,
			const CglTreeInfo info)
{
   int i;
   bool has_petol_set = petol != -1.0;

   if (! has_petol_set)
      si.getDblParam(OsiPrimalTolerance, petol);
   int numberOriginalRows = si.getNumRows();
   if (info.inTree&&justOriginalRows_)
     numberOriginalRows = info.formulation_rows;
   int numberRowCutsBefore = cs.sizeRowCuts();
   // First select which rows/columns we are interested in.
   if (!setPacking_) {
      selectFractionalBinaries(si);
      if (!sp_orig_row_ind) {
	 selectRowCliques(si,numberOriginalRows);
      }
   } else {
      selectFractionals(si);
      delete[] sp_orig_row_ind;
      sp_numrows = numberOriginalRows;
      //sp_numcols = si.getNumCols();
      sp_orig_row_ind = new int[sp_numrows];
      for (i = 0; i < sp_numrows; ++i)
	 sp_orig_row_ind[i] = i;
   }
   // Just original rows
   if (justOriginalRows_&&info.inTree) 
     sp_numrows = CoinMin(info.formulation_rows,sp_numrows);
     

   createSetPackingSubMatrix(si);
   fgraph.edgenum = createNodeNode();
   createFractionalGraph();

   cl_indices = new int[sp_numcols];
   cl_del_indices = new int[sp_numcols];

   if (do_row_clique)
      find_rcl(cs);
   if (do_star_clique)
      find_scl(cs);
   if (!info.inTree&&((info.options&4)==4||((info.options&8)&&!info.pass))) {
     int numberRowCutsAfter = cs.sizeRowCuts();
     for (int i=numberRowCutsBefore;i<numberRowCutsAfter;i++)
       cs.rowCutPtr(i)->setGloballyValid();
   }

   delete[] cl_indices;     cl_indices = 0;
   delete[] cl_del_indices; cl_del_indices = 0;

   deleteFractionalGraph();
   delete[] node_node;      node_node = 0;
   deleteSetPackingSubMatrix();

   if (! has_petol_set)
      petol = -1;
}
开发者ID:bubuker,项目名称:keggle_santa,代码行数:60,代码来源:CglClique.cpp

示例3: CoinMax

CbcBranchingObject *
CbcNWay::createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * /*info*/, int /*way*/)
{
    int numberFree = 0;
    int j;

    //OsiSolverInterface * solver = model_->solver();
    const double * solution = model_->testSolution();
    const double * lower = solver->getColLower();
    const double * upper = solver->getColUpper();
    int * list = new int[numberMembers_];
    double * sort = new double[numberMembers_];

    for (j = 0; j < numberMembers_; j++) {
        int iColumn = members_[j];
        double value = solution[iColumn];
        value = CoinMax(value, lower[iColumn]);
        value = CoinMin(value, upper[iColumn]);
        if (upper[iColumn] > lower[iColumn]) {
            double distance = upper[iColumn] - value;
            list[numberFree] = j;
            sort[numberFree++] = distance;
        }
    }
    assert (numberFree);
    // sort
    CoinSort_2(sort, sort + numberFree, list);
    // create object
    CbcBranchingObject * branch;
    branch = new CbcNWayBranchingObject(model_, this, numberFree, list);
    branch->setOriginalObject(this);
    delete [] list;
    delete [] sort;
    return branch;
}
开发者ID:SnowyJune973,项目名称:future_net,代码行数:35,代码来源:CbcNWay.cpp

示例4: CoinMax

// Return "down" estimate
double
CbcSimpleIntegerPseudoCost::downEstimate() const
{
    OsiSolverInterface * solver = model_->solver();
    const double * solution = model_->testSolution();
    const double * lower = solver->getColLower();
    const double * upper = solver->getColUpper();
    double value = solution[columnNumber_];
    value = CoinMax(value, lower[columnNumber_]);
    value = CoinMin(value, upper[columnNumber_]);
    if (upper[columnNumber_] == lower[columnNumber_]) {
        // fixed
        return 0.0;
    }
    double integerTolerance =
        model_->getDblParam(CbcModel::CbcIntegerTolerance);
    double below = floor(value + integerTolerance);
    double above = below + 1.0;
    if (above > upper[columnNumber_]) {
        above = below;
        below = above - 1;
    }
    double downCost = CoinMax((value - below) * downPseudoCost_, 0.0);
    return downCost;
}
开发者ID:amosr,项目名称:limp-cbc,代码行数:26,代码来源:CbcSimpleIntegerPseudoCost.cpp

示例5: CoinMax

// Creates a branching object
CbcBranchingObject * 
CbcSimpleIntegerFixed::createBranch(OsiSolverInterface * solver,
					    const OsiBranchingInformation * info, int way)  
{
  const double * solution = model_->testSolution();
  const double * lower = solver->getColLower();
  const double * upper = solver->getColUpper();
  double value = solution[columnNumber_];
  value = CoinMax(value, lower[columnNumber_]);
  value = CoinMin(value, upper[columnNumber_]);
  assert (upper[columnNumber_]>lower[columnNumber_]);
  if (!model_->hotstartSolution()) {
    double nearest = floor(value+0.5);
    double integerTolerance = 
    model_->getDblParam(CbcModel::CbcIntegerTolerance);
    if (fabs(value-nearest)<integerTolerance) {
      // adjust value
      if (nearest!=upper[columnNumber_])
	value = nearest+2.0*integerTolerance;
      else
	value = nearest-2.0*integerTolerance;
    }
  } else {
    const double * hotstartSolution = model_->hotstartSolution();
    double targetValue = hotstartSolution[columnNumber_];
    if (way>0)
      value = targetValue-0.1;
    else
      value = targetValue+0.1;
  }
  CbcBranchingObject * branch = new CbcIntegerBranchingObject(model_,columnNumber_,way,
					     value);
  branch->setOriginalObject(this);
  return branch;
}
开发者ID:aykutbulut,项目名称:Cbc,代码行数:36,代码来源:CbcBranchUser.cpp

示例6: assert

// Fill most values
void
ClpDualRowSteepest::fill(const ClpDualRowSteepest& rhs)
{
     state_ = rhs.state_;
     mode_ = rhs.mode_;
     persistence_ = rhs.persistence_;
     assert (model_->numberRows() == rhs.model_->numberRows());
     model_ = rhs.model_;
     assert(model_);
     int number = model_->numberRows();
     if (rhs.savedWeights_)
          number = CoinMin(number, rhs.savedWeights_->capacity());
     if (rhs.infeasible_ != NULL) {
          if (!infeasible_)
               infeasible_ = new CoinIndexedVector(rhs.infeasible_);
          else
               *infeasible_ = *rhs.infeasible_;
     } else {
          delete infeasible_;
          infeasible_ = NULL;
     }
     if (rhs.weights_ != NULL) {
          if (!weights_)
               weights_ = new double[number];
          ClpDisjointCopyN(rhs.weights_, number, weights_);
     } else {
          delete [] weights_;
          weights_ = NULL;
     }
     if (rhs.alternateWeights_ != NULL) {
          if (!alternateWeights_)
               alternateWeights_ = new CoinIndexedVector(rhs.alternateWeights_);
          else
               *alternateWeights_ = *rhs.alternateWeights_;
     } else {
          delete alternateWeights_;
          alternateWeights_ = NULL;
     }
     if (rhs.savedWeights_ != NULL) {
          if (!savedWeights_)
               savedWeights_ = new CoinIndexedVector(rhs.savedWeights_);
          else
               *savedWeights_ = *rhs.savedWeights_;
     } else {
          delete savedWeights_;
          savedWeights_ = NULL;
     }
     if (rhs.dubiousWeights_) {
          assert(model_);
          int number = model_->numberRows();
          if (!dubiousWeights_)
               dubiousWeights_ = new int[number];
          ClpDisjointCopyN(rhs.dubiousWeights_, number, dubiousWeights_);
     } else {
          delete [] dubiousWeights_;
          dubiousWeights_ = NULL;
     }
}
开发者ID:Alihina,项目名称:ogdf,代码行数:59,代码来源:ClpDualRowSteepest.cpp

示例7: Clp_problemName

/* Fills in array with problem name  */
COINLIBAPI void COINLINKAGE
Clp_problemName(Clp_Simplex * model, int maxNumberCharacters, char * array)
{
     std::string name = model->model_->problemName();
     maxNumberCharacters = CoinMin(maxNumberCharacters,
     				   ((int) strlen(name.c_str()))+1) ;
     strncpy(array, name.c_str(), maxNumberCharacters - 1);
     array[maxNumberCharacters-1] = '\0';
}
开发者ID:bubuker,项目名称:keggle_santa,代码行数:10,代码来源:Clp_C_Interface.cpp

示例8: main

int main(int argc, const char *argv[])
{

     // Get model in some way
     ClpInterior model;
     // Open graph and parameter files
     //FILE *fpin = fopen("./g.graph","r");
     //FILE *fpp = fopen("./gparm","r");
     FILE *fpin = fopen("./g.tiny", "r");
     FILE *fpp = fopen("./gparm.tiny", "r");
     assert(fpin);
     assert(fpp);
     myPdco stuff(model, fpin, fpp);
     Info info;
     Outfo outfo;
     Options options;


     /*
      *     Set the input parameters for LSQR.
      */
     options.gamma = stuff.getD1();
     options.delta = stuff.getD2();
     options.MaxIter = 40;
     options.FeaTol = 5.0e-4;
     options.OptTol = 5.0e-4;
     options.StepTol = 0.99;
     //  options.x0min = 10.0/num_cols;
     options.x0min = 0.01;
     options.z0min = 0.01;
     options.mu0 = 1.0e-6;
     options.LSmethod = 3;   // 1=Cholesky    2=QR    3=LSQR
     options.LSproblem = 1;  // See below
     options.LSQRMaxIter = 999;
     options.LSQRatol1 = 1.0e-3; // Initial  atol
     options.LSQRatol2 = 1.0e-6; // Smallest atol (unless atol1 is smaller)
     options.LSQRconlim = 1.0e12;
     info.atolmin = options.LSQRatol2;
     info.LSdamp = 0.0;
     // These are already set?
     model.xsize_ = 50.0 / (model.numberColumns());
     model.xsize_ = CoinMin(1.0, model.xsize_);

     /*
      *     Solve the test problem
      */
     model.pdco(&stuff, options, info, outfo);

     /*
      *     Examine the results.
      *     Print the residual norms RNORM and ARNORM given by LSQR, and then compute
      */
     return 0;
}
开发者ID:coin-or,项目名称:Clp,代码行数:54,代码来源:pdco.cpp

示例9: assert

  /// heuristic method
  int
  GuessHeuristic::solution(double &solutionValue, double *betterSolution)
  {
    // Get pointer to pseudo costs object
    const BonChooseVariable* chooseMethod = dynamic_cast<BonChooseVariable*>(model_->branchingMethod()->chooseMethod());

    if (!chooseMethod) {
      (*model_->messageHandler()) << "Can't get pseudo costs!!!\n";
      solutionValue = model_->getCurrentMinimizationObjValue();
      return -1;
    }
    const OsiPseudoCosts& pseudoCosts = chooseMethod->pseudoCosts();
    int numberObjects = pseudoCosts.numberObjects();
    assert(numberObjects == model_->numberObjects());
    const double* upTotalChange = pseudoCosts.upTotalChange();
    const double* downTotalChange = pseudoCosts.downTotalChange();
    const int* upNumber = pseudoCosts.upNumber();
    const int* downNumber = pseudoCosts.downNumber();

    double sumUpTot = 0.;
    int numberUpTot = 0;
    double sumDownTot = 0.;
    int numberDownTot = 0;
    for (int i=0;i<numberObjects;i++) {
      sumUpTot += upTotalChange[i];
      numberUpTot += upNumber[i];
      sumDownTot += downTotalChange[i];
      numberDownTot += downNumber[i];
    }
    if (!numberUpTot || !numberDownTot) {
      // don't have ANY pseudo-costs information yet
      solutionValue = COIN_DBL_MAX;
      return -1;
    }
    double upAvrg=sumUpTot/numberUpTot;
    double downAvrg=sumDownTot/numberDownTot;

    OsiObject** object =  model_->objects();

    solutionValue = model_->getCurrentMinimizationObjValue();
    for (int iObj = 0; iObj < numberObjects; iObj++) {
      //printf("%3d upest=%e uptot=%e upnum=%d downest=%e downtot=%e downnum=%d  ", iObj, object[iObj]->upEstimate(), upTotalChange[iObj], upNumber[iObj], object[iObj]->downEstimate(), downTotalChange[iObj], downNumber[iObj]);

      double upEstimate = upNumber[iObj] ? object[iObj]->upEstimate()*upTotalChange[iObj]/upNumber[iObj] : object[iObj]->upEstimate()*upAvrg;
      double downEstimate = downNumber[iObj] ? object[iObj]->downEstimate()*downTotalChange[iObj]/downNumber[iObj] : object[iObj]->downEstimate()*downAvrg;
      //printf("up=%e down=%e\n", upEstimate, downEstimate);
      solutionValue += CoinMin(upEstimate,downEstimate);
    }
    //printf("solutionValue = %e\n", solutionValue);
    return -1;
  }
开发者ID:coin-or,项目名称:Bonmin,代码行数:52,代码来源:BonGuessHeuristic.cpp

示例10: CoinMemcpyN

// Resize objective
void ClpQuadraticObjective::resize(int newNumberColumns)
{
  if (numberColumns_ != newNumberColumns) {
    int newExtended = newNumberColumns + (numberExtendedColumns_ - numberColumns_);
    int i;
    double *newArray = new double[newExtended];
    if (objective_)
      CoinMemcpyN(objective_, CoinMin(newExtended, numberExtendedColumns_), newArray);
    delete[] objective_;
    objective_ = newArray;
    for (i = numberColumns_; i < newNumberColumns; i++)
      objective_[i] = 0.0;
    if (gradient_) {
      newArray = new double[newExtended];
      if (gradient_)
        CoinMemcpyN(gradient_, CoinMin(newExtended, numberExtendedColumns_), newArray);
      delete[] gradient_;
      gradient_ = newArray;
      for (i = numberColumns_; i < newNumberColumns; i++)
        gradient_[i] = 0.0;
    }
    if (quadraticObjective_) {
      if (newNumberColumns < numberColumns_) {
        int *which = new int[numberColumns_ - newNumberColumns];
        int i;
        for (i = newNumberColumns; i < numberColumns_; i++)
          which[i - newNumberColumns] = i;
        quadraticObjective_->deleteRows(numberColumns_ - newNumberColumns, which);
        quadraticObjective_->deleteCols(numberColumns_ - newNumberColumns, which);
        delete[] which;
      } else {
        quadraticObjective_->setDimensions(newNumberColumns, newNumberColumns);
      }
    }
    numberColumns_ = newNumberColumns;
    numberExtendedColumns_ = newExtended;
  }
}
开发者ID:coin-or,项目名称:Clp,代码行数:39,代码来源:ClpQuadraticObjective.cpp

示例11: createProblem

DSP_RTN_CODE BdMaster::init()
{
	BGN_TRY_CATCH

	/** create problem */
	createProblem();

	/** set node limit */
	si_->setNodeLimit(par_->getIntParam("NODE_LIM"));

	/** set print level */
	si_->setPrintLevel(CoinMin(par_->getIntParam("LOG_LEVEL") + 2, 5));

	END_TRY_CATCH_RTN(;,DSP_RTN_ERR)
开发者ID:Argonne-National-Laboratory,项目名称:DSP,代码行数:14,代码来源:BdMaster.cpp

示例12: assert

template <typename T> void
CoinDenseVector<T>::resize(int newsize, T value)
{
  if (newsize != nElements_){
    assert(newsize > 0);
    T *newarray = new T[newsize];
    int cpysize = CoinMin(newsize, nElements_);
    CoinMemcpyN( elements_,cpysize,newarray);
    delete[] elements_;
    elements_ = newarray;
    nElements_ = newsize;
    for(int i=cpysize; i<newsize; i++)
      elements_[i] = value;
  }
}
开发者ID:sednanref,项目名称:tesis,代码行数:15,代码来源:CoinDenseVector.cpp

示例13: ClpDualRowPivot

//-------------------------------------------------------------------
// Copy constructor
//-------------------------------------------------------------------
ClpDualRowSteepest::ClpDualRowSteepest (const ClpDualRowSteepest & rhs)
     : ClpDualRowPivot(rhs)
{
     state_ = rhs.state_;
     mode_ = rhs.mode_;
     persistence_ = rhs.persistence_;
     model_ = rhs.model_;
     if ((model_ && model_->whatsChanged() & 1) != 0) {
          int number = model_->numberRows();
          if (rhs.savedWeights_)
               number = CoinMin(number, rhs.savedWeights_->capacity());
          if (rhs.infeasible_) {
               infeasible_ = new CoinIndexedVector(rhs.infeasible_);
          } else {
               infeasible_ = NULL;
          }
          if (rhs.weights_) {
               weights_ = new double[number];
               ClpDisjointCopyN(rhs.weights_, number, weights_);
          } else {
               weights_ = NULL;
          }
          if (rhs.alternateWeights_) {
               alternateWeights_ = new CoinIndexedVector(rhs.alternateWeights_);
          } else {
               alternateWeights_ = NULL;
          }
          if (rhs.savedWeights_) {
               savedWeights_ = new CoinIndexedVector(rhs.savedWeights_);
          } else {
               savedWeights_ = NULL;
          }
          if (rhs.dubiousWeights_) {
               assert(model_);
               int number = model_->numberRows();
               dubiousWeights_ = new int[number];
               ClpDisjointCopyN(rhs.dubiousWeights_, number, dubiousWeights_);
          } else {
               dubiousWeights_ = NULL;
          }
     } else {
          infeasible_ = NULL;
          weights_ = NULL;
          alternateWeights_ = NULL;
          savedWeights_ = NULL;
          dubiousWeights_ = NULL;
     }
}
开发者ID:Alihina,项目名称:ogdf,代码行数:51,代码来源:ClpDualRowSteepest.cpp

示例14: CoinMemcpyN

// Resize objective
void
ClpLinearObjective::resize(int newNumberColumns)
{
     if (numberColumns_ != newNumberColumns) {
          int i;
          double * newArray = new double[newNumberColumns];
          if (objective_)
               CoinMemcpyN(objective_, CoinMin(newNumberColumns, numberColumns_), newArray);
          delete [] objective_;
          objective_ = newArray;
          for (i = numberColumns_; i < newNumberColumns; i++)
               objective_[i] = 0.0;
          numberColumns_ = newNumberColumns;
     }

}
开发者ID:e2bsq,项目名称:Symphony,代码行数:17,代码来源:ClpLinearObjective.cpp

示例15: CoinMax

// Creates a branching object from this infeasible object.
BcpsBranchObject * 
BlisObjectInt::createBranchObject(BcpsModel *m, int direction) const
{
    BlisModel *model = dynamic_cast<BlisModel* >(m);
    OsiSolverInterface * solver = model->solver();
    
    double integerTolerance = model->BlisPar()->entry(BlisParams::integerTol);
    
    const double * solution = solver->getColSolution();
    const double * lower = solver->getColLower();
    const double * upper = solver->getColUpper();
    
    double value = solution[columnIndex_];
    //std::cout << "COL"<< columnIndex_ << ": x = " << value << std::endl;
    
    // Force value in bounds.
    value = CoinMax(value, lower[columnIndex_]);
    value = CoinMin(value, upper[columnIndex_]);
    
    double nearest = floor(value + 0.5);
    
    assert (upper[columnIndex_] > lower[columnIndex_]);
    
    int hotstartStrategy = model->getHotstartStrategy();
    
    if (hotstartStrategy <= 0) {
        if (fabs(value - nearest) < integerTolerance) {
            // Already integeral.
            std::cout << "ERROR: COL" << columnIndex_ << ": x=" << value 
                      << ", nearest=" << nearest 
                      << ", intTol=" << integerTolerance << std::endl;
            assert(0);
        }
    } 
    else {
	const double * incumbent = model->incumbent();
	double targetValue = incumbent[columnIndex_];
	if (direction > 0) {
	    value = targetValue - 0.1;
	}
	else {
	    value = targetValue + 0.1;
	}
    }
    
    return new BlisBranchObjectInt(model, objectIndex_, direction, value);
}
开发者ID:aykutbulut,项目名称:CHiPPS-BiCePS,代码行数:48,代码来源:BlisObjectInt.cpp


注:本文中的CoinMin函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。