source: branches/devel/Clp/src/CbcOrClpParam.hpp @ 904

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

rins

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