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

Last change on this file since 169 was 169, 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.6 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,CUTOFF,TIMELIMIT,
45    DUALBOUND, PRIMALWEIGHT,  OBJSCALE, RHSSCALE,
46   
47    INFEASIBILITYWEIGHT = 51, INTEGERTOLERANCE,INCREMENT,ALLOWABLEGAP,
48   
49    DJFIX = 81, GAPRATIO,TIGHTENFACTOR,
50
51    SOLVERLOGLEVEL=101,
52#ifndef COIN_USE_CBC
53    LOGLEVEL = 101, 
54#endif
55    MAXFACTOR,PERTVALUE,MAXITERATION,PRESOLVEPASS,IDIOT,SPRINT,
56    OUTPUTFORMAT,SLPVALUE,PRESOLVEOPTIONS,PRINTOPTIONS,SPECIALOPTIONS,
57    SUBSTITUTION,DUALIZE,
58
59    STRONGBRANCHING=151,CUTDEPTH, MAXNODES,NUMBERBEFORE,
60#ifdef COIN_USE_CBC
61    LOGLEVEL , 
62#endif
63 
64    DIRECTION=201,DUALPIVOT,SCALING,ERRORSALLOWED,KEEPNAMES,SPARSEFACTOR,
65    PRIMALPIVOT,PRESOLVE,CRASH,BIASLU,PERTURBATION,MESSAGES,AUTOSCALE,
66    CHOLESKY,KKT,BARRIERSCALE,GAMMA,CROSSOVER,PFI,
67   
68    NODESTRATEGY = 251,BRANCHSTRATEGY,ADDCUTSSTRATEGY,
69    GOMORYCUTS,PROBINGCUTS,KNAPSACKCUTS,REDSPLITCUTS,
70    ROUNDING,SOLVER,CLIQUECUTS,COSTSTRATEGY,FLOWCUTS,MIXEDCUTS,
71    TWOMIRCUTS,PREPROCESS,
72   
73    DIRECTORY=301,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,EITHERSIMPLEX,
74    MAXIMIZE,MINIMIZE,EXIT,STDIN,UNITTEST,NETLIB_EITHER,NETLIB_DUAL,NETLIB_PRIMAL,SOLUTION,
75    TIGHTEN,FAKEBOUND,HELP,PLUSMINUS,NETWORK,ALLSLACK,REVERSE,BARRIER,NETLIB_BARRIER,NETLIB_TUNE,
76    REALLY_SCALE,BASISIN,BASISOUT,SOLVECONTINUOUS,CLEARCUTS,VERSION,STATISTICS,
77
78    BAB=351,MIPLIB,
79
80    OSLSTUFF = 401,CBCSTUFF,
81
82    INVALID = 1000 } ;
83#include <vector>
84#include <string>
85
86/// Very simple class for setting parameters
87
88class CbcOrClpParam
89{
90public:
91  /**@name Constructor and destructor */
92  //@{
93  /// Constructors
94  CbcOrClpParam (  );
95  CbcOrClpParam (std::string name, std::string help,
96           double lower, double upper, CbcOrClpParameterType type,bool display=true);
97  CbcOrClpParam (std::string name, std::string help,
98           int lower, int upper, CbcOrClpParameterType type,bool display=true);
99  // Other strings will be added by insert
100  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
101           CbcOrClpParameterType type,int defaultIndex=0,bool display=true);
102  // Action
103  CbcOrClpParam (std::string name, std::string help,
104           CbcOrClpParameterType type,int indexNumber=-1,bool display=true);
105  /// Copy constructor.
106  CbcOrClpParam(const CbcOrClpParam &);
107  /// Assignment operator. This copies the data
108    CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
109  /// Destructor
110  ~CbcOrClpParam (  );
111  //@}
112
113  /**@name stuff */
114  //@{
115  /// Insert string (only valid for keywords)
116  void append(std::string keyWord);
117  /// Adds one help line
118  void addHelp(std::string keyWord);
119  /// Returns name
120  inline std::string  name(  ) const {
121    return name_;
122  };
123  /// Returns short help
124  inline std::string  shortHelp(  ) const {
125    return shortHelp_;
126  };
127  /// Sets a double parameter (nonzero code if error)
128  int setDoubleParameter(CbcModel & model, double value) ;
129  /// Gets a double parameter
130  double doubleParameter(CbcModel & model) const;
131  /// Sets a int parameter (nonzero code if error)
132  int setIntParameter(CbcModel & model, int value) ;
133  /// Gets a int parameter
134  int intParameter(CbcModel & model) const;
135  /// Sets a double parameter (nonzero code if error)
136  int setDoubleParameter(ClpSimplex * model, double value) ;
137  /// Gets a double parameter
138  double doubleParameter(ClpSimplex * model) const;
139  /// Sets a int parameter (nonzero code if error)
140  int setIntParameter(ClpSimplex * model, int value) ;
141  /// Gets a int parameter
142  int intParameter(ClpSimplex * model) const;
143  /// Sets a double parameter (nonzero code if error)
144  int setDoubleParameter(OsiSolverInterface * model, double value) ;
145  /// Gets a double parameter
146  double doubleParameter(OsiSolverInterface * model) const;
147  /// Sets a int parameter (nonzero code if error)
148  int setIntParameter(OsiSolverInterface * model, int value) ;
149  /// Gets a int parameter
150  int intParameter(OsiSolverInterface * model) const;
151  /// Checks a double parameter (nonzero code if error)
152  int checkDoubleParameter(double value) const;
153  /// Returns name which could match
154  std::string matchName (  ) const;
155  /// Returns parameter option which matches (-1 if none)
156  int parameterOption ( std::string check ) const;
157  /// Prints parameter options
158  void printOptions (  ) const;
159  /// Returns current parameter option
160  inline std::string currentOption (  ) const
161  { return definedKeyWords_[currentKeyWord_]; };
162  /// Sets current parameter option
163  inline void setCurrentOption ( int value )
164  { currentKeyWord_=value; };
165  /// Sets int value
166  void setIntValue ( int value );
167    inline int intValue () const
168  { return intValue_; };
169  /// Sets double value
170  void setDoubleValue ( double value );
171  inline double doubleValue () const
172  { return doubleValue_; };
173  /// Sets string value
174  void setStringValue ( std::string value );
175  inline std::string stringValue () const
176  { return stringValue_; };
177  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
178  int matches (std::string input) const;
179  /// type
180  inline CbcOrClpParameterType type() const
181  { return type_;};
182  /// whether to display
183  inline bool displayThis() const
184  { return display_;};
185  /// Set Long help
186  inline void setLonghelp(const std::string help) 
187  {longHelp_=help;};
188  /// Print Long help
189  void printLongHelp() const;
190  /// Print action and string
191  void printString() const;
192  /// type for classification
193  inline int indexNumber() const
194  { return indexNumber_;};
195private:
196  /// gutsOfConstructor
197  void gutsOfConstructor();
198  //@}
199////////////////// data //////////////////
200private:
201
202  /**@name data
203   We might as well throw all type data in - could derive?
204  */
205  //@{
206  // Type see CbcOrClpParameterType
207  CbcOrClpParameterType type_;
208  /// If double == okay
209  double lowerDoubleValue_;
210  double upperDoubleValue_;
211  /// If int == okay
212  int lowerIntValue_;
213  int upperIntValue_;
214  // Length of name
215  unsigned int lengthName_;
216  // Minimum match
217  unsigned int lengthMatch_;
218  /// set of valid strings
219  std::vector<std::string> definedKeyWords_;
220  /// Name
221  std::string name_;
222  /// Short help
223  std::string shortHelp_;
224  /// Long help
225  std::string longHelp_;
226  /// Action
227  CbcOrClpParameterType action_;
228  /// Current keyWord (if a keyword parameter)
229  int currentKeyWord_;
230  /// Display on ?
231  bool display_;
232  /// Integer parameter - current value
233  int intValue_;
234  /// Double parameter - current value
235  double doubleValue_;
236  /// String parameter - current value
237  std::string stringValue_;
238  /// index number to use for display purposes
239  int indexNumber_;
240  //@}
241};
242/// Simple read stuff
243std::string CoinReadNextField();
244
245std::string CoinReadGetCommand(int argc, const char *argv[]);
246std::string CoinReadGetString(int argc, const char *argv[]);
247// valid 0 - okay, 1 bad, 2 not there
248int CoinReadGetIntField(int argc, const char *argv[],int * valid);
249double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
250void CoinReadPrintit(const char * input);
251
252#define CBCMAXPARAMETERS 200
253/*
254  Subroutine to establish the cbc parameter array. See the description of
255  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
256*/
257void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
258// Given a parameter type - returns its number in list
259int whichParam (CbcOrClpParameterType name, 
260                int numberParameters, CbcOrClpParam *const parameters);
261#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.