00001
00002
00003
00004
00005
00006
00007
00008
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
00022 BonRandomChoice(const OsiSolverInterface * solver):
00023 OsiChooseVariable(solver){
00024 }
00025
00026
00027 BonRandomChoice(const BonRandomChoice &other):
00028 OsiChooseVariable(other){
00029 }
00030
00031
00032 BonRandomChoice & operator=(const BonRandomChoice &rhs){
00033 OsiChooseVariable::operator=(rhs);
00034 return (*this);
00035 }
00036
00037
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