/home/coin/SVN-release/OS-2.2.0/Bonmin/src/CbcBonmin/Heuristics/BonFixAndSolveHeuristic.cpp

Go to the documentation of this file.
00001 // (C) Copyright CNRS
00002 // This code is published under the Common Public License.
00003 //
00004 // Authors :
00005 // Pierre Bonami, LIF Université de la Méditérannée-CNRS
00006 //
00007 // Date : 06/18/2008
00008 
00009 #include "BonFixAndSolveHeuristic.hpp"
00010 #include "CbcModel.hpp"
00011 #include "OsiBranchingObject.hpp"
00012 
00013 namespace Bonmin {
00014 
00016   FixAndSolveHeuristic::FixAndSolveHeuristic():
00017     LocalSolverBasedHeuristic()
00018     {
00019   }
00021   FixAndSolveHeuristic::FixAndSolveHeuristic(BonminSetup * setup):
00022     LocalSolverBasedHeuristic(setup)
00023     {
00024   }
00025 
00027   FixAndSolveHeuristic::FixAndSolveHeuristic
00028              (const FixAndSolveHeuristic &other):
00029     LocalSolverBasedHeuristic(other){
00030   }
00031 
00032   FixAndSolveHeuristic::~FixAndSolveHeuristic(){
00033   }
00034 
00036   int
00037   FixAndSolveHeuristic::solution(double & objectiveValue,
00038                                  double * newSolution){
00039     //if(model_->getNodeCount() || model_->getCurrentPassNumber() > 1) return 0;
00040     if(model_->getSolutionCount() > 0) return 0;
00041     if(model_->getNodeCount() > 1000) return 0;
00042     if(model_->getNodeCount() % 100 != 0) return 0;
00043     int numberObjects = model_->numberObjects();
00044     OsiObject ** objects = model_->objects();
00045 
00046     OsiTMINLPInterface * nlp = dynamic_cast<OsiTMINLPInterface *>
00047                                (model_->solver());
00048     if(nlp == NULL){
00049        nlp = dynamic_cast<OsiTMINLPInterface *>
00050                          (setup_->nonlinearSolver()->clone());
00051      }
00052      else {
00053        nlp = dynamic_cast<OsiTMINLPInterface *>(nlp->clone());
00054      }
00055 
00056     OsiBranchingInformation info = model_->usefulInformation();
00057     info.solution_ = model_->getColSolution();
00058 
00059     int dummy;
00060     int nFixed = 0;
00061     for(int i = 0 ; i < numberObjects; i++){
00062       if(objects[i]->infeasibility(&info, dummy) == 0.){
00063          objects[i]->feasibleRegion(nlp, &info);
00064          nFixed ++;
00065       }
00066     }
00067     if(nFixed < numberObjects / 3) return 0;
00068     double cutoff = info.cutoff_; 
00069     int r_val = doLocalSearch(nlp, newSolution, objectiveValue, cutoff);
00070     delete nlp;
00071     return r_val;
00072   }
00073 
00074   void
00075   FixAndSolveHeuristic::registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions){
00076    roptions->SetRegisteringCategory("Test Heuristics", RegisteredOptions::UndocumentedCategory);
00077    roptions->AddStringOption2(
00078      "fix_and_solve_heuristic",
00079      "if yes runs a heuristic at root where fixes all variables integer in the continuous solution",
00080      "no",
00081      "no", "don't run it",
00082      "yes", "runs the heuristic",
00083      "");
00084    roptions->setOptionExtraInfo("fix_and_solve_heuristic", 63);
00085   }
00086 
00088    void 
00089    FixAndSolveHeuristic::Initialize(Ipopt::SmartPtr<Bonmin::OptionsList> options){
00090    }
00091 }/* ends bonmin namespace*/

Generated on Thu Aug 5 03:02:54 2010 by  doxygen 1.4.7