source: stable/1.14/Clp/src/CbcOrClpParam.hpp @ 1905

Last change on this file since 1905 was 1905, checked in by forrest, 7 years ago

put multiple root solvers into stable (only on if >Cbc2.8)

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