Bonmin  1.8.8
BonRandomChoice.hpp
Go to the documentation of this file.
1 // (C) Copyright CNRS 2008
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // Pierre Bonami, LIF, CNRS-Marseille Universites.
7 //
8 // Date : 03/17/2008
9 #ifndef BonRandomChoice_H
10 #define BonRandomChoice_H
11 
12 #include "OsiChooseVariable.hpp"
13 #include "OsiSolverInterface.hpp"
14 #include <list>
15 #include <cmath>
16 
17 class BonRandomChoice : public OsiChooseVariable {
18  public:
20  BonRandomChoice(): OsiChooseVariable(){
21  }
22 
23  //Constructor from solver
24  BonRandomChoice(const OsiSolverInterface * solver):
25  OsiChooseVariable(solver){
26  }
27 
28  // Copy constructor
30  OsiChooseVariable(other){
31  }
32 
33  // Assignment operator
35  OsiChooseVariable::operator=(rhs);
36  return (*this);
37  }
38 
39  // Virtual copy
40  virtual OsiChooseVariable * clone() const{
41  return new BonRandomChoice(*this);
42  }
43 
45  virtual ~BonRandomChoice(){
46  }
47 
50  virtual int setupList(OsiBranchingInformation * info, bool initialize);
51 
52  virtual int chooseVariable( OsiSolverInterface * solver,
53  OsiBranchingInformation * info,
54  bool fixVariables){
55  if(numberUnsatisfied_){
56  int chosen = (int) (floor(CoinDrand48() * (numberUnsatisfied_)));
57  bestObjectIndex_ = list_[chosen];
58  bestWhichWay_ = solver->object(bestObjectIndex_)->whichWay();
59  firstForcedObjectIndex_ = -1;
60  firstForcedWhichWay_ =-1;
61  return 0;
62  }
63  else {
64  return 1;
65  }
66  }
67 };
68 #endif
BonRandomChoice()
Default constructor.
BonRandomChoice & operator=(const BonRandomChoice &rhs)
virtual ~BonRandomChoice()
Destructor.
BonRandomChoice(const OsiSolverInterface *solver)
virtual int setupList(OsiBranchingInformation *info, bool initialize)
Own version of setupList since Osi version is broken and what we want to do here is anyway much simpl...
virtual OsiChooseVariable * clone() const
BonRandomChoice(const BonRandomChoice &other)
virtual int chooseVariable(OsiSolverInterface *solver, OsiBranchingInformation *info, bool fixVariables)