source: trunk/Alps/examples/Abc/AbcHeuristic.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.1 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//#############################################################################
19// This file is modified from SbbHeuristic.hpp
20//#############################################################################
21
22#ifndef AbcHeuristic_h_
23#define AbcHeuristic_h_
24
25#include <string>
26#include <vector>
27#include "CoinPackedMatrix.hpp"
28#include "OsiCuts.hpp"
29
30class OsiSolverInterface;
31class AbcModel;
32
33//#############################################################################
34
35/** Heuristic base class */
36class AbcHeuristic {
37public:
38  // Default Constructor
39  AbcHeuristic ();
40
41  // Constructor with model - assumed before cuts
42  AbcHeuristic (AbcModel & model);
43
44  virtual ~AbcHeuristic();
45
46  /// update model (This is needed if cliques update matrix etc)
47  virtual void setModel(AbcModel * model);
48 
49  /// Clone
50  virtual AbcHeuristic * clone() const=0;
51
52  /** returns 0 if no solution, 1 if valid solution
53      with better objective value than one passed in
54      Sets solution values if good, sets objective value
55      This is called after cuts have been added - so can not add cuts
56  */
57  virtual int solution(double & objectiveValue,
58                       double * newSolution)=0;
59
60  /** returns 0 if no solution, 1 if valid solution, -1 if just
61      returning an estimate of best possible solution
62      with better objective value than one passed in
63      Sets solution values if good, sets objective value (only if nonzero code)
64      This is called at same time as cut generators - so can add cuts
65      Default is do nothing
66  */
67  virtual int solution(double & objectiveValue,
68                       double * newSolution,
69                       OsiCuts & cs) {return 0;};
70
71protected:
72
73  /// Model
74  AbcModel * model_;
75private:
76 
77  /// Illegal Assignment operator
78  AbcHeuristic & operator=(const AbcHeuristic& rhs);
79 
80};
81
82/** Rounding class
83 */
84
85class AbcRounding : public AbcHeuristic {
86public:
87
88  // Default Constructor
89  AbcRounding ();
90
91  // Constructor with model - assumed before cuts
92  AbcRounding (AbcModel & model);
93 
94  // Copy constructor
95  AbcRounding ( const AbcRounding &);
96   
97  // Destructor
98  ~AbcRounding ();
99 
100  /// Clone
101  virtual AbcHeuristic * clone() const;
102
103  /// update model (This is needed if cliques update matrix etc)
104  virtual void setModel(AbcModel * model);
105 
106  /** returns 0 if no solution, 1 if valid solution
107      with better objective value than one passed in
108      Sets solution values if good, sets objective value (only if good)
109      This is called after cuts have been added - so can not add cuts
110  */
111  virtual int solution(double & objectiveValue,
112                       double * newSolution);
113
114
115  /// Set seed
116  void setSeed(int value)
117  { seed_ = value;};
118
119protected:
120  // Data
121
122  // Original matrix by column
123  CoinPackedMatrix matrix_;
124
125  // Original matrix by
126  CoinPackedMatrix matrixByRow_;
127
128  // Seed for random stuff
129  int seed_;
130
131private:
132  /// Illegal Assignment operator
133  AbcRounding & operator=(const AbcRounding& rhs);
134};
135
136
137#endif
138
Note: See TracBrowser for help on using the repository browser.