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

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

add Orbital branching

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