source: trunk/Cbc/src/CbcParam.hpp

Last change on this file was 2833, checked in by stefan, 3 days ago

merge branch autotools-update

  • exclude travis and appveyor updates
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1/* $Id: CbcParam.hpp 2833 2020-01-16 10:30:36Z stefan $ */
2// Copyright (C) 2002, International Business Machines
3// Corporation and others.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6#ifndef CbcParam_H
7#define CbcParam_H
8
9#include "OsiSolverInterface.hpp"
10#include "CbcModel.hpp"
11class ClpSimplex;
12/*! \brief Parameter codes
13
14  Parameter type ranges are allocated as follows
15  <ul>
16    <li>   1 -- 100     double parameters
17    <li> 101 -- 200     integer parameters
18    <li> 201 -- 250     string parameters
19    <li> 251 -- 300     cuts etc(string but broken out for clarity)
20    <li> 301 -- 400     `actions'
21  </ul>
22
23  `Actions' do not necessarily invoke an immediate action; it's just that they
24  don't fit neatly into the parameters array.
25
26  This coding scheme is in flux.
27  CBC_PARAM_STR_NODESTRATEGY,
28  CBC_PARAM_STR_BRANCHSTRATEGY,
29  CBC_PARAM_NOTUSED_ADDCUTSSTRATEGY,
30  CLP_PARAM_ACTION_CLEARCUTS,
31  CBC_PARAM_NOTUSED_OSLSTUFF,
32  CBC_PARAM_NOTUSED_CBCSTUFF are not used at present (03.10.24).
33*/
34
35enum CbcParameterType
36
37{ CBC_PARAM_GENERALQUERY = -100,
38  CBC_PARAM_FULLGENERALQUERY,
39
40  CLP_PARAM_DBL_PRIMALTOLERANCE = 1,
41  CLP_PARAM_DBL_DUALTOLERANCE,
42  CBC_PARAM_DBL_CUTOFF,
43  CLP_PARAM_DBL_TIMELIMIT,
44  CLP_PARAM_DBL_DUALBOUND,
45  CLP_PARAM_DBL_PRIMALWEIGHT,
46  CLP_PARAM_DBL_OBJSCALE,
47  CLP_PARAM_DBL_RHSSCALE,
48
49  CBC_PARAM_DBL_INFEASIBILITYWEIGHT = 51,
50  CBC_PARAM_DBL_INTEGERTOLERANCE,
51  CBC_PARAM_DBL_INCREMENT,
52  CBC_PARAM_DBL_ALLOWABLEGAP,
53
54  CBC_PARAM_DBL_DJFIX = 81,
55  CBC_PARAM_DBL_GAPRATIO,
56  CBC_PARAM_DBL_TIGHTENFACTOR,
57
58  CLP_PARAM_INT_LOGLEVEL = 101,
59  CLP_PARAM_INT_SOLVERLOGLEVEL,
60  CBC_PARAM_INT_MAXNODES,
61  CBC_PARAM_INT_STRONGBRANCHING,
62  CLP_PARAM_INT_MAXFACTOR,
63  CLP_PARAM_INT_PERTVALUE,
64  CLP_PARAM_INT_MAXITERATION,
65  CLP_PARAM_INT_PRESOLVEPASS,
66  CLP_PARAM_INT_IDIOT,
67  CLP_PARAM_INT_SPRINT,
68  CLP_PARAM_INT_OUTPUTFORMAT,
69  CLP_PARAM_INT_SLPVALUE,
70  CLP_PARAM_INT_PRESOLVEOPTIONS,
71  CLP_PARAM_INT_PRINTOPTIONS,
72  CLP_PARAM_INT_SPECIALOPTIONS,
73
74  CLP_PARAM_STR_DIRECTION = 201,
75  CLP_PARAM_STR_DUALPIVOT,
76  CLP_PARAM_STR_SCALING,
77  CLP_PARAM_STR_ERRORSALLOWED,
78  CLP_PARAM_STR_KEEPNAMES,
79  CLP_PARAM_STR_SPARSEFACTOR,
80  CLP_PARAM_STR_PRIMALPIVOT,
81  CLP_PARAM_STR_PRESOLVE,
82  CLP_PARAM_STR_CRASH,
83  CLP_PARAM_STR_BIASLU,
84  CLP_PARAM_STR_PERTURBATION,
85  CLP_PARAM_STR_MESSAGES,
86  CLP_PARAM_STR_AUTOSCALE,
87  CLP_PARAM_STR_CHOLESKY,
88  CLP_PARAM_STR_KKT,
89  CLP_PARAM_STR_BARRIERSCALE,
90  CLP_PARAM_STR_GAMMA,
91  CLP_PARAM_STR_CROSSOVER,
92  CLP_PARAM_STR_PFI,
93  CLP_PARAM_NOTUSED_ALGORITHM,
94
95  CBC_PARAM_STR_NODESTRATEGY = 251,
96  CBC_PARAM_STR_BRANCHSTRATEGY,
97  CBC_PARAM_NOTUSED_ADDCUTSSTRATEGY,
98  CBC_PARAM_STR_GOMORYCUTS,
99  CBC_PARAM_STR_PROBINGCUTS,
100  CBC_PARAM_STR_KNAPSACKCUTS,
101  CBC_PARAM_NOTUSED_ODDHOLECUTS,
102  CBC_PARAM_STR_ROUNDING,
103  CBC_PARAM_STR_SOLVER,
104  CBC_PARAM_STR_CLIQUECUTS,
105  CBC_PARAM_STR_COSTSTRATEGY,
106  CBC_PARAM_STR_FLOWCUTS,
107  CBC_PARAM_STR_MIXEDCUTS,
108  CBC_PARAM_STR_TWOMIRCUTS,
109  CBC_PARAM_STR_PREPROCESS,
110
111  CLP_PARAM_ACTION_DIRECTORY = 301,
112  CLP_PARAM_ACTION_IMPORT,
113  CLP_PARAM_ACTION_EXPORT,
114  CLP_PARAM_ACTION_RESTORE,
115  CLP_PARAM_ACTION_SAVE,
116  CLP_PARAM_ACTION_DUALSIMPLEX,
117  CLP_PARAM_ACTION_PRIMALSIMPLEX,
118  CLP_PARAM_ACTION_MAXIMIZE,
119  CLP_PARAM_ACTION_MINIMIZE,
120  CLP_PARAM_ACTION_EXIT,
121  CLP_PARAM_ACTION_STDIN,
122  CLP_PARAM_ACTION_UNITTEST,
123  CLP_PARAM_ACTION_NETLIB_DUAL,
124  CLP_PARAM_ACTION_NETLIB_PRIMAL,
125  CLP_PARAM_ACTION_SOLUTION,
126  CLP_PARAM_ACTION_TIGHTEN,
127  CLP_PARAM_ACTION_FAKEBOUND,
128  CLP_PARAM_ACTION_HELP,
129  CLP_PARAM_ACTION_PLUSMINUS,
130  CLP_PARAM_ACTION_NETWORK,
131  CLP_PARAM_ACTION_ALLSLACK,
132  CLP_PARAM_ACTION_REVERSE,
133  CLP_PARAM_ACTION_BARRIER,
134  CLP_PARAM_ACTION_NETLIB_BARRIER,
135  CLP_PARAM_ACTION_REALLY_SCALE,
136  CLP_PARAM_ACTION_BASISIN,
137  CLP_PARAM_ACTION_BASISOUT,
138  CLP_PARAM_ACTION_SOLVECONTINUOUS,
139  CBC_PARAM_ACTION_BAB,
140  CBC_PARAM_ACTION_MIPLIB,
141  CLP_PARAM_ACTION_CLEARCUTS,
142  CLP_VERSION_NOTUSED_PRINTVERSION,
143
144  CBC_PARAM_NOTUSED_OSLSTUFF = 401,
145  CBC_PARAM_NOTUSED_CBCSTUFF,
146
147  CBC_PARAM_NOTUSED_INVALID = 1000
148};
149
150/// Very simple class for setting parameters
151
152class CBCLIB_EXPORT CbcParam {
153
154public:
155  /**@name Constructor and destructor */
156  //@{
157  /// Constructors
158  CbcParam();
159  CbcParam(std::string name, std::string help,
160    double lower, double upper, CbcParameterType type, bool display = true);
161  CbcParam(std::string name, std::string help,
162    int lower, int upper, CbcParameterType type, bool display = true);
163  // Other strings will be added by insert
164  CbcParam(std::string name, std::string help, std::string firstValue,
165    CbcParameterType type, int defaultIndex = 0, bool display = true);
166  // Action
167  CbcParam(std::string name, std::string help,
168    CbcParameterType type, int indexNumber = -1, bool display = true);
169  /// Copy constructor.
170  CbcParam(const CbcParam &);
171  /// Assignment operator. This copies the data
172  CbcParam &operator=(const CbcParam &rhs);
173  /// Destructor
174  ~CbcParam();
175  //@}
176
177  /**@name stuff */
178  //@{
179  /// Insert string (only valid for keywords)
180  void append(std::string keyWord);
181  /// Adds one help line
182  void addHelp(std::string keyWord);
183  /// Returns name
184  inline std::string name() const
185  {
186    return name_;
187  };
188  /// Returns short help
189  inline std::string shortHelp() const
190  {
191    return shortHelp_;
192  };
193  /// Sets a double parameter (nonzero code if error)
194  int setDoubleParameter(CbcModel &model, double value) const;
195  /// Gets a double parameter
196  double doubleParameter(CbcModel &model) const;
197  /// Sets a int parameter (nonzero code if error)
198  int setIntParameter(CbcModel &model, int value) const;
199  /// Gets a int parameter
200  int intParameter(CbcModel &model) const;
201  /// Sets a double parameter (nonzero code if error)
202  int setDoubleParameter(ClpSimplex *model, double value) const;
203  /// Gets a double parameter
204  double doubleParameter(ClpSimplex *model) const;
205  /// Sets a int parameter (nonzero code if error)
206  int setIntParameter(ClpSimplex *model, int value) const;
207  /// Gets a int parameter
208  int intParameter(ClpSimplex *model) const;
209  /// Sets a double parameter (nonzero code if error)
210  int setDoubleParameter(OsiSolverInterface *model, double value) const;
211  /// Gets a double parameter
212  double doubleParameter(OsiSolverInterface *model) const;
213  /// Sets a int parameter (nonzero code if error)
214  int setIntParameter(OsiSolverInterface *model, int value) const;
215  /// Gets a int parameter
216  int intParameter(OsiSolverInterface *model) const;
217  /// Checks a double parameter (nonzero code if error)
218  int checkDoubleParameter(double value) const;
219  /// Returns name which could match
220  std::string matchName() const;
221  /// Returns parameter option which matches (-1 if none)
222  int parameterOption(std::string check) const;
223  /// Prints parameter options
224  void printOptions() const;
225  /// Returns current parameter option
226  inline std::string currentOption() const
227  {
228    return definedKeyWords_[currentKeyWord_];
229  }
230  /// Sets current parameter option
231  inline void setCurrentOption(int value)
232  {
233    currentKeyWord_ = value;
234  }
235  /// Sets int value
236  inline void setIntValue(int value)
237  {
238    intValue_ = value;
239  }
240  inline int intValue() const
241  {
242    return intValue_;
243  }
244  /// Sets double value
245  inline void setDoubleValue(double value)
246  {
247    doubleValue_ = value;
248  }
249  inline double doubleValue() const
250  {
251    return doubleValue_;
252  }
253  /// Sets string value
254  inline void setStringValue(std::string value)
255  {
256    stringValue_ = value;
257  }
258  inline std::string stringValue() const
259  {
260    return stringValue_;
261  }
262  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
263  int matches(std::string input) const;
264  /// type
265  inline CbcParameterType type() const
266  {
267    return type_;
268  }
269  /// whether to display
270  inline bool displayThis() const
271  {
272    return display_;
273  }
274  /// Set Long help
275  inline void setLonghelp(const std::string help)
276  {
277    longHelp_ = help;
278  }
279  /// Print Long help
280  void printLongHelp() const;
281  /// Print action and string
282  void printString() const;
283  /// type for classification
284  inline int indexNumber() const
285  {
286    return indexNumber_;
287  }
288
289private:
290  /// gutsOfConstructor
291  void gutsOfConstructor();
292  //@}
293  ////////////////// data //////////////////
294private:
295  /**@name data
296     We might as well throw all type data in - could derive?
297    */
298  //@{
299  // Type see CbcParameterType
300  CbcParameterType type_;
301  /// If double == okay
302  double lowerDoubleValue_;
303  double upperDoubleValue_;
304  /// If int == okay
305  int lowerIntValue_;
306  int upperIntValue_;
307  // Length of name
308  unsigned int lengthName_;
309  // Minimum match
310  unsigned int lengthMatch_;
311  /// set of valid strings
312  std::vector< std::string > definedKeyWords_;
313  /// Name
314  std::string name_;
315  /// Short help
316  std::string shortHelp_;
317  /// Long help
318  std::string longHelp_;
319  /// Action
320  CbcParameterType action_;
321  /// Current keyWord (if a keyword parameter)
322  int currentKeyWord_;
323  /// Display on ?
324  bool display_;
325  /// Integer parameter - current value
326  int intValue_;
327  /// Double parameter - current value
328  double doubleValue_;
329  /// String parameter - current value
330  std::string stringValue_;
331  /// index number to use for display purposes
332  int indexNumber_;
333  //@}
334};
335#endif /* CbcParam_H */
336
337/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
338*/
Note: See TracBrowser for help on using the repository browser.