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

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

change for mipstart

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