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

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

finished Clp (create now bin/clp_solver)

  • 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#ifndef CbcOrClpParam_H
5#define CbcOrClpParam_H
6/**
7   This has parameter handling stuff which can be shared between Cbc and Clp (and Dylp etc).
8
9   This (and .cpp) should be copied so that it is the same in Cbc/Test and Clp/Test.
10   I know this is not elegant but it seems simplest.
11   
12   It uses COIN_HAS_CBC for parameters wanted by CBC
13   It uses COIN_HAS_CLP for parameters wanted by CLP (or CBC using CLP)
14   It could use COIN_HAS_DYLP for parameters wanted by DYLP
15   It could use COIN_HAS_DYLP_OR_CLP for parameters wanted by DYLP or CLP etc etc
16
17 */
18class OsiSolverInterface;
19class CbcModel;
20class ClpSimplex;
21/*! \brief Parameter codes
22
23  Parameter type ranges are allocated as follows
24  <ul>
25    <li>   1 -- 100     double parameters
26    <li> 101 -- 200     integer parameters
27    <li> 201 -- 250     string parameters
28    <li> 251 -- 300     cuts etc(string but broken out for clarity)
29    <li> 301 -- 400     `actions'
30  </ul>
31
32  `Actions' do not necessarily invoke an immediate action; it's just that they
33  don't fit neatly into the parameters array.
34 
35  This coding scheme is in flux.
36*/
37
38enum CbcOrClpParameterType
39
40  { GENERALQUERY = -100,FULLGENERALQUERY,
41   
42    PRIMALTOLERANCE = 1, DUALTOLERANCE, TIMELIMIT,
43    DUALBOUND, PRIMALWEIGHT,  OBJSCALE, RHSSCALE,
44   
45    INFEASIBILITYWEIGHT = 51, CUTOFF, INTEGERTOLERANCE,INCREMENT,ALLOWABLEGAP,
46    TIMELIMIT_BAB,
47   
48    DJFIX = 81, GAPRATIO,TIGHTENFACTOR,PRESOLVETOLERANCE,OBJSCALE2,
49
50    SOLVERLOGLEVEL=101,
51#ifndef COIN_HAS_CBC
52    LOGLEVEL = 101, 
53#endif
54    MAXFACTOR,PERTVALUE,MAXITERATION,PRESOLVEPASS,IDIOT,SPRINT,
55    OUTPUTFORMAT,SLPVALUE,PRESOLVEOPTIONS,PRINTOPTIONS,SPECIALOPTIONS,
56    SUBSTITUTION,DUALIZE,VERBOSE,THREADS,
57
58    STRONGBRANCHING=151,CUTDEPTH, MAXNODES,NUMBERBEFORE,NUMBERANALYZE,
59    NUMBERMINI,MIPOPTIONS,MOREMIPOPTIONS,MAXHOTITS,FPUMPITS,CUTPASS,
60#ifdef COIN_HAS_CBC
61    LOGLEVEL , 
62#endif
63 
64    DIRECTION=201,DUALPIVOT,SCALING,ERRORSALLOWED,KEEPNAMES,SPARSEFACTOR,
65    PRIMALPIVOT,PRESOLVE,CRASH,BIASLU,PERTURBATION,MESSAGES,AUTOSCALE,
66    CHOLESKY,KKT,BARRIERSCALE,GAMMA,CROSSOVER,PFI,INTPRINT,
67   
68    NODESTRATEGY = 251,BRANCHSTRATEGY,CUTSSTRATEGY,HEURISTICSTRATEGY,
69    GOMORYCUTS,PROBINGCUTS,KNAPSACKCUTS,REDSPLITCUTS,
70    ROUNDING,SOLVER,CLIQUECUTS,COSTSTRATEGY,FLOWCUTS,MIXEDCUTS,
71    TWOMIRCUTS,PREPROCESS,FPUMP,GREEDY,COMBINE,LOCALTREE,
72   
73    DIRECTORY=301,IMPORT,EXPORT,RESTORE,SAVE,DUALSIMPLEX,PRIMALSIMPLEX,EITHERSIMPLEX,
74    MAXIMIZE,MINIMIZE,EXIT,STDIN,UNITTEST,NETLIB_EITHER,NETLIB_DUAL,NETLIB_PRIMAL,SOLUTION,SAVESOL,
75    TIGHTEN,FAKEBOUND,HELP,PLUSMINUS,NETWORK,ALLSLACK,REVERSE,BARRIER,NETLIB_BARRIER,NETLIB_TUNE,
76    REALLY_SCALE,BASISIN,BASISOUT,SOLVECONTINUOUS,CLEARCUTS,VERSION,STATISTICS,DEBUG,DUMMY,PRINTMASK,
77
78    BAB=351,MIPLIB,STRENGTHEN,PRIORITYIN,
79
80    OSLSTUFF = 401,CBCSTUFF,
81
82    INVALID = 1000 } ;
83#include <vector>
84#include <string>
85
86/// Very simple class for setting parameters
87
88class CbcOrClpParam
89{
90public:
91  /**@name Constructor and destructor */
92  //@{
93  /// Constructors
94  CbcOrClpParam (  );
95  CbcOrClpParam (std::string name, std::string help,
96           double lower, double upper, CbcOrClpParameterType type,bool display=true);
97  CbcOrClpParam (std::string name, std::string help,
98           int lower, int upper, CbcOrClpParameterType type,bool display=true);
99  // Other strings will be added by insert
100  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
101           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
102  // Action
103  CbcOrClpParam (std::string name, std::string help,
104           CbcOrClpParameterType type,int whereUsed=7,bool display=true);
105  /// Copy constructor.
106  CbcOrClpParam(const CbcOrClpParam &);
107  /// Assignment operator. This copies the data
108    CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
109  /// Destructor
110  ~CbcOrClpParam (  );
111  //@}
112
113  /**@name stuff */
114  //@{
115  /// Insert string (only valid for keywords)
116  void append(std::string keyWord);
117  /// Adds one help line
118  void addHelp(std::string keyWord);
119  /// Returns name
120  inline std::string  name(  ) const {
121    return name_;
122  };
123  /// Returns short help
124  inline std::string  shortHelp(  ) const {
125    return shortHelp_;
126  };
127  /// Sets a double parameter (nonzero code if error)
128  int setDoubleParameter(CbcModel & model, double value) ;
129  /// Gets a double parameter
130  double doubleParameter(CbcModel & model) const;
131  /// Sets a int parameter (nonzero code if error)
132  int setIntParameter(CbcModel & model, int value) ;
133  /// Gets a int parameter
134  int intParameter(CbcModel & model) const;
135  /// Sets a double parameter (nonzero code if error)
136  int setDoubleParameter(ClpSimplex * model, double value) ;
137  /// Gets a double parameter
138  double doubleParameter(ClpSimplex * model) const;
139  /// Sets a int parameter (nonzero code if error)
140  int setIntParameter(ClpSimplex * model, int value) ;
141  /// Gets a int parameter
142  int intParameter(ClpSimplex * model) const;
143  /// Sets a double parameter (nonzero code if error)
144  int setDoubleParameter(OsiSolverInterface * model, double value) ;
145  /// Gets a double parameter
146  double doubleParameter(OsiSolverInterface * model) const;
147  /// Sets a int parameter (nonzero code if error)
148  int setIntParameter(OsiSolverInterface * model, int value) ;
149  /// Gets a int parameter
150  int intParameter(OsiSolverInterface * model) const;
151  /// Checks a double parameter (nonzero code if error)
152  int checkDoubleParameter(double value) const;
153  /// Returns name which could match
154  std::string matchName (  ) const;
155  /// Returns parameter option which matches (-1 if none)
156  int parameterOption ( std::string check ) const;
157  /// Prints parameter options
158  void printOptions (  ) const;
159  /// Returns current parameter option
160  inline std::string currentOption (  ) const
161  { return definedKeyWords_[currentKeyWord_]; };
162  /// Sets current parameter option
163  void setCurrentOption ( int value , bool printIt=false);
164  /// Sets current parameter option using string
165  void setCurrentOption (const std::string value );
166  /// Sets int value
167  void setIntValue ( int value );
168    inline int intValue () const
169  { return intValue_; };
170  /// Sets double value
171  void setDoubleValue ( double value );
172  inline double doubleValue () const
173  { return doubleValue_; };
174  /// Sets string value
175  void setStringValue ( std::string value );
176  inline std::string stringValue () const
177  { return stringValue_; };
178  /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
179  int matches (std::string input) const;
180  /// type
181  inline CbcOrClpParameterType type() const
182  { return type_;};
183  /// whether to display
184  inline bool displayThis() const
185  { return display_;};
186  /// Set Long help
187  inline void setLonghelp(const std::string help) 
188  {longHelp_=help;};
189  /// Print Long help
190  void printLongHelp() const;
191  /// Print action and string
192  void printString() const;
193  /** 7 if used everywhere,
194      1 - used by clp
195      2 - used by cbc
196      4 - used by ampl
197  */
198  inline int whereUsed() const
199  { return whereUsed_;};
200 
201private:
202  /// gutsOfConstructor
203  void gutsOfConstructor();
204  //@}
205////////////////// data //////////////////
206private:
207
208  /**@name data
209   We might as well throw all type data in - could derive?
210  */
211  //@{
212  // Type see CbcOrClpParameterType
213  CbcOrClpParameterType type_;
214  /// If double == okay
215  double lowerDoubleValue_;
216  double upperDoubleValue_;
217  /// If int == okay
218  int lowerIntValue_;
219  int upperIntValue_;
220  // Length of name
221  unsigned int lengthName_;
222  // Minimum match
223  unsigned int lengthMatch_;
224  /// set of valid strings
225  std::vector<std::string> definedKeyWords_;
226  /// Name
227  std::string name_;
228  /// Short help
229  std::string shortHelp_;
230  /// Long help
231  std::string longHelp_;
232  /// Action
233  CbcOrClpParameterType action_;
234  /// Current keyWord (if a keyword parameter)
235  int currentKeyWord_;
236  /// Display on ?
237  bool display_;
238  /// Integer parameter - current value
239  int intValue_;
240  /// Double parameter - current value
241  double doubleValue_;
242  /// String parameter - current value
243  std::string stringValue_;
244  /** 7 if used everywhere,
245      1 - used by clp
246      2 - used by cbc
247      4 - used by ampl
248  */
249  int whereUsed_;
250  //@}
251};
252/// Simple read stuff
253std::string CoinReadNextField();
254
255std::string CoinReadGetCommand(int argc, const char *argv[]);
256std::string CoinReadGetString(int argc, const char *argv[]);
257// valid 0 - okay, 1 bad, 2 not there
258int CoinReadGetIntField(int argc, const char *argv[],int * valid);
259double CoinReadGetDoubleField(int argc, const char *argv[],int * valid);
260void CoinReadPrintit(const char * input);
261void setCbcOrClpPrinting(bool yesNo);
262#define CBCMAXPARAMETERS 200
263/*
264  Subroutine to establish the cbc parameter array. See the description of
265  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
266*/
267void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
268// Given a parameter type - returns its number in list
269int whichParam (CbcOrClpParameterType name, 
270                int numberParameters, CbcOrClpParam *const parameters);
271// Dump a solution to file
272void saveSolution(const ClpSimplex * lpSolver,std::string fileName);
273#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.