source: trunk/Cbc/src/CbcHeuristicFPump.hpp @ 1433

Last change on this file since 1433 was 1432, checked in by bjarni, 10 years ago

Added extra return at end of each source file where needed, to remove possible linefeed conflicts (NightlyBuild? errors)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.2 KB
Line 
1/* $Id: CbcHeuristicFPump.hpp 1432 2010-02-07 19:33:53Z tkr $ */
2// Copyright (C) 2004, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef CbcHeuristicFeasibilityPump_H
5#define CbcHeuristicFeasibilityPump_H
6
7#include "CbcHeuristic.hpp"
8#include "OsiClpSolverInterface.hpp"
9
10/** Feasibility Pump class
11 */
12
13class CbcHeuristicFPump : public CbcHeuristic {
14public:
15
16    // Default Constructor
17    CbcHeuristicFPump ();
18
19    // Constructor with model - assumed before cuts
20    CbcHeuristicFPump (CbcModel & model,
21                       double downValue = 0.5, bool roundExpensive = false);
22
23    // Copy constructor
24    CbcHeuristicFPump ( const CbcHeuristicFPump &);
25
26    // Destructor
27    ~CbcHeuristicFPump ();
28
29    /// Assignment operator
30    CbcHeuristicFPump & operator=(const CbcHeuristicFPump& rhs);
31    /// Clone
32    virtual CbcHeuristic * clone() const;
33    /// Create C++ lines to get to current state
34    virtual void generateCpp( FILE * fp) ;
35
36    /// Resets stuff if model changes
37    virtual void resetModel(CbcModel * model);
38
39    /// update model (This is needed if cliques update matrix etc)
40    virtual void setModel(CbcModel * model);
41
42    using CbcHeuristic::solution ;
43    /** returns 0 if no solution, 1 if valid solution
44        with better objective value than one passed in
45        Sets solution values if good, sets objective value (only if good)
46        This is called after cuts have been added - so can not add cuts.
47
48        It may make sense for user to call this outside Branch and Cut to
49        get solution.  Or normally is just at root node.
50
51        * new meanings for when_ - on first try then set back to 1
52          11 - at end fix all integers at same bound throughout
53          12 - also fix all integers staying at same internal integral value throughout
54          13 - also fix all continuous variables staying at same bound throughout
55          14 - also fix all continuous variables staying at same internal value throughout
56          15 - as 13 but no internal integers
57      And beyond that, it's apparently possible for the range to be between 21
58      and 25, in which case it's reduced on entry to solution() to be between
59      11 and 15 and allSlack is set to true. Then, if we're not processing
60      general integers, we'll use an all-slack basis to solve ... what? Don't
61      see that yet.
62    */
63    virtual int solution(double & objectiveValue,
64                         double * newSolution);
65
66    /// Set maximum Time (default off) - also sets starttime to current
67    void setMaximumTime(double value);
68    /// Get maximum Time (default 0.0 == time limit off)
69    inline double maximumTime() const {
70        return maximumTime_;
71    }
72    /// Set fake cutoff (default COIN_DBL_MAX == off)
73    inline void setFakeCutoff(double value) {
74        fakeCutoff_ = value;
75    }
76    /// Get fake cutoff (default 0.0 == off)
77    inline double fakeCutoff() const {
78        return fakeCutoff_;
79    }
80    /// Set absolute increment (default 0.0 == off)
81    inline void setAbsoluteIncrement(double value) {
82        absoluteIncrement_ = value;
83    }
84    /// Get absolute increment (default 0.0 == off)
85    inline double absoluteIncrement() const {
86        return absoluteIncrement_;
87    }
88    /// Set relative increment (default 0.0 == off)
89    inline void setRelativeIncrement(double value) {
90        relativeIncrement_ = value;
91    }
92    /// Get relative increment (default 0.0 == off)
93    inline double relativeIncrement() const {
94        return relativeIncrement_;
95    }
96    /// Set default rounding (default 0.5)
97    inline void setDefaultRounding(double value) {
98        defaultRounding_ = value;
99    }
100    /// Get default rounding (default 0.5)
101    inline double defaultRounding() const {
102        return defaultRounding_;
103    }
104    /// Set initial weight (default 0.0 == off)
105    inline void setInitialWeight(double value) {
106        initialWeight_ = value;
107    }
108    /// Get initial weight (default 0.0 == off)
109    inline double initialWeight() const {
110        return initialWeight_;
111    }
112    /// Set weight factor (default 0.1)
113    inline void setWeightFactor(double value) {
114        weightFactor_ = value;
115    }
116    /// Get weight factor (default 0.1)
117    inline double weightFactor() const {
118        return weightFactor_;
119    }
120    /// Set threshold cost for using original cost - even on continuous (default infinity)
121    inline void setArtificialCost(double value) {
122        artificialCost_ = value;
123    }
124    /// Get threshold cost for using original cost - even on continuous (default infinity)
125    inline double artificialCost() const {
126        return artificialCost_;
127    }
128    /// Get iteration to size ratio
129    inline double iterationRatio() const {
130        return iterationRatio_;
131    }
132    /// Set iteration to size ratio
133    inline void setIterationRatio(double value) {
134        iterationRatio_ = value;
135    }
136    /// Set maximum passes (default 100)
137    inline void setMaximumPasses(int value) {
138        maximumPasses_ = value;
139    }
140    /// Get maximum passes (default 100)
141    inline int maximumPasses() const {
142        return maximumPasses_;
143    }
144    /// Set maximum retries (default 1)
145    inline void setMaximumRetries(int value) {
146        maximumRetries_ = value;
147    }
148    /// Get maximum retries (default 1)
149    inline int maximumRetries() const {
150        return maximumRetries_;
151    }
152    /**  Set use of multiple solutions and solves
153         0 - do not reuse solves, do not accumulate integer solutions for local search
154         1 - do not reuse solves, accumulate integer solutions for local search
155         2 - reuse solves, do not accumulate integer solutions for local search
156         3 - reuse solves, accumulate integer solutions for local search
157         If we add 4 then use second form of problem (with extra rows and variables for general integers)
158       At some point (date?), I added
159
160       And then there are a few bit fields:
161       4 - something about general integers
162       So my (lh) guess for 4 was at least in the ballpark, but I'll have to
163       rethink 8 entirely (and it may well not mean the same thing as it did
164       when I added that comment.
165       8 - determines whether we process general integers
166
167       And on 090831, John added
168
169       If we add 4 then use second form of problem (with extra rows and
170       variables for general integers)
171         If we add 8 then can run after initial cuts (if no solution)
172    */
173    inline void setAccumulate(int value) {
174        accumulate_ = value;
175    }
176    /// Get accumulation option
177    inline int accumulate() const {
178        return accumulate_;
179    }
180    /**  Set whether to fix variables on known solution
181         0 - do not fix
182         1 - fix integers on reduced costs
183         2 - fix integers on reduced costs but only on entry
184    */
185    inline void setFixOnReducedCosts(int value) {
186        fixOnReducedCosts_ = value;
187    }
188    /// Get reduced cost option
189    inline int fixOnReducedCosts() const {
190        return fixOnReducedCosts_;
191    }
192    /**  Set reduced cost multiplier
193         1.0 as normal
194         <1.0 (x) - pretend gap is x* actual gap - just for fixing
195    */
196    inline void setReducedCostMultiplier(double value) {
197        reducedCostMultiplier_ = value;
198    }
199    /// Get reduced cost multiplier
200    inline double reducedCostMultiplier() const {
201        return reducedCostMultiplier_;
202    }
203
204protected:
205    // Data
206    /// Start time
207    double startTime_;
208    /// Maximum Cpu seconds
209    double maximumTime_;
210    /** Fake cutoff value.
211        If set then better of real cutoff and this used to add a constraint
212    */
213    double fakeCutoff_;
214    /// If positive carry on after solution expecting gain of at least this
215    double absoluteIncrement_;
216    /// If positive carry on after solution expecting gain of at least this times objective
217    double relativeIncrement_;
218    /// Default is round up if > this
219    double defaultRounding_;
220    /// Initial weight for true objective
221    double initialWeight_;
222    /// Factor for decreasing weight
223    double weightFactor_;
224    /// Threshold cost for using original cost - even on continuous
225    double artificialCost_;
226    /** If iterationRatio >0 use instead of maximumPasses_
227        test is iterations > ratio*(2*nrow+ncol) */
228    double iterationRatio_;
229    /**  Reduced cost multiplier
230         1.0 as normal
231         <1.0 (x) - pretend gap is x* actual gap - just for fixing
232    */
233    double reducedCostMultiplier_;
234    /// Maximum number of passes
235    int maximumPasses_;
236    /** Maximum number of retries if we find a solution.
237        If negative we clean out used array
238    */
239    int maximumRetries_;
240    /**  Set use of multiple solutions and solves
241         0 - do not reuse solves, do not accumulate integer solutions for local search
242         1 - do not reuse solves, accumulate integer solutions for local search
243         2 - reuse solves, do not accumulate integer solutions for local search
244         3 - reuse solves, accumulate integer solutions for local search
245         If we add 4 then use second form of problem (with extra rows and variables for general integers)
246         If we do not accumulate solutions then no mini branch and bounds will be done
247         reuse - refers to initial solve after adding in new "cut"
248         If we add 8 then can run after initial cuts (if no solution)
249    */
250    int accumulate_;
251    /**  Set whether to fix variables on known solution
252         0 - do not fix
253         1 - fix integers on reduced costs
254         2 - fix integers on reduced costs but only on entry
255    */
256    int fixOnReducedCosts_;
257    /// If true round to expensive
258    bool roundExpensive_;
259
260private:
261    /** Rounds solution - down if < downValue
262        If roundExpensive then always to more expnsive.
263        returns 0 if current is solution
264    */
265    int rounds(OsiSolverInterface * solver, double * solution,
266               /*const double * objective, */
267               int numberIntegers, const int * integerVariable,
268               /*char * pumpPrint,*/int passNumber,
269               /*bool roundExpensive=false,*/
270               double downValue = 0.5, int *flip = 0);
271    /* note for eagle eyed readers.
272       when_ can now be exotic -
273       <=10 normal
274    */
275};
276
277# ifdef COIN_HAS_CLP
278
279class CbcDisasterHandler : public OsiClpDisasterHandler {
280public:
281    /**@name Virtual methods that the derived classe should provide.
282    */
283    //@{
284#ifdef JJF_ZERO
285    /// Into simplex
286    virtual void intoSimplex();
287    /// Checks if disaster
288    virtual bool check() const ;
289    /// saves information for next attempt
290    virtual void saveInfo();
291#endif
292    /// Type of disaster 0 can fix, 1 abort
293    virtual int typeOfDisaster();
294    //@}
295
296
297    /**@name Constructors, destructor */
298
299    //@{
300    /** Default constructor. */
301    CbcDisasterHandler(CbcModel * model = NULL);
302    /** Destructor */
303    virtual ~CbcDisasterHandler();
304    // Copy
305    CbcDisasterHandler(const CbcDisasterHandler&);
306    // Assignment
307    CbcDisasterHandler& operator=(const CbcDisasterHandler&);
308    /// Clone
309    virtual ClpDisasterHandler * clone() const;
310
311    //@}
312
313    /**@name Sets/gets */
314
315    //@{
316    /** set model. */
317    void setCbcModel(CbcModel * model);
318    /// Get model
319    inline CbcModel * cbcModel() const {
320        return cbcModel_;
321    }
322
323    //@}
324
325
326protected:
327    /**@name Data members
328       The data members are protected to allow access for derived classes. */
329    //@{
330    /// Pointer to model
331    CbcModel * cbcModel_;
332
333    //@}
334};
335#endif
336
337#endif
338
Note: See TracBrowser for help on using the repository browser.