source: trunk/Alps/examples/Abc/AbcBranchActual.h @ 277

Last change on this file since 277 was 277, checked in by andreasw, 13 years ago

first working version with autotools

File size: 4.5 KB
Line 
1/*===========================================================================*
2 * This file is part of the Abstract Library for Parallel Search (ALPS).     *
3 *                                                                           *
4 * ALPS is distributed under the Common Public License as part of the        *
5 * COIN-OR repository (http://www.coin-or.org).                              *
6 *                                                                           *
7 * Authors: Yan Xu, SAS Institute Inc.                                       *
8 *          Ted Ralphs, Lehigh University                                    *
9 *          Laszlo Ladanyi, IBM T.J. Watson Research Center                  *
10 *          Matthew Saltzman, Clemson University                             *
11 *                                                                           *
12 *                                                                           *
13 * Copyright (C) 2001-2004, International Business Machines                  *
14 * Corporation, Lehigh University, Yan Xu, Ted Ralphs, Matthew Salzman and   *
15 * others. All Rights Reserved.                                              *
16 *===========================================================================*/
17
18#ifndef AbcBranchActual_h_
19#define AbcBranchActual_h_
20
21//#############################################################################
22// This file is modified from SbbBranchActual.hpp
23//#############################################################################
24
25#include "AbcBranchBase.h"
26
27//#############################################################################
28/** Branching decision default class
29
30  This class implements a simple default algorithm
31  (betterBranch()) for choosing a branching variable.
32*/
33class AbcBranchDefaultDecision : public AbcBranchDecision {
34
35 public:
36    // Default Constructor
37    AbcBranchDefaultDecision();
38
39    // Copy constructor
40    AbcBranchDefaultDecision(const AbcBranchDefaultDecision &);
41   
42    virtual ~AbcBranchDefaultDecision();
43
44    /// Clone
45    virtual AbcBranchDecision * clone() const;
46
47    /// Initialize, <i>e.g.</i> before the start of branch selection at a node
48    virtual void initialize(AbcModel * model);
49
50    /** \brief Compare two branching objects. Return nonzero if \p thisOne is
51        better than \p bestSoFar.
52
53        The routine compares branches using the values supplied in
54        \p numInfUp and \p numInfDn until a solution is found by search,
55        after which it uses the values supplied in \p changeUp and
56        \p changeDn. The best branching object seen so far and the
57        associated parameter values are remembered in the
58        \c AbcBranchDefaultDecision object. The nonzero return value is +1
59        if the up branch is preferred, -1 if the down branch is preferred.
60       
61        As the names imply, the assumption is that the values supplied for
62        \p numInfUp and \p numInfDn will be the number of infeasibilities
63        reported by the branching object, and \p changeUp and \p changeDn
64        will be the estimated change in objective. Other measures can be
65        used if desired.
66
67        Because an \c AbcBranchDefaultDecision object remembers the current
68        best branching candidate (#bestObject_) as well as the values used
69        in the comparison, the parameter \p bestSoFar is redundant, hence
70        unused.
71    */
72    virtual int betterBranch(int thisOne,
73                             int bestSoFar,
74                             double changeUp, int numInfUp,
75                             double changeDn, int numInfDn);
76
77 private:
78 
79    /// Illegal Assignment operator
80    AbcBranchDefaultDecision & operator=(const AbcBranchDefaultDecision& rhs);
81
82    /// data
83    /// Point to the model
84    AbcModel * model_;
85
86    /// "best" so far
87    double bestCriterion_;
88
89    /// Change up for best
90    double bestChangeUp_;
91
92    /// Number of infeasibilities for up
93    int bestNumberUp_;
94
95    /// Change down for best
96    double bestChangeDown_;
97
98    /// Number of infeasibilities for down
99    int bestNumberDown_;
100
101    /// Index of the best branching integer variable
102    int bestObject_;
103};
104
105
106class AbcPseudocost
107{
108 public:
109    int colInd_;
110    double upCost_;
111    int upNum_;
112    double downCost_;
113    int downNum_;
114
115 public:
116    AbcPseudocost() 
117        : 
118        colInd_(-1), 
119        upCost_(0.0), upNum_(0), 
120        downCost_(0.0), downNum_(0) {}
121
122    AbcPseudocost(const int ind, 
123                  const double uc, 
124                  const int un,
125                  const double dc, 
126                  const int dn)
127        :
128        colInd_(ind), 
129        upCost_(uc), upNum_(un),
130        downCost_(dc), downNum_(dn) {}
131   
132    void update(const int dir,
133                const double parentObjValue,
134                const double objValue,
135                const double solValue);
136   
137};
138
139#endif
Note: See TracBrowser for help on using the repository browser.