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

Last change on this file since 1732 was 1732, checked in by forrest, 8 years ago

various fixes plus slightly weighted pricing plus lagomory switches

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