root/pico/stable/1.3/src/milp/pico/lpBasedHeuristic.h

Revision 5996, 14.7 kB (checked in by wehart, 3 months ago)

Merged revisions 5282-5995 via svnmerge from
https://software.sandia.gov/svn/public/acro/pico/trunk

……..

r5295 | jdsiiro | 2007-12-17 17:48:22 -0700 (Mon, 17 Dec 2007) | 4 lines


Propagating utilib::exception_mngr::exit_fn API change.


See log message for utilib r1429.

……..

r5298 | jberry | 2008-02-15 12:49:25 -0700 (Fri, 15 Feb 2008) | 3 lines


Prettified some of the debug output.

……..

r5311 | wehart | 2008-02-17 22:30:53 -0700 (Sun, 17 Feb 2008) | 2 lines


Misc change to account for the setup of pyacro.

……..

r5332 | wehart | 2008-03-02 13:10:17 -0700 (Sun, 02 Mar 2008) | 2 lines


Update given reor of Python.

……..

r5344 | wehart | 2008-03-26 20:32:45 -0700 (Wed, 26 Mar 2008) | 3 lines


Creating the 'ipconvert' command, which doesn't rely on
the PICO MIP solvers.

……..

r5345 | wehart | 2008-03-27 09:09:21 -0700 (Thu, 27 Mar 2008) | 3 lines


Rework of ipconvert command line to support —output option
and to enable the specification of multi-file inputs.

……..

r5375 | lafisk | 2008-05-23 13:52:36 -0600 (Fri, 23 May 2008) | 2 lines


Add link flags needed when —enable-static-executables

……..

r5429 | jeckstei | 2008-06-13 15:09:14 -0600 (Fri, 13 Jun 2008) | 10 lines


Fixed some bugs in paralllel MIP heuristic invocation, although one
big one remains — parBCMipNode::boundComputationGuts is not getting
called.


In parallel runs, the output summary information about MIP heuristics
is now clean and informative, instead a mishmosh of interleaved
printouts from each individual processor.

……..

r5448 | caphill | 2008-06-22 09:08:09 -0600 (Sun, 22 Jun 2008) | 8 lines


Fixing a problem in reading val files in an application created by
gen_milp_app. This code infers the data type. If the first values
for a parameter are integer, and then there are doubles, subsequent
reads of the first "integer" variables fail. This fix stores data
as both integer and double during read-in. There may be a more
elegant solution, but this works.

……..

r5458 | caphill | 2008-07-01 08:44:15 -0600 (Tue, 01 Jul 2008) | 4 lines


Fixing a bug in generation of dense solutions. It was causing bombs when running
PICO from ampl.

……..

r5459 | caphill | 2008-07-02 05:08:29 -0600 (Wed, 02 Jul 2008) | 8 lines


Bug fix for SOS. When SOS overlap, we should not generally fix them
when we discover a half-infeasible problem during pseudocost
initialization. This will generally affect the sets it overlaps,
especially if it fully determines the set (fixes a 1). If PICO
chooses to (or must) then branch on a collaterally-modified SOS, this
creates chaos.

……..

r5471 | caphill | 2008-07-16 15:32:16 -0600 (Wed, 16 Jul 2008) | 8 lines


Fix to reading in .val files for gen_milp_app-generated derivative
applications. The mechanism for splitting pieces from a line
(index tuples and value) was dropping the negative sign from
exponents of numbers input in scientific notation. So every
number that looked like 123e-45 became 123e45, which can be
quite different from the original.

……..

r5493 | wehart | 2008-08-04 16:03:30 -0600 (Mon, 04 Aug 2008) | 2 lines


Changes due to reorg of coopr.

……..

r5512 | wehart | 2008-08-17 14:53:48 -0600 (Sun, 17 Aug 2008) | 8 lines


A complete reimplementation of the classes used to support PICO
customization in SUCASA. The biggest change is that setupMappedMILP is
no longer supported! Now, the SUCASA script in Coopr is responsible for
managing the creating and reading of the *.map file!


