source: branches/devel/Cbc/src/CbcParam.hpp @ 435

Last change on this file since 435 was 388, checked in by andreasw, 13 years ago

fixed problem with VERSION preprocessor symbol

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