CbcOrClpParam.hpp
Go to the documentation of this file.
1 
2 /* $Id: CbcOrClpParam.hpp 2070 2014-11-18 11:12:54Z 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 
27 class OsiSolverInterface;
28 class CbcModel;
29 class ClpSimplex;
48 
49 {
52 
61 
69 
81 
83 #ifndef COIN_HAS_CBC
85 #endif
106 
137 #ifdef COIN_HAS_CBC
139 #endif
147 
173 
223 
274 
283 
286 
288 } ;
289 #include <vector>
290 #include <string>
291 
293 
295 public:
298  CbcOrClpParam ( );
300  CbcOrClpParam (std::string name, std::string help,
301  double lower, double upper, CbcOrClpParameterType type, int display = 2);
302  CbcOrClpParam (std::string name, std::string help,
303  int lower, int upper, CbcOrClpParameterType type, int display = 2);
304  // Other strings will be added by insert
305  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
306  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
307  // Action
308  CbcOrClpParam (std::string name, std::string help,
309  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
311  CbcOrClpParam(const CbcOrClpParam &);
313  CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
315  ~CbcOrClpParam ( );
317 
320  void append(std::string keyWord);
323  void addHelp(std::string keyWord);
325  inline std::string name( ) const {
326  return name_;
327  }
329  inline std::string shortHelp( ) const {
330  return shortHelp_;
331  }
333  int setDoubleParameter(CbcModel & model, double value) ;
335  const char * setDoubleParameterWithMessage ( CbcModel & model, double value , int & returnCode);
337  double doubleParameter(CbcModel & model) const;
339  int setIntParameter(CbcModel & model, int value) ;
341  const char * setIntParameterWithMessage ( CbcModel & model, int value , int & returnCode);
343  int intParameter(CbcModel & model) const;
345  int setDoubleParameter(ClpSimplex * model, double value) ;
347  double doubleParameter(ClpSimplex * model) const;
349  const char * setDoubleParameterWithMessage ( ClpSimplex * model, double value , int & returnCode);
351  int setIntParameter(ClpSimplex * model, int value) ;
353  const char * setIntParameterWithMessage ( ClpSimplex * model, int value , int & returnCode);
355  int intParameter(ClpSimplex * model) const;
357  int setDoubleParameter(OsiSolverInterface * model, double value) ;
359  const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double value , int & returnCode);
361  double doubleParameter(OsiSolverInterface * model) const;
363  int setIntParameter(OsiSolverInterface * model, int value) ;
365  const char * setIntParameterWithMessage ( OsiSolverInterface * model, int value , int & returnCode);
367  int intParameter(OsiSolverInterface * model) const;
369  int checkDoubleParameter(double value) const;
371  std::string matchName ( ) const;
373  int lengthMatchName ( ) const;
375  int parameterOption ( std::string check ) const;
377  void printOptions ( ) const;
379  inline std::string currentOption ( ) const {
381  }
383  void setCurrentOption ( int value , bool printIt = false);
385  const char * setCurrentOptionWithMessage ( int value );
387  void setCurrentOption (const std::string value );
389  const char * setCurrentOptionWithMessage (const std::string value );
391  int currentOptionAsInteger ( ) const ;
396  int currentOptionAsInteger ( int & fakeInteger ) const;
398  void setIntValue ( int value );
400  const char * setIntValueWithMessage ( int value );
401  inline int intValue () const {
402  return intValue_;
403  }
405  void setDoubleValue ( double value );
407  const char * setDoubleValueWithMessage ( double value );
408  inline double doubleValue () const {
409  return doubleValue_;
410  }
412  void setStringValue ( std::string value );
413  inline std::string stringValue () const {
414  return stringValue_;
415  }
417  int matches (std::string input) const;
419  inline CbcOrClpParameterType type() const {
420  return type_;
421  }
423  inline int displayThis() const {
424  return display_;
425  }
427  inline void setLonghelp(const std::string help) {
428  longHelp_ = help;
429  }
431  void printLongHelp() const;
433  void printString() const;
439  inline int whereUsed() const {
440  return whereUsed_;
441  }
443  inline int fakeKeyWord() const
444  { return fakeKeyWord_;}
446  inline void setFakeKeyWord(int value, int fakeValue)
447  { fakeKeyWord_ = value; fakeValue_ = fakeValue;}
449  void setFakeKeyWord(int fakeValue);
450 
451 private:
453  void gutsOfConstructor();
455 private:
457 
462  // Type see CbcOrClpParameterType
470  // Length of name
471  unsigned int lengthName_;
472  // Minimum match
473  unsigned int lengthMatch_;
475  std::vector<std::string> definedKeyWords_;
477  std::string name_;
479  std::string shortHelp_;
481  std::string longHelp_;
487  int display_;
491  double doubleValue_;
493  std::string stringValue_;
508 };
510 std::string CoinReadNextField();
511 
512 std::string CoinReadGetCommand(int argc, const char *argv[]);
513 std::string CoinReadGetString(int argc, const char *argv[]);
514 // valid 0 - okay, 1 bad, 2 not there
515 int CoinReadGetIntField(int argc, const char *argv[], int * valid);
516 double CoinReadGetDoubleField(int argc, const char *argv[], int * valid);
517 void CoinReadPrintit(const char * input);
518 void setCbcOrClpPrinting(bool yesNo);
519 #define CBCMAXPARAMETERS 250
520 /*
521  Subroutine to establish the cbc parameter array. See the description of
522  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
523 */
524 void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
525 // Given a parameter type - returns its number in list
527  int numberParameters, CbcOrClpParam *const parameters);
528 // Dump/restore a solution to file
529 void saveSolution(const ClpSimplex * lpSolver, std::string fileName);
530 void restoreSolution(ClpSimplex * lpSolver, std::string fileName, int mode);
531 #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 setFakeKeyWord(int value, int fakeValue)
Sets value of fake keyword.
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)
void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode)
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.
int fakeKeyWord() const
Gets value of fake keyword.
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.
Abstract Base Class for describing an interface to a solver.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70
int intValue() const
Insert string (only valid for keywords)
int display_
Display on ?
void printIt(const char *msg)
Utility to print a long message as filled lines of text.
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
const char * setIntValueWithMessage(int value)
Sets int value with message.
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.
int fakeValue_
Return this as main value if an integer.
const char * setDoubleValueWithMessage(double value)
Sets double value with message.
void setIntValue(int value)
Sets int value.
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)
int fakeKeyWord_
If &gt;=0 then integers allowed as a fake keyword So minusnnnn would got to -nnnn in currentKeyword_ and...
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.