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

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

minor changes to implement Aboca

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