source: stable/2.4/Cbc/src/CbcParam.hpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

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