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

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

more special options

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