summaryrefslogtreecommitdiff
path: root/newstructure/thirdparty/linux/include/coin/CbcBranchDecision.hpp
blob: 538fe8c84fbb9c50027d26884292a07c2f0fe472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// $Id: CbcBranchDecision.hpp 1899 2013-04-09 18:12:08Z stefan $
// Copyright (C) 2002, International Business Machines
// Corporation and others.  All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).

// Edwin 11/12/2009 carved from CbcBranchBase

#ifndef CbcBranchDecision_H
#define CbcBranchDecision_H

#include "CbcBranchBase.hpp"

/** Abstract branching decision base class

  In the abstract, an CbcBranchDecision object is expected to be able to
  compare two possible branching choices.

  The #betterBranch() method is the crucial routine. It is expected to be able
  to compare two \link CbcBranchingObject CbcBranchingObjects \endlink.

  See CbcObject for an overview of the three classes (CbcObject,
  CbcBranchingObject, and CbcBranchDecision) which make up cbc's branching
  model.
*/
class CbcModel;
class OsiChooseVariable;

class CbcBranchDecision {
public:
    /// Default Constructor
    CbcBranchDecision ();

    // Copy constructor
    CbcBranchDecision ( const CbcBranchDecision &);

    /// Destructor
    virtual ~CbcBranchDecision();

/// Clone
    virtual CbcBranchDecision * clone() const = 0;

    /// Initialize <i>e.g.</i> before starting to choose a branch at a node
    virtual void initialize(CbcModel * model) = 0;

    /** \brief Compare two branching objects. Return nonzero if branching
           using \p thisOne is better than branching using \p bestSoFar.

      If \p bestSoFar is NULL, the routine should return a nonzero value.
      This routine is used only after strong branching.
      Either this or bestBranch is used depending which user wants.

    */

    virtual int
    betterBranch (CbcBranchingObject * thisOne,
                  CbcBranchingObject * bestSoFar,
                  double changeUp, int numberInfeasibilitiesUp,
                  double changeDown, int numberInfeasibilitiesDown) = 0 ;

    /** \brief Compare N branching objects. Return index of best
        and sets way of branching in chosen object.

      Either this or betterBranch is used depending which user wants.
    */

    virtual int
    bestBranch (CbcBranchingObject ** objects, int numberObjects, int numberUnsatisfied,
                double * changeUp, int * numberInfeasibilitiesUp,
                double * changeDown, int * numberInfeasibilitiesDown,
                double objectiveValue) ;

    /** Says whether this method can handle both methods -
        1 better, 2 best, 3 both */
    virtual int whichMethod() {
        return 2;
    }

    /** Saves a clone of current branching object.  Can be used to update
        information on object causing branch - after branch */
    virtual void saveBranchingObject(OsiBranchingObject * ) {}
    /** Pass in information on branch just done.
        assumes object can get information from solver */
    virtual void updateInformation(OsiSolverInterface * ,
                                   const CbcNode * ) {}
    /** Sets or gets best criterion so far */
    virtual void setBestCriterion(double ) {}
    virtual double getBestCriterion() const {
        return 0.0;
    }
    /// Create C++ lines to get to current state
    virtual void generateCpp( FILE * ) {}
    /// Model
    inline CbcModel * cbcModel() const {
        return model_;
    }
    /* If chooseMethod_ id non-null then the rest is fairly pointless
       as choosemethod_ will be doing all work
     This comment makes more sense if you realise that there's a conversion in
     process from the Cbc branching classes to Osi branching classes. The test
     for use of the Osi branching classes is CbcModel::branchingMethod_
     non-null (i.e., it points to one of these CbcBranchDecision objects) and
     that branch decision object has an OsiChooseVariable method set. In which
     case, we'll use it, rather than the choose[*]Variable methods defined in
     CbcNode.
	*/

    OsiChooseVariable * chooseMethod() const {
        return chooseMethod_;
    }
    /// Set (clone) chooseMethod
    void setChooseMethod(const OsiChooseVariable & method);

protected:

    // Clone of branching object
    CbcBranchingObject * object_;
    /// Pointer to model
    CbcModel * model_;
    /* If chooseMethod_ id non-null then the rest is fairly pointless
       as choosemethod_ will be doing all work
    */
    OsiChooseVariable * chooseMethod_;
private:
    /// Assignment is illegal
    CbcBranchDecision & operator=(const CbcBranchDecision& rhs);

};
#endif