source: branches/sandbox/Clp/src/CbcOrClpParam.hpp @ 1474

Last change on this file since 1474 was 1474, checked in by bjarni, 11 years ago

Renamed parameter constants in CbcOrClpParam? and ClpMain? to make them more readable/search-able

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.2 KB
Line 
1
2/* $Id: CbcOrClpParam.hpp 1474 2009-12-06 21:19:23Z bjarni $ */
3// Copyright (C) 2002, International Business Machines
4// Corporation and others.  All Rights Reserved.
5
6#ifdef USE_CBCCONFIG
7# include "CbcConfig.h"
8#else
9# include "ClpConfig.h"
10#endif
11
12#ifndef CbcOrClpParam_H
13#define CbcOrClpParam_H
14/**
15   This has parameter handling stuff which can be shared between Cbc and Clp (and Dylp etc).
16
17   This (and .cpp) should be copied so that it is the same in Cbc/Test and Clp/Test.
18   I know this is not elegant but it seems simplest.
19   
20   It uses COIN_HAS_CBC for parameters wanted by CBC
21   It uses COIN_HAS_CLP for parameters wanted by CLP (or CBC using CLP)
22   It could use COIN_HAS_DYLP for parameters wanted by DYLP
23   It could use COIN_HAS_DYLP_OR_CLP for parameters wanted by DYLP or CLP etc etc
24
25 */
26class OsiSolverInterface;
27class CbcModel;
28class ClpSimplex;
29/*! \brief Parameter codes
30
31  Parameter type ranges are allocated as follows
32  <ul>
33    <li>   1 -- 100     double parameters
34    <li> 101 -- 200     integer parameters
35    <li> 201 -- 250     string parameters
36    <li> 251 -- 300     cuts etc(string but broken out for clarity)
37    <li> 301 -- 400     `actions'
38  </ul>
39
40  `Actions' do not necessarily invoke an immediate action; it's just that they
41  don't fit neatly into the parameters array.
42 
43  This coding scheme is in flux.
44*/
45
46enum CbcOrClpParameterType
47
48  { CBC_PARAM_GENERALQUERY = -100,
49    CBC_PARAM_FULLGENERALQUERY,
50   
51    CLP_PARAM_DBL_PRIMALTOLERANCE = 1, 
52        CLP_PARAM_DBL_DUALTOLERANCE, 
53        CLP_PARAM_DBL_TIMELIMIT,
54    CLP_PARAM_DBL_DUALBOUND, 
55        CLP_PARAM_DBL_PRIMALWEIGHT, 
56        CLP_PARAM_DBL_OBJSCALE, 
57        CLP_PARAM_DBL_RHSSCALE,
58   
59    CBC_PARAM_DBL_INFEASIBILITYWEIGHT = 51, 
60        CBC_PARAM_DBL_CUTOFF, 
61        CBC_PARAM_DBL_INTEGERTOLERANCE,
62        CBC_PARAM_DBL_INCREMENT,
63        CBC_PARAM_DBL_ALLOWABLEGAP,
64    CBC_PARAM_DBL_TIMELIMIT_BAB, 
65        CBC_PARAM_DBL_GAPRATIO,
66   
67    CBC_PARAM_DBL_DJFIX = 81, 
68        CBC_PARAM_DBL_TIGHTENFACTOR,
69        CLP_PARAM_DBL_PRESOLVETOLERANCE,
70        CLP_PARAM_DBL_OBJSCALE2,
71    CBC_PARAM_DBL_FAKEINCREMENT, 
72        CBC_PARAM_DBL_FAKECUTOFF, 
73        CBC_PARAM_DBL_ARTIFICIALCOST,
74        CBC_PARAM_DBL_DEXTRA3, 
75        CBC_PARAM_DBL_SMALLBAB, 
76        CBC_PARAM_DBL_DEXTRA4, 
77        CBC_PARAM_DBL_DEXTRA5,
78
79    CLP_PARAM_INT_SOLVERLOGLEVEL=101,
80#ifndef COIN_HAS_CBC
81    CLP_PARAM_INT_LOGLEVEL = 101, 
82#endif
83    CLP_PARAM_INT_MAXFACTOR,
84        CLP_PARAM_INT_PERTVALUE,
85        CLP_PARAM_INT_MAXITERATION,
86        CLP_PARAM_INT_PRESOLVEPASS,
87        CLP_PARAM_INT_IDIOT,
88        CLP_PARAM_INT_SPRINT,
89    CLP_PARAM_INT_OUTPUTFORMAT,
90        CLP_PARAM_INT_SLPVALUE,
91        CLP_PARAM_INT_PRESOLVEOPTIONS,
92        CLP_PARAM_INT_PRINTOPTIONS,
93        CLP_PARAM_INT_SPECIALOPTIONS,
94    CLP_PARAM_INT_SUBSTITUTION,
95        CLP_PARAM_INT_DUALIZE,
96        CLP_PARAM_INT_VERBOSE,
97        CLP_PARAM_INT_CPP,
98        CLP_PARAM_INT_PROCESSTUNE,
99        CLP_PARAM_INT_USESOLUTION,
100
101    CBC_PARAM_INT_STRONGBRANCHING=151,
102        CBC_PARAM_INT_CUTDEPTH, 
103        CBC_PARAM_INT_MAXNODES,
104        CBC_PARAM_INT_NUMBERBEFORE,
105        CBC_PARAM_INT_NUMBERANALYZE,
106    CBC_PARAM_INT_MIPOPTIONS,
107        CBC_PARAM_INT_MOREMIPOPTIONS,
108        CBC_PARAM_INT_MAXHOTITS,
109        CBC_PARAM_INT_FPUMPITS,
110        CBC_PARAM_INT_MAXSOLS,
111    CBC_PARAM_INT_FPUMPTUNE,
112        CBC_PARAM_INT_TESTOSI,
113        CBC_PARAM_INT_EXTRA1,
114        CBC_PARAM_INT_EXTRA2,
115        CBC_PARAM_INT_EXTRA3,
116        CBC_PARAM_INT_EXTRA4,
117        CBC_PARAM_INT_DEPTHMINIBAB,
118        CBC_PARAM_INT_CUTPASSINTREE,
119    CBC_PARAM_INT_THREADS,
120        CBC_PARAM_INT_CUTPASS,
121        CBC_PARAM_INT_VUBTRY,
122        CBC_PARAM_INT_DENSE,
123        CBC_PARAM_INT_EXPERIMENT,
124        CBC_PARAM_INT_DIVEOPT,
125        CBC_PARAM_INT_STRATEGY,
126        CBC_PARAM_INT_SMALLFACT,
127    CBC_PARAM_INT_HOPTIONS,
128        CBC_PARAM_INT_CUTLENGTH,
129        CBC_PARAM_INT_FPUMPTUNE2,
130#ifdef COIN_HAS_CBC
131    CLP_PARAM_INT_LOGLEVEL , 
132#endif
133 
134    CLP_PARAM_STR_DIRECTION=201,
135        CLP_PARAM_STR_DUALPIVOT,
136        CLP_PARAM_STR_SCALING,
137        CLP_PARAM_STR_ERRORSALLOWED,
138        CLP_PARAM_STR_KEEPNAMES,
139        CLP_PARAM_STR_SPARSEFACTOR,
140    CLP_PARAM_STR_PRIMALPIVOT,
141        CLP_PARAM_STR_PRESOLVE,
142        CLP_PARAM_STR_CRASH,
143        CLP_PARAM_STR_BIASLU,
144        CLP_PARAM_STR_PERTURBATION,
145        CLP_PARAM_STR_MESSAGES,
146        CLP_PARAM_STR_AUTOSCALE,
147    CLP_PARAM_STR_CHOLESKY,
148        CLP_PARAM_STR_KKT,
149        CLP_PARAM_STR_BARRIERSCALE,
150        CLP_PARAM_STR_GAMMA,
151        CLP_PARAM_STR_CROSSOVER,
152        CLP_PARAM_STR_PFI,
153        CLP_PARAM_STR_INTPRINT,
154        CLP_PARAM_STR_VECTOR,
155    CLP_PARAM_STR_FACTORIZATION,
156        CLP_PARAM_STR_ALLCOMMANDS,
157   
158    CBC_PARAM_STR_NODESTRATEGY = 251,
159        CBC_PARAM_STR_BRANCHSTRATEGY,
160        CBC_PARAM_STR_CUTSSTRATEGY,
161        CBC_PARAM_STR_HEURISTICSTRATEGY,
162    CBC_PARAM_STR_GOMORYCUTS,
163        CBC_PARAM_STR_PROBINGCUTS,
164        CBC_PARAM_STR_KNAPSACKCUTS,
165        CBC_PARAM_STR_REDSPLITCUTS,
166    CBC_PARAM_STR_ROUNDING,
167        CBC_PARAM_STR_SOLVER,
168        CBC_PARAM_STR_CLIQUECUTS,
169        CBC_PARAM_STR_COSTSTRATEGY,
170        CBC_PARAM_STR_FLOWCUTS,
171        CBC_PARAM_STR_MIXEDCUTS,
172    CBC_PARAM_STR_TWOMIRCUTS,
173        CBC_PARAM_STR_PREPROCESS,
174        CBC_PARAM_STR_FPUMP,
175        CBC_PARAM_STR_GREEDY,
176        CBC_PARAM_STR_COMBINE,
177        CBC_PARAM_STR_LOCALTREE,
178        CBC_PARAM_STR_SOS,
179    CBC_PARAM_STR_LANDPCUTS,
180        CBC_PARAM_STR_RINS,
181        CBC_PARAM_STR_RESIDCUTS,
182        CBC_PARAM_STR_RENS,
183        CBC_PARAM_STR_DIVINGS,
184        CBC_PARAM_STR_DIVINGC,
185        CBC_PARAM_STR_DIVINGF,
186        CBC_PARAM_STR_DIVINGG,
187        CBC_PARAM_STR_DIVINGL,
188    CBC_PARAM_STR_DIVINGP,
189        CBC_PARAM_STR_DIVINGV,
190        CBC_PARAM_STR_DINS,
191        CBC_PARAM_STR_PIVOTANDFIX,
192        CBC_PARAM_STR_RANDROUND,
193        CBC_PARAM_STR_NAIVE,
194        CBC_PARAM_STR_ZEROHALFCUTS,
195        CBC_PARAM_STR_CPX,
196    CBC_PARAM_STR_CROSSOVER2,
197        CBC_PARAM_STR_PIVOTANDCOMPLEMENT,
198        CBC_PARAM_STR_VND,
199   
200    CLP_PARAM_ACTION_DIRECTORY=301,
201        CLP_PARAM_ACTION_DIRSAMPLE,
202        CLP_PARAM_ACTION_DIRNETLIB,
203        CBC_PARAM_ACTION_DIRMIPLIB,
204        CLP_PARAM_ACTION_IMPORT,
205        CLP_PARAM_ACTION_EXPORT,
206        CLP_PARAM_ACTION_RESTORE,
207        CLP_PARAM_ACTION_SAVE,
208        CLP_PARAM_ACTION_DUALSIMPLEX,
209        CLP_PARAM_ACTION_PRIMALSIMPLEX,
210        CLP_PARAM_ACTION_EITHERSIMPLEX,
211    CLP_PARAM_ACTION_MAXIMIZE,
212        CLP_PARAM_ACTION_MINIMIZE,
213        CLP_PARAM_ACTION_EXIT,
214        CLP_PARAM_ACTION_STDIN,
215        CLP_PARAM_ACTION_UNITTEST,
216        CLP_PARAM_ACTION_NETLIB_EITHER,
217        CLP_PARAM_ACTION_NETLIB_DUAL,
218        CLP_PARAM_ACTION_NETLIB_PRIMAL,
219        CLP_PARAM_ACTION_SOLUTION,
220        CLP_PARAM_ACTION_SAVESOL,
221    CLP_PARAM_ACTION_TIGHTEN,
222        CLP_PARAM_ACTION_FAKEBOUND,
223        CLP_PARAM_ACTION_HELP,
224        CLP_PARAM_ACTION_PLUSMINUS,
225        CLP_PARAM_ACTION_NETWORK,
226        CLP_PARAM_ACTION_ALLSLACK,
227        CLP_PARAM_ACTION_REVERSE,
228        CLP_PARAM_ACTION_BARRIER,
229        CLP_PARAM_ACTION_NETLIB_BARRIER,
230        CLP_PARAM_ACTION_NETLIB_TUNE,
231    CLP_PARAM_ACTION_REALLY_SCALE,
232        CLP_PARAM_ACTION_BASISIN,
233        CLP_PARAM_ACTION_BASISOUT,
234        CLP_PARAM_ACTION_SOLVECONTINUOUS,
235        CLP_PARAM_ACTION_CLEARCUTS,
236        CLP_PARAM_ACTION_VERSION,
237        CLP_PARAM_ACTION_STATISTICS,
238        CLP_PARAM_ACTION_DEBUG,
239        CLP_PARAM_ACTION_DUMMY,
240        CLP_PARAM_ACTION_PRINTMASK,
241    CLP_PARAM_ACTION_OUTDUPROWS,
242        CLP_PARAM_ACTION_USERCLP,
243        CLP_PARAM_ACTION_MODELIN,
244        CLP_PARAM_ACTION_CSVSTATISTICS,
245        CLP_PARAM_ACTION_STOREDFILE,
246        CLP_PARAM_ACTION_ENVIRONMENT,
247
248    CBC_PARAM_ACTION_BAB=351,
249        CBC_PARAM_ACTION_MIPLIB,
250        CBC_PARAM_ACTION_STRENGTHEN,
251        CBC_PARAM_ACTION_PRIORITYIN,
252        CBC_PARAM_ACTION_USERCBC,
253        CBC_PARAM_ACTION_DOHEURISTIC,
254
255    CBC_PARAM_NOTUSED_OSLSTUFF = 401,
256        CBC_PARAM_NOTUSED_CBCSTUFF,
257
258    CBC_PARAM_NOTUSED_INVALID = 1000 } ;
259#include <vector>
260#include <string>
261
262/// Very simple class for setting parameters
263
264class CbcOrClpParam
265{
266public:
267  /**@name Constructor and destructor */
268  //@{
269  /// Constructors
270  CbcOrClpParam (  );
271  CbcOrClpParam (std::string name, std::string help,
272           double lower, double upper, CbcOrClpParameterType type,int display=2);
273  CbcOrClpParam (std::string name, std::string help,
274           int lower, int upper, CbcOrClpParameterType type,int display=2);
275  // Other strings will be added by insert
276  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
277           CbcOrClpParameterType type,int whereUsed=7,int display=2);
278  // Action
279  CbcOrClpParam (std::string name, std::string help,
280           CbcOrClpParameterType type,int whereUsed=7,int display=2);
281  /// Copy constructor.
282  CbcOrClpParam(const CbcOrClpParam &);
283  /// Assignment operator. This copies the data
284    CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
285  /// Destructor
286  ~CbcOrClpParam (  );
287  //@}
288
289  /**@name stuff */
290  //@{
291  /// Insert string (only valid for keywords)
292  void append(std::string keyWord);
293  /// Adds one help line
294  void addHelp(std::string keyWord);
295  /// Returns name
296  inline std::string  name(  ) const {
297    return name_;
298  }
299  /// Returns short help
300  inline std::string  shortHelp(  ) const {
301    return shortHelp_;
302  }
303  /// Sets a double parameter (nonzero code if error)
304  int setDoubleParameter(CbcModel & model, double value) ;
305  /// Sets double parameter and returns printable string and error code
306  const char * setDoubleParameterWithMessage ( CbcModel & model, double  value ,int & returnCode);
307  /// Gets a double parameter
308  double doubleParameter(CbcModel & model) const;
309  /// Sets a int parameter (nonzero code if error)
310  int setIntParameter(CbcModel & model, int value) ;
311  /// Sets int parameter and returns printable string and error code
312  const char * setIntParameterWithMessage ( CbcModel & model, int value ,int & returnCode);
313  /// Gets a int parameter
314  int intParameter(CbcModel & model) const;
315  /// Sets a double parameter (nonzero code if error)
316  int setDoubleParameter(ClpSimplex * model, double value) ;
317  /// Gets a double parameter
318  double doubleParameter(ClpSimplex * model) const;
319  /// Sets double parameter and returns printable string and error code
320  const char * setDoubleParameterWithMessage ( ClpSimplex * model, double  value ,int & returnCode);
321  /// Sets a int parameter (nonzero code if error)
322  int setIntParameter(ClpSimplex * model, int value) ;
323  /// Sets int parameter and returns printable string and error code
324  const char * setIntParameterWithMessage ( ClpSimplex * model, int  value ,int & returnCode);
325  /// Gets a int parameter
326  int intParameter(ClpSimplex * model) const;
327  /// Sets a double parameter (nonzero code if error)
328  int setDoubleParameter(OsiSolverInterface * model, double value) ;
329  /// Sets double parameter and returns printable string and error code
330  const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double  value ,int & returnCode);
331  /// Gets a double parameter
332  double doubleParameter(OsiSolverInterface * model) const;
333  /// Sets a int parameter (nonzero code if error)
334  int setIntParameter(OsiSolverInterface * model, int value) ;
335  /// Sets int parameter and returns printable string and error code
336  const char * setIntParameterWithMessage ( OsiSolverInterface * model, int  value ,int & returnCode);
337  /// Gets a int parameter
338  int intParameter(OsiSolverInterface * model) const;
339  /// Checks a double parameter (nonzero code if error)
340  int checkDoubleParameter(double value) const;
341  /// Returns name which could match
342  std::string matchName (  ) const;
343  /// Returns length of name for ptinting
344  int lengthMatchName (  ) const;
345  /// Returns parameter option which matches (-1 if none)
346  int parameterOption ( std::string check ) const;
347  /// Prints parameter options
348  void printOptions (  ) const;
349  /// Returns current parameter option
350  inline std::string currentOption (  ) const
351  { return definedKeyWords_[currentKeyWord_]; }
352  /// Sets current parameter option
353  void setCurrentOption ( int value , bool printIt=false);
354  /// Sets current parameter option and returns printable string
355  const char * setCurrentOptionWithMessage ( int value );
356  /// Sets current parameter option using string
357  void setCurrentOption (const std::string value );
358  /// Returns current parameter option position
359  inline int currentOptionAsInteger (  ) const
360  { return currentKeyWord_; }
361  /// Sets int value
362  void setIntValue ( int value );
363    inline int intValue () const
364  { return intValue_; }
365  /// Sets double value
366  void setDoubleValue ( double value );
367  inline double doubleValue () const
368  { return doubleValue_; }
369  /// Sets string value
370  void setStringValue ( std::string value );
371  inline std::string stringValue () const
372  { return stringValue_; }
373  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
374  int matches (std::string input) const;
375  /// type
376  inline CbcOrClpParameterType type() const
377  { return type_;}
378  /// whether to display
379  inline int displayThis() const
380  { return display_;}
381  /// Set Long help
382  inline void setLonghelp(const std::string help) 
383  {longHelp_=help;}
384  /// Print Long help
385  void printLongHelp() const;
386  /// Print action and string
387  void printString() const;
388  /** 7 if used everywhere,
389      1 - used by clp
390      2 - used by cbc
391      4 - used by ampl
392  */
393  inline int whereUsed() const
394  { return whereUsed_;}
395 
396private:
397  /// gutsOfConstructor
398  void gutsOfConstructor();
399  //@}
400////////////////// data //////////////////
401private:
402
403  /**@name data
404   We might as well throw all type data in - could derive?
405  */
406  //@{
407  // Type see CbcOrClpParameterType
408  CbcOrClpParameterType type_;
409  /// If double == okay
410  double lowerDoubleValue_;
411  double upperDoubleValue_;
412  /// If int == okay
413  int lowerIntValue_;
414  int upperIntValue_;
415  // Length of name
416  unsigned int lengthName_;
417  // Minimum match
418  unsigned int lengthMatch_;
419  /// set of valid strings
420  std::vector<std::string> definedKeyWords_;
421  /// Name
422  std::string name_;
423  /// Short help
424  std::string shortHelp_;
425  /// Long help
426  std::string longHelp_;
427  /// Action
428  CbcOrClpParameterType action_;
429  /// Current keyWord (if a keyword parameter)
430  int currentKeyWord_;
431  /// Display on ?
432  int display_;
433  /// Integer parameter - current value
434  int intValue_;
435  /// Double parameter - current value
436  double doubleValue_;
437  /// String parameter - current value
438  std::string stringValue_;
439  /** 7 if used everywhere,
440      1 - used by clp
441      2 - used by cbc
442      4 - used by ampl
443  */
444  int whereUsed_;
445  //@}
446};
447/// Simple read stuff
448std::string CoinReadNextField();
449
450std::string CoinReadGetCommand(int argc, const char *argv[]);
451std::string CoinReadGetString(int argc, const char *argv[]);
452// valid 0 - okay, 1 bad, 2 not there
453int CoinReadGetIntField(int argc, const char *argv[],int * valid);
454double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
455void CoinReadPrintit(const char * input);
456void setCbcOrClpPrinting(bool yesNo);
457#define CBCMAXPARAMETERS 200
458/*
459  Subroutine to establish the cbc parameter array. See the description of
460  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
461*/
462void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
463// Given a parameter type - returns its number in list
464int whichParam (CbcOrClpParameterType name, 
465                int numberParameters, CbcOrClpParam *const parameters);
466// Dump a solution to file
467void saveSolution(const ClpSimplex * lpSolver,std::string fileName);
468#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.