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 
18  public:
21  }
22 
23  //Constructor from solver
25  OsiChooseVariable(solver){
26  }
27 
28  // Copy constructor
30  OsiChooseVariable(other){
31  }
32 
33  // Assignment operator
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,
54  bool fixVariables){
56  int chosen = (int) (floor(CoinDrand48() * (numberUnsatisfied_)));
57  bestObjectIndex_ = list_[chosen];
61  return 0;
62  }
63  else {
64  return 1;
65  }
66  }
67 };
68 #endif
BonRandomChoice::BonRandomChoice
BonRandomChoice(const BonRandomChoice &other)
Definition: BonRandomChoice.hpp:29
OsiChooseVariable.hpp
OsiSolverInterface::object
const OsiObject * object(int which) const
OsiChooseVariable::list_
int * list_
OsiObject::whichWay
int whichWay() const
BonRandomChoice::setupList
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...
BonRandomChoice::BonRandomChoice
BonRandomChoice()
Default constructor.
Definition: BonRandomChoice.hpp:20
OsiChooseVariable::bestObjectIndex_
int bestObjectIndex_
OsiSolverInterface.hpp
BonRandomChoice::BonRandomChoice
BonRandomChoice(const OsiSolverInterface *solver)
Definition: BonRandomChoice.hpp:24
OsiChooseVariable
BonRandomChoice
Definition: BonRandomChoice.hpp:17
OsiSolverInterface
OsiChooseVariable::bestWhichWay_
int bestWhichWay_
OsiChooseVariable::numberUnsatisfied_
int numberUnsatisfied_
OsiChooseVariable::operator=
OsiChooseVariable & operator=(const OsiChooseVariable &rhs)
BonRandomChoice::~BonRandomChoice
virtual ~BonRandomChoice()
Destructor.
Definition: BonRandomChoice.hpp:45
OsiBranchingInformation
BonRandomChoice::clone
virtual OsiChooseVariable * clone() const
Definition: BonRandomChoice.hpp:40
OsiChooseVariable::firstForcedObjectIndex_
int firstForcedObjectIndex_
CoinDrand48
double CoinDrand48(bool isSeed=false, unsigned int seed=1)
BonRandomChoice::operator=
BonRandomChoice & operator=(const BonRandomChoice &rhs)
Definition: BonRandomChoice.hpp:34
OsiChooseVariable::firstForcedWhichWay_
int firstForcedWhichWay_
BonRandomChoice::chooseVariable
virtual int chooseVariable(OsiSolverInterface *solver, OsiBranchingInformation *info, bool fixVariables)
Definition: BonRandomChoice.hpp:52