source: trunk/Test/include/CbcOrClpParam.hpp @ 170

Last change on this file since 170 was 170, checked in by forrest, 16 years ago

for solve

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