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

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

add keyword for naive heuristic

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.8 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, GAPRATIO,
53   
54    DJFIX = 81, TIGHTENFACTOR,PRESOLVETOLERANCE,OBJSCALE2,
55    DEXTRA1, DEXTRA2, DEXTRA3, DEXTRA4, DEXTRA5,
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,EXPERIMENT,DIVEOPT,STRATEGY,SMALLFACT,
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,DIVINGS,DIVINGC,DIVINGF,DIVINGG,DIVINGL,
82    DIVINGP,DIVINGV,DINS,PIVOTANDFIX,RANDROUND,NAIVE,
83   
84    DIRECTORY=301,DIRSAMPLE,DIRNETLIB,DIRMIPLIB,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,EITHERSIMPLEX,
85    MAXIMIZE,MINIMIZE,EXIT,STDIN,UNITTEST,NETLIB_EITHER,NETLIB_DUAL,NETLIB_PRIMAL,SOLUTION,SAVESOL,
86    TIGHTEN,FAKEBOUND,HELP,PLUSMINUS,NETWORK,ALLSLACK,REVERSE,BARRIER,NETLIB_BARRIER,NETLIB_TUNE,
87    REALLY_SCALE,BASISIN,BASISOUT,SOLVECONTINUOUS,CLEARCUTS,VERSION,STATISTICS,DEBUG,DUMMY,PRINTMASK,
88    OUTDUPROWS,USERCLP,MODELIN,CSVSTATISTICS,
89
90    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,USERCBC,DOHEURISTIC,
91
92    OSLSTUFF = 401,CBCSTUFF,
93
94    INVALID = 1000 } ;
95#include <vector>
96#include <string>
97
98/// Very simple class for setting parameters
99
100class CbcOrClpParam
101{
102public:
103  /**@name Constructor and destructor */
104  //@{
105  /// Constructors
106  CbcOrClpParam (  );
107  CbcOrClpParam (std::string name, std::string help,
108           double lower, double upper, CbcOrClpParameterType type,bool display=true);
109  CbcOrClpParam (std::string name, std::string help,
110           int lower, int upper, CbcOrClpParameterType type,bool display=true);
111  // Other strings will be added by insert
112  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
113           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
114  // Action
115  CbcOrClpParam (std::string name, std::string help,
116           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
117  /// Copy constructor.
118  CbcOrClpParam(const CbcOrClpParam &);
119  /// Assignment operator. This copies the data
120    CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
121  /// Destructor
122  ~CbcOrClpParam (  );
123  //@}
124
125  /**@name stuff */
126  //@{
127  /// Insert string (only valid for keywords)
128  void append(std::string keyWord);
129  /// Adds one help line
130  void addHelp(std::string keyWord);
131  /// Returns name
132  inline std::string  name(  ) const {
133    return name_;
134  }
135  /// Returns short help
136  inline std::string  shortHelp(  ) const {
137    return shortHelp_;
138  }
139  /// Sets a double parameter (nonzero code if error)
140  int setDoubleParameter(CbcModel & model, double value) ;
141  /// Sets double parameter and returns printable string and error code
142  const char * setDoubleParameterWithMessage ( CbcModel & model, double  value ,int & returnCode);
143  /// Gets a double parameter
144  double doubleParameter(CbcModel & model) const;
145  /// Sets a int parameter (nonzero code if error)
146  int setIntParameter(CbcModel & model, int value) ;
147  /// Sets int parameter and returns printable string and error code
148  const char * setIntParameterWithMessage ( CbcModel & model, int value ,int & returnCode);
149  /// Gets a int parameter
150  int intParameter(CbcModel & model) const;
151  /// Sets a double parameter (nonzero code if error)
152  int setDoubleParameter(ClpSimplex * model, double value) ;
153  /// Gets a double parameter
154  double doubleParameter(ClpSimplex * model) const;
155  /// Sets double parameter and returns printable string and error code
156  const char * setDoubleParameterWithMessage ( ClpSimplex * model, double  value ,int & returnCode);
157  /// Sets a int parameter (nonzero code if error)
158  int setIntParameter(ClpSimplex * model, int value) ;
159  /// Sets int parameter and returns printable string and error code
160  const char * setIntParameterWithMessage ( ClpSimplex * model, int  value ,int & returnCode);
161  /// Gets a int parameter
162  int intParameter(ClpSimplex * model) const;
163  /// Sets a double parameter (nonzero code if error)
164  int setDoubleParameter(OsiSolverInterface * model, double value) ;
165  /// Sets double parameter and returns printable string and error code
166  const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double  value ,int & returnCode);
167  /// Gets a double parameter
168  double doubleParameter(OsiSolverInterface * model) const;
169  /// Sets a int parameter (nonzero code if error)
170  int setIntParameter(OsiSolverInterface * model, int value) ;
171  /// Sets int parameter and returns printable string and error code
172  const char * setIntParameterWithMessage ( OsiSolverInterface * model, int  value ,int & returnCode);
173  /// Gets a int parameter
174  int intParameter(OsiSolverInterface * model) const;
175  /// Checks a double parameter (nonzero code if error)
176  int checkDoubleParameter(double value) const;
177  /// Returns name which could match
178  std::string matchName (  ) const;
179  /// Returns parameter option which matches (-1 if none)
180  int parameterOption ( std::string check ) const;
181  /// Prints parameter options
182  void printOptions (  ) const;
183  /// Returns current parameter option
184  inline std::string currentOption (  ) const
185  { return definedKeyWords_[currentKeyWord_]; }
186  /// Sets current parameter option
187  void setCurrentOption ( int value , bool printIt=false);
188  /// Sets current parameter option and returns printable string
189  const char * setCurrentOptionWithMessage ( int value );
190  /// Sets current parameter option using string
191  void setCurrentOption (const std::string value );
192  /// Returns current parameter option position
193  inline int currentOptionAsInteger (  ) const
194  { return currentKeyWord_; }
195  /// Sets int value
196  void setIntValue ( int value );
197    inline int intValue () const
198  { return intValue_; }
199  /// Sets double value
200  void setDoubleValue ( double value );
201  inline double doubleValue () const
202  { return doubleValue_; }
203  /// Sets string value
204  void setStringValue ( std::string value );
205  inline std::string stringValue () const
206  { return stringValue_; }
207  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
208  int matches (std::string input) const;
209  /// type
210  inline CbcOrClpParameterType type() const
211  { return type_;}
212  /// whether to display
213  inline bool displayThis() const
214  { return display_;}
215  /// Set Long help
216  inline void setLonghelp(const std::string help) 
217  {longHelp_=help;}
218  /// Print Long help
219  void printLongHelp() const;
220  /// Print action and string
221  void printString() const;
222  /** 7 if used everywhere,
223      1 - used by clp
224      2 - used by cbc
225      4 - used by ampl
226  */
227  inline int whereUsed() const
228  { return whereUsed_;}
229 
230private:
231  /// gutsOfConstructor
232  void gutsOfConstructor();
233  //@}
234////////////////// data //////////////////
235private:
236
237  /**@name data
238   We might as well throw all type data in - could derive?
239  */
240  //@{
241  // Type see CbcOrClpParameterType
242  CbcOrClpParameterType type_;
243  /// If double == okay
244  double lowerDoubleValue_;
245  double upperDoubleValue_;
246  /// If int == okay
247  int lowerIntValue_;
248  int upperIntValue_;
249  // Length of name
250  unsigned int lengthName_;
251  // Minimum match
252  unsigned int lengthMatch_;
253  /// set of valid strings
254  std::vector<std::string> definedKeyWords_;
255  /// Name
256  std::string name_;
257  /// Short help
258  std::string shortHelp_;
259  /// Long help
260  std::string longHelp_;
261  /// Action
262  CbcOrClpParameterType action_;
263  /// Current keyWord (if a keyword parameter)
264  int currentKeyWord_;
265  /// Display on ?
266  bool display_;
267  /// Integer parameter - current value
268  int intValue_;
269  /// Double parameter - current value
270  double doubleValue_;
271  /// String parameter - current value
272  std::string stringValue_;
273  /** 7 if used everywhere,
274      1 - used by clp
275      2 - used by cbc
276      4 - used by ampl
277  */
278  int whereUsed_;
279  //@}
280};
281/// Simple read stuff
282std::string CoinReadNextField();
283
284std::string CoinReadGetCommand(int argc, const char *argv[]);
285std::string CoinReadGetString(int argc, const char *argv[]);
286// valid 0 - okay, 1 bad, 2 not there
287int CoinReadGetIntField(int argc, const char *argv[],int * valid);
288double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
289void CoinReadPrintit(const char * input);
290void setCbcOrClpPrinting(bool yesNo);
291#define CBCMAXPARAMETERS 200
292/*
293  Subroutine to establish the cbc parameter array. See the description of
294  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
295*/
296void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
297// Given a parameter type - returns its number in list
298int whichParam (CbcOrClpParameterType name, 
299                int numberParameters, CbcOrClpParam *const parameters);
300// Dump a solution to file
301void saveSolution(const ClpSimplex * lpSolver,std::string fileName);
302#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.