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

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

more options

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