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

Last change on this file since 1344 was 1344, checked in by forrest, 11 years ago

changes to simplex and lots of stuff and start Mumps cholesky

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.8 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, GAPRATIO,
53   
54    DJFIX = 81, TIGHTENFACTOR,PRESOLVETOLERANCE,OBJSCALE2,
55    DEXTRA1, DEXTRA2, DEXTRA3, DEXTRA4, DEXTRA5,
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,EXPERIMENT,DIVEOPT,STRATEGY,SMALLFACT,
69    HOPTIONS,
70#ifdef COIN_HAS_CBC
71    LOGLEVEL , 
72#endif
73 
74    DIRECTION=201,DUALPIVOT,SCALING,ERRORSALLOWED,KEEPNAMES,SPARSEFACTOR,
75    PRIMALPIVOT,PRESOLVE,CRASH,BIASLU,PERTURBATION,MESSAGES,AUTOSCALE,
76    CHOLESKY,KKT,BARRIERSCALE,GAMMA,CROSSOVER,PFI,INTPRINT,VECTOR,
77   
78    NODESTRATEGY = 251,BRANCHSTRATEGY,CUTSSTRATEGY,HEURISTICSTRATEGY,
79    GOMORYCUTS,PROBINGCUTS,KNAPSACKCUTS,REDSPLITCUTS,
80    ROUNDING,SOLVER,CLIQUECUTS,COSTSTRATEGY,FLOWCUTS,MIXEDCUTS,
81    TWOMIRCUTS,PREPROCESS,FPUMP,GREEDY,COMBINE,LOCALTREE,SOS,
82    LANDPCUTS,RINS,RESIDCUTS,RENS,DIVINGS,DIVINGC,DIVINGF,DIVINGG,DIVINGL,
83    DIVINGP,DIVINGV,DINS,PIVOTANDFIX,RANDROUND,NAIVE,ZEROHALFCUTS,CPX,
84   
85    DIRECTORY=301,DIRSAMPLE,DIRNETLIB,DIRMIPLIB,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,EITHERSIMPLEX,
86    MAXIMIZE,MINIMIZE,EXIT,STDIN,UNITTEST,NETLIB_EITHER,NETLIB_DUAL,NETLIB_PRIMAL,SOLUTION,SAVESOL,
87    TIGHTEN,FAKEBOUND,HELP,PLUSMINUS,NETWORK,ALLSLACK,REVERSE,BARRIER,NETLIB_BARRIER,NETLIB_TUNE,
88    REALLY_SCALE,BASISIN,BASISOUT,SOLVECONTINUOUS,CLEARCUTS,VERSION,STATISTICS,DEBUG,DUMMY,PRINTMASK,
89    OUTDUPROWS,USERCLP,MODELIN,CSVSTATISTICS,STOREDFILE,
90
91    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,USERCBC,DOHEURISTIC,
92
93    OSLSTUFF = 401,CBCSTUFF,
94
95    INVALID = 1000 } ;
96#include <vector>
97#include <string>
98
99/// Very simple class for setting parameters
100
101class CbcOrClpParam
102{
103public:
104  /**@name Constructor and destructor */
105  //@{
106  /// Constructors
107  CbcOrClpParam (  );
108  CbcOrClpParam (std::string name, std::string help,
109           double lower, double upper, CbcOrClpParameterType type,bool display=true);
110  CbcOrClpParam (std::string name, std::string help,
111           int lower, int upper, CbcOrClpParameterType type,bool display=true);
112  // Other strings will be added by insert
113  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
114           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
115  // Action
116  CbcOrClpParam (std::string name, std::string help,
117           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
118  /// Copy constructor.
119  CbcOrClpParam(const CbcOrClpParam &);
120  /// Assignment operator. This copies the data
121    CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
122  /// Destructor
123  ~CbcOrClpParam (  );
124  //@}
125
126  /**@name stuff */
127  //@{
128  /// Insert string (only valid for keywords)
129  void append(std::string keyWord);
130  /// Adds one help line
131  void addHelp(std::string keyWord);
132  /// Returns name
133  inline std::string  name(  ) const {
134    return name_;
135  }
136  /// Returns short help
137  inline std::string  shortHelp(  ) const {
138    return shortHelp_;
139  }
140  /// Sets a double parameter (nonzero code if error)
141  int setDoubleParameter(CbcModel & model, double value) ;
142  /// Sets double parameter and returns printable string and error code
143  const char * setDoubleParameterWithMessage ( CbcModel & model, double  value ,int & returnCode);
144  /// Gets a double parameter
145  double doubleParameter(CbcModel & model) const;
146  /// Sets a int parameter (nonzero code if error)
147  int setIntParameter(CbcModel & model, int value) ;
148  /// Sets int parameter and returns printable string and error code
149  const char * setIntParameterWithMessage ( CbcModel & model, int value ,int & returnCode);
150  /// Gets a int parameter
151  int intParameter(CbcModel & model) const;
152  /// Sets a double parameter (nonzero code if error)
153  int setDoubleParameter(ClpSimplex * model, double value) ;
154  /// Gets a double parameter
155  double doubleParameter(ClpSimplex * model) const;
156  /// Sets double parameter and returns printable string and error code
157  const char * setDoubleParameterWithMessage ( ClpSimplex * model, double  value ,int & returnCode);
158  /// Sets a int parameter (nonzero code if error)
159  int setIntParameter(ClpSimplex * model, int value) ;
160  /// Sets int parameter and returns printable string and error code
161  const char * setIntParameterWithMessage ( ClpSimplex * model, int  value ,int & returnCode);
162  /// Gets a int parameter
163  int intParameter(ClpSimplex * model) const;
164  /// Sets a double parameter (nonzero code if error)
165  int setDoubleParameter(OsiSolverInterface * model, double value) ;
166  /// Sets double parameter and returns printable string and error code
167  const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double  value ,int & returnCode);
168  /// Gets a double parameter
169  double doubleParameter(OsiSolverInterface * model) const;
170  /// Sets a int parameter (nonzero code if error)
171  int setIntParameter(OsiSolverInterface * model, int value) ;
172  /// Sets int parameter and returns printable string and error code
173  const char * setIntParameterWithMessage ( OsiSolverInterface * model, int  value ,int & returnCode);
174  /// Gets a int parameter
175  int intParameter(OsiSolverInterface * model) const;
176  /// Checks a double parameter (nonzero code if error)
177  int checkDoubleParameter(double value) const;
178  /// Returns name which could match
179  std::string matchName (  ) const;
180  /// Returns parameter option which matches (-1 if none)
181  int parameterOption ( std::string check ) const;
182  /// Prints parameter options
183  void printOptions (  ) const;
184  /// Returns current parameter option
185  inline std::string currentOption (  ) const
186  { return definedKeyWords_[currentKeyWord_]; }
187  /// Sets current parameter option
188  void setCurrentOption ( int value , bool printIt=false);
189  /// Sets current parameter option and returns printable string
190  const char * setCurrentOptionWithMessage ( int value );
191  /// Sets current parameter option using string
192  void setCurrentOption (const std::string value );
193  /// Returns current parameter option position
194  inline int currentOptionAsInteger (  ) const
195  { return currentKeyWord_; }
196  /// Sets int value
197  void setIntValue ( int value );
198    inline int intValue () const
199  { return intValue_; }
200  /// Sets double value
201  void setDoubleValue ( double value );
202  inline double doubleValue () const
203  { return doubleValue_; }
204  /// Sets string value
205  void setStringValue ( std::string value );
206  inline std::string stringValue () const
207  { return stringValue_; }
208  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
209  int matches (std::string input) const;
210  /// type
211  inline CbcOrClpParameterType type() const
212  { return type_;}
213  /// whether to display
214  inline bool displayThis() const
215  { return display_;}
216  /// Set Long help
217  inline void setLonghelp(const std::string help) 
218  {longHelp_=help;}
219  /// Print Long help
220  void printLongHelp() const;
221  /// Print action and string
222  void printString() const;
223  /** 7 if used everywhere,
224      1 - used by clp
225      2 - used by cbc
226      4 - used by ampl
227  */
228  inline int whereUsed() const
229  { return whereUsed_;}
230 
231private:
232  /// gutsOfConstructor
233  void gutsOfConstructor();
234  //@}
235////////////////// data //////////////////
236private:
237
238  /**@name data
239   We might as well throw all type data in - could derive?
240  */
241  //@{
242  // Type see CbcOrClpParameterType
243  CbcOrClpParameterType type_;
244  /// If double == okay
245  double lowerDoubleValue_;
246  double upperDoubleValue_;
247  /// If int == okay
248  int lowerIntValue_;
249  int upperIntValue_;
250  // Length of name
251  unsigned int lengthName_;
252  // Minimum match
253  unsigned int lengthMatch_;
254  /// set of valid strings
255  std::vector<std::string> definedKeyWords_;
256  /// Name
257  std::string name_;
258  /// Short help
259  std::string shortHelp_;
260  /// Long help
261  std::string longHelp_;
262  /// Action
263  CbcOrClpParameterType action_;
264  /// Current keyWord (if a keyword parameter)
265  int currentKeyWord_;
266  /// Display on ?
267  bool display_;
268  /// Integer parameter - current value
269  int intValue_;
270  /// Double parameter - current value
271  double doubleValue_;
272  /// String parameter - current value
273  std::string stringValue_;
274  /** 7 if used everywhere,
275      1 - used by clp
276      2 - used by cbc
277      4 - used by ampl
278  */
279  int whereUsed_;
280  //@}
281};
282/// Simple read stuff
283std::string CoinReadNextField();
284
285std::string CoinReadGetCommand(int argc, const char *argv[]);
286std::string CoinReadGetString(int argc, const char *argv[]);
287// valid 0 - okay, 1 bad, 2 not there
288int CoinReadGetIntField(int argc, const char *argv[],int * valid);
289double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
290void CoinReadPrintit(const char * input);
291void setCbcOrClpPrinting(bool yesNo);
292#define CBCMAXPARAMETERS 200
293/*
294  Subroutine to establish the cbc parameter array. See the description of
295  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
296*/
297void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
298// Given a parameter type - returns its number in list
299int whichParam (CbcOrClpParameterType name, 
300                int numberParameters, CbcOrClpParam *const parameters);
301// Dump a solution to file
302void saveSolution(const ClpSimplex * lpSolver,std::string fileName);
303#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.