1 | /* $Id: CouenneAggrProbing.hpp 490 2011-01-14 16:07:12Z pbelotti $ |
---|
2 | * |
---|
3 | * Name: CouenneAggrProbing.hpp |
---|
4 | * Author: Giacomo Nannicini |
---|
5 | * Purpose: A bound tightener based on aggressive probing |
---|
6 | * |
---|
7 | * (C) Giacomo Nannicini, 2010. |
---|
8 | * This file is licensed under the Eclipse Public License (EPL) |
---|
9 | */ |
---|
10 | |
---|
11 | #ifndef COUENNEAGGRPROBING_HPP |
---|
12 | #define COUENNEAGGRPROBING_HPP |
---|
13 | |
---|
14 | #include "BonRegisteredOptions.hpp" |
---|
15 | |
---|
16 | #include "BonOaDecBase.hpp" |
---|
17 | #include "CglCutGenerator.hpp" |
---|
18 | #include "OsiColCut.hpp" |
---|
19 | #include "OsiSolverInterface.hpp" |
---|
20 | #include "CouenneProblem.hpp" |
---|
21 | #include "BonCouenneSetup.hpp" |
---|
22 | |
---|
23 | namespace Couenne { |
---|
24 | |
---|
25 | /// Cut Generator for aggressive BT; i.e., an aggressive probing. |
---|
26 | /// This probing strategy is very expensive and was initially |
---|
27 | /// developed to be run in parallel; hence, the user can choose to |
---|
28 | /// probe just a particular variable, without adding this cut |
---|
29 | /// generator to the list of cut generators normally employed by |
---|
30 | /// Couenne. However, it can also be used in the standard way; in |
---|
31 | /// that case, it chooses automatically the variables to probe (in a |
---|
32 | /// very naive way, for the moment). |
---|
33 | /// TODO: Implement some way to automatically choose the variables |
---|
34 | /// TODO: Implement the generateCuts method, for use in Branch-and-Bound |
---|
35 | |
---|
36 | class CouenneAggrProbing: public CglCutGenerator { |
---|
37 | |
---|
38 | public: |
---|
39 | |
---|
40 | /// Constructor |
---|
41 | CouenneAggrProbing(CouenneSetup* couenne, |
---|
42 | const Ipopt::SmartPtr<Ipopt::OptionsList> options); |
---|
43 | |
---|
44 | /// Copy constructor |
---|
45 | CouenneAggrProbing(const CouenneAggrProbing& rhs); |
---|
46 | |
---|
47 | /// Destructor |
---|
48 | ~CouenneAggrProbing(); |
---|
49 | |
---|
50 | /// Clone method (necessary for the abstract CglCutGenerator class) |
---|
51 | CouenneAggrProbing *clone () const |
---|
52 | {return new CouenneAggrProbing (*this);} |
---|
53 | |
---|
54 | /// The main CglCutGenerator; not implemented yet |
---|
55 | void generateCuts(const OsiSolverInterface & solver, |
---|
56 | OsiCuts& cuts, |
---|
57 | const CglTreeInfo = CglTreeInfo ()) const; |
---|
58 | |
---|
59 | /// Probe one variable (try to tigthen the lower or the upper |
---|
60 | /// bound, depending on the value of the second argument), so that |
---|
61 | /// we can generate the corresponding column cut. This runs the |
---|
62 | /// main algorithm. It returns the new bound (equal to the initial |
---|
63 | /// one if we could not tigthen) |
---|
64 | double probeVariable(int index, bool probeLower); |
---|
65 | |
---|
66 | /// Alternative probing algorithm. This one does not work yet! |
---|
67 | /// Do not use, will probably segfault. |
---|
68 | double probeVariable2(int index, bool lower); |
---|
69 | |
---|
70 | /// Add list of options to be read from file |
---|
71 | static void registerOptions(Ipopt::SmartPtr <Bonmin::RegisteredOptions> roptions); |
---|
72 | |
---|
73 | /// Set/get maximum time to probe one variable |
---|
74 | void setMaxTime(double value); |
---|
75 | double getMaxTime() const; |
---|
76 | |
---|
77 | /// Set/get maximum number of failed steps |
---|
78 | void setMaxFailedSteps(int value); |
---|
79 | int getMaxFailedSteps() const; |
---|
80 | |
---|
81 | /// Set/get maximum number of nodes to probe one variable |
---|
82 | void setMaxNodes(int value); |
---|
83 | int getMaxNodes() const; |
---|
84 | |
---|
85 | /// Set/get restoreCutoff parameter (should we restore the initial |
---|
86 | /// cutoff value after each probing run?) |
---|
87 | void setRestoreCutoff(bool value); |
---|
88 | bool getRestoreCutoff() const; |
---|
89 | |
---|
90 | protected: |
---|
91 | |
---|
92 | /// Pointer to the CouenneProblem representation |
---|
93 | CouenneSetup* couenne_; |
---|
94 | |
---|
95 | /// Number of columns (want to have this handy) |
---|
96 | int numCols_; |
---|
97 | |
---|
98 | /// Maximum time to probe one variable |
---|
99 | double maxTime_; |
---|
100 | |
---|
101 | /// Maximum number of failed iterations |
---|
102 | int maxFailedSteps_; |
---|
103 | |
---|
104 | /// Maximum number of nodes in probing |
---|
105 | int maxNodes_; |
---|
106 | |
---|
107 | /// Restore initial cutoff (value and solution)? |
---|
108 | bool restoreCutoff_; |
---|
109 | |
---|
110 | /// Initial cutoff |
---|
111 | double initCutoff_; |
---|
112 | |
---|
113 | }; |
---|
114 | } |
---|
115 | |
---|
116 | #endif |
---|