Changeset 186


Ignore:
Timestamp:
Oct 7, 2005 4:27:24 PM (14 years ago)
Author:
forrest
Message:

heuristics

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CbcHeuristicFPump.cpp

    r181 r186  
    9494  // Clone solver - otherwise annoys root node computations
    9595  OsiSolverInterface * solver = model_->solver()->clone();
    96  
     96  solver->setDblParam(OsiDualObjectiveLimit,1.0e50);
    9797  solver->resolve();
    9898  const double * lower = solver->getColLower();
     
    170170      // SOLUTION IS INTEGER
    171171      // Put back correct objective
    172       printf("\n");
    173       newLineNeeded=false;
    174172      for (i=0;i<numberColumns;i++)
    175173        solver->setObjCoeff(i,saveObjective[i]);
     
    177175      // Compute using dot product
    178176      double newSolutionValue = direction*solver->OsiSolverInterface::getObjValue();
     177      printf(" - solution value of %g\n",newSolutionValue);
     178      newLineNeeded=false;
    179179      if (newSolutionValue<solutionValue) {
    180180        memcpy(betterSolution,newSolution,numberColumns*sizeof(double));
  • trunk/CbcModel.cpp

    r182 r186  
    2121#include "CbcHeuristic.hpp"
    2222#include "CbcModel.hpp"
     23#include "CbcTreeLocal.hpp"
    2324#include "CbcStatistics.hpp"
    2425#include "CbcStrategy.hpp"
     
    503504    currentSolution_ = new double[numberColumns] ;
    504505  testSolution_ = currentSolution_;
     506  /* Tell solver we are in Branch and Cut
     507     Could use last parameter for subtle differences */
     508  solver_->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo,NULL) ;
    505509/*
    506510  Create a copy of the solver, thus capturing the original (root node)
     
    793797      printFrequency_ = 100 ;
    794798  }
    795   /* Tell solver we are in Branch and Cut
    796      Could use last parameter for subtle differences */
    797   solver_->setHintParam(OsiDoInBranchAndCut,true,OsiHintDo,NULL) ;
    798799  /*
    799800    It is possible that strong branching fixes one variable and then the code goes round
     
    31123113      setBestSolution(CBC_ROUNDING,heuristicValue,newSolution) ;
    31133114      lastHeuristic_ = heuristic_[found];
     3115      CbcTreeLocal * tree
     3116          = dynamic_cast<CbcTreeLocal *> (tree_);
     3117      if (tree)
     3118        tree->passInSolution(bestSolution_,heuristicValue);
    31143119    }
    31153120    delete [] newSolution ;
  • trunk/CbcTreeLocal.cpp

    r185 r186  
    301301{
    302302  return new CbcTreeLocal(*this);
     303}
     304// Pass in solution (so can be used after heuristic)
     305void
     306CbcTreeLocal::passInSolution(const double * solution, double solutionValue)
     307{
     308  int numberColumns = model_->getNumCols();
     309  delete [] savedSolution_;
     310  savedSolution_ = new double [numberColumns];
     311  memcpy(savedSolution_,solution,numberColumns*sizeof(double));
     312  rhs_=range_;
     313  // Check feasible
     314  int goodSolution=createCut(solution,cut_);
     315  if (goodSolution>=0) {
     316    bestCutoff_=solutionValue;
     317  } else {
     318    model_=NULL;
     319  }
    303320}
    304321// Return the top node of the heap
  • trunk/Test/CoinSolve.cpp

    r183 r186  
    6868#include "CbcHeuristicGreedy.hpp"
    6969#include "CbcHeuristicFPump.hpp"
     70#include "CbcTreeLocal.hpp"
    7071#include "CbcCompareActual.hpp"
    7172#include  "CbcOrClpParam.hpp"
     
    255256    int useFpump=0;
    256257    bool useGreedy=false;
    257     bool useLocal=false;
     258    bool useCombine=false;
     259    bool useLocalTree=false;
    258260   
    259261    // total number of commands read
     
    675677              useRounding = action;
    676678              useGreedy = action;
    677               useLocal = action;
    678               useFpump = action;
     679              useCombine = action;
     680              //useLocalTree = action;
     681              if (action&&useFpump==0)
     682                useFpump=parameters[whichParam(FPUMPITS,numberParameters,parameters)].intValue();
     683              else if (!action)
     684                useFpump=0;
    679685              parameters[whichParam(ROUNDING,numberParameters,parameters)].setCurrentOption(action);
    680686              parameters[whichParam(GREEDY,numberParameters,parameters)].setCurrentOption(action);
    681               parameters[whichParam(LOCAL,numberParameters,parameters)].setCurrentOption(action);
     687              parameters[whichParam(COMBINE,numberParameters,parameters)].setCurrentOption(action);
     688              //parameters[whichParam(LOCALTREE,numberParameters,parameters)].setCurrentOption(action);
    682689              parameters[whichParam(FPUMP,numberParameters,parameters)].setCurrentOption(action);
    683690              break;
     
    686693              useGreedy = action;
    687694              break;
    688             case LOCAL:
     695            case COMBINE:
    689696              defaultSettings=false; // user knows what she is doing
    690               useLocal = action;
     697              useCombine = action;
     698              break;
     699            case LOCALTREE:
     700              defaultSettings=false; // user knows what she is doing
     701              useLocalTree = action;
    691702              break;
    692703            case COSTSTRATEGY:
     
    962973              //model.solver()->getStrParam(OsiProbName,problemName) ;
    963974              //model.solver()->activateRowCutDebugger(problemName.c_str()) ;
     975              // FPump done first as it only works if no solution
     976              CbcHeuristicFPump heuristic4(model);
     977              if (useFpump) {
     978                heuristic4.setMaximumPasses(useFpump);
     979                model.addHeuristic(&heuristic4);
     980              }
    964981              CbcRounding heuristic1(model);
    965982              if (useRounding)
     
    967984              CbcHeuristicLocal heuristic2(model);
    968985              heuristic2.setSearchType(1);
    969               if (useLocal)
     986              if (useCombine)
    970987                model.addHeuristic(&heuristic2);
    971988              CbcHeuristicGreedyCover heuristic3(model);
     
    975992                model.addHeuristic(&heuristic3a);
    976993              }
    977               CbcHeuristicFPump heuristic4(model);
    978               if (useFpump) {
    979                 heuristic4.setMaximumPasses(useFpump);
    980                 model.addHeuristic(&heuristic4);
    981               }
     994              CbcTreeLocal localTree(&model,NULL,10,0,0,10000,2000);
     995              if (useLocalTree)
     996                model.passInTreeHandler(localTree);
    982997              // add cut generators if wanted
    983998              if (probingAction==1)
  • trunk/include/CbcTreeLocal.hpp

    r185 r186  
    9797  /// Delete last cut branch
    9898  void deleteCut(OsiRowCut & cut);
     99  /// Pass in solution (so can be used after heuristic)
     100  void passInSolution(const double * solution, double solutionValue);
    99101
    100102//@}
Note: See TracChangeset for help on using the changeset viewer.