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

Last change on this file since 772 was 772, checked in by andreasw, 13 years ago

changed Config.h behavior

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 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,
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,
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
84    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,
85
86    OSLSTUFF = 401,CBCSTUFF,
87
88    INVALID = 1000 } ;
89#include <vector>
90#include <string>
91
92/// Very simple class for setting parameters
93
94class CbcOrClpParam
95{
96public:
97  /**@name Constructor and destructor */
98  //@{
99  /// Constructors
100  CbcOrClpParam (  );
101  CbcOrClpParam (std::string name, std::string help,
102           double lower, double upper, CbcOrClpParameterType type,bool display=true);
103  CbcOrClpParam (std::string name, std::string help,
104           int lower, int upper, CbcOrClpParameterType type,bool display=true);
105  // Other strings will be added by insert
106  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
107           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
108  // Action
109  CbcOrClpParam (std::string name, std::string help,
110           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
111  /// Copy constructor.
112  CbcOrClpParam(const CbcOrClpParam &);
113  /// Assignment operator. This copies the data
114    CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
115  /// Destructor
116  ~CbcOrClpParam (  );
117  //@}
118
119  /**@name stuff */
120  //@{
121  /// Insert string (only valid for keywords)
122  void append(std::string keyWord);
123  /// Adds one help line
124  void addHelp(std::string keyWord);
125  /// Returns name
126  inline std::string  name(  ) const {
127    return name_;
128  };
129  /// Returns short help
130  inline std::string  shortHelp(  ) const {
131    return shortHelp_;
132  };
133  /// Sets a double parameter (nonzero code if error)
134  int setDoubleParameter(CbcModel & model, double value) ;
135  /// Gets a double parameter
136  double doubleParameter(CbcModel & model) const;
137  /// Sets a int parameter (nonzero code if error)
138  int setIntParameter(CbcModel & model, int value) ;
139  /// Gets a int parameter
140  int intParameter(CbcModel & model) const;
141  /// Sets a double parameter (nonzero code if error)
142  int setDoubleParameter(ClpSimplex * model, double value) ;
143  /// Gets a double parameter
144  double doubleParameter(ClpSimplex * model) const;
145  /// Sets a int parameter (nonzero code if error)
146  int setIntParameter(ClpSimplex * model, int value) ;
147  /// Gets a int parameter
148  int intParameter(ClpSimplex * model) const;
149  /// Sets a double parameter (nonzero code if error)
150  int setDoubleParameter(OsiSolverInterface * model, double value) ;
151  /// Gets a double parameter
152  double doubleParameter(OsiSolverInterface * model) const;
153  /// Sets a int parameter (nonzero code if error)
154  int setIntParameter(OsiSolverInterface * model, int value) ;
155  /// Gets a int parameter
156  int intParameter(OsiSolverInterface * model) const;
157  /// Checks a double parameter (nonzero code if error)
158  int checkDoubleParameter(double value) const;
159  /// Returns name which could match
160  std::string matchName (  ) const;
161  /// Returns parameter option which matches (-1 if none)
162  int parameterOption ( std::string check ) const;
163  /// Prints parameter options
164  void printOptions (  ) const;
165  /// Returns current parameter option
166  inline std::string currentOption (  ) const
167  { return definedKeyWords_[currentKeyWord_]; };
168  /// Sets current parameter option
169  void setCurrentOption ( int value , bool printIt=false);
170  /// Sets current parameter option using string
171  void setCurrentOption (const std::string value );
172  /// Sets int value
173  void setIntValue ( int value );
174    inline int intValue () const
175  { return intValue_; };
176  /// Sets double value
177  void setDoubleValue ( double value );
178  inline double doubleValue () const
179  { return doubleValue_; };
180  /// Sets string value
181  void setStringValue ( std::string value );
182  inline std::string stringValue () const
183  { return stringValue_; };
184  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
185  int matches (std::string input) const;
186  /// type
187  inline CbcOrClpParameterType type() const
188  { return type_;};
189  /// whether to display
190  inline bool displayThis() const
191  { return display_;};
192  /// Set Long help
193  inline void setLonghelp(const std::string help) 
194  {longHelp_=help;};
195  /// Print Long help
196  void printLongHelp() const;
197  /// Print action and string
198  void printString() const;
199  /** 7 if used everywhere,
200      1 - used by clp
201      2 - used by cbc
202      4 - used by ampl
203  */
204  inline int whereUsed() const
205  { return whereUsed_;};
206 
207private:
208  /// gutsOfConstructor
209  void gutsOfConstructor();
210  //@}
211////////////////// data //////////////////
212private:
213
214  /**@name data
215   We might as well throw all type data in - could derive?
216  */
217  //@{
218  // Type see CbcOrClpParameterType
219  CbcOrClpParameterType type_;
220  /// If double == okay
221  double lowerDoubleValue_;
222  double upperDoubleValue_;
223  /// If int == okay
224  int lowerIntValue_;
225  int upperIntValue_;
226  // Length of name
227  unsigned int lengthName_;
228  // Minimum match
229  unsigned int lengthMatch_;
230  /// set of valid strings
231  std::vector<std::string> definedKeyWords_;
232  /// Name
233  std::string name_;
234  /// Short help
235  std::string shortHelp_;
236  /// Long help
237  std::string longHelp_;
238  /// Action
239  CbcOrClpParameterType action_;
240  /// Current keyWord (if a keyword parameter)
241  int currentKeyWord_;
242  /// Display on ?
243  bool display_;
244  /// Integer parameter - current value
245  int intValue_;
246  /// Double parameter - current value
247  double doubleValue_;
248  /// String parameter - current value
249  std::string stringValue_;
250  /** 7 if used everywhere,
251      1 - used by clp
252      2 - used by cbc
253      4 - used by ampl
254  */
255  int whereUsed_;
256  //@}
257};
258/// Simple read stuff
259std::string CoinReadNextField();
260
261std::string CoinReadGetCommand(int argc, const char *argv[]);
262std::string CoinReadGetString(int argc, const char *argv[]);
263// valid 0 - okay, 1 bad, 2 not there
264int CoinReadGetIntField(int argc, const char *argv[],int * valid);
265double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
266void CoinReadPrintit(const char * input);
267void setCbcOrClpPrinting(bool yesNo);
268#define CBCMAXPARAMETERS 200
269/*
270  Subroutine to establish the cbc parameter array. See the description of
271  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
272*/
273void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
274// Given a parameter type - returns its number in list
275int whichParam (CbcOrClpParameterType name, 
276                int numberParameters, CbcOrClpParam *const parameters);
277// Dump a solution to file
278void saveSolution(const ClpSimplex * lpSolver,std::string fileName);
279#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.