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

Last change on this file since 1665 was 1665, checked in by lou, 9 years ago

Add EPL license notice in src.

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