source: trunk/Test/include/CbcParam.hpp @ 2

Last change on this file since 2 was 2, checked in by ladanyi, 16 years ago

Import of Coin Branch-and-Cut (formerly known as Sbb)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 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"
9
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 -- 300     string parameters
17    <li> 301 -- 400     `actions'
18  </ul>
19
20  `Actions' do not necessarily invoke an immediate action; it's just that they
21  don't fit neatly into the parameters array.
22 
23  This coding scheme is in flux.
24  NODESTRATEGY, BRANCHSTRATEGY, ADDCUTSSTRATEGY,
25  CLEARCUTS, OSLSTUFF, CBCSTUFF are not used at present (03.10.24).
26*/
27
28enum CbcParameterType
29
30{ GENERALQUERY = -100,
31 
32  PRIMALTOLERANCE = 1, DUALTOLERANCE,CUTOFF,TIMELIMIT,
33
34  INFEASIBILITYWEIGHT = 51, INTEGERTOLERANCE,INCREMENT,ALLOWABLEGAP,
35
36  DJFIX = 81, GAPRATIO,TIGHTENFACTOR,
37
38  LOGLEVEL = 151, SOLVERLOGLEVEL, MAXNODES,STRONGBRANCHING,
39 
40  DIRECTION = 201,ERRORSALLOWED,KEEPNAMES,SCALING,
41
42  NODESTRATEGY = 251,BRANCHSTRATEGY,ADDCUTSSTRATEGY,
43  GOMORYCUTS,PROBINGCUTS,KNAPSACKCUTS,ODDHOLECUTS,PRESOLVE,
44  ROUNDING,SOLVER,CLIQUECUTS,COSTSTRATEGY,FLOWCUTS,MIXEDCUTS,
45  TWOMIRCUTS,
46 
47  DIRECTORY = 301,IMPORT,EXPORT,RESTORE,SAVE,SOLVECONTINUOUS,BAB,
48    MAXIMIZE,MINIMIZE,EXIT,STDIN,UNITTEST,MIPLIB,SOLUTION,CLEARCUTS,
49    VERSION,
50
51  OSLSTUFF = 401,CBCSTUFF,
52
53  INVALID = 1000 } ;
54
55
56/// Very simple class for setting parameters
57
58class CbcParam
59
60{ public:
61
62  /**@name Constructor and destructor */
63  //@{
64  /// Constructors
65  CbcParam (  );
66  CbcParam (std::string name, std::string help,
67           double lower, double upper, CbcParameterType type);
68  CbcParam (std::string name, std::string help,
69           int lower, int upper, CbcParameterType type);
70  // Other strings will be added by insert
71  CbcParam (std::string name, std::string help, std::string defaultValue,
72           CbcParameterType type);
73  // Action
74  CbcParam (std::string name, std::string help,
75           CbcParameterType type);
76  /// Copy constructor.
77  CbcParam(const CbcParam &);
78  /// Assignment operator. This copies the data
79    CbcParam & operator = (const CbcParam & rhs);
80  /// Destructor
81  ~CbcParam (  );
82  //@}
83
84  /**@name stuff */
85  //@{
86  /// Insert string (only valid for keywords)
87  void append(std::string keyWord);
88  /// Adds one help line
89  void addHelp(std::string keyWord);
90  /// Returns name
91  inline std::string  name(  ) const {
92    return name_;
93  };
94  /// Returns short help
95  inline std::string  shortHelp(  ) const {
96    return shortHelp_;
97  };
98  /// Sets a double parameter (nonzero code if error)
99  int setDoubleParameter(OsiSolverInterface * model, double value) const;
100  /// Gets a double parameter
101  double doubleParameter(OsiSolverInterface * model) const;
102  /// Sets a int parameter (nonzero code if error)
103  int setIntParameter(OsiSolverInterface * model, int value) const;
104  /// Gets a int parameter
105  int intParameter(OsiSolverInterface * model) const;
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  /// Checks a double parameter (nonzero code if error)
111  int checkDoubleParameter(double value) const;
112  /// Sets a int parameter (nonzero code if error)
113  int setIntParameter(CbcModel &model, int value) const;
114  /// Gets a int parameter
115  int intParameter(CbcModel &model) const;
116  /// Returns name which could match
117  std::string matchName (  ) const;
118  /// Returns parameter option which matches (-1 if none)
119  int parameterOption ( std::string check ) const;
120  /// Prints parameter options
121  void printOptions (  ) const;
122  /// Returns current parameter option
123  inline std::string currentOption (  ) const
124  { return definedKeyWords_[currentKeyWord_]; };
125  /// Sets current parameter option
126  inline void setCurrentOption ( int value )
127  { currentKeyWord_ = value; };
128  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
129  int matches (std::string input) const;
130  /// type
131  inline CbcParameterType type() const
132  { return type_;};
133private:
134  /// gutsOfConstructor
135  void gutsOfConstructor();
136  //@}
137////////////////// data //////////////////
138private:
139
140  /**@name data
141   We might as well throw all type data in - could derive?
142  */
143  //@{
144  // Type see CbcParameterType
145  CbcParameterType type_;
146  /// If double == okay
147  double lowerDoubleValue_;
148  double upperDoubleValue_;
149  /// If int == okay
150  int lowerIntValue_;
151  int upperIntValue_;
152  // Length of name
153  unsigned int lengthName_;
154  // Minimum match
155  unsigned int lengthMatch_;
156  /// set of valid strings
157  std::vector<std::string> definedKeyWords_;
158  /// Name
159  std::string name_;
160  /// Short help
161  std::string shortHelp_;
162  /// Long help
163  std::vector<std::string> longHelp_;
164  /// Action
165  CbcParameterType action_;
166  /// Current keyWord (if a keyword parameter)
167  int currentKeyWord_;
168  //@}
169};
170
171#endif  /* CbcParam_H */
Note: See TracBrowser for help on using the repository browser.