source: trunk/Clp/src/CbcOrClpParam.hpp @ 1152

Last change on this file since 1152 was 1152, checked in by forrest, 12 years ago

allow dense factorization

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.5 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4#ifdef USE_CBCCONFIG
5# include "CbcConfig.h"
6#else
7# include "ClpConfig.h"
8#endif
9
10#ifndef CbcOrClpParam_H
11#define CbcOrClpParam_H
12/**
13   This has parameter handling stuff which can be shared between Cbc and Clp (and Dylp etc).
14
15   This (and .cpp) should be copied so that it is the same in Cbc/Test and Clp/Test.
16   I know this is not elegant but it seems simplest.
17   
18   It uses COIN_HAS_CBC for parameters wanted by CBC
19   It uses COIN_HAS_CLP for parameters wanted by CLP (or CBC using CLP)
20   It could use COIN_HAS_DYLP for parameters wanted by DYLP
21   It could use COIN_HAS_DYLP_OR_CLP for parameters wanted by DYLP or CLP etc etc
22
23 */
24class OsiSolverInterface;
25class CbcModel;
26class ClpSimplex;
27/*! \brief Parameter codes
28
29  Parameter type ranges are allocated as follows
30  <ul>
31    <li>   1 -- 100     double parameters
32    <li> 101 -- 200     integer parameters
33    <li> 201 -- 250     string parameters
34    <li> 251 -- 300     cuts etc(string but broken out for clarity)
35    <li> 301 -- 400     `actions'
36  </ul>
37
38  `Actions' do not necessarily invoke an immediate action; it's just that they
39  don't fit neatly into the parameters array.
40 
41  This coding scheme is in flux.
42*/
43
44enum CbcOrClpParameterType
45
46  { GENERALQUERY = -100,FULLGENERALQUERY,
47   
48    PRIMALTOLERANCE = 1, DUALTOLERANCE, TIMELIMIT,
49    DUALBOUND, PRIMALWEIGHT,  OBJSCALE, RHSSCALE,
50   
51    INFEASIBILITYWEIGHT = 51, CUTOFF, INTEGERTOLERANCE,INCREMENT,ALLOWABLEGAP,
52    TIMELIMIT_BAB,
53   
54    DJFIX = 81, GAPRATIO,TIGHTENFACTOR,PRESOLVETOLERANCE,OBJSCALE2,
55    DEXTRA1, DEXTRA2, DEXTRA3, DEXTRA4,
56
57    SOLVERLOGLEVEL=101,
58#ifndef COIN_HAS_CBC
59    LOGLEVEL = 101, 
60#endif
61    MAXFACTOR,PERTVALUE,MAXITERATION,PRESOLVEPASS,IDIOT,SPRINT,
62    OUTPUTFORMAT,SLPVALUE,PRESOLVEOPTIONS,PRINTOPTIONS,SPECIALOPTIONS,
63    SUBSTITUTION,DUALIZE,VERBOSE,CPP,PROCESSTUNE,USESOLUTION,
64
65    STRONGBRANCHING=151,CUTDEPTH, MAXNODES,NUMBERBEFORE,NUMBERANALYZE,
66    NUMBERMINI,MIPOPTIONS,MOREMIPOPTIONS,MAXHOTITS,FPUMPITS,MAXSOLS,
67    FPUMPTUNE,TESTOSI,EXTRA1,EXTRA2,EXTRA3,EXTRA4,CUTPASSINTREE,
68    THREADS,CUTPASS,VUBTRY,DENSE,
69#ifdef COIN_HAS_CBC
70    LOGLEVEL , 
71#endif
72 
73    DIRECTION=201,DUALPIVOT,SCALING,ERRORSALLOWED,KEEPNAMES,SPARSEFACTOR,
74    PRIMALPIVOT,PRESOLVE,CRASH,BIASLU,PERTURBATION,MESSAGES,AUTOSCALE,
75    CHOLESKY,KKT,BARRIERSCALE,GAMMA,CROSSOVER,PFI,INTPRINT,VECTOR,
76   
77    NODESTRATEGY = 251,BRANCHSTRATEGY,CUTSSTRATEGY,HEURISTICSTRATEGY,
78    GOMORYCUTS,PROBINGCUTS,KNAPSACKCUTS,REDSPLITCUTS,
79    ROUNDING,SOLVER,CLIQUECUTS,COSTSTRATEGY,FLOWCUTS,MIXEDCUTS,
80    TWOMIRCUTS,PREPROCESS,FPUMP,GREEDY,COMBINE,LOCALTREE,SOS,
81    LANDPCUTS,RINS,RESIDCUTS,RENS,
82   
83    DIRECTORY=301,DIRSAMPLE,DIRNETLIB,DIRMIPLIB,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,EITHERSIMPLEX,
84    MAXIMIZE,MINIMIZE,EXIT,STDIN,UNITTEST,NETLIB_EITHER,NETLIB_DUAL,NETLIB_PRIMAL,SOLUTION,SAVESOL,
85    TIGHTEN,FAKEBOUND,HELP,PLUSMINUS,NETWORK,ALLSLACK,REVERSE,BARRIER,NETLIB_BARRIER,NETLIB_TUNE,
86    REALLY_SCALE,BASISIN,BASISOUT,SOLVECONTINUOUS,CLEARCUTS,VERSION,STATISTICS,DEBUG,DUMMY,PRINTMASK,
87    OUTDUPROWS,USERCLP,MODELIN,CSVSTATISTICS,
88
89    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,USERCBC,DOHEURISTIC,
90
91    OSLSTUFF = 401,CBCSTUFF,
92
93    INVALID = 1000 } ;
94#include <vector>
95#include <string>
96
97/// Very simple class for setting parameters
98
99class CbcOrClpParam
100{
101public:
102  /**@name Constructor and destructor */
103  //@{
104  /// Constructors
105  CbcOrClpParam (  );
106  CbcOrClpParam (std::string name, std::string help,
107           double lower, double upper, CbcOrClpParameterType type,bool display=true);
108  CbcOrClpParam (std::string name, std::string help,
109           int lower, int upper, CbcOrClpParameterType type,bool display=true);
110  // Other strings will be added by insert
111  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
112           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
113  // Action
114  CbcOrClpParam (std::string name, std::string help,
115           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
116  /// Copy constructor.
117  CbcOrClpParam(const CbcOrClpParam &);
118  /// Assignment operator. This copies the data
119    CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
120  /// Destructor
121  ~CbcOrClpParam (  );
122  //@}
123
124  /**@name stuff */
125  //@{
126  /// Insert string (only valid for keywords)
127  void append(std::string keyWord);
128  /// Adds one help line
129  void addHelp(std::string keyWord);
130  /// Returns name
131  inline std::string  name(  ) const {
132    return name_;
133  }
134  /// Returns short help
135  inline std::string  shortHelp(  ) const {
136    return shortHelp_;
137  }
138  /// Sets a double parameter (nonzero code if error)
139  int setDoubleParameter(CbcModel & model, double value) ;
140  /// Gets a double parameter
141  double doubleParameter(CbcModel & model) const;
142  /// Sets a int parameter (nonzero code if error)
143  int setIntParameter(CbcModel & model, int value) ;
144  /// Gets a int parameter
145  int intParameter(CbcModel & model) const;
146  /// Sets a double parameter (nonzero code if error)
147  int setDoubleParameter(ClpSimplex * model, double value) ;
148  /// Gets a double parameter
149  double doubleParameter(ClpSimplex * model) const;
150  /// Sets a int parameter (nonzero code if error)
151  int setIntParameter(ClpSimplex * model, int value) ;
152  /// Gets a int parameter
153  int intParameter(ClpSimplex * model) const;
154  /// Sets a double parameter (nonzero code if error)
155  int setDoubleParameter(OsiSolverInterface * model, double value) ;
156  /// Gets a double parameter
157  double doubleParameter(OsiSolverInterface * model) const;
158  /// Sets a int parameter (nonzero code if error)
159  int setIntParameter(OsiSolverInterface * model, int value) ;
160  /// Gets a int parameter
161  int intParameter(OsiSolverInterface * model) const;
162  /// Checks a double parameter (nonzero code if error)
163  int checkDoubleParameter(double value) const;
164  /// Returns name which could match
165  std::string matchName (  ) const;
166  /// Returns parameter option which matches (-1 if none)
167  int parameterOption ( std::string check ) const;
168  /// Prints parameter options
169  void printOptions (  ) const;
170  /// Returns current parameter option
171  inline std::string currentOption (  ) const
172  { return definedKeyWords_[currentKeyWord_]; }
173  /// Sets current parameter option
174  void setCurrentOption ( int value , bool printIt=false);
175  /// Sets current parameter option using string
176  void setCurrentOption (const std::string value );
177  /// Returns current parameter option position
178  inline int currentOptionAsInteger (  ) const
179  { return currentKeyWord_; }
180  /// Sets int value
181  void setIntValue ( int value );
182    inline int intValue () const
183  { return intValue_; }
184  /// Sets double value
185  void setDoubleValue ( double value );
186  inline double doubleValue () const
187  { return doubleValue_; }
188  /// Sets string value
189  void setStringValue ( std::string value );
190  inline std::string stringValue () const
191  { return stringValue_; }
192  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
193  int matches (std::string input) const;
194  /// type
195  inline CbcOrClpParameterType type() const
196  { return type_;}
197  /// whether to display
198  inline bool displayThis() const
199  { return display_;}
200  /// Set Long help
201  inline void setLonghelp(const std::string help) 
202  {longHelp_=help;}
203  /// Print Long help
204  void printLongHelp() const;
205  /// Print action and string
206  void printString() const;
207  /** 7 if used everywhere,
208      1 - used by clp
209      2 - used by cbc
210      4 - used by ampl
211  */
212  inline int whereUsed() const
213  { return whereUsed_;}
214 
215private:
216  /// gutsOfConstructor
217  void gutsOfConstructor();
218  //@}
219////////////////// data //////////////////
220private:
221
222  /**@name data
223   We might as well throw all type data in - could derive?
224  */
225  //@{
226  // Type see CbcOrClpParameterType
227  CbcOrClpParameterType type_;
228  /// If double == okay
229  double lowerDoubleValue_;
230  double upperDoubleValue_;
231  /// If int == okay
232  int lowerIntValue_;
233  int upperIntValue_;
234  // Length of name
235  unsigned int lengthName_;
236  // Minimum match
237  unsigned int lengthMatch_;
238  /// set of valid strings
239  std::vector<std::string> definedKeyWords_;
240  /// Name
241  std::string name_;
242  /// Short help
243  std::string shortHelp_;
244  /// Long help
245  std::string longHelp_;
246  /// Action
247  CbcOrClpParameterType action_;
248  /// Current keyWord (if a keyword parameter)
249  int currentKeyWord_;
250  /// Display on ?
251  bool display_;
252  /// Integer parameter - current value
253  int intValue_;
254  /// Double parameter - current value
255  double doubleValue_;
256  /// String parameter - current value
257  std::string stringValue_;
258  /** 7 if used everywhere,
259      1 - used by clp
260      2 - used by cbc
261      4 - used by ampl
262  */
263  int whereUsed_;
264  //@}
265};
266/// Simple read stuff
267std::string CoinReadNextField();
268
269std::string CoinReadGetCommand(int argc, const char *argv[]);
270std::string CoinReadGetString(int argc, const char *argv[]);
271// valid 0 - okay, 1 bad, 2 not there
272int CoinReadGetIntField(int argc, const char *argv[],int * valid);
273double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
274void CoinReadPrintit(const char * input);
275void setCbcOrClpPrinting(bool yesNo);
276#define CBCMAXPARAMETERS 200
277/*
278  Subroutine to establish the cbc parameter array. See the description of
279  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
280*/
281void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
282// Given a parameter type - returns its number in list
283int whichParam (CbcOrClpParameterType name, 
284                int numberParameters, CbcOrClpParam *const parameters);
285// Dump a solution to file
286void saveSolution(const ClpSimplex * lpSolver,std::string fileName);
287#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.