These changes touched some of the core PICO files only to remove
the functionality that was needed for setupMappedMILP.

……..

r5513 | wehart | 2008-08-17 21:13:27 -0600 (Sun, 17 Aug 2008) | 2 lines


Fixing various bugs in the sucasa customization classes.

……..

r5518 | jwatson | 2008-08-22 14:12:10 -0600 (Fri, 22 Aug 2008) | 2 lines


Some minor structural changes and cleanup to the feasibility pump code base.

……..

r5519 | jwatson | 2008-08-22 15:24:45 -0600 (Fri, 22 Aug 2008) | 1 line


Fixed some reporting output in the feasibility pump, and added cycle checking (via hash vectors) for iteration solutions to the core algorithm.

……..

r5520 | jwatson | 2008-08-22 23:43:45 -0600 (Fri, 22 Aug 2008) | 1 line


Enhanced cycle detection code in feasibility pump.

……..

r5522 | wehart | 2008-08-25 14:29:26 -0600 (Mon, 25 Aug 2008) | 2 lines


Misc fix.

……..

r5523 | wehart | 2008-08-25 15:32:43 -0600 (Mon, 25 Aug 2008) | 3 lines


Misc changes to optimize the insertion process when initially building
the maps used for symbols.

……..

r5525 | wehart | 2008-08-26 17:27:22 -0600 (Tue, 26 Aug 2008) | 4 lines


Initial rework of SUCASA objects to support initialization from *.val files.


This may change substantially…

……..

r5531 | wehart | 2008-08-30 08:03:07 -0600 (Sat, 30 Aug 2008) | 6 lines


An initial rework of the MILPSymbol concept to unify the MILPSymbol and MILPSet logic. This change is needed to support sets of sets.


I'm going to rework this further, but I thought I'd archive this version for
future reference. My next revision of this is going to involve UTILIB Any
objects, which will enable a much more dynamic syntax for set-of-sets.

……..

r5553 | wehart | 2008-09-08 00:05:27 -0600 (Mon, 08 Sep 2008) | 7 lines


A major rework of the MILPSymbol functionality. This rework
combines the MILPSymbol and MILPSet classes, and the MILPSet class
has been deleted.


This functionality does not impact core PICO builds, but it is used in
the SUCASA customized PICO solvers.

……..

r5568 | wehart | 2008-09-15 14:20:02 -0600 (Mon, 15 Sep 2008) | 2 lines


Hacking out a build problem. For some reason, this builds find with g++ on tofu…?

……..

r5572 | jberry | 2008-09-17 11:19:29 -0600 (Wed, 17 Sep 2008) | 3 lines


Fixes relating to the use of initialSolve() versus resolve() in the OsiSolverInterface?; the latter was not behaving correctly on a good number of benchmarks in FP iterations ≥ 2, so I changed it to always call "initialSolve()" and added in warm-start behaviors.

……..

r5583 | wehart | 2008-09-18 13:51:27 -0600 (Thu, 18 Sep 2008) | 4 lines


Adding pack/unpack capabilities to MILPSymbol objects.


Deleting old development directories.

……..

r5588 | jwatson | 2008-09-20 13:38:04 -0600 (Sat, 20 Sep 2008) | 7 lines


Minor fix involving issues relating to run-time-limit termination. For NSR8K,
the root solve takes longer than an allocated run-time of 10 minutes ⇒ negative
run-time limits were showing up in the output of the core FP procedure. I now check
for a positive time limit prior to calling the core procedure, and bail with
a message if it is negative. No functional change - just reporting.

……..

r5589 | jwatson | 2008-09-20 21:39:44 -0600 (Sat, 20 Sep 2008) | 5 lines


Added a simple randomized rounding component to FP, which rounds - in the process of forming the x-tilde vector - any
integer variable with a fractional component on [0.33,0.67] to 0 or 1 with equal probability. Eventually will promote
the 0.33/0.67 parameters to FP command-line parameters, but only once I flush out issues with the new scheme.

……..

r5590 | jwatson | 2008-09-22 10:13:22 -0600 (Mon, 22 Sep 2008) | 3 lines


