CbcOrClpParam.hpp
Go to the documentation of this file.
1 
2 /* $Id: CbcOrClpParam.hpp 2175 2015-10-06 08:56:43Z 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 
174 
224 
275 
284 
287 
289 } ;
290 #include <vector>
291 #include <string>
292 
294 
296 public:
299  CbcOrClpParam ( );
301  CbcOrClpParam (std::string name, std::string help,
302  double lower, double upper, CbcOrClpParameterType type, int display = 2);
303  CbcOrClpParam (std::string name, std::string help,
304  int lower, int upper, CbcOrClpParameterType type, int display = 2);
305  // Other strings will be added by insert
306  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
307  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
308  // Action
309  CbcOrClpParam (std::string name, std::string help,
310  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
312  CbcOrClpParam(const CbcOrClpParam &);
314  CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
316  ~CbcOrClpParam ( );
318 
321  void append(std::string keyWord);
324  void addHelp(std::string keyWord);
326  inline std::string name( ) const {
327  return name_;
328  }
330  inline std::string shortHelp( ) const {
331  return shortHelp_;
332  }
334  int setDoubleParameter(CbcModel & model, double value) ;
336  const char * setDoubleParameterWithMessage ( CbcModel & model, double value , int & returnCode);
338  double doubleParameter(CbcModel & model) const;
340  int setIntParameter(CbcModel & model, int value) ;
342  const char * setIntParameterWithMessage ( CbcModel & model, int value , int & returnCode);
344  int intParameter(CbcModel & model) const;
346  int setDoubleParameter(ClpSimplex * model, double value) ;
348  double doubleParameter(ClpSimplex * model) const;
350  const char * setDoubleParameterWithMessage ( ClpSimplex * model, double value , int & returnCode);
352  int setIntParameter(ClpSimplex * model, int value) ;
354  const char * setIntParameterWithMessage ( ClpSimplex * model, int value , int & returnCode);
356  int intParameter(ClpSimplex * model) const;
358  int setDoubleParameter(OsiSolverInterface * model, double value) ;
360  const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double value , int & returnCode);
362  double doubleParameter(OsiSolverInterface * model) const;
364  int setIntParameter(OsiSolverInterface * model, int value) ;
366  const char * setIntParameterWithMessage ( OsiSolverInterface * model, int value , int & returnCode);
368  int intParameter(OsiSolverInterface * model) const;
370  int checkDoubleParameter(double value) const;
372  std::string matchName ( ) const;
374  int lengthMatchName ( ) const;
376  int parameterOption ( std::string check ) const;
378  void printOptions ( ) const;
380  inline std::string currentOption ( ) const {
382  }
384  void setCurrentOption ( int value , bool printIt = false);
386  const char * setCurrentOptionWithMessage ( int value );
388  void setCurrentOption (const std::string value );
390  const char * setCurrentOptionWithMessage (const std::string value );
392  int currentOptionAsInteger ( ) const ;
397  int currentOptionAsInteger ( int & fakeInteger ) const;
399  void setIntValue ( int value );
401  const char * setIntValueWithMessage ( int value );
402  inline int intValue () const {
403  return intValue_;
404  }
406  void setDoubleValue ( double value );
408  const char * setDoubleValueWithMessage ( double value );
409  inline double doubleValue () const {
410  return doubleValue_;
411  }
413  void setStringValue ( std::string value );
414  inline std::string stringValue () const {
415  return stringValue_;
416  }
418  int matches (std::string input) const;
420  inline CbcOrClpParameterType type() const {
421  return type_;
422  }
424  inline int displayThis() const {
425  return display_;
426  }
428  inline void setLonghelp(const std::string help) {
429  longHelp_ = help;
430  }
432  void printLongHelp() const;
434  void printString() const;
440  inline int whereUsed() const {
441  return whereUsed_;
442  }
444  inline int fakeKeyWord() const
445  { return fakeKeyWord_;}
447  inline void setFakeKeyWord(int value, int fakeValue)
448  { fakeKeyWord_ = value; fakeValue_ = fakeValue;}
450  void setFakeKeyWord(int fakeValue);
451 
452 private:
454  void gutsOfConstructor();
456 private:
458 
463  // Type see CbcOrClpParameterType
471  // Length of name
472  unsigned int lengthName_;
473  // Minimum match
474  unsigned int lengthMatch_;
476  std::vector<std::string> definedKeyWords_;
478  std::string name_;
480  std::string shortHelp_;
482  std::string longHelp_;
488  int display_;
492  double doubleValue_;
494  std::string stringValue_;
509 };
511 std::string CoinReadNextField();
512 
513 std::string CoinReadGetCommand(int argc, const char *argv[]);
514 std::string CoinReadGetString(int argc, const char *argv[]);
515 // valid 0 - okay, 1 bad, 2 not there
516 int CoinReadGetIntField(int argc, const char *argv[], int * valid);
517 double CoinReadGetDoubleField(int argc, const char *argv[], int * valid);
518 void CoinReadPrintit(const char * input);
519 void setCbcOrClpPrinting(bool yesNo);
520 #define CBCMAXPARAMETERS 250
521 /*
522  Subroutine to establish the cbc parameter array. See the description of
523  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
524 */
525 void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
526 // Given a parameter type - returns its number in list
528  int numberParameters, CbcOrClpParam *const parameters);
529 // Dump/restore a solution to file
530 void saveSolution(const ClpSimplex * lpSolver, std::string fileName);
531 void restoreSolution(ClpSimplex * lpSolver, std::string fileName, int mode);
532 #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.