/home/coin/SVN-release/OS-2.1.0/Bonmin/src/Algorithms/Branching/BonRandomChoice.hpp

Go to the documentation of this file.
00001 // (C) Copyright CNRS 2008
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Pierre Bonami, LIF, CNRS-Marseille Universites.
00007 //
00008 // Date : 03/17/2008
00009 #ifndef BonRandomChoice_H
00010 #define BonRandomChoice_H
00011 
00012 #include "OsiChooseVariable.hpp"
00013 #include "OsiSolverInterface.hpp"
00014 
00015 class BonRandomChoice : public OsiChooseVariable {
00016   public:
00018   BonRandomChoice(): OsiChooseVariable(){
00019   }
00020 
00021   //Constructor from solver
00022   BonRandomChoice(const OsiSolverInterface * solver):
00023     OsiChooseVariable(solver){
00024   }
00025 
00026   // Copy constructor
00027   BonRandomChoice(const BonRandomChoice &other):
00028     OsiChooseVariable(other){
00029   }
00030 
00031   // Assignment operator
00032   BonRandomChoice & operator=(const BonRandomChoice &rhs){
00033     OsiChooseVariable::operator=(rhs);
00034     return (*this);
00035   }
00036 
00037   // Virtual copy
00038   virtual OsiChooseVariable * clone() const{
00039      return new BonRandomChoice(*this);
00040   }
00041 
00043   virtual ~BonRandomChoice(){
00044   }
00045 
00046   virtual int chooseVariable( OsiSolverInterface * solver,
00047                               OsiBranchingInformation * info,
00048                               bool fixVariables){
00049     if(numberUnsatisfied_){
00050       int chosen = (int) (floor(CoinDrand48() * (numberUnsatisfied_)));
00051       bestObjectIndex_ = list_[chosen];
00052       bestWhichWay_ = solver->object(bestObjectIndex_)->whichWay();
00053       firstForcedObjectIndex_ = -1;
00054       firstForcedWhichWay_ =-1;
00055       return 0;
00056     }
00057     else {
00058       return 1;
00059     }
00060   }
00061 };
00062 #endif

Generated on Tue Mar 30 03:04:33 2010 by  doxygen 1.4.7