Promoted the perturbation interval in FP to a full parameter.

……..

r5595 | jwatson | 2008-09-28 21:53:12 -0600 (Sun, 28 Sep 2008) | 3 lines


Commit of Eckstein-Nediak implementation in the new heuristics framework. The version is stripped-down, in particular no parallel and only deals with binary variables. The purpose of this check-in is to assist debug of the generalized FP code. Let's not delete the bbhConfig and mipHeuristic files quite yet.

……..

r5597 | jwatson | 2008-09-29 14:37:46 -0600 (Mon, 29 Sep 2008) | 3 lines


Changed the "solve()" invocation in ENHeuristic.cpp to be "resolve()"; this seems to correct much of the weird behavior in the E-N heuristic that I was observing (both here and in the generalized feasibility pump). I haven't a clue why this works, but I'll take it.

……..

r5599 | jwatson | 2008-09-29 20:34:30 -0600 (Mon, 29 Sep 2008) | 3 lines


Added run-time bound on Eckstein-Nediak heuristic; parameter is ENHRunTime, quantified in seconds.

……..

r5600 | jwatson | 2008-09-29 21:15:25 -0600 (Mon, 29 Sep 2008) | 3 lines


In the Eckstein-Nediak heuristic, fixed problem with imposing a limit on the aggregate number of Gomory cuts.

……..

r5602 | jwatson | 2008-10-02 15:37:52 -0600 (Thu, 02 Oct 2008) | 7 lines


Various enhancements of FP output, in an effort to debug the EN heuristic. Some minor fixes to boundary-condition input cases as well.


Complete re-work of the randomization scheme for EN, including reflection of the merit function. It now behaves in that mode as a generalized FP.


I turned off any influence of the objective weight in EN for now, as it is causing serious issues with cycling and the like. The relative scaling with the current rule is way off, leading to this and other weird behaviors that I just killed a day mucking with.

……..

r5603 | jwatson | 2008-10-03 14:37:36 -0600 (Fri, 03 Oct 2008) | 5 lines


Numerous changes/improvements related to cycle detection and escape from local minima.
Configured the current EH variant to use triangular merit functions, to verify FP-equivalence.
When verified, I will be making the merit function type a command-line argument.

……..

r5604 | jwatson | 2008-10-04 16:23:25 -0600 (Sat, 04 Oct 2008) | 4 lines


Added randomized visitation sequence to FP to randomly tie-break among flip candidates whose distances are identical.
Mainly, no reason to do so deterministically, and I have seem cases where the deterministic order leads to artificial cycles.

……..

r5605 | jwatson | 2008-10-04 20:08:52 -0600 (Sat, 04 Oct 2008) | 3 lines


When randomized rounding is enabled in FP, apply to construction of initial solution (i.e., the gradient) vector.

……..

r5606 | jwatson | 2008-10-05 09:58:36 -0600 (Sun, 05 Oct 2008) | 3 lines


Changed FP randomization behavior to escape local minima. If fractional components are on the interval [0.33, 0.67], always flip - there isn't good gradient information anyway. In all other cases, there is less of an argument to flip, so do so with probability 0.5.

……..

r5612 | jwatson | 2008-10-06 14:55:22 -0600 (Mon, 06 Oct 2008) | 3 lines


Minor updates to ENHeuristic to (1) output cumulative # of iterations for statistics gathering and (2) flip integers in the FP-fashion.

……..

r5613 | jwatson | 2008-10-07 19:29:43 -0600 (Tue, 07 Oct 2008) | 3 lines


Removed LP relaxation randomization from the FP code, as the performance is rather erratic.

……..

r5614 | jwatson | 2008-10-08 09:51:47 -0600 (Wed, 08 Oct 2008) | 3 lines


Added random flip option (FPRandomFlip) to test hypothesis that flipping fractionals doesn't seem to matter all that much… (?!).

……..

r5616 | jwatson | 2008-10-08 13:43:10 -0600 (Wed, 08 Oct 2008) | 3 lines


Modification of perturbation mechanism in EN heuristic to break cycling.

……..

r5772 | jeckstei | 2008-11-10 15:08:27 -0700 (Mon, 10 Nov 2008) | 4 lines


Changed "lp" to "sol" in various EN-Heuristic debugging statements, so
that PICO will compile with validating and MPI enabled.

……..

r5779 | wehart | 2008-11-11 01:13:22 -0700 (Tue, 11 Nov 2008) | 2 lines


Update due to rename of stl_auxillary.h

……..

r5789 | wehart | 2008-11-12 15:40:21 -0700 (Wed, 12 Nov 2008) | 4 lines


Adding hook for generating *.i files.


Misc fix to get the pico_test code working.

……..

r5831 | wehart | 2008-11-19 19:45:31 -0700 (Wed, 19 Nov 2008) | 2 lines


Fixing bug with parallel build.

……..

r5835 | wehart | 2008-11-23 20:02:08 -0700 (Sun, 23 Nov 2008) | 2 lines


Update of copyright assertions.

……..

r5878 | wehart | 2008-11-24 20:16:34 -0700 (Mon, 24 Nov 2008) | 2 lines


Updates to use new GLPK release.

……..

r5884 | wehart | 2008-11-25 23:39:02 -0700 (Tue, 25 Nov 2008) | 4 lines


Adding a test directory of PICO command line drivers.
This uses PyUnit? test mechanisms, leveragin the capabilites
of PyUtilib?.

……..

r5885 | wehart | 2008-11-25 23:39:36 -0700 (Tue, 25 Nov 2008) | 2 lines


Adding an NL file used for testing ipconvert.

……..

r5886 | wehart | 2008-11-26 13:44:49 -0700 (Wed, 26 Nov 2008) | 6 lines


Update of ipconvert to recognize integer variables.


NOTE: when converting to an MPS file, this conversion
translates the problem into a minimization problem. Many MILP solvers
cannot understand the OBJSENSE field in MPS files… :(

……..

r5887 | wehart | 2008-11-26 14:51:32 -0700 (Wed, 26 Nov 2008) | 5 lines


Renaming ipconvert to pico_convert. Cindy and I realized that we
would also like to leverage glpsol and/or ampl to do conversions, but
that's not directly possible. I'm going to create an ipconvert script
in Coopr to support that more general functionality.

……..

r5902 | wehart | 2008-12-01 21:14:01 -0700 (Mon, 01 Dec 2008) | 3 lines


Updates for UTILIB commit for enum labels.
Portability fix for gcc 4.3.1

……..

r5920 | caphill | 2008-12-03 00:57:23 -0700 (Wed, 03 Dec 2008) | 5 lines


Outputs a solution file problem.sol.txt when we are solving only the
root LP. It prints the objective value, the (non-zero, within a hard-coded
tolerance of 1e-16) primal solution and dual solution in the form
name = value

……..

r5931 | wehart | 2008-12-03 22:01:19 -0700 (Wed, 03 Dec 2008) | 2 lines


Adding diagnostic output when debug=1

……..

r5932 | wehart | 2008-12-03 22:18:21 -0700 (Wed, 03 Dec 2008) | 2 lines


Printing out the optimization sense.

……..

r5936 | wehart | 2008-12-04 10:59:07 -0700 (Thu, 04 Dec 2008) | 3 lines


If the IP file defines the name of the problem, then
override the default name, which is derived from the filename.

……..

r5938 | wehart | 2008-12-04 15:30:27 -0700 (Thu, 04 Dec 2008) | 5 lines


When reading a *.nl file, initialize the problem name with
the filename.


Fix to milp.cpp to strip off *.nl or *.lp file suffixes.

……..

r5955 | wehart | 2008-12-05 12:19:53 -0700 (Fri, 05 Dec 2008) | 2 lines


Fixes for building with validation.

……..

r5981 | wehart | 2008-12-06 18:39:42 -0700 (Sat, 06 Dec 2008) | 8 lines


Setting the sense of optimization after loading the LP.


When an LP maximization problem is loaded, the sense was not being set
here.


NOTE: this may not be the right place to set the sense, but I don't
see a better place in the MILP object.

……..

r5982 | wehart | 2008-12-06 19:24:45 -0700 (Sat, 06 Dec 2008) | 5 lines


Rework of pico_convert to use the utilib::OptionParser?.


Misc update of Makefile to link with tinyxml (which this
OptionParser? needs).

……..

Line 
1/*  _________________________________________________________________________
2 *
3 *  Acro: A Common Repository for Optimizers
4 *  Copyright (c) 2008 Sandia Corporation.
5 *  This software is distributed under the BSD License.
6 *  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7 *  the U.S. Government retains certain rights in this software.
8 *  For more information, see the README.txt file in the top Acro directory.
9 *  _________________________________________________________________________
10 */
11
12/**
13 * \file lpBasedHeuristic.h
14 *
15 * Defines the pico::lpBasedHeuristic class.
16 */
17
18
19/// This is a base class for all heuristics that start from
20/// LP-feasible but integer-infeasible solutions.
21
22
23#ifndef pico_lpBasedHeuristic_h
24#define pico_lpBasedHeuristic_h
25
26
27#include <acro_config.h>
28#include <utilib/CommonIO.h>
29#include <pico/PicoLPInterface.h>
30#include <pico/PicoLPSolver.h>
31#include <CoinPackedVector.hpp>
32#include <CoinShallowPackedVector.hpp>
33#include <pebbl/pebblBase.h>
34#include <pebbl/gRandom.h>
35#include <pico/lpSetupObj.h>
36
37#ifdef ACRO_HAVE_MPI
38#include <utilib/Basic2DArray.h>
39#include <pebbl/parBranching.h>
40#else
41#include <pebbl/branching.h>
42#endif
43
44namespace pico {
45
46  using namespace utilib;
47  using namespace pebbl;
48  using std::min;
49
50  // Forward declaration of needed classes
51
52  class MILP;
53  class MILPProblem;
54  class MILPNode;
55  class MILPSolution;
56#ifdef ACRO_HAVE_MPI
57  class parMILP;
58#endif
59
60
61  /// Tiny class to help heuristics share LP interfaces
62
63  class lpShareObj
64    {
65    public:
66
67      PicoLPSolver     lpOwner;
68      PicoLPInterface* lp;
69
70      int timesShared;
71      int seqNum;
72
73      double originalObjConst;
74
75#ifdef ACRO_HAVE_MPI
76      int psSize;   // If we might presplit, also store grouping parameters
77      int psDepth;
78#endif
79
80      lpShareObj() :
81        lp(NULL),
82        timesShared(0),
83        seqNum(-1),
84        originalObjConst(0)
85#ifdef ACRO_HAVE_MPI
86        , psSize(0),
87        psDepth(0)
88#endif
89        { };
90    };
91
92 
93  /// Note: declaration of preSplitNode class may eventually have to
94  /// go here after we get rid of the old Eckstein-Nediak
95  /// "mipHeuristic" class.
96
97
98  /// Main base class for LP-based MIP heuristics
99
100  class lpBasedHeuristic : public CommonIO, public ParameterSet
101    {
102
103      ///
104      /// First, atuff that is used in both serial and parallel
105      ///
106
107    public:
108
109      /// Constructor.  Just set up name and parameters.
110
111      lpBasedHeuristic();
112
113      /// Main reset method
114
115      virtual void reset(MILP* mGlobal_, lpShareObj* lpShare_ = NULL);
116
117      /// Destructor; basically just a subset of some stuff done by
118      /// the reset method
119
120      virtual ~lpBasedHeuristic() { destructorResetCommonCode(); };
121
122      /// To invoke the heuristic on a subproblem (if it wants to run)
123      /// although virtual, it will typically not need to be overridden.
124
125      virtual void possibleRun(MILPNode* sp);
126
127    protected:
128
129      /// Used by both reset and destructor
130
131      void destructorResetCommonCode();
132
133      /// To decide whether to run on a subproblem
134
135      virtual bool wantToRunOn(MILPNode* sp);
136
137      /// A generic form of wantToRunOn that takes a random number
138      /// generator as an additional argument.
139
140      bool standardWantRunDecision(MILPNode* sp,utilib::Uniform& rng);
141
142      /// Overridable function used by standard implementation of wantToRunOn
143
144      virtual double gapFunction(double gap) { return min(gap,1.0); };
145
146      /// Standard code once we have decided that we do want to run
147
148      virtual void applyHeuristicTo(MILPNode* sp);
149
150      /// To see whether the LP needs to be set up to match a
151      /// subproblem; if not, it already has been
152
153      virtual bool needLPSetup(MILPNode* sp);
154
155      /// To get the LP set up to match a subproblem
156
157      virtual void setupLP(MILPNode* sp);
158
159      /// Standard core implementation of setupLP
160
161      void standardLPSetup(MILPNode* sp);
162
163      /// To indicate the LP has indeed been set up to match a
164      /// particular subproblem.
165
166      virtual void markLPSetup(MILPNode* sp);
167
168      /// To apply any necessary transformations to the LP; in the base
169      /// version, this is a stub
170
171      virtual void transformLP() { };
172
173      /// Pure virtual function to actually run the heuristic
174
175      virtual MILPSolution* runHeuristic() = 0;
176
177      /// Standard wrapper code around the LP, similar to MILPNode:runLP
178
179      virtual PicoLPInterface::problemState runLP(__LPSolver_Interface *lp
180                                                  = NULL);
181
182      /// Default procedure to construct a solution from the LP
183
184      virtual MILPSolution* makeSolution();
185
186      /// To track how often the heuristic is succeeding, and update
187      /// the "quality" measure
188
189      virtual void trackPerformance(double oldIncumbentValue,
190                                    double boundValue,
191                                    double intMeasure);
192
193      /// To add an "objective cut", something that many heuristics need
194
195      void addObjCut();
196
197      /// Optional validation check
198
199      bool validate(DoubleVector trialSolution,double objective);
200
201      /// Utility methods to remove rows or columsn from the end of the LP
202
203      void clearRows(int rowsToRemain);
204      void clearCols(int colsToRemain);
205
206      /// Utility functions to access data from the main MILP class
207
208      bool   haveIncumbent();
209      double relGap();
210
211
212      /// Data members
213
214    public:
215
216      /// Indicates whether this heuristic uses an objective cut
217
218      bool useObjCut;
219
220      /// Self-determined "quality" of the heuristic and related information
221
222      double quality;
223      int    timesInvoked;
224      int    timesSucceeded;
225      double hpCost;           // "Heuristic pseudocost" = ratio of
226                               // sumObjDiffs and sumIntMeasures below
227      double timeSpent;
228
229      /// Name of the heuristic
230
231      const char* name;
232
233      /// Heuristic debug level
234
235      int heurDebug;
236
237    protected:
238
239      /// Pointers to key objects
240
241      MILP*            mGlobal;
242      branching*       bGlobal;
243      MILPProblem*     problem;
244      lpShareObj*      lpShare;
245      PicoLPInterface* lp;
246
247      /// Used to calculate hpCost, but probably don't need to be public
248
249      double sumObjDiffs;
250      double sumIntMeasures;
251
252      /// Most heuristics will probably want to examine the LP
253      /// solution vector that comes from the subproblem or LP setup
254      /// object.  The way the rest of PICO works, this contains only
255      /// integer variables.
256
257      DoubleVector lpSolIntsOnly;
258     
259      /// Used to create the objective cut, if we want one
260
261      IntVector               cSparseNdx;
262      DoubleVector            cSparse;
263      CoinShallowPackedVector cVector;
264
265      /// Stores any changes we've made to the constant portion of the
266      /// objective function
267
268      double objConstChange;
269
270      /// Information we don't want to retrieve repeatedly about the problem
271
272      int baseRows;    // Rows in original problem
273      int baseCols;    // Columns in original problem
274      pebblBase::optimType sense;
275      int numInts;
276
277      double intTol;
278
279      /// loadedRows is the number of rows right after setting up the
280      /// LP to match the subproblem, but before any transformations.
281      /// It might be larger than baseRows because of cuts.
282      /// loadedCols is included for symmetry.
283
284      int loadedRows;
285      int loadedCols;
286
287      /// Parameters
288
289      int    depthThreshold;
290      double qualityAdjustUp;
291      double qualityAdjustDown;
292
293
294      ///
295      /// The remainder of the class is used only in parallel
296      ///
297
298#ifdef ACRO_HAVE_MPI
299
300    public:
301
302      /// The following method is called before the heuristic is used
303      /// in parallel.  The "hNum" argument is supposed to be the
304      /// position of the heuristic in the master array of heuristics,
305      /// but could in principle be anything so long as it is
306      /// identical in all processors.
307
308      virtual void parallelReset(parMILP* pmGlobal_, int hNum);
309
310      /// Ramp-up-related methods
311
312      /// Main routine called when we might want to use a heuristic in
313      /// ramp-up: the ramp-up equivalent of "possibleRun".  Although
314      /// virtual, it should probably not have to be overridden.
315
316    public:
317
318      virtual void possibleRampUpRun(MILPNode* sp);
319
320      /// Clean up at end of the ramp-up phase
321
322      virtual void rampUpCleanUp();
323
324      /// Decides whether to run during ramp-up.  If you don't want a
325      /// heuristic to be used at all during ramp up, clear the
326      /// usedInRampUp data member.
327
328    protected:
329
330      virtual bool wantRampUpRunOn(MILPNode* sp);
331
332      /// Ramp-up method for invoking heuristic once we've decided to
333      /// use it.  ALthough virtual, it probably won't need to be
334      /// overridden.
335
336      virtual void applyRampUpHeuristic(MILPNode* sp);
337
338      /// Predicate that decides if the LP needs to be set up during
339      /// ramp-up, or whether it has already been setup correctly.
340      /// Does not need to be overridden if one is using the standard
341      /// "presplitting" approach to ramp-up.
342
343      virtual bool needRampUpLPSetup(MILPNode* sp);
344
345      /// Sister routine to the above that marks an LP as set up
346      /// during ramp-up.  The default implementation is for
347      /// presplitting.
348
349      virtual void markRampUpLPSetup(MILPNode* sp);
350
351      /// Routine to set up LPs during ramp up.  The default
352      /// implementation uses presplitting.  This routine returns a
353      /// flag which is true if anything ended up being done
354      /// differently from the serial version.
355
356      virtual bool setupRampUpLP(MILPNode* sp);
357
358      /// Core method to run the heuristic during ramp up.  The
359      /// default implementation is just to run it the same way as in
360      /// serial, although the results could be different if the LP
361      /// has been set up differently.
362
363      virtual MILPSolution* runRampUpHeuristic() { return runHeuristic(); };
364
365      /// Incumbent-thread-related methods
366
367    public:
368
369      /// These methods are the main vehicles for putting solutions
370      /// into the heuristic's rounding pool, for later rounding when
371      /// the incumbent thread is running. The first offers a
372      /// subproblem, and the second offers an LP setup object.  Note
373      /// that these routines may decide not to use the offered
374      /// solution.  The lpSetupObj version will delete its argument
375      /// if it does not want to put it in the pool.  These methods
376      /// are virtual, but I don't think it's very likely overrides
377      /// will be needed.  The "level" argument is optional and
378      /// defaults to zero, appropriate for newly-seen solution.
379
380      virtual void offerToRoundingPool(MILPNode* sp,int level=0);
381
382      virtual void offerToRoundingPool(lpSetupObj* lpo,int level=0);
383
384      // Called to prune the rounding pool if a new incumbent comes along
385
386      virtual void prunePool();
387
388      /// Run the heuristic inside the incumbent thread
389
390      void poolRun();
391
392      /// Method that decides if a particular heuristic is able to run
393
394      virtual bool ready() { return poolSize > 0; };
395
396      /// Initialize the rounding pool.  Override if you want a
397      /// non-default rounding pool representation.
398
399      virtual void initRoundingPool();
400
401    protected:
402
403      /// "Scores" for ranking subproblems and LP setup objects (lower
404      /// scores are better).  "rScore" means "randomized score"
405
406      virtual double score(double bound,double intMeasure);
407
408      virtual double rScore(double bound,double intMeasure)
409        {
410          return pebbl::gRandom()*score(bound,intMeasure);
411        };
412
413      virtual double rScore(MILPNode* sp);
414
415      virtual double rScore(lpSetupObj* lpo);
416
417      /// Methods for deciding whether something should enter the
418      /// rounding pool, and doing rounding pool manipulations.
419      /// Override if you want a different rounding pool
420      /// representation.
421
422      /// Do we want to put a newly-offered solution into the pool?
423      /// The "l" argument is the "level" of the pool, and defaults to
424      /// zero.
425
426      virtual bool wantInRoundingPool(double bound,
427                                      double intMeasure,
428                                      int    l = 0);
429
430      /// To insert new objects into the pool
431
432      virtual void poolInsert(lpSetupObj* lpo,int level=0);
433
434      /// To remove objects from the pool; for a different pool
435      /// representation, this will probably need different arguments
436      /// instead of a simple override.
437
438      virtual void poolRemove(int level,int entry);
439
440      /// Select something from the pool to try to round (and also
441      /// remove it from the pool)
442
443      virtual lpSetupObj* selectFromPool();
444
445      /// Invokes the heuristic once we've chosen an object to run on
446
447      void applyPoolHeuristic(lpSetupObj* lpo);
448
449      /// Called on lp setup objects after they have been run.  The
450      /// default implementation just puts the solution back in the
451      /// pool.  Override if you want different behavior, such as just
452      /// deleting the object.
453
454      void postPoolRun(MILPSolution* solReturned,lpSetupObj* lpo);
455
456      /// To setup the LP from pool objects
457
458      virtual void setupLP(lpSetupObj* lpo);
459 
460      virtual void standardLPSetup(lpSetupObj* lpo);
461
462      /// Data members
463
464    public:
465
466      // Parameters -- set in specialParallelInits(), possibly from
467      // command-line parameters, if you don't want the generic
468      // default values.
469
470      // Flags that control when the heuristic is used
471
472      bool usedInRampUp;         // Call this heuristic during ramp-up?
473      bool usedInThread;         // Use in the incumbent thread?
474      bool usedInQuickHeuristic; // Use in "quick" subproblem heuristic?   
475
476      // The following are parameters used in the default ramp-up
477      // (presplitting) implementation, and might not be used if
478      // standard ramp-up is overridden.
479
480      int preSplitSize;       // Preferred size for presplitting groups
481      int preSplitDepth;      // Preferred depth of presplitting
482
483      // Incumbent-thread-related parameters
484
485      int maxPool;
486      int poolLevels;
487
488      double poolEnterProb;
489      double poolBlockProb;
490      double combineLevelProb;
491
492     // Ramp-up-related variables
493
494      double rampUpTime;      // Time used by heuristic during ramp-up
495      double threadTime;      // Time used by heuristic within incumbent thread
496
497      int rampUpTimesInvoked;
498      int rampUpTimesSucceeded;
499
500    protected:
501
502      // Pointers to parallel MILP and parallel branching classes
503
504      parMILP*           pmGlobal;
505      parallelBranching* pbGlobal;
506
507      // A random number generator that won't vary by processor --
508      // needed during ramp-up to make synchronized random decisions
509      // whether to run heuristics.
510
511      PM_LCG  rampUpLCG;
512      Uniform rampUpRNG;
513
514      // Default representation of pool of solutions to be rounded
515      // when invoked by the incumbent thread.
516
517      Basic2DArray<lpSetupObj*> rPool;
518
519      IntVector levelSize;
520      int       firstUsedLevel;
521      int       lastUsedLevel;
522      int       poolSize;
523
524      int       lastSelectLevel;
525
526#endif
527
528    };
529
530} // namespace pico
531
532#endif
Note: See TracBrowser for help on using the browser.