source: branches/BSP/trunk/Clp/src/CbcOrClpParam.hpp @ 1074

Last change on this file since 1074 was 1061, checked in by forrest, 13 years ago

nonlinear and a few parameters

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 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,
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,
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,USESOLUTION,SOS,
81    LANDPCUTS,RINS,RESIDCUTS,
82   
83    DIRECTORY=301,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,
88
89    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,USERCBC,
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  /// Sets int value
178  void setIntValue ( int value );
179    inline int intValue () const
180  { return intValue_; }
181  /// Sets double value
182  void setDoubleValue ( double value );
183  inline double doubleValue () const
184  { return doubleValue_; }
185  /// Sets string value
186  void setStringValue ( std::string value );
187  inline std::string stringValue () const
188  { return stringValue_; }
189  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
190  int matches (std::string input) const;
191  /// type
192  inline CbcOrClpParameterType type() const
193  { return type_;}
194  /// whether to display
195  inline bool displayThis() const
196  { return display_;}
197  /// Set Long help
198  inline void setLonghelp(const std::string help) 
199  {longHelp_=help;}
200  /// Print Long help
201  void printLongHelp() const;
202  /// Print action and string
203  void printString() const;
204  /** 7 if used everywhere,
205      1 - used by clp
206      2 - used by cbc
207      4 - used by ampl
208  */
209  inline int whereUsed() const
210  { return whereUsed_;}
211 
212private:
213  /// gutsOfConstructor
214  void gutsOfConstructor();
215  //@}
216////////////////// data //////////////////
217private:
218
219  /**@name data
220   We might as well throw all type data in - could derive?
221  */
222  //@{
223  // Type see CbcOrClpParameterType
224  CbcOrClpParameterType type_;
225  /// If double == okay
226  double lowerDoubleValue_;
227  double upperDoubleValue_;
228  /// If int == okay
229  int lowerIntValue_;
230  int upperIntValue_;
231  // Length of name
232  unsigned int lengthName_;
233  // Minimum match
234  unsigned int lengthMatch_;
235  /// set of valid strings
236  std::vector<std::string> definedKeyWords_;
237  /// Name
238  std::string name_;
239  /// Short help
240  std::string shortHelp_;
241  /// Long help
242  std::string longHelp_;
243  /// Action
244  CbcOrClpParameterType action_;
245  /// Current keyWord (if a keyword parameter)
246  int currentKeyWord_;
247  /// Display on ?
248  bool display_;
249  /// Integer parameter - current value
250  int intValue_;
251  /// Double parameter - current value
252  double doubleValue_;
253  /// String parameter - current value
254  std::string stringValue_;
255  /** 7 if used everywhere,
256      1 - used by clp
257      2 - used by cbc
258      4 - used by ampl
259  */
260  int whereUsed_;
261  //@}
262};
263/// Simple read stuff
264std::string CoinReadNextField();
265
266std::string CoinReadGetCommand(int argc, const char *argv[]);
267std::string CoinReadGetString(int argc, const char *argv[]);
268// valid 0 - okay, 1 bad, 2 not there
269int CoinReadGetIntField(int argc, const char *argv[],int * valid);
270double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
271void CoinReadPrintit(const char * input);
272void setCbcOrClpPrinting(bool yesNo);
273#define CBCMAXPARAMETERS 200
274/*
275  Subroutine to establish the cbc parameter array. See the description of
276  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
277*/
278void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
279// Given a parameter type - returns its number in list
280int whichParam (CbcOrClpParameterType name, 
281                int numberParameters, CbcOrClpParam *const parameters);
282// Dump a solution to file
283void saveSolution(const ClpSimplex * lpSolver,std::string fileName);
284#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.