source: trunk/Clp/src/CbcOrClpParam.hpp @ 1711

Last change on this file since 1711 was 1711, checked in by forrest, 11 years ago

allow for elapsed time on unix systems

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.7 KB
Line 
1
2/* $Id: CbcOrClpParam.hpp 1711 2011-03-25 19:02:34Z forrest $ */
3// Copyright (C) 2002, International Business Machines
4// Corporation and others.  All Rights Reserved.
5// This code is licensed under the terms of the Eclipse Public License (EPL).
6
7#ifdef USE_CBCCONFIG
8# include "CbcConfig.h"
9#else
10# include "ClpConfig.h"
11#endif
12
13#ifndef CbcOrClpParam_H
14#define CbcOrClpParam_H
15/**
16   This has parameter handling stuff which can be shared between Cbc and Clp (and Dylp etc).
17
18   This (and .cpp) should be copied so that it is the same in Cbc/Test and Clp/Test.
19   I know this is not elegant but it seems simplest.
20
21   It uses COIN_HAS_CBC for parameters wanted by CBC
22   It uses COIN_HAS_CLP for parameters wanted by CLP (or CBC using CLP)
23   It could use COIN_HAS_DYLP for parameters wanted by DYLP
24   It could use COIN_HAS_DYLP_OR_CLP for parameters wanted by DYLP or CLP etc etc
25
26 */
27class OsiSolverInterface;
28class CbcModel;
29class ClpSimplex;
30/*! \brief Parameter codes
31
32  Parameter type ranges are allocated as follows
33  <ul>
34    <li>   1 -- 100     double parameters
35    <li> 101 -- 200     integer parameters
36    <li> 201 -- 250     string parameters
37    <li> 251 -- 300     cuts etc(string but broken out for clarity)
38    <li> 301 -- 400     `actions'
39  </ul>
40
41  `Actions' do not necessarily invoke an immediate action; it's just that they
42  don't fit neatly into the parameters array.
43
44  This coding scheme is in flux.
45*/
46
47enum CbcOrClpParameterType
48
49{
50     CBC_PARAM_GENERALQUERY = -100,
51     CBC_PARAM_FULLGENERALQUERY,
52
53     CLP_PARAM_DBL_PRIMALTOLERANCE = 1,
54     CLP_PARAM_DBL_DUALTOLERANCE,
55     CLP_PARAM_DBL_TIMELIMIT,
56     CLP_PARAM_DBL_DUALBOUND,
57     CLP_PARAM_DBL_PRIMALWEIGHT,
58     CLP_PARAM_DBL_OBJSCALE,
59     CLP_PARAM_DBL_RHSSCALE,
60
61     CBC_PARAM_DBL_INFEASIBILITYWEIGHT = 51,
62     CBC_PARAM_DBL_CUTOFF,
63     CBC_PARAM_DBL_INTEGERTOLERANCE,
64     CBC_PARAM_DBL_INCREMENT,
65     CBC_PARAM_DBL_ALLOWABLEGAP,
66     CBC_PARAM_DBL_TIMELIMIT_BAB,
67     CBC_PARAM_DBL_GAPRATIO,
68
69     CBC_PARAM_DBL_DJFIX = 81,
70     CBC_PARAM_DBL_TIGHTENFACTOR,
71     CLP_PARAM_DBL_PRESOLVETOLERANCE,
72     CLP_PARAM_DBL_OBJSCALE2,
73     CBC_PARAM_DBL_FAKEINCREMENT,
74     CBC_PARAM_DBL_FAKECUTOFF,
75     CBC_PARAM_DBL_ARTIFICIALCOST,
76     CBC_PARAM_DBL_DEXTRA3,
77     CBC_PARAM_DBL_SMALLBAB,
78     CBC_PARAM_DBL_DEXTRA4,
79     CBC_PARAM_DBL_DEXTRA5,
80
81     CLP_PARAM_INT_SOLVERLOGLEVEL = 101,
82#ifndef COIN_HAS_CBC
83     CLP_PARAM_INT_LOGLEVEL = 101,
84#endif
85     CLP_PARAM_INT_MAXFACTOR,
86     CLP_PARAM_INT_PERTVALUE,
87     CLP_PARAM_INT_MAXITERATION,
88     CLP_PARAM_INT_PRESOLVEPASS,
89     CLP_PARAM_INT_IDIOT,
90     CLP_PARAM_INT_SPRINT,
91     CLP_PARAM_INT_OUTPUTFORMAT,
92     CLP_PARAM_INT_SLPVALUE,
93     CLP_PARAM_INT_PRESOLVEOPTIONS,
94     CLP_PARAM_INT_PRINTOPTIONS,
95     CLP_PARAM_INT_SPECIALOPTIONS,
96     CLP_PARAM_INT_SUBSTITUTION,
97     CLP_PARAM_INT_DUALIZE,
98     CLP_PARAM_INT_VERBOSE,
99     CLP_PARAM_INT_CPP,
100     CLP_PARAM_INT_PROCESSTUNE,
101     CLP_PARAM_INT_USESOLUTION,
102
103     CBC_PARAM_INT_STRONGBRANCHING = 151,
104     CBC_PARAM_INT_CUTDEPTH,
105     CBC_PARAM_INT_MAXNODES,
106     CBC_PARAM_INT_NUMBERBEFORE,
107     CBC_PARAM_INT_NUMBERANALYZE,
108     CBC_PARAM_INT_MIPOPTIONS,
109     CBC_PARAM_INT_MOREMIPOPTIONS,
110     CBC_PARAM_INT_MAXHOTITS,
111     CBC_PARAM_INT_FPUMPITS,
112     CBC_PARAM_INT_MAXSOLS,
113     CBC_PARAM_INT_FPUMPTUNE,
114     CBC_PARAM_INT_TESTOSI,
115     CBC_PARAM_INT_EXTRA1,
116     CBC_PARAM_INT_EXTRA2,
117     CBC_PARAM_INT_EXTRA3,
118     CBC_PARAM_INT_EXTRA4,
119     CBC_PARAM_INT_DEPTHMINIBAB,
120     CBC_PARAM_INT_CUTPASSINTREE,
121     CBC_PARAM_INT_THREADS,
122     CBC_PARAM_INT_CUTPASS,
123     CBC_PARAM_INT_VUBTRY,
124     CBC_PARAM_INT_DENSE,
125     CBC_PARAM_INT_EXPERIMENT,
126     CBC_PARAM_INT_DIVEOPT,
127     CBC_PARAM_INT_STRATEGY,
128     CBC_PARAM_INT_SMALLFACT,
129     CBC_PARAM_INT_HOPTIONS,
130     CBC_PARAM_INT_CUTLENGTH,
131     CBC_PARAM_INT_FPUMPTUNE2,
132#ifdef COIN_HAS_CBC
133     CLP_PARAM_INT_LOGLEVEL ,
134#endif
135
136     CLP_PARAM_STR_DIRECTION = 201,
137     CLP_PARAM_STR_DUALPIVOT,
138     CLP_PARAM_STR_SCALING,
139     CLP_PARAM_STR_ERRORSALLOWED,
140     CLP_PARAM_STR_KEEPNAMES,
141     CLP_PARAM_STR_SPARSEFACTOR,
142     CLP_PARAM_STR_PRIMALPIVOT,
143     CLP_PARAM_STR_PRESOLVE,
144     CLP_PARAM_STR_CRASH,
145     CLP_PARAM_STR_BIASLU,
146     CLP_PARAM_STR_PERTURBATION,
147     CLP_PARAM_STR_MESSAGES,
148     CLP_PARAM_STR_AUTOSCALE,
149     CLP_PARAM_STR_CHOLESKY,
150     CLP_PARAM_STR_KKT,
151     CLP_PARAM_STR_BARRIERSCALE,
152     CLP_PARAM_STR_GAMMA,
153     CLP_PARAM_STR_CROSSOVER,
154     CLP_PARAM_STR_PFI,
155     CLP_PARAM_STR_INTPRINT,
156     CLP_PARAM_STR_VECTOR,
157     CLP_PARAM_STR_FACTORIZATION,
158     CLP_PARAM_STR_ALLCOMMANDS,
159     CLP_PARAM_STR_TIME_MODE,
160
161     CBC_PARAM_STR_NODESTRATEGY = 251,
162     CBC_PARAM_STR_BRANCHSTRATEGY,
163     CBC_PARAM_STR_CUTSSTRATEGY,
164     CBC_PARAM_STR_HEURISTICSTRATEGY,
165     CBC_PARAM_STR_GOMORYCUTS,
166     CBC_PARAM_STR_PROBINGCUTS,
167     CBC_PARAM_STR_KNAPSACKCUTS,
168     CBC_PARAM_STR_REDSPLITCUTS,
169     CBC_PARAM_STR_ROUNDING,
170     CBC_PARAM_STR_SOLVER,
171     CBC_PARAM_STR_CLIQUECUTS,
172     CBC_PARAM_STR_COSTSTRATEGY,
173     CBC_PARAM_STR_FLOWCUTS,
174     CBC_PARAM_STR_MIXEDCUTS,
175     CBC_PARAM_STR_TWOMIRCUTS,
176     CBC_PARAM_STR_PREPROCESS,
177     CBC_PARAM_STR_FPUMP,
178     CBC_PARAM_STR_GREEDY,
179     CBC_PARAM_STR_COMBINE,
180     CBC_PARAM_STR_LOCALTREE,
181     CBC_PARAM_STR_SOS,
182     CBC_PARAM_STR_LANDPCUTS,
183     CBC_PARAM_STR_RINS,
184     CBC_PARAM_STR_RESIDCUTS,
185     CBC_PARAM_STR_RENS,
186     CBC_PARAM_STR_DIVINGS,
187     CBC_PARAM_STR_DIVINGC,
188     CBC_PARAM_STR_DIVINGF,
189     CBC_PARAM_STR_DIVINGG,
190     CBC_PARAM_STR_DIVINGL,
191     CBC_PARAM_STR_DIVINGP,
192     CBC_PARAM_STR_DIVINGV,
193     CBC_PARAM_STR_DINS,
194     CBC_PARAM_STR_PIVOTANDFIX,
195     CBC_PARAM_STR_RANDROUND,
196     CBC_PARAM_STR_NAIVE,
197     CBC_PARAM_STR_ZEROHALFCUTS,
198     CBC_PARAM_STR_CPX,
199     CBC_PARAM_STR_CROSSOVER2,
200     CBC_PARAM_STR_PIVOTANDCOMPLEMENT,
201     CBC_PARAM_STR_VND,
202
203     CLP_PARAM_ACTION_DIRECTORY = 301,
204     CLP_PARAM_ACTION_DIRSAMPLE,
205     CLP_PARAM_ACTION_DIRNETLIB,
206     CBC_PARAM_ACTION_DIRMIPLIB,
207     CLP_PARAM_ACTION_IMPORT,
208     CLP_PARAM_ACTION_EXPORT,
209     CLP_PARAM_ACTION_RESTORE,
210     CLP_PARAM_ACTION_SAVE,
211     CLP_PARAM_ACTION_DUALSIMPLEX,
212     CLP_PARAM_ACTION_PRIMALSIMPLEX,
213     CLP_PARAM_ACTION_EITHERSIMPLEX,
214     CLP_PARAM_ACTION_MAXIMIZE,
215     CLP_PARAM_ACTION_MINIMIZE,
216     CLP_PARAM_ACTION_EXIT,
217     CLP_PARAM_ACTION_STDIN,
218     CLP_PARAM_ACTION_UNITTEST,
219     CLP_PARAM_ACTION_NETLIB_EITHER,
220     CLP_PARAM_ACTION_NETLIB_DUAL,
221     CLP_PARAM_ACTION_NETLIB_PRIMAL,
222     CLP_PARAM_ACTION_SOLUTION,
223     CLP_PARAM_ACTION_SAVESOL,
224     CLP_PARAM_ACTION_TIGHTEN,
225     CLP_PARAM_ACTION_FAKEBOUND,
226     CLP_PARAM_ACTION_HELP,
227     CLP_PARAM_ACTION_PLUSMINUS,
228     CLP_PARAM_ACTION_NETWORK,
229     CLP_PARAM_ACTION_ALLSLACK,
230     CLP_PARAM_ACTION_REVERSE,
231     CLP_PARAM_ACTION_BARRIER,
232     CLP_PARAM_ACTION_NETLIB_BARRIER,
233     CLP_PARAM_ACTION_NETLIB_TUNE,
234     CLP_PARAM_ACTION_REALLY_SCALE,
235     CLP_PARAM_ACTION_BASISIN,
236     CLP_PARAM_ACTION_BASISOUT,
237     CLP_PARAM_ACTION_SOLVECONTINUOUS,
238     CLP_PARAM_ACTION_CLEARCUTS,
239     CLP_PARAM_ACTION_VERSION,
240     CLP_PARAM_ACTION_STATISTICS,
241     CLP_PARAM_ACTION_DEBUG,
242     CLP_PARAM_ACTION_DUMMY,
243     CLP_PARAM_ACTION_PRINTMASK,
244     CLP_PARAM_ACTION_OUTDUPROWS,
245     CLP_PARAM_ACTION_USERCLP,
246     CLP_PARAM_ACTION_MODELIN,
247     CLP_PARAM_ACTION_CSVSTATISTICS,
248     CLP_PARAM_ACTION_STOREDFILE,
249     CLP_PARAM_ACTION_ENVIRONMENT,
250     CLP_PARAM_ACTION_PARAMETRICS,
251     CLP_PARAM_ACTION_GMPL_SOLUTION,
252
253     CBC_PARAM_ACTION_BAB = 351,
254     CBC_PARAM_ACTION_MIPLIB,
255     CBC_PARAM_ACTION_STRENGTHEN,
256     CBC_PARAM_ACTION_PRIORITYIN,
257     CBC_PARAM_ACTION_USERCBC,
258     CBC_PARAM_ACTION_DOHEURISTIC,
259
260     CBC_PARAM_NOTUSED_OSLSTUFF = 401,
261     CBC_PARAM_NOTUSED_CBCSTUFF,
262
263     CBC_PARAM_NOTUSED_INVALID = 1000
264} ;
265#include <vector>
266#include <string>
267
268/// Very simple class for setting parameters
269
270class CbcOrClpParam {
271public:
272     /**@name Constructor and destructor */
273     //@{
274     /// Constructors
275     CbcOrClpParam (  );
276     CbcOrClpParam (std::string name, std::string help,
277                    double lower, double upper, CbcOrClpParameterType type, int display = 2);
278     CbcOrClpParam (std::string name, std::string help,
279                    int lower, int upper, CbcOrClpParameterType type, int display = 2);
280     // Other strings will be added by insert
281     CbcOrClpParam (std::string name, std::string help, std::string firstValue,
282                    CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
283     // Action
284     CbcOrClpParam (std::string name, std::string help,
285                    CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
286     /// Copy constructor.
287     CbcOrClpParam(const CbcOrClpParam &);
288     /// Assignment operator. This copies the data
289     CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
290     /// Destructor
291     ~CbcOrClpParam (  );
292     //@}
293
294     /**@name stuff */
295     //@{
296     /// Insert string (only valid for keywords)
297     void append(std::string keyWord);
298     /// Adds one help line
299     void addHelp(std::string keyWord);
300     /// Returns name
301     inline std::string  name(  ) const {
302          return name_;
303     }
304     /// Returns short help
305     inline std::string  shortHelp(  ) const {
306          return shortHelp_;
307     }
308     /// Sets a double parameter (nonzero code if error)
309     int setDoubleParameter(CbcModel & model, double value) ;
310     /// Sets double parameter and returns printable string and error code
311     const char * setDoubleParameterWithMessage ( CbcModel & model, double  value , int & returnCode);
312     /// Gets a double parameter
313     double doubleParameter(CbcModel & model) const;
314     /// Sets a int parameter (nonzero code if error)
315     int setIntParameter(CbcModel & model, int value) ;
316     /// Sets int parameter and returns printable string and error code
317     const char * setIntParameterWithMessage ( CbcModel & model, int value , int & returnCode);
318     /// Gets a int parameter
319     int intParameter(CbcModel & model) const;
320     /// Sets a double parameter (nonzero code if error)
321     int setDoubleParameter(ClpSimplex * model, double value) ;
322     /// Gets a double parameter
323     double doubleParameter(ClpSimplex * model) const;
324     /// Sets double parameter and returns printable string and error code
325     const char * setDoubleParameterWithMessage ( ClpSimplex * model, double  value , int & returnCode);
326     /// Sets a int parameter (nonzero code if error)
327     int setIntParameter(ClpSimplex * model, int value) ;
328     /// Sets int parameter and returns printable string and error code
329     const char * setIntParameterWithMessage ( ClpSimplex * model, int  value , int & returnCode);
330     /// Gets a int parameter
331     int intParameter(ClpSimplex * model) const;
332     /// Sets a double parameter (nonzero code if error)
333     int setDoubleParameter(OsiSolverInterface * model, double value) ;
334     /// Sets double parameter and returns printable string and error code
335     const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double  value , int & returnCode);
336     /// Gets a double parameter
337     double doubleParameter(OsiSolverInterface * model) const;
338     /// Sets a int parameter (nonzero code if error)
339     int setIntParameter(OsiSolverInterface * model, int value) ;
340     /// Sets int parameter and returns printable string and error code
341     const char * setIntParameterWithMessage ( OsiSolverInterface * model, int  value , int & returnCode);
342     /// Gets a int parameter
343     int intParameter(OsiSolverInterface * model) const;
344     /// Checks a double parameter (nonzero code if error)
345     int checkDoubleParameter(double value) const;
346     /// Returns name which could match
347     std::string matchName (  ) const;
348     /// Returns length of name for ptinting
349     int lengthMatchName (  ) const;
350     /// Returns parameter option which matches (-1 if none)
351     int parameterOption ( std::string check ) const;
352     /// Prints parameter options
353     void printOptions (  ) const;
354     /// Returns current parameter option
355     inline std::string currentOption (  ) const {
356          return definedKeyWords_[currentKeyWord_];
357     }
358     /// Sets current parameter option
359     void setCurrentOption ( int value , bool printIt = false);
360     /// Sets current parameter option and returns printable string
361     const char * setCurrentOptionWithMessage ( int value );
362     /// Sets current parameter option using string
363     void setCurrentOption (const std::string value );
364     /// Returns current parameter option position
365     inline int currentOptionAsInteger (  ) const {
366          return currentKeyWord_;
367     }
368     /// Sets int value
369     void setIntValue ( int value );
370     inline int intValue () const {
371          return intValue_;
372     }
373     /// Sets double value
374     void setDoubleValue ( double value );
375     inline double doubleValue () const {
376          return doubleValue_;
377     }
378     /// Sets string value
379     void setStringValue ( std::string value );
380     inline std::string stringValue () const {
381          return stringValue_;
382     }
383     /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
384     int matches (std::string input) const;
385     /// type
386     inline CbcOrClpParameterType type() const {
387          return type_;
388     }
389     /// whether to display
390     inline int displayThis() const {
391          return display_;
392     }
393     /// Set Long help
394     inline void setLonghelp(const std::string help) {
395          longHelp_ = help;
396     }
397     /// Print Long help
398     void printLongHelp() const;
399     /// Print action and string
400     void printString() const;
401     /** 7 if used everywhere,
402         1 - used by clp
403         2 - used by cbc
404         4 - used by ampl
405     */
406     inline int whereUsed() const {
407          return whereUsed_;
408     }
409
410private:
411     /// gutsOfConstructor
412     void gutsOfConstructor();
413     //@}
414////////////////// data //////////////////
415private:
416
417     /**@name data
418      We might as well throw all type data in - could derive?
419     */
420     //@{
421     // Type see CbcOrClpParameterType
422     CbcOrClpParameterType type_;
423     /// If double == okay
424     double lowerDoubleValue_;
425     double upperDoubleValue_;
426     /// If int == okay
427     int lowerIntValue_;
428     int upperIntValue_;
429     // Length of name
430     unsigned int lengthName_;
431     // Minimum match
432     unsigned int lengthMatch_;
433     /// set of valid strings
434     std::vector<std::string> definedKeyWords_;
435     /// Name
436     std::string name_;
437     /// Short help
438     std::string shortHelp_;
439     /// Long help
440     std::string longHelp_;
441     /// Action
442     CbcOrClpParameterType action_;
443     /// Current keyWord (if a keyword parameter)
444     int currentKeyWord_;
445     /// Display on ?
446     int display_;
447     /// Integer parameter - current value
448     int intValue_;
449     /// Double parameter - current value
450     double doubleValue_;
451     /// String parameter - current value
452     std::string stringValue_;
453     /** 7 if used everywhere,
454         1 - used by clp
455         2 - used by cbc
456         4 - used by ampl
457     */
458     int whereUsed_;
459     //@}
460};
461/// Simple read stuff
462std::string CoinReadNextField();
463
464std::string CoinReadGetCommand(int argc, const char *argv[]);
465std::string CoinReadGetString(int argc, const char *argv[]);
466// valid 0 - okay, 1 bad, 2 not there
467int CoinReadGetIntField(int argc, const char *argv[], int * valid);
468double CoinReadGetDoubleField(int argc, const char *argv[], int * valid);
469void CoinReadPrintit(const char * input);
470void setCbcOrClpPrinting(bool yesNo);
471#define CBCMAXPARAMETERS 200
472/*
473  Subroutine to establish the cbc parameter array. See the description of
474  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
475*/
476void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
477// Given a parameter type - returns its number in list
478int whichParam (CbcOrClpParameterType name,
479                int numberParameters, CbcOrClpParam *const parameters);
480// Dump a solution to file
481void saveSolution(const ClpSimplex * lpSolver, std::string fileName);
482#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.