source: trunk/Alps/examples/Abc/AbcCutGenerator.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: 7.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 SbbCutGenerator.hpp
20//#############################################################################
21
22#ifndef AbcCutGenerator_h_
23#define AbcCutGenerator_h_
24
25#include "OsiSolverInterface.hpp"
26#include "OsiCuts.hpp"
27
28class AbcModel;
29class OsiRowCut;
30class OsiRowCutDebugger;
31class CglCutGenerator;
32
33//#############################################################################
34
35/** Interface between Abc and Cut Generation Library.
36   
37    \c AbcCutGenerator is intended to provide an intelligent interface between
38    Abc and the cutting plane algorithms in the CGL. A \c AbcCutGenerator is
39    bound to a \c CglCutGenerator and to an \c AbcModel. It contains parameters
40    which control when and how the \c generateCuts method of the
41    \c CglCutGenerator will be called.
42
43    The builtin decision criteria available to use when deciding whether to
44    generate cuts are limited: every <i>X</i> nodes, when a solution is found,
45    and when a subproblem is found to be infeasible. The idea is that the class
46    will grow more intelligent with time.
47   
48    \todo Add a pointer to function member which will allow a client to install
49        their own decision algorithm to decide whether or not to call the CGL
50        \p generateCuts method. Create a default decision method that looks
51        at the builtin criteria.
52 
53    \todo It strikes me as not good that generateCuts contains code specific to
54        individual CGL algorithms. Another set of pointer to function members,
55        so that the client can specify the cut generation method as well as
56        pre- and post-generation methods? Taken a bit further, should this
57        class contain a bunch of pointer to function members, one for each
58        of the places where the cut generator might be referenced?
59        Initialization, root node, search tree node, discovery of solution,
60        and termination all come to mind. Initialization and termination would
61        also be useful for instrumenting sbb.
62*/
63
64class AbcCutGenerator  {
65   
66 public:
67   
68    /** \name Generate Cuts */
69    //@{
70    /** Generate cuts for the client model.
71
72        Evaluate the state of the client model and decide whether to
73        generate cuts. The generated cuts are inserted into and returned
74        in the collection of cuts \p cs.
75       
76        If \p fullScan is true, the generator is obliged to call the CGL
77        \c generateCuts routine.  Otherwise, it is free to make a local
78        decision. The current implementation uses \c whenCutGenerator_
79        to decide.
80
81        The routine returns true if reoptimisation is needed (because the
82        state of the solver interface has been modified).
83    */
84    bool generateCuts( OsiCuts &cs, bool fullScan); 
85    //@}
86
87   
88    /**@name Constructors and destructors */
89    //@{
90    /// Default constructor
91    AbcCutGenerator (); 
92   
93    /// Normal constructor
94    AbcCutGenerator(AbcModel * model,CglCutGenerator * generator,
95                    int howOften=1, const char * name=NULL,
96                    bool normal=true, bool atSolution=false, 
97                    bool infeasible=false);
98   
99    /// Copy constructor
100    AbcCutGenerator (const AbcCutGenerator &);
101   
102    /// Assignment operator
103    AbcCutGenerator & operator=(const AbcCutGenerator& rhs);
104   
105    /// Destructor
106    ~AbcCutGenerator ();
107    //@}
108
109    /**@name Gets and sets */
110    //@{
111    /** Set the client model.
112       
113        In addition to setting the client model, refreshModel also calls
114        the \c refreshSolver method of the CglCutGenerator object.
115    */
116    void refreshModel(AbcModel * model);
117   
118    /// return name of generator
119    inline const char * cutGeneratorName() const
120        { 
121            return generatorName_; 
122        }
123   
124    /** Set the cut generation interval
125       
126        Set the number of nodes evaluated between calls to the Cgl object's
127        \p generateCuts routine.
128       
129        If \p value is positive, cuts will always be generated at the specified
130        interval.
131        If \p value is negative, cuts will initially be generated at the
132        specified interval, but Abc may adjust the value depending on the
133        success of cuts produced by this generator.
134
135        A value of -100 disables the generator, while a value of -99 means
136        just at root.
137    */
138    void setHowOften(int value) ;
139   
140    /// Get the cut generation interval.
141    inline int howOften() const
142        { return whenCutGenerator_; }
143   
144    /// Get whether the cut generator should be called in the normal place
145    inline bool normal() const
146        { return normal_; }
147    /// Set whether the cut generator should be called in the normal place
148    inline void setNormal(bool value) 
149        { normal_=value; }
150    /// Get whether the cut generator should be called when a solution is found
151    inline bool atSolution() const
152        { return atSolution_; }
153    /// Set whether the cut generator should be called when a solution is found
154    inline void setAtSolution(bool value) 
155        { atSolution_=value; }
156    /** Get whether the cut generator should be called when the subproblem is
157        found to be infeasible.
158    */
159    inline bool whenInfeasible() const
160        { return whenInfeasible_; }
161    /** Set whether the cut generator should be called when the subproblem is
162        found to be infeasible.
163    */
164    inline void setWhenInfeasible(bool value) 
165        { whenInfeasible_=value; }
166    /// Get the \c CglCutGenerator bound to this \c AbcCutGenerator.
167    inline CglCutGenerator * generator() const
168        { return generator_; }
169    //@}
170 
171 private:
172    /// The client model
173    AbcModel *model_;
174
175    // The CglCutGenerator object
176    CglCutGenerator * generator_;
177
178    /** Number of nodes between calls to the CglCutGenerator::generateCuts
179        routine.
180    */
181    int whenCutGenerator_;
182   
183    /// Name of generator
184    char * generatorName_;
185   
186    /// Whether to call the generator in the normal place
187    bool normal_;
188
189    /// Whether to call the generator when a new solution is found
190    bool atSolution_;
191
192    /// Whether to call generator when a subproblem is found to be infeasible
193    bool whenInfeasible_; 
194};
195
196#endif
Note: See TracBrowser for help on using the repository browser.