CbcOrClpParam.hpp
Go to the documentation of this file.
1 
2 /* $Id: CbcOrClpParam.hpp 1525 2010-02-26 17:27:59Z mjs $ */
3 // Copyright (C) 2002, International Business Machines
4 // Corporation and others. All Rights Reserved.
5 
6 #ifdef USE_CBCCONFIG
7 # include "CbcConfig.h"
8 #else
9 # include "ClpConfig.h"
10 #endif
11 
12 #ifndef CbcOrClpParam_H
13 #define CbcOrClpParam_H
14 
26 class OsiSolverInterface;
27 class CbcModel;
28 class ClpSimplex;
47 
48 {
51 
59 
67 
79 
81 #ifndef COIN_HAS_CBC
83 #endif
101 
131 #ifdef COIN_HAS_CBC
133 #endif
134 
158 
200 
248 
255 
258 
260 } ;
261 #include <vector>
262 #include <string>
263 
265 
267 public:
270  CbcOrClpParam ( );
272  CbcOrClpParam (std::string name, std::string help,
273  double lower, double upper, CbcOrClpParameterType type, int display = 2);
274  CbcOrClpParam (std::string name, std::string help,
275  int lower, int upper, CbcOrClpParameterType type, int display = 2);
276  // Other strings will be added by insert
277  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
278  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
279  // Action
280  CbcOrClpParam (std::string name, std::string help,
281  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
283  CbcOrClpParam(const CbcOrClpParam &);
285  CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
287  ~CbcOrClpParam ( );
289 
292  void append(std::string keyWord);
295  void addHelp(std::string keyWord);
297  inline std::string name( ) const {
298  return name_;
299  }
301  inline std::string shortHelp( ) const {
302  return shortHelp_;
303  }
305  int setDoubleParameter(CbcModel & model, double value) ;
307  const char * setDoubleParameterWithMessage ( CbcModel & model, double value , int & returnCode);
309  double doubleParameter(CbcModel & model) const;
311  int setIntParameter(CbcModel & model, int value) ;
313  const char * setIntParameterWithMessage ( CbcModel & model, int value , int & returnCode);
315  int intParameter(CbcModel & model) const;
317  int setDoubleParameter(ClpSimplex * model, double value) ;
319  double doubleParameter(ClpSimplex * model) const;
321  const char * setDoubleParameterWithMessage ( ClpSimplex * model, double value , int & returnCode);
323  int setIntParameter(ClpSimplex * model, int value) ;
325  const char * setIntParameterWithMessage ( ClpSimplex * model, int value , int & returnCode);
327  int intParameter(ClpSimplex * model) const;
329  int setDoubleParameter(OsiSolverInterface * model, double value) ;
331  const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double value , int & returnCode);
333  double doubleParameter(OsiSolverInterface * model) const;
335  int setIntParameter(OsiSolverInterface * model, int value) ;
337  const char * setIntParameterWithMessage ( OsiSolverInterface * model, int value , int & returnCode);
339  int intParameter(OsiSolverInterface * model) const;
341  int checkDoubleParameter(double value) const;
343  std::string matchName ( ) const;
345  int lengthMatchName ( ) const;
347  int parameterOption ( std::string check ) const;
349  void printOptions ( ) const;
351  inline std::string currentOption ( ) const {
353  }
355  void setCurrentOption ( int value , bool printIt = false);
357  const char * setCurrentOptionWithMessage ( int value );
359  void setCurrentOption (const std::string value );
361  inline int currentOptionAsInteger ( ) const {
362  return currentKeyWord_;
363  }
365  void setIntValue ( int value );
366  inline int intValue () const {
367  return intValue_;
368  }
370  void setDoubleValue ( double value );
371  inline double doubleValue () const {
372  return doubleValue_;
373  }
375  void setStringValue ( std::string value );
376  inline std::string stringValue () const {
377  return stringValue_;
378  }
380  int matches (std::string input) const;
382  inline CbcOrClpParameterType type() const {
383  return type_;
384  }
386  inline int displayThis() const {
387  return display_;
388  }
390  inline void setLonghelp(const std::string help) {
391  longHelp_ = help;
392  }
394  void printLongHelp() const;
396  void printString() const;
402  inline int whereUsed() const {
403  return whereUsed_;
404  }
405 
406 private:
408  void gutsOfConstructor();
410 private:
412 
417  // Type see CbcOrClpParameterType
425  // Length of name
426  unsigned int lengthName_;
427  // Minimum match
428  unsigned int lengthMatch_;
430  std::vector<std::string> definedKeyWords_;
432  std::string name_;
434  std::string shortHelp_;
436  std::string longHelp_;
442  int display_;
446  double doubleValue_;
448  std::string stringValue_;
456 };
458 std::string CoinReadNextField();
459 
460 std::string CoinReadGetCommand(int argc, const char *argv[]);
461 std::string CoinReadGetString(int argc, const char *argv[]);
462 // valid 0 - okay, 1 bad, 2 not there
463 int CoinReadGetIntField(int argc, const char *argv[], int * valid);
464 double CoinReadGetDoubleField(int argc, const char *argv[], int * valid);
465 void CoinReadPrintit(const char * input);
466 void setCbcOrClpPrinting(bool yesNo);
467 #define CBCMAXPARAMETERS 200
468 /*
469  Subroutine to establish the cbc parameter array. See the description of
470  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
471 */
472 void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
473 // Given a parameter type - returns its number in list
475  int numberParameters, CbcOrClpParam *const parameters);
476 // Dump a solution to file
477 void saveSolution(const ClpSimplex * lpSolver, std::string fileName);
478 #endif /* CbcOrClpParam_H */
CbcOrClpParameterType type() const
type
void printString() const
Print action and string.
CbcOrClpParameterType
Parameter codes.
const char * setIntParameterWithMessage(CbcModel &model, int value, int &returnCode)
Sets int parameter and returns printable string and error code.
unsigned int lengthMatch_
If double == okay.
CbcOrClpParam()
Constructors.
double lowerDoubleValue_
If double == okay.
std::string CoinReadNextField()
Simple read stuff.
double doubleParameter(CbcModel &model) const
Gets a double parameter.
std::string CoinReadGetCommand(int argc, const char *argv[])
std::string stringValue_
String parameter - current value.
std::string name_
Name.
CbcOrClpParameterType type_
If double == okay.
int displayThis() const
whether to display
std::string CoinReadGetString(int argc, const char *argv[])
std::string longHelp_
Long help.
double doubleValue() const
Insert string (only valid for keywords)
void addHelp(std::string keyWord)
Adds one help line.
std::vector< std::string > definedKeyWords_
set of valid strings
int CoinReadGetIntField(int argc, const char *argv[], int *valid)
CbcOrClpParam & operator=(const CbcOrClpParam &rhs)
Assignment operator. This copies the data.
void setLonghelp(const std::string help)
Set Long help.
int currentKeyWord_
Current keyWord (if a keyword parameter)
~CbcOrClpParam()
Destructor.
int setDoubleParameter(CbcModel &model, double value)
Sets a double parameter (nonzero code if error)
std::string stringValue() const
Insert string (only valid for keywords)
Very simple class for setting parameters.
void append(std::string keyWord)
Insert string (only valid for keywords)
int lowerIntValue_
If int == okay.
std::string currentOption() const
Returns current parameter option.
unsigned int lengthName_
If double == okay.
std::string matchName() const
Returns name which could match.
double upperDoubleValue_
If double == okay.
CbcOrClpParameterType action_
Action.
int upperIntValue_
If double == okay.
double CoinReadGetDoubleField(int argc, const char *argv[], int *valid)
int intValue_
Integer parameter - current value.
void setCbcOrClpPrinting(bool yesNo)
void printOptions() const
Prints parameter options.
int lengthMatchName() const
Returns length of name for ptinting.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:49
int intValue() const
Insert string (only valid for keywords)
int display_
Display on ?
int currentOptionAsInteger() const
Returns current parameter option position.
int matches(std::string input) const
Returns 1 if matches minimum, 2 if matches less, 0 if not matched.
int whichParam(CbcOrClpParameterType name, int numberParameters, CbcOrClpParam *const parameters)
int whereUsed() const
7 if used everywhere, 1 - used by clp 2 - used by cbc 4 - used by ampl
double doubleValue_
Double parameter - current value.
int intParameter(CbcModel &model) const
Gets a int parameter.
void gutsOfConstructor()
gutsOfConstructor
std::string shortHelp() const
Returns short help.
void setIntValue(int value)
Sets int value.
#define OsiSolverInterface
Definition: Idiot.hpp:12
int checkDoubleParameter(double value) const
Checks a double parameter (nonzero code if error)
void CoinReadPrintit(const char *input)
void printLongHelp() const
Print Long help.
int setIntParameter(CbcModel &model, int value)
Sets a int parameter (nonzero code if error)
std::string shortHelp_
Short help.
void establishParams(int &numberParameters, CbcOrClpParam *const parameters)
void setStringValue(std::string value)
Sets string value.
void setCurrentOption(int value, bool printIt=false)
Sets current parameter option.
int whereUsed_
7 if used everywhere, 1 - used by clp 2 - used by cbc 4 - used by ampl
int parameterOption(std::string check) const
Returns parameter option which matches (-1 if none)
void setDoubleValue(double value)
Sets double value.
void saveSolution(const ClpSimplex *lpSolver, std::string fileName)
const char * setDoubleParameterWithMessage(CbcModel &model, double value, int &returnCode)
Sets double parameter and returns printable string and error code.
const char * setCurrentOptionWithMessage(int value)
Sets current parameter option and returns printable string.
std::string name() const
Returns name.