Clp  1.16.6
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 {
380  return definedKeyWords_[currentKeyWord_];
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
463  CbcOrClpParameterType type_;
465  double lowerDoubleValue_;
466  double upperDoubleValue_;
468  int lowerIntValue_;
469  int upperIntValue_;
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_;
483  CbcOrClpParameterType action_;
485  int currentKeyWord_;
487  int display_;
489  int intValue_;
491  double doubleValue_;
493  std::string stringValue_;
499  int whereUsed_;
504  int fakeKeyWord_;
506  int fakeValue_;
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 */
int displayThis() const
whether to display
std::string shortHelp() const
Returns short help.
std::string CoinReadNextField()
Simple read stuff.
int lengthMatchName() const
Returns length of name for ptinting.
void setCbcOrClpPrinting(bool yesNo)
void establishParams(int &numberParameters, CbcOrClpParam *const parameters)
double doubleValue() const
std::string CoinReadGetCommand(int argc, const char *argv[])
int intParameter(CbcModel &model) const
Gets a int parameter.
int whichParam(CbcOrClpParameterType name, int numberParameters, CbcOrClpParam *const parameters)
std::string stringValue() const
std::string name() const
Returns name.
std::string CoinReadGetString(int argc, const char *argv[])
const char * setCurrentOptionWithMessage(int value)
Sets current parameter option and returns printable string.
Very simple class for setting parameters.
void addHelp(std::string keyWord)
Adds one help line.
void setIntValue(int value)
Sets int value.
CbcOrClpParam & operator=(const CbcOrClpParam &rhs)
Assignment operator. This copies the data.
void setCurrentOption(int value, bool printIt=false)
Sets current parameter option.
int whereUsed() const
7 if used everywhere, 1 - used by clp 2 - used by cbc 4 - used by ampl
const char * setDoubleParameterWithMessage(CbcModel &model, double value, int &returnCode)
Sets double parameter and returns printable string and error code.
void printLongHelp() const
Print Long help.
const char * setDoubleValueWithMessage(double value)
Sets double value with message.
const char * setIntParameterWithMessage(CbcModel &model, int value, int &returnCode)
Sets int parameter and returns printable string and error code.
void setFakeKeyWord(int value, int fakeValue)
Sets value of fake keyword.
void setDoubleValue(double value)
Sets double value.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70
void CoinReadPrintit(const char *input)
void printOptions() const
Prints parameter options.
double CoinReadGetDoubleField(int argc, const char *argv[], int *valid)
int fakeKeyWord() const
Gets value of fake keyword.
int checkDoubleParameter(double value) const
Checks a double parameter (nonzero code if error)
void append(std::string keyWord)
Insert string (only valid for keywords)
CbcOrClpParameterType type() const
type
int CoinReadGetIntField(int argc, const char *argv[], int *valid)
int intValue() const
void setLonghelp(const std::string help)
Set Long help.
CbcOrClpParameterType
Parameter codes.
CbcOrClpParam()
Constructors.
double doubleParameter(CbcModel &model) const
Gets a double parameter.
void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode)
int parameterOption(std::string check) const
Returns parameter option which matches (-1 if none)
std::string matchName() const
Returns name which could match.
~CbcOrClpParam()
Destructor.
int setDoubleParameter(CbcModel &model, double value)
Sets a double parameter (nonzero code if error)
void setStringValue(std::string value)
Sets string value.
std::string currentOption() const
Returns current parameter option.
#define OsiSolverInterface
Definition: Idiot.hpp:14
void saveSolution(const ClpSimplex *lpSolver, std::string fileName)
int matches(std::string input) const
Returns 1 if matches minimum, 2 if matches less, 0 if not matched.
int currentOptionAsInteger() const
Returns current parameter option position.
void printString() const
Print action and string.
int setIntParameter(CbcModel &model, int value)
Sets a int parameter (nonzero code if error)
const char * setIntValueWithMessage(int value)
Sets int value with message.