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

Last change on this file since 2069 was 2069, checked in by forrest, 6 years ago

changes to diving heuristics

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.3 KB
Line 
1
2/* $Id: CbcOrClpParam.hpp 2069 2014-11-06 15:50:00Z 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     CLP_PARAM_INT_RANDOMSEED,
104     CLP_PARAM_INT_MORESPECIALOPTIONS,
105     CLP_PARAM_INT_DECOMPOSE_BLOCKS,
106
107     CBC_PARAM_INT_STRONGBRANCHING = 151,
108     CBC_PARAM_INT_CUTDEPTH,
109     CBC_PARAM_INT_MAXNODES,
110     CBC_PARAM_INT_NUMBERBEFORE,
111     CBC_PARAM_INT_NUMBERANALYZE,
112     CBC_PARAM_INT_MIPOPTIONS,
113     CBC_PARAM_INT_MOREMIPOPTIONS,
114     CBC_PARAM_INT_MAXHOTITS,
115     CBC_PARAM_INT_FPUMPITS,
116     CBC_PARAM_INT_MAXSOLS,
117     CBC_PARAM_INT_FPUMPTUNE,
118     CBC_PARAM_INT_TESTOSI,
119     CBC_PARAM_INT_EXTRA1,
120     CBC_PARAM_INT_EXTRA2,
121     CBC_PARAM_INT_EXTRA3,
122     CBC_PARAM_INT_EXTRA4,
123     CBC_PARAM_INT_DEPTHMINIBAB,
124     CBC_PARAM_INT_CUTPASSINTREE,
125     CBC_PARAM_INT_THREADS,
126     CBC_PARAM_INT_CUTPASS,
127     CBC_PARAM_INT_VUBTRY,
128     CBC_PARAM_INT_DENSE,
129     CBC_PARAM_INT_EXPERIMENT,
130     CBC_PARAM_INT_DIVEOPT,
131     CBC_PARAM_INT_DIVEOPTSOLVES,
132     CBC_PARAM_INT_STRATEGY,
133     CBC_PARAM_INT_SMALLFACT,
134     CBC_PARAM_INT_HOPTIONS,
135     CBC_PARAM_INT_CUTLENGTH,
136     CBC_PARAM_INT_FPUMPTUNE2,
137#ifdef COIN_HAS_CBC
138     CLP_PARAM_INT_LOGLEVEL ,
139#endif
140     CBC_PARAM_INT_MAXSAVEDSOLS,
141     CBC_PARAM_INT_RANDOMSEED,
142     CBC_PARAM_INT_MULTIPLEROOTS,
143     CBC_PARAM_INT_STRONG_STRATEGY,
144     CBC_PARAM_INT_EXTRA_VARIABLES,
145     CBC_PARAM_INT_MAX_SLOW_CUTS,
146     CBC_PARAM_INT_MOREMOREMIPOPTIONS,
147
148     CLP_PARAM_STR_DIRECTION = 201,
149     CLP_PARAM_STR_DUALPIVOT,
150     CLP_PARAM_STR_SCALING,
151     CLP_PARAM_STR_ERRORSALLOWED,
152     CLP_PARAM_STR_KEEPNAMES,
153     CLP_PARAM_STR_SPARSEFACTOR,
154     CLP_PARAM_STR_PRIMALPIVOT,
155     CLP_PARAM_STR_PRESOLVE,
156     CLP_PARAM_STR_CRASH,
157     CLP_PARAM_STR_BIASLU,
158     CLP_PARAM_STR_PERTURBATION,
159     CLP_PARAM_STR_MESSAGES,
160     CLP_PARAM_STR_AUTOSCALE,
161     CLP_PARAM_STR_CHOLESKY,
162     CLP_PARAM_STR_KKT,
163     CLP_PARAM_STR_BARRIERSCALE,
164     CLP_PARAM_STR_GAMMA,
165     CLP_PARAM_STR_CROSSOVER,
166     CLP_PARAM_STR_PFI,
167     CLP_PARAM_STR_INTPRINT,
168     CLP_PARAM_STR_VECTOR,
169     CLP_PARAM_STR_FACTORIZATION,
170     CLP_PARAM_STR_ALLCOMMANDS,
171     CLP_PARAM_STR_TIME_MODE,
172     CLP_PARAM_STR_ABCWANTED,
173
174     CBC_PARAM_STR_NODESTRATEGY = 251,
175     CBC_PARAM_STR_BRANCHSTRATEGY,
176     CBC_PARAM_STR_CUTSSTRATEGY,
177     CBC_PARAM_STR_HEURISTICSTRATEGY,
178     CBC_PARAM_STR_GOMORYCUTS,
179     CBC_PARAM_STR_PROBINGCUTS,
180     CBC_PARAM_STR_KNAPSACKCUTS,
181     CBC_PARAM_STR_REDSPLITCUTS,
182     CBC_PARAM_STR_ROUNDING,
183     CBC_PARAM_STR_SOLVER,
184     CBC_PARAM_STR_CLIQUECUTS,
185     CBC_PARAM_STR_COSTSTRATEGY,
186     CBC_PARAM_STR_FLOWCUTS,
187     CBC_PARAM_STR_MIXEDCUTS,
188     CBC_PARAM_STR_TWOMIRCUTS,
189     CBC_PARAM_STR_PREPROCESS,
190     CBC_PARAM_STR_FPUMP,
191     CBC_PARAM_STR_GREEDY,
192     CBC_PARAM_STR_COMBINE,
193     CBC_PARAM_STR_PROXIMITY,
194     CBC_PARAM_STR_LOCALTREE,
195     CBC_PARAM_STR_SOS,
196     CBC_PARAM_STR_LANDPCUTS,
197     CBC_PARAM_STR_RINS,
198     CBC_PARAM_STR_RESIDCUTS,
199     CBC_PARAM_STR_RENS,
200     CBC_PARAM_STR_DIVINGS,
201     CBC_PARAM_STR_DIVINGC,
202     CBC_PARAM_STR_DIVINGF,
203     CBC_PARAM_STR_DIVINGG,
204     CBC_PARAM_STR_DIVINGL,
205     CBC_PARAM_STR_DIVINGP,
206     CBC_PARAM_STR_DIVINGV,
207     CBC_PARAM_STR_DINS,
208     CBC_PARAM_STR_PIVOTANDFIX,
209     CBC_PARAM_STR_RANDROUND,
210     CBC_PARAM_STR_NAIVE,
211     CBC_PARAM_STR_ZEROHALFCUTS,
212     CBC_PARAM_STR_CPX,
213     CBC_PARAM_STR_CROSSOVER2,
214     CBC_PARAM_STR_PIVOTANDCOMPLEMENT,
215     CBC_PARAM_STR_VND,
216     CBC_PARAM_STR_LAGOMORYCUTS,
217     CBC_PARAM_STR_LATWOMIRCUTS,
218     CBC_PARAM_STR_REDSPLIT2CUTS,
219     CBC_PARAM_STR_GMICUTS,
220     CBC_PARAM_STR_CUTOFF_CONSTRAINT,
221     CBC_PARAM_STR_DW,
222     CBC_PARAM_STR_ORBITAL,
223
224     CLP_PARAM_ACTION_DIRECTORY = 301,
225     CLP_PARAM_ACTION_DIRSAMPLE,
226     CLP_PARAM_ACTION_DIRNETLIB,
227     CBC_PARAM_ACTION_DIRMIPLIB,
228     CLP_PARAM_ACTION_IMPORT,
229     CLP_PARAM_ACTION_EXPORT,
230     CLP_PARAM_ACTION_RESTORE,
231     CLP_PARAM_ACTION_SAVE,
232     CLP_PARAM_ACTION_DUALSIMPLEX,
233     CLP_PARAM_ACTION_PRIMALSIMPLEX,
234     CLP_PARAM_ACTION_EITHERSIMPLEX,
235     CLP_PARAM_ACTION_MAXIMIZE,
236     CLP_PARAM_ACTION_MINIMIZE,
237     CLP_PARAM_ACTION_EXIT,
238     CLP_PARAM_ACTION_STDIN,
239     CLP_PARAM_ACTION_UNITTEST,
240     CLP_PARAM_ACTION_NETLIB_EITHER,
241     CLP_PARAM_ACTION_NETLIB_DUAL,
242     CLP_PARAM_ACTION_NETLIB_PRIMAL,
243     CLP_PARAM_ACTION_SOLUTION,
244     CLP_PARAM_ACTION_SAVESOL,
245     CLP_PARAM_ACTION_TIGHTEN,
246     CLP_PARAM_ACTION_FAKEBOUND,
247     CLP_PARAM_ACTION_HELP,
248     CLP_PARAM_ACTION_PLUSMINUS,
249     CLP_PARAM_ACTION_NETWORK,
250     CLP_PARAM_ACTION_ALLSLACK,
251     CLP_PARAM_ACTION_REVERSE,
252     CLP_PARAM_ACTION_BARRIER,
253     CLP_PARAM_ACTION_NETLIB_BARRIER,
254     CLP_PARAM_ACTION_NETLIB_TUNE,
255     CLP_PARAM_ACTION_REALLY_SCALE,
256     CLP_PARAM_ACTION_BASISIN,
257     CLP_PARAM_ACTION_BASISOUT,
258     CLP_PARAM_ACTION_SOLVECONTINUOUS,
259     CLP_PARAM_ACTION_CLEARCUTS,
260     CLP_PARAM_ACTION_VERSION,
261     CLP_PARAM_ACTION_STATISTICS,
262     CLP_PARAM_ACTION_DEBUG,
263     CLP_PARAM_ACTION_DUMMY,
264     CLP_PARAM_ACTION_PRINTMASK,
265     CLP_PARAM_ACTION_OUTDUPROWS,
266     CLP_PARAM_ACTION_USERCLP,
267     CLP_PARAM_ACTION_MODELIN,
268     CLP_PARAM_ACTION_CSVSTATISTICS,
269     CLP_PARAM_ACTION_STOREDFILE,
270     CLP_PARAM_ACTION_ENVIRONMENT,
271     CLP_PARAM_ACTION_PARAMETRICS,
272     CLP_PARAM_ACTION_GMPL_SOLUTION,
273     CLP_PARAM_ACTION_RESTORESOL,
274
275     CBC_PARAM_ACTION_BAB = 361,
276     CBC_PARAM_ACTION_MIPLIB,
277     CBC_PARAM_ACTION_STRENGTHEN,
278     CBC_PARAM_ACTION_PRIORITYIN,
279     CBC_PARAM_ACTION_MIPSTART,
280     CBC_PARAM_ACTION_USERCBC,
281     CBC_PARAM_ACTION_DOHEURISTIC,
282     CLP_PARAM_ACTION_NEXTBESTSOLUTION,
283
284     CBC_PARAM_NOTUSED_OSLSTUFF = 401,
285     CBC_PARAM_NOTUSED_CBCSTUFF,
286
287     CBC_PARAM_NOTUSED_INVALID = 1000
288} ;
289#include <vector>
290#include <string>
291
292/// Very simple class for setting parameters
293
294class CbcOrClpParam {
295public:
296     /**@name Constructor and destructor */
297     //@{
298     /// Constructors
299     CbcOrClpParam (  );
300     CbcOrClpParam (std::string name, std::string help,
301                    double lower, double upper, CbcOrClpParameterType type, int display = 2);
302     CbcOrClpParam (std::string name, std::string help,
303                    int lower, int upper, CbcOrClpParameterType type, int display = 2);
304     // Other strings will be added by insert
305     CbcOrClpParam (std::string name, std::string help, std::string firstValue,
306                    CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
307     // Action
308     CbcOrClpParam (std::string name, std::string help,
309                    CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
310     /// Copy constructor.
311     CbcOrClpParam(const CbcOrClpParam &);
312     /// Assignment operator. This copies the data
313     CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
314     /// Destructor
315     ~CbcOrClpParam (  );
316     //@}
317
318     /**@name stuff */
319     //@{
320     /// Insert string (only valid for keywords)
321     void append(std::string keyWord);
322     /// Adds one help line
323     void addHelp(std::string keyWord);
324     /// Returns name
325     inline std::string  name(  ) const {
326          return name_;
327     }
328     /// Returns short help
329     inline std::string  shortHelp(  ) const {
330          return shortHelp_;
331     }
332     /// Sets a double parameter (nonzero code if error)
333     int setDoubleParameter(CbcModel & model, double value) ;
334     /// Sets double parameter and returns printable string and error code
335     const char * setDoubleParameterWithMessage ( CbcModel & model, double  value , int & returnCode);
336     /// Gets a double parameter
337     double doubleParameter(CbcModel & model) const;
338     /// Sets a int parameter (nonzero code if error)
339     int setIntParameter(CbcModel & model, int value) ;
340     /// Sets int parameter and returns printable string and error code
341     const char * setIntParameterWithMessage ( CbcModel & model, int value , int & returnCode);
342     /// Gets a int parameter
343     int intParameter(CbcModel & model) const;
344     /// Sets a double parameter (nonzero code if error)
345     int setDoubleParameter(ClpSimplex * model, double value) ;
346     /// Gets a double parameter
347     double doubleParameter(ClpSimplex * model) const;
348     /// Sets double parameter and returns printable string and error code
349     const char * setDoubleParameterWithMessage ( ClpSimplex * model, double  value , int & returnCode);
350     /// Sets a int parameter (nonzero code if error)
351     int setIntParameter(ClpSimplex * model, int value) ;
352     /// Sets int parameter and returns printable string and error code
353     const char * setIntParameterWithMessage ( ClpSimplex * model, int  value , int & returnCode);
354     /// Gets a int parameter
355     int intParameter(ClpSimplex * model) const;
356     /// Sets a double parameter (nonzero code if error)
357     int setDoubleParameter(OsiSolverInterface * model, double value) ;
358     /// Sets double parameter and returns printable string and error code
359     const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double  value , int & returnCode);
360     /// Gets a double parameter
361     double doubleParameter(OsiSolverInterface * model) const;
362     /// Sets a int parameter (nonzero code if error)
363     int setIntParameter(OsiSolverInterface * model, int value) ;
364     /// Sets int parameter and returns printable string and error code
365     const char * setIntParameterWithMessage ( OsiSolverInterface * model, int  value , int & returnCode);
366     /// Gets a int parameter
367     int intParameter(OsiSolverInterface * model) const;
368     /// Checks a double parameter (nonzero code if error)
369     int checkDoubleParameter(double value) const;
370     /// Returns name which could match
371     std::string matchName (  ) const;
372     /// Returns length of name for ptinting
373     int lengthMatchName (  ) const;
374     /// Returns parameter option which matches (-1 if none)
375     int parameterOption ( std::string check ) const;
376     /// Prints parameter options
377     void printOptions (  ) const;
378     /// Returns current parameter option
379     inline std::string currentOption (  ) const {
380          return definedKeyWords_[currentKeyWord_];
381     }
382     /// Sets current parameter option
383     void setCurrentOption ( int value , bool printIt = false);
384     /// Sets current parameter option and returns printable string
385     const char * setCurrentOptionWithMessage ( int value );
386     /// Sets current parameter option using string
387     void setCurrentOption (const std::string value );
388     /// Returns current parameter option position
389     int currentOptionAsInteger (  ) const ;
390     /** Returns current parameter option position
391         but if fake keyword returns a fake value and sets
392         fakeInteger to true value.  If not fake then fakeInteger is -COIN_INT_MAX
393      */
394     int currentOptionAsInteger ( int & fakeInteger ) const;
395     /// Sets int value
396     void setIntValue ( int value );
397     inline int intValue () const {
398          return intValue_;
399     }
400     /// Sets double value
401     void setDoubleValue ( double value );
402     inline double doubleValue () const {
403          return doubleValue_;
404     }
405     /// Sets string value
406     void setStringValue ( std::string value );
407     inline std::string stringValue () const {
408          return stringValue_;
409     }
410     /// Returns 1 if matches minimum, 2 if matches less, 0 if not matched
411     int matches (std::string input) const;
412     /// type
413     inline CbcOrClpParameterType type() const {
414          return type_;
415     }
416     /// whether to display
417     inline int displayThis() const {
418          return display_;
419     }
420     /// Set Long help
421     inline void setLonghelp(const std::string help) {
422          longHelp_ = help;
423     }
424     /// Print Long help
425     void printLongHelp() const;
426     /// Print action and string
427     void printString() const;
428     /** 7 if used everywhere,
429         1 - used by clp
430         2 - used by cbc
431         4 - used by ampl
432     */
433     inline int whereUsed() const {
434          return whereUsed_;
435     }
436     /// Gets value of fake keyword
437     inline int fakeKeyWord() const
438     { return fakeKeyWord_;}
439     /// Sets value of fake keyword
440     inline void setFakeKeyWord(int value, int fakeValue)
441     { fakeKeyWord_ = value; fakeValue_ = fakeValue;}
442     /// Sets value of fake keyword to current size of keywords
443     void setFakeKeyWord(int fakeValue);
444
445private:
446     /// gutsOfConstructor
447     void gutsOfConstructor();
448     //@}
449////////////////// data //////////////////
450private:
451
452     /**@name data
453      We might as well throw all type data in - could derive?
454     */
455     //@{
456     // Type see CbcOrClpParameterType
457     CbcOrClpParameterType type_;
458     /// If double == okay
459     double lowerDoubleValue_;
460     double upperDoubleValue_;
461     /// If int == okay
462     int lowerIntValue_;
463     int upperIntValue_;
464     // Length of name
465     unsigned int lengthName_;
466     // Minimum match
467     unsigned int lengthMatch_;
468     /// set of valid strings
469     std::vector<std::string> definedKeyWords_;
470     /// Name
471     std::string name_;
472     /// Short help
473     std::string shortHelp_;
474     /// Long help
475     std::string longHelp_;
476     /// Action
477     CbcOrClpParameterType action_;
478     /// Current keyWord (if a keyword parameter)
479     int currentKeyWord_;
480     /// Display on ?
481     int display_;
482     /// Integer parameter - current value
483     int intValue_;
484     /// Double parameter - current value
485     double doubleValue_;
486     /// String parameter - current value
487     std::string stringValue_;
488     /** 7 if used everywhere,
489         1 - used by clp
490         2 - used by cbc
491         4 - used by ampl
492     */
493     int whereUsed_;
494     /** If >=0 then integers allowed as a fake keyword
495         So minusnnnn would got to -nnnn in currentKeyword_
496         and plusnnnn would go to fakeKeyword_+nnnn
497     */
498     int fakeKeyWord_;
499     /// Return this as main value if an integer
500     int fakeValue_;
501     //@}
502};
503/// Simple read stuff
504std::string CoinReadNextField();
505
506std::string CoinReadGetCommand(int argc, const char *argv[]);
507std::string CoinReadGetString(int argc, const char *argv[]);
508// valid 0 - okay, 1 bad, 2 not there
509int CoinReadGetIntField(int argc, const char *argv[], int * valid);
510double CoinReadGetDoubleField(int argc, const char *argv[], int * valid);
511void CoinReadPrintit(const char * input);
512void setCbcOrClpPrinting(bool yesNo);
513#define CBCMAXPARAMETERS 250
514/*
515  Subroutine to establish the cbc parameter array. See the description of
516  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
517*/
518void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
519// Given a parameter type - returns its number in list
520int whichParam (CbcOrClpParameterType name,
521                int numberParameters, CbcOrClpParam *const parameters);
522// Dump/restore a solution to file
523void saveSolution(const ClpSimplex * lpSolver, std::string fileName);
524void restoreSolution(ClpSimplex * lpSolver, std::string fileName, int mode);
525#endif  /* CbcOrClpParam_H */
Note: See TracBrowser for help on using the repository browser.