Ignore:
Timestamp:
Nov 5, 2009 10:57:25 AM (10 years ago)
Author:
forrest
Message:

Creating new stable branch 2.4 from trunk (rev 1270)

Location:
stable/2.4
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable/2.4

    • Property svn:externals
      •  

        old new  
        77CoinUtils         https://projects.coin-or.org/svn/CoinUtils/stable/2.5/CoinUtils
        88Cgl               https://projects.coin-or.org/svn/Cgl/stable/0.54/Cgl
        9 Clp               https://projects.coin-or.org/svn/Clp/stable/1.10/Clp
         9Clp               https://projects.coin-or.org/svn/Clp/stable/1.11/Clp
        1010Osi               https://projects.coin-or.org/svn/Osi/stable/0.100/Osi
        1111Vol               https://projects.coin-or.org/svn/Vol/stable/1.1/Vol
  • stable/2.4/Cbc/src/CbcHeuristicDivePseudoCost.cpp

    r945 r1271  
     1/* $Id: CbcHeuristicDivePseudoCost.cpp 1240 2009-10-02 18:41:44Z forrest $ */
    12// Copyright (C) 2008, International Business Machines
    23// Corporation and others.  All Rights Reserved.
     
    89#include "CbcHeuristicDivePseudoCost.hpp"
    910#include "CbcStrategy.hpp"
     11#include "CbcBranchDynamic.hpp"
    1012
    1113// Default Constructor
     
    7577
    7678  // get pseudo costs
    77   double * pseudoCostDown = new double[numberIntegers];
    78   double * pseudoCostUp = new double[numberIntegers];
    79   model_->fillPseudoCosts(pseudoCostDown, pseudoCostUp);
     79  double * pseudoCostDown = downArray_;
     80  double * pseudoCostUp = upArray_;
    8081
    8182  bestColumn = -1;
     
    138139  }
    139140
    140   delete [] pseudoCostDown;
    141   delete [] pseudoCostUp;
    142 
    143141  return allTriviallyRoundableSoFar;
    144142}
     143void
     144CbcHeuristicDivePseudoCost::initializeData()
     145{
     146  int numberIntegers = model_->numberIntegers();
     147  if (!downArray_) {
     148    downArray_ = new double [numberIntegers];
     149    upArray_ = new double [numberIntegers];
     150  }
     151  // get pseudo costs
     152  model_->fillPseudoCosts(downArray_, upArray_);
     153  int diveOptions = when_/100;
     154  if (diveOptions) {
     155    // pseudo shadow prices
     156    int k = diveOptions%100;
     157    if (diveOptions>=100)
     158      k +=32;
     159    model_->pseudoShadow(k-1);
     160    int numberInts=CoinMin(model_->numberObjects(),numberIntegers);
     161    OsiObject ** objects = model_->objects();
     162    for (int i=0;i<numberInts;i++) {
     163      CbcSimpleIntegerDynamicPseudoCost * obj1 =
     164        dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(objects[i]) ;
     165      if (obj1) {
     166        //int iColumn = obj1->columnNumber();
     167        double downPseudoCost = 1.0e-2*obj1->downDynamicPseudoCost();
     168        double downShadow = obj1->downShadowPrice();
     169        double upPseudoCost = 1.0e-2*obj1->upDynamicPseudoCost();
     170        double upShadow = obj1->upShadowPrice();
     171        downPseudoCost = CoinMax(downPseudoCost,downShadow);
     172        downPseudoCost = CoinMax(downPseudoCost,0.001*upShadow);
     173        downArray_[i]=downPseudoCost;
     174        upPseudoCost = CoinMax(upPseudoCost,upShadow);
     175        upPseudoCost = CoinMax(upPseudoCost,0.001*downShadow);
     176        upArray_[i]=upPseudoCost;
     177      }
     178    }
     179  }
     180}
     181// Fix other variables at bounds
     182int
     183CbcHeuristicDivePseudoCost::fixOtherVariables(OsiSolverInterface * solver,
     184                                              const double * solution,
     185                                              PseudoReducedCost * candidate,
     186                                              const double * random)
     187{
     188  const double * lower = solver->getColLower();
     189  const double * upper = solver->getColUpper();
     190  double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance);
     191  double primalTolerance;
     192  solver->getDblParam(OsiPrimalTolerance,primalTolerance);
     193
     194  int numberIntegers = model_->numberIntegers();
     195  const int * integerVariable = model_->integerVariable();
     196  const double* reducedCost = solver->getReducedCost();
     197  // fix other integer variables that are at their bounds
     198  int cnt=0;
     199  int numberFree=0;
     200  int numberFixedAlready=0;
     201  for (int i=0; i<numberIntegers; i++) {
     202    int iColumn = integerVariable[i];
     203    if (upper[iColumn]>lower[iColumn]) {
     204      numberFree++;
     205      double value=solution[iColumn];
     206      if(value-lower[iColumn]<=integerTolerance) {
     207        candidate[cnt].var = iColumn;
     208        candidate[cnt++].pseudoRedCost = CoinMax(1.0e-2*reducedCost[iColumn],
     209                                                 downArray_[i])*random[i];
     210      } else if(upper[iColumn]-value<=integerTolerance) {
     211        candidate[cnt].var = iColumn;
     212        candidate[cnt++].pseudoRedCost = CoinMax(-1.0e-2*reducedCost[iColumn],
     213                                                 downArray_[i])*random[i];
     214      }
     215    } else {
     216      numberFixedAlready++;
     217    }
     218  }
     219#ifdef CLP_INVESTIGATE
     220  printf("cutoff %g obj %g - %d free, %d fixed\n",
     221         model_->getCutoff(),solver->getObjValue(),numberFree,
     222         numberFixedAlready);
     223#endif
     224  return cnt;
     225  //return CbcHeuristicDive::fixOtherVariables(solver, solution,
     226  //                                 candidate, random);
     227}
Note: See TracChangeset for help on using the changeset viewer.