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

Last change on this file since 800 was 800, checked in by ladanyi, 13 years ago

finishing conversion to svn

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