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

Last change on this file since 1158 was 1158, checked in by forrest, 12 years ago

for diving heuristics

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.7 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4#ifdef USE_CBCCONFIG
5# include "CbcConfig.h"
6#else
7# include "ClpConfig.h"
8#endif
9
10#ifndef CbcOrClpParam_H
11#define CbcOrClpParam_H
12/**
13   This has parameter handling stuff which can be shared between Cbc and Clp (and Dylp etc).
14
15   This (and .cpp) should be copied so that it is the same in Cbc/Test and Clp/Test.
16   I know this is not elegant but it seems simplest.
17   
18   It uses COIN_HAS_CBC for parameters wanted by CBC
19   It uses COIN_HAS_CLP for parameters wanted by CLP (or CBC using CLP)
20   It could use COIN_HAS_DYLP for parameters wanted by DYLP
21   It could use COIN_HAS_DYLP_OR_CLP for parameters wanted by DYLP or CLP etc etc
22
23 */
24class OsiSolverInterface;
25class CbcModel;
26class ClpSimplex;
27/*! \brief Parameter codes
28
29  Parameter type ranges are allocated as follows
30  <ul>
31    <li>   1 -- 100     double parameters
32    <li> 101 -- 200     integer parameters
33    <li> 201 -- 250     string parameters
34    <li> 251 -- 300     cuts etc(string but broken out for clarity)
35    <li> 301 -- 400     `actions'
36  </ul>
37
38  `Actions' do not necessarily invoke an immediate action; it's just that they
39  don't fit neatly into the parameters array.
40 
41  This coding scheme is in flux.
42*/
43
44enum CbcOrClpParameterType
45
46  { GENERALQUERY = -100,FULLGENERALQUERY,
47   
48    PRIMALTOLERANCE = 1, DUALTOLERANCE, TIMELIMIT,
49    DUALBOUND, PRIMALWEIGHT,  OBJSCALE, RHSSCALE,
50   
51    INFEASIBILITYWEIGHT = 51, CUTOFF, INTEGERTOLERANCE,INCREMENT,ALLOWABLEGAP,
52    TIMELIMIT_BAB,
53   
54    DJFIX = 81, GAPRATIO,TIGHTENFACTOR,PRESOLVETOLERANCE,OBJSCALE2,
55    DEXTRA1, DEXTRA2, DEXTRA3, DEXTRA4,
56
57    SOLVERLOGLEVEL=101,
58#ifndef COIN_HAS_CBC
59    LOGLEVEL = 101, 
60#endif
61    MAXFACTOR,PERTVALUE,MAXITERATION,PRESOLVEPASS,IDIOT,SPRINT,
62    OUTPUTFORMAT,SLPVALUE,PRESOLVEOPTIONS,PRINTOPTIONS,SPECIALOPTIONS,
63    SUBSTITUTION,DUALIZE,VERBOSE,CPP,PROCESSTUNE,USESOLUTION,
64
65    STRONGBRANCHING=151,CUTDEPTH, MAXNODES,NUMBERBEFORE,NUMBERANALYZE,
66    NUMBERMINI,MIPOPTIONS,MOREMIPOPTIONS,MAXHOTITS,FPUMPITS,MAXSOLS,
67    FPUMPTUNE,TESTOSI,EXTRA1,EXTRA2,EXTRA3,EXTRA4,CUTPASSINTREE,
68    THREADS,CUTPASS,VUBTRY,DENSE,
69#ifdef COIN_HAS_CBC
70    LOGLEVEL , 
71#endif
72 
73    DIRECTION=201,DUALPIVOT,SCALING,ERRORSALLOWED,KEEPNAMES,SPARSEFACTOR,
74    PRIMALPIVOT,PRESOLVE,CRASH,BIASLU,PERTURBATION,MESSAGES,AUTOSCALE,
75    CHOLESKY,KKT,BARRIERSCALE,GAMMA,CROSSOVER,PFI,INTPRINT,VECTOR,
76   
77    NODESTRATEGY = 251,BRANCHSTRATEGY,CUTSSTRATEGY,HEURISTICSTRATEGY,
78    GOMORYCUTS,PROBINGCUTS,KNAPSACKCUTS,REDSPLITCUTS,
79    ROUNDING,SOLVER,CLIQUECUTS,COSTSTRATEGY,FLOWCUTS,MIXEDCUTS,
80    TWOMIRCUTS,PREPROCESS,FPUMP,GREEDY,COMBINE,LOCALTREE,SOS,
81    LANDPCUTS,RINS,RESIDCUTS,RENS,DIVING,
82   
83    DIRECTORY=301,DIRSAMPLE,DIRNETLIB,DIRMIPLIB,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,EITHERSIMPLEX,
84    MAXIMIZE,MINIMIZE,EXIT,STDIN,UNITTEST,NETLIB_EITHER,NETLIB_DUAL,NETLIB_PRIMAL,SOLUTION,SAVESOL,
85    TIGHTEN,FAKEBOUND,HELP,PLUSMINUS,NETWORK,ALLSLACK,REVERSE,BARRIER,NETLIB_BARRIER,NETLIB_TUNE,
86    REALLY_SCALE,BASISIN,BASISOUT,SOLVECONTINUOUS,CLEARCUTS,VERSION,STATISTICS,DEBUG,DUMMY,PRINTMASK,
87    OUTDUPROWS,USERCLP,MODELIN,CSVSTATISTICS,
88
89    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,USERCBC,DOHEURISTIC,
90
91    OSLSTUFF = 401,CBCSTUFF,
92
93    INVALID = 1000 } ;
94#include <vector>
95#include <string>
96
97/// Very simple class for setting parameters
98
99class CbcOrClpParam
100{
101public:
102  /**@name Constructor and destructor */
103  //@{
104  /// Constructors
105  CbcOrClpParam (  );
106  CbcOrClpParam (std::string name, std::string help,
107           double lower, double upper, CbcOrClpParameterType type,bool display=true);
108  CbcOrClpParam (std::string name, std::string help,
109           int lower, int upper, CbcOrClpParameterType type,bool display=true);
110  // Other strings will be added by insert
111  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
112           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
113  // Action
114  CbcOrClpParam (std::string name, std::string help,
115           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
116  /// Copy constructor.
117  CbcOrClpParam(const CbcOrClpParam &);
118  /// Assignment operator. This copies the data
119    CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
120  /// Destructor
121  ~CbcOrClpParam (  );
122  //@}
123
124  /**@name stuff */
125  //@{
126  /// Insert string (only valid for keywords)
127  void append(std::string keyWord);
128  /// Adds one help line
129  void addHelp(std::string keyWord);
130  /// Returns name
131  inline std::string  name(  ) const {
132    return name_;
133  }
134  /// Returns short help
135  inline std::string  shortHelp(  ) const {
136    return shortHelp_;
137  }
138  /// Sets a double parameter (nonzero code if error)
139  int setDoubleParameter(CbcModel & model, double value) ;
140  /// Gets a double parameter
141  double doubleParameter(CbcModel & model) const;
142  /// Sets a int parameter (nonzero code if error)
143  int setIntParameter(CbcModel & model, int value) ;
144  /// Gets a int parameter
145  int intParameter(CbcModel & model) const;
146  /// Sets a double parameter (nonzero code if error)
147  int setDoubleParameter(ClpSimplex * model, double value) ;
148  /// Gets a double parameter
149  double doubleParameter(ClpSimplex * model) const;
150  /// Sets a int parameter (nonzero code if error)
151  int setIntParameter(ClpSimplex * model, int value) ;
152  /// Gets a int parameter
153  int intParameter(ClpSimplex * model) const;
154  /// Sets a double parameter (nonzero code if error)
155  int setDoubleParameter(OsiSolverInterface * model, double value) ;
156  /// Gets a double parameter
157  double doubleParameter(OsiSolverInterface * model) const;
158  /// Sets a int parameter (nonzero code if error)
159  int setIntParameter(OsiSolverInterface * model, int value) ;
160  /// Gets a int parameter
161  int intParameter(OsiSolverInterface * model) const;
162  /// Checks a double parameter (nonzero code if error)
163  int checkDoubleParameter(double value) const;
164  /// Returns name which could match
165  std::string matchName (  ) const;
166  /// Returns parameter option which matches (-1 if none)
167  int parameterOption ( std::string check ) const;
168  /// Prints parameter options
169  void printOptions (  ) const;
170  /// Returns current parameter option
171  inline std::string currentOption (  ) const
172  { return definedKeyWords_[currentKeyWord_]; }
173  /// Sets current parameter option
174  void setCurrentOption ( int value , bool printIt=false);
175  /// Sets current parameter option and returns printable string
176  const char * setCurrentOptionWithMessage ( int value );
177  /// Sets current parameter option using string
178  void setCurrentOption (const std::string value );
179  /// Returns current parameter option position
180  inline int currentOptionAsInteger (  ) const
181  { return currentKeyWord_; }
182  /// Sets int value
183  void setIntValue ( int value );
184    inline int intValue () const
185  { return intValue_; }
186  /// Sets double value
187  void setDoubleValue ( double value );
188  inline double doubleValue () const
189  { return doubleValue_; }
190  /// Sets string value
191  void setStringValue ( std::string value );
192  inline std::string stringValue () const
193  { return stringValue_; }
194  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
195  int matches (std::string input) const;
196  /// type
197  inline CbcOrClpParameterType type() const
198  { return type_;}
199  /// whether to display
200  inline bool displayThis() const
201  { return display_;}
202  /// Set Long help
203  inline void setLonghelp(const std::string help) 
204  {longHelp_=help;}
205  /// Print Long help
206  void printLongHelp() const;
207  /// Print action and string
208  void printString() const;
209  /** 7 if used everywhere,
210      1 - used by clp
211      2 - used by cbc
212      4 - used by ampl
213  */
214  inline int whereUsed() const
215  { return whereUsed_;}
216 
217private:
218  /// gutsOfConstructor
219  void gutsOfConstructor();
220  //@}
221////////////////// data //////////////////
222private:
223
224  /**@name data
225   We might as well throw all type data in - could derive?
226  */
227  //@{
228  // Type see CbcOrClpParameterType
229  CbcOrClpParameterType type_;
230  /// If double == okay
231  double lowerDoubleValue_;
232  double upperDoubleValue_;
233  /// If int == okay
234  int lowerIntValue_;
235  int upperIntValue_;
236  // Length of name
237  unsigned int lengthName_;
238  // Minimum match
239  unsigned int lengthMatch_;
240  /// set of valid strings
241  std::vector<std::string> definedKeyWords_;
242  /// Name
243  std::string name_;
244  /// Short help
245  std::string shortHelp_;
246  /// Long help
247  std::string longHelp_;
248  /// Action
249  CbcOrClpParameterType action_;
250  /// Current keyWord (if a keyword parameter)
251  int currentKeyWord_;
252  /// Display on ?
253  bool display_;
254  /// Integer parameter - current value
255  int intValue_;
256  /// Double parameter - current value
257  double doubleValue_;
258  /// String parameter - current value
259  std::string stringValue_;
260  /** 7 if used everywhere,
261      1 - used by clp
262      2 - used by cbc
263      4 - used by ampl
264  */
265  int whereUsed_;
266  //@}
267};
268/// Simple read stuff
269std::string CoinReadNextField();
270
271std::string CoinReadGetCommand(int argc, const char *argv[]);
272std::string CoinReadGetString(int argc, const char *argv[]);
273// valid 0 - okay, 1 bad, 2 not there
274int CoinReadGetIntField(int argc, const char *argv[],int * valid);
275double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
276void CoinReadPrintit(const char * input);
277void setCbcOrClpPrinting(bool yesNo);
278#define CBCMAXPARAMETERS 200
279/*
280  Subroutine to establish the cbc parameter array. See the description of
281  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
282*/
283void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
284// Given a parameter type - returns its number in list
285int whichParam (CbcOrClpParameterType name, 
286                int numberParameters, CbcOrClpParam *const parameters);
287// Dump a solution to file
288void saveSolution(const ClpSimplex * lpSolver,std::string fileName);
289#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.