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

Last change on this file since 1424 was 1424, checked in by forrest, 10 years ago

fixes for various things

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