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 #include <list>
00015 #include <cmath>
00016
00017 class BonRandomChoice : public OsiChooseVariable {
00018 public:
00020 BonRandomChoice(): OsiChooseVariable(){
00021 }
00022
00023
00024 BonRandomChoice(const OsiSolverInterface * solver):
00025 OsiChooseVariable(solver){
00026 }
00027
00028
00029 BonRandomChoice(const BonRandomChoice &other):
00030 OsiChooseVariable(other){
00031 }
00032
00033
00034 BonRandomChoice & operator=(const BonRandomChoice &rhs){
00035 OsiChooseVariable::operator=(rhs);
00036 return (*this);
00037 }
00038
00039
00040 virtual OsiChooseVariable * clone() const{
00041 return new BonRandomChoice(*this);
00042 }
00043
00045 virtual ~BonRandomChoice(){
00046 }
00047
00050 virtual int setupList(OsiBranchingInformation * info, bool initialize);
00051
00052 virtual int chooseVariable( OsiSolverInterface * solver,
00053 OsiBranchingInformation * info,
00054 bool fixVariables){
00055 if(numberUnsatisfied_){
00056 int chosen = (int) (floor(CoinDrand48() * (numberUnsatisfied_)));
00057 bestObjectIndex_ = list_[chosen];
00058 bestWhichWay_ = solver->object(bestObjectIndex_)->whichWay();
00059 firstForcedObjectIndex_ = -1;
00060 firstForcedWhichWay_ =-1;
00061 return 0;
00062 }
00063 else {
00064 return 1;
00065 }
00066 }
00067 };
00068 #endif