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

Last change on this file since 1577 was 1525, checked in by mjs, 10 years ago

Formatted .cpp, .hpp, .c, .h files with "astyle -A4 -p". This matches the formatting used in the grand CBC reorganization.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.5 KB
Line 
1
2/* $Id: CbcOrClpParam.hpp 1525 2010-02-26 17:27:59Z stefan $ */
3// Copyright (C) 2002, International Business Machines
4// Corporation and others.  All Rights Reserved.
5
6#ifdef USE_CBCCONFIG
7# include "CbcConfig.h"
8#else
9# include "ClpConfig.h"
10#endif
11
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
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
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{
49     CBC_PARAM_GENERALQUERY = -100,
50     CBC_PARAM_FULLGENERALQUERY,
51
52     CLP_PARAM_DBL_PRIMALTOLERANCE = 1,
53     CLP_PARAM_DBL_DUALTOLERANCE,
54     CLP_PARAM_DBL_TIMELIMIT,
55     CLP_PARAM_DBL_DUALBOUND,
56     CLP_PARAM_DBL_PRIMALWEIGHT,
57     CLP_PARAM_DBL_OBJSCALE,
58     CLP_PARAM_DBL_RHSSCALE,
59
60     CBC_PARAM_DBL_INFEASIBILITYWEIGHT = 51,
61     CBC_PARAM_DBL_CUTOFF,
62     CBC_PARAM_DBL_INTEGERTOLERANCE,
63     CBC_PARAM_DBL_INCREMENT,
64     CBC_PARAM_DBL_ALLOWABLEGAP,
65     CBC_PARAM_DBL_TIMELIMIT_BAB,
66     CBC_PARAM_DBL_GAPRATIO,
67
68     CBC_PARAM_DBL_DJFIX = 81,
69     CBC_PARAM_DBL_TIGHTENFACTOR,
70     CLP_PARAM_DBL_PRESOLVETOLERANCE,
71     CLP_PARAM_DBL_OBJSCALE2,
72     CBC_PARAM_DBL_FAKEINCREMENT,
73     CBC_PARAM_DBL_FAKECUTOFF,
74     CBC_PARAM_DBL_ARTIFICIALCOST,
75     CBC_PARAM_DBL_DEXTRA3,
76     CBC_PARAM_DBL_SMALLBAB,
77     CBC_PARAM_DBL_DEXTRA4,
78     CBC_PARAM_DBL_DEXTRA5,
79
80     CLP_PARAM_INT_SOLVERLOGLEVEL = 101,
81#ifndef COIN_HAS_CBC
82     CLP_PARAM_INT_LOGLEVEL = 101,
83#endif
84     CLP_PARAM_INT_MAXFACTOR,
85     CLP_PARAM_INT_PERTVALUE,
86     CLP_PARAM_INT_MAXITERATION,
87     CLP_PARAM_INT_PRESOLVEPASS,
88     CLP_PARAM_INT_IDIOT,
89     CLP_PARAM_INT_SPRINT,
90     CLP_PARAM_INT_OUTPUTFORMAT,
91     CLP_PARAM_INT_SLPVALUE,
92     CLP_PARAM_INT_PRESOLVEOPTIONS,
93     CLP_PARAM_INT_PRINTOPTIONS,
94     CLP_PARAM_INT_SPECIALOPTIONS,
95     CLP_PARAM_INT_SUBSTITUTION,
96     CLP_PARAM_INT_DUALIZE,
97     CLP_PARAM_INT_VERBOSE,
98     CLP_PARAM_INT_CPP,
99     CLP_PARAM_INT_PROCESSTUNE,
100     CLP_PARAM_INT_USESOLUTION,
101
102     CBC_PARAM_INT_STRONGBRANCHING = 151,
103     CBC_PARAM_INT_CUTDEPTH,
104     CBC_PARAM_INT_MAXNODES,
105     CBC_PARAM_INT_NUMBERBEFORE,
106     CBC_PARAM_INT_NUMBERANALYZE,
107     CBC_PARAM_INT_MIPOPTIONS,
108     CBC_PARAM_INT_MOREMIPOPTIONS,
109     CBC_PARAM_INT_MAXHOTITS,
110     CBC_PARAM_INT_FPUMPITS,
111     CBC_PARAM_INT_MAXSOLS,
112     CBC_PARAM_INT_FPUMPTUNE,
113     CBC_PARAM_INT_TESTOSI,
114     CBC_PARAM_INT_EXTRA1,
115     CBC_PARAM_INT_EXTRA2,
116     CBC_PARAM_INT_EXTRA3,
117     CBC_PARAM_INT_EXTRA4,
118     CBC_PARAM_INT_DEPTHMINIBAB,
119     CBC_PARAM_INT_CUTPASSINTREE,
120     CBC_PARAM_INT_THREADS,
121     CBC_PARAM_INT_CUTPASS,
122     CBC_PARAM_INT_VUBTRY,
123     CBC_PARAM_INT_DENSE,
124     CBC_PARAM_INT_EXPERIMENT,
125     CBC_PARAM_INT_DIVEOPT,
126     CBC_PARAM_INT_STRATEGY,
127     CBC_PARAM_INT_SMALLFACT,
128     CBC_PARAM_INT_HOPTIONS,
129     CBC_PARAM_INT_CUTLENGTH,
130     CBC_PARAM_INT_FPUMPTUNE2,
131#ifdef COIN_HAS_CBC
132     CLP_PARAM_INT_LOGLEVEL ,
133#endif
134
135     CLP_PARAM_STR_DIRECTION = 201,
136     CLP_PARAM_STR_DUALPIVOT,
137     CLP_PARAM_STR_SCALING,
138     CLP_PARAM_STR_ERRORSALLOWED,
139     CLP_PARAM_STR_KEEPNAMES,
140     CLP_PARAM_STR_SPARSEFACTOR,
141     CLP_PARAM_STR_PRIMALPIVOT,
142     CLP_PARAM_STR_PRESOLVE,
143     CLP_PARAM_STR_CRASH,
144     CLP_PARAM_STR_BIASLU,
145     CLP_PARAM_STR_PERTURBATION,
146     CLP_PARAM_STR_MESSAGES,
147     CLP_PARAM_STR_AUTOSCALE,
148     CLP_PARAM_STR_CHOLESKY,
149     CLP_PARAM_STR_KKT,
150     CLP_PARAM_STR_BARRIERSCALE,
151     CLP_PARAM_STR_GAMMA,
152     CLP_PARAM_STR_CROSSOVER,
153     CLP_PARAM_STR_PFI,
154     CLP_PARAM_STR_INTPRINT,
155     CLP_PARAM_STR_VECTOR,
156     CLP_PARAM_STR_FACTORIZATION,
157     CLP_PARAM_STR_ALLCOMMANDS,
158
159     CBC_PARAM_STR_NODESTRATEGY = 251,
160     CBC_PARAM_STR_BRANCHSTRATEGY,
161     CBC_PARAM_STR_CUTSSTRATEGY,
162     CBC_PARAM_STR_HEURISTICSTRATEGY,
163     CBC_PARAM_STR_GOMORYCUTS,
164     CBC_PARAM_STR_PROBINGCUTS,
165     CBC_PARAM_STR_KNAPSACKCUTS,
166     CBC_PARAM_STR_REDSPLITCUTS,
167     CBC_PARAM_STR_ROUNDING,
168     CBC_PARAM_STR_SOLVER,
169     CBC_PARAM_STR_CLIQUECUTS,
170     CBC_PARAM_STR_COSTSTRATEGY,
171     CBC_PARAM_STR_FLOWCUTS,
172     CBC_PARAM_STR_MIXEDCUTS,
173     CBC_PARAM_STR_TWOMIRCUTS,
174     CBC_PARAM_STR_PREPROCESS,
175     CBC_PARAM_STR_FPUMP,
176     CBC_PARAM_STR_GREEDY,
177     CBC_PARAM_STR_COMBINE,
178     CBC_PARAM_STR_LOCALTREE,
179     CBC_PARAM_STR_SOS,
180     CBC_PARAM_STR_LANDPCUTS,
181     CBC_PARAM_STR_RINS,
182     CBC_PARAM_STR_RESIDCUTS,
183     CBC_PARAM_STR_RENS,
184     CBC_PARAM_STR_DIVINGS,
185     CBC_PARAM_STR_DIVINGC,
186     CBC_PARAM_STR_DIVINGF,
187     CBC_PARAM_STR_DIVINGG,
188     CBC_PARAM_STR_DIVINGL,
189     CBC_PARAM_STR_DIVINGP,
190     CBC_PARAM_STR_DIVINGV,
191     CBC_PARAM_STR_DINS,
192     CBC_PARAM_STR_PIVOTANDFIX,
193     CBC_PARAM_STR_RANDROUND,
194     CBC_PARAM_STR_NAIVE,
195     CBC_PARAM_STR_ZEROHALFCUTS,
196     CBC_PARAM_STR_CPX,
197     CBC_PARAM_STR_CROSSOVER2,
198     CBC_PARAM_STR_PIVOTANDCOMPLEMENT,
199     CBC_PARAM_STR_VND,
200
201     CLP_PARAM_ACTION_DIRECTORY = 301,
202     CLP_PARAM_ACTION_DIRSAMPLE,
203     CLP_PARAM_ACTION_DIRNETLIB,
204     CBC_PARAM_ACTION_DIRMIPLIB,
205     CLP_PARAM_ACTION_IMPORT,
206     CLP_PARAM_ACTION_EXPORT,
207     CLP_PARAM_ACTION_RESTORE,
208     CLP_PARAM_ACTION_SAVE,
209     CLP_PARAM_ACTION_DUALSIMPLEX,
210     CLP_PARAM_ACTION_PRIMALSIMPLEX,
211     CLP_PARAM_ACTION_EITHERSIMPLEX,
212     CLP_PARAM_ACTION_MAXIMIZE,
213     CLP_PARAM_ACTION_MINIMIZE,
214     CLP_PARAM_ACTION_EXIT,
215     CLP_PARAM_ACTION_STDIN,
216     CLP_PARAM_ACTION_UNITTEST,
217     CLP_PARAM_ACTION_NETLIB_EITHER,
218     CLP_PARAM_ACTION_NETLIB_DUAL,
219     CLP_PARAM_ACTION_NETLIB_PRIMAL,
220     CLP_PARAM_ACTION_SOLUTION,
221     CLP_PARAM_ACTION_SAVESOL,
222     CLP_PARAM_ACTION_TIGHTEN,
223     CLP_PARAM_ACTION_FAKEBOUND,
224     CLP_PARAM_ACTION_HELP,
225     CLP_PARAM_ACTION_PLUSMINUS,
226     CLP_PARAM_ACTION_NETWORK,
227     CLP_PARAM_ACTION_ALLSLACK,
228     CLP_PARAM_ACTION_REVERSE,
229     CLP_PARAM_ACTION_BARRIER,
230     CLP_PARAM_ACTION_NETLIB_BARRIER,
231     CLP_PARAM_ACTION_NETLIB_TUNE,
232     CLP_PARAM_ACTION_REALLY_SCALE,
233     CLP_PARAM_ACTION_BASISIN,
234     CLP_PARAM_ACTION_BASISOUT,
235     CLP_PARAM_ACTION_SOLVECONTINUOUS,
236     CLP_PARAM_ACTION_CLEARCUTS,
237     CLP_PARAM_ACTION_VERSION,
238     CLP_PARAM_ACTION_STATISTICS,
239     CLP_PARAM_ACTION_DEBUG,
240     CLP_PARAM_ACTION_DUMMY,
241     CLP_PARAM_ACTION_PRINTMASK,
242     CLP_PARAM_ACTION_OUTDUPROWS,
243     CLP_PARAM_ACTION_USERCLP,
244     CLP_PARAM_ACTION_MODELIN,
245     CLP_PARAM_ACTION_CSVSTATISTICS,
246     CLP_PARAM_ACTION_STOREDFILE,
247     CLP_PARAM_ACTION_ENVIRONMENT,
248
249     CBC_PARAM_ACTION_BAB = 351,
250     CBC_PARAM_ACTION_MIPLIB,
251     CBC_PARAM_ACTION_STRENGTHEN,
252     CBC_PARAM_ACTION_PRIORITYIN,
253     CBC_PARAM_ACTION_USERCBC,
254     CBC_PARAM_ACTION_DOHEURISTIC,
255
256     CBC_PARAM_NOTUSED_OSLSTUFF = 401,
257     CBC_PARAM_NOTUSED_CBCSTUFF,
258
259     CBC_PARAM_NOTUSED_INVALID = 1000
260} ;
261#include <vector>
262#include <string>
263
264/// Very simple class for setting parameters
265
266class CbcOrClpParam {
267public:
268     /**@name Constructor and destructor */
269     //@{
270     /// Constructors
271     CbcOrClpParam (  );
272     CbcOrClpParam (std::string name, std::string help,
273                    double lower, double upper, CbcOrClpParameterType type, int display = 2);
274     CbcOrClpParam (std::string name, std::string help,
275                    int lower, int upper, CbcOrClpParameterType type, int display = 2);
276     // Other strings will be added by insert
277     CbcOrClpParam (std::string name, std::string help, std::string firstValue,
278                    CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
279     // Action
280     CbcOrClpParam (std::string name, std::string help,
281                    CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
282     /// Copy constructor.
283     CbcOrClpParam(const CbcOrClpParam &);
284     /// Assignment operator. This copies the data
285     CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
286     /// Destructor
287     ~CbcOrClpParam (  );
288     //@}
289
290     /**@name stuff */
291     //@{
292     /// Insert string (only valid for keywords)
293     void append(std::string keyWord);
294     /// Adds one help line
295     void addHelp(std::string keyWord);
296     /// Returns name
297     inline std::string  name(  ) const {
298          return name_;
299     }
300     /// Returns short help
301     inline std::string  shortHelp(  ) const {
302          return shortHelp_;
303     }
304     /// Sets a double parameter (nonzero code if error)
305     int setDoubleParameter(CbcModel & model, double value) ;
306     /// Sets double parameter and returns printable string and error code
307     const char * setDoubleParameterWithMessage ( CbcModel & model, double  value , int & returnCode);
308     /// Gets a double parameter
309     double doubleParameter(CbcModel & model) const;
310     /// Sets a int parameter (nonzero code if error)
311     int setIntParameter(CbcModel & model, int value) ;
312     /// Sets int parameter and returns printable string and error code
313     const char * setIntParameterWithMessage ( CbcModel & model, int value , int & returnCode);
314     /// Gets a int parameter
315     int intParameter(CbcModel & model) const;
316     /// Sets a double parameter (nonzero code if error)
317     int setDoubleParameter(ClpSimplex * model, double value) ;
318     /// Gets a double parameter
319     double doubleParameter(ClpSimplex * model) const;
320     /// Sets double parameter and returns printable string and error code
321     const char * setDoubleParameterWithMessage ( ClpSimplex * model, double  value , int & returnCode);
322     /// Sets a int parameter (nonzero code if error)
323     int setIntParameter(ClpSimplex * model, int value) ;
324     /// Sets int parameter and returns printable string and error code
325     const char * setIntParameterWithMessage ( ClpSimplex * model, int  value , int & returnCode);
326     /// Gets a int parameter
327     int intParameter(ClpSimplex * model) const;
328     /// Sets a double parameter (nonzero code if error)
329     int setDoubleParameter(OsiSolverInterface * model, double value) ;
330     /// Sets double parameter and returns printable string and error code
331     const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double  value , int & returnCode);
332     /// Gets a double parameter
333     double doubleParameter(OsiSolverInterface * model) const;
334     /// Sets a int parameter (nonzero code if error)
335     int setIntParameter(OsiSolverInterface * model, int value) ;
336     /// Sets int parameter and returns printable string and error code
337     const char * setIntParameterWithMessage ( OsiSolverInterface * model, int  value , int & returnCode);
338     /// Gets a int parameter
339     int intParameter(OsiSolverInterface * model) const;
340     /// Checks a double parameter (nonzero code if error)
341     int checkDoubleParameter(double value) const;
342     /// Returns name which could match
343     std::string matchName (  ) const;
344     /// Returns length of name for ptinting
345     int lengthMatchName (  ) const;
346     /// Returns parameter option which matches (-1 if none)
347     int parameterOption ( std::string check ) const;
348     /// Prints parameter options
349     void printOptions (  ) const;
350     /// Returns current parameter option
351     inline std::string currentOption (  ) const {
352          return definedKeyWords_[currentKeyWord_];
353     }
354     /// Sets current parameter option
355     void setCurrentOption ( int value , bool printIt = false);
356     /// Sets current parameter option and returns printable string
357     const char * setCurrentOptionWithMessage ( int value );
358     /// Sets current parameter option using string
359     void setCurrentOption (const std::string value );
360     /// Returns current parameter option position
361     inline int currentOptionAsInteger (  ) const {
362          return currentKeyWord_;
363     }
364     /// Sets int value
365     void setIntValue ( int value );
366     inline int intValue () const {
367          return intValue_;
368     }
369     /// Sets double value
370     void setDoubleValue ( double value );
371     inline double doubleValue () const {
372          return doubleValue_;
373     }
374     /// Sets string value
375     void setStringValue ( std::string value );
376     inline std::string stringValue () const {
377          return stringValue_;
378     }
379     /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
380     int matches (std::string input) const;
381     /// type
382     inline CbcOrClpParameterType type() const {
383          return type_;
384     }
385     /// whether to display
386     inline int displayThis() const {
387          return display_;
388     }
389     /// Set Long help
390     inline void setLonghelp(const std::string help) {
391          longHelp_ = help;
392     }
393     /// Print Long help
394     void printLongHelp() const;
395     /// Print action and string
396     void printString() const;
397     /** 7 if used everywhere,
398         1 - used by clp
399         2 - used by cbc
400         4 - used by ampl
401     */
402     inline int whereUsed() const {
403          return whereUsed_;
404     }
405
406private:
407     /// gutsOfConstructor
408     void gutsOfConstructor();
409     //@}
410////////////////// data //////////////////
411private:
412
413     /**@name data
414      We might as well throw all type data in - could derive?
415     */
416     //@{
417     // Type see CbcOrClpParameterType
418     CbcOrClpParameterType type_;
419     /// If double == okay
420     double lowerDoubleValue_;
421     double upperDoubleValue_;
422     /// If int == okay
423     int lowerIntValue_;
424     int upperIntValue_;
425     // Length of name
426     unsigned int lengthName_;
427     // Minimum match
428     unsigned int lengthMatch_;
429     /// set of valid strings
430     std::vector<std::string> definedKeyWords_;
431     /// Name
432     std::string name_;
433     /// Short help
434     std::string shortHelp_;
435     /// Long help
436     std::string longHelp_;
437     /// Action
438     CbcOrClpParameterType action_;
439     /// Current keyWord (if a keyword parameter)
440     int currentKeyWord_;
441     /// Display on ?
442     int display_;
443     /// Integer parameter - current value
444     int intValue_;
445     /// Double parameter - current value
446     double doubleValue_;
447     /// String parameter - current value
448     std::string stringValue_;
449     /** 7 if used everywhere,
450         1 - used by clp
451         2 - used by cbc
452         4 - used by ampl
453     */
454     int whereUsed_;
455     //@}
456};
457/// Simple read stuff
458std::string CoinReadNextField();
459
460std::string CoinReadGetCommand(int argc, const char *argv[]);
461std::string CoinReadGetString(int argc, const char *argv[]);
462// valid 0 - okay, 1 bad, 2 not there
463int CoinReadGetIntField(int argc, const char *argv[], int * valid);
464double CoinReadGetDoubleField(int argc, const char *argv[], int * valid);
465void CoinReadPrintit(const char * input);
466void setCbcOrClpPrinting(bool yesNo);
467#define CBCMAXPARAMETERS 200
468/*
469  Subroutine to establish the cbc parameter array. See the description of
470  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
471*/
472void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
473// Given a parameter type - returns its number in list
474int whichParam (CbcOrClpParameterType name,
475                int numberParameters, CbcOrClpParam *const parameters);
476// Dump a solution to file
477void saveSolution(const ClpSimplex * lpSolver, std::string fileName);
478#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.