Clp  1.15.10
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CbcOrClpParam.hpp
Go to the documentation of this file.
1 
2 /* $Id: CbcOrClpParam.hpp 1928 2013-04-06 12:54:16Z stefan $ */
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
105 
135 #ifdef COIN_HAS_CBC
137 #endif
144 
170 
218 
268 
277 
280 
282 } ;
283 #include <vector>
284 #include <string>
285 
287 
289 public:
292  CbcOrClpParam ( );
294  CbcOrClpParam (std::string name, std::string help,
295  double lower, double upper, CbcOrClpParameterType type, int display = 2);
296  CbcOrClpParam (std::string name, std::string help,
297  int lower, int upper, CbcOrClpParameterType type, int display = 2);
298  // Other strings will be added by insert
299  CbcOrClpParam (std::string name, std::string help, std::string firstValue,
300  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
301  // Action
302  CbcOrClpParam (std::string name, std::string help,
303  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
305  CbcOrClpParam(const CbcOrClpParam &);
307  CbcOrClpParam & operator=(const CbcOrClpParam & rhs);
309  ~CbcOrClpParam ( );
311 
314  void append(std::string keyWord);
317  void addHelp(std::string keyWord);
319  inline std::string name( ) const {
320  return name_;
321  }
323  inline std::string shortHelp( ) const {
324  return shortHelp_;
325  }
327  int setDoubleParameter(CbcModel & model, double value) ;
329  const char * setDoubleParameterWithMessage ( CbcModel & model, double value , int & returnCode);
331  double doubleParameter(CbcModel & model) const;
333  int setIntParameter(CbcModel & model, int value) ;
335  const char * setIntParameterWithMessage ( CbcModel & model, int value , int & returnCode);
337  int intParameter(CbcModel & model) const;
339  int setDoubleParameter(ClpSimplex * model, double value) ;
341  double doubleParameter(ClpSimplex * model) const;
343  const char * setDoubleParameterWithMessage ( ClpSimplex * model, double value , int & returnCode);
345  int setIntParameter(ClpSimplex * model, int value) ;
347  const char * setIntParameterWithMessage ( ClpSimplex * model, int value , int & returnCode);
349  int intParameter(ClpSimplex * model) const;
351  int setDoubleParameter(OsiSolverInterface * model, double value) ;
353  const char * setDoubleParameterWithMessage ( OsiSolverInterface * model, double value , int & returnCode);
355  double doubleParameter(OsiSolverInterface * model) const;
357  int setIntParameter(OsiSolverInterface * model, int value) ;
359  const char * setIntParameterWithMessage ( OsiSolverInterface * model, int value , int & returnCode);
361  int intParameter(OsiSolverInterface * model) const;
363  int checkDoubleParameter(double value) const;
365  std::string matchName ( ) const;
367  int lengthMatchName ( ) const;
369  int parameterOption ( std::string check ) const;
371  void printOptions ( ) const;
373  inline std::string currentOption ( ) const {
374  return definedKeyWords_[currentKeyWord_];
375  }
377  void setCurrentOption ( int value , bool printIt = false);
379  const char * setCurrentOptionWithMessage ( int value );
381  void setCurrentOption (const std::string value );
383  inline int currentOptionAsInteger ( ) const {
384  return currentKeyWord_;
385  }
387  void setIntValue ( int value );
388  inline int intValue () const {
389  return intValue_;
390  }
392  void setDoubleValue ( double value );
393  inline double doubleValue () const {
394  return doubleValue_;
395  }
397  void setStringValue ( std::string value );
398  inline std::string stringValue () const {
399  return stringValue_;
400  }
402  int matches (std::string input) const;
404  inline CbcOrClpParameterType type() const {
405  return type_;
406  }
408  inline int displayThis() const {
409  return display_;
410  }
412  inline void setLonghelp(const std::string help) {
413  longHelp_ = help;
414  }
416  void printLongHelp() const;
418  void printString() const;
424  inline int whereUsed() const {
425  return whereUsed_;
426  }
427 
428 private:
430  void gutsOfConstructor();
432 private:
434 
439  // Type see CbcOrClpParameterType
440  CbcOrClpParameterType type_;
442  double lowerDoubleValue_;
443  double upperDoubleValue_;
445  int lowerIntValue_;
446  int upperIntValue_;
447  // Length of name
448  unsigned int lengthName_;
449  // Minimum match
450  unsigned int lengthMatch_;
452  std::vector<std::string> definedKeyWords_;
454  std::string name_;
456  std::string shortHelp_;
458  std::string longHelp_;
460  CbcOrClpParameterType action_;
462  int currentKeyWord_;
464  int display_;
466  int intValue_;
468  double doubleValue_;
470  std::string stringValue_;
476  int whereUsed_;
478 };
480 std::string CoinReadNextField();
481 
482 std::string CoinReadGetCommand(int argc, const char *argv[]);
483 std::string CoinReadGetString(int argc, const char *argv[]);
484 // valid 0 - okay, 1 bad, 2 not there
485 int CoinReadGetIntField(int argc, const char *argv[], int * valid);
486 double CoinReadGetDoubleField(int argc, const char *argv[], int * valid);
487 void CoinReadPrintit(const char * input);
488 void setCbcOrClpPrinting(bool yesNo);
489 #define CBCMAXPARAMETERS 250
490 /*
491  Subroutine to establish the cbc parameter array. See the description of
492  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
493 */
494 void establishParams (int &numberParameters, CbcOrClpParam *const parameters);
495 // Given a parameter type - returns its number in list
497  int numberParameters, CbcOrClpParam *const parameters);
498 // Dump a solution to file
499 void saveSolution(const ClpSimplex * lpSolver, std::string fileName);
500 #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 * setIntParameterWithMessage(CbcModel &model, int value, int &returnCode)
Sets int parameter and returns printable string and error code.
void setDoubleValue(double value)
Sets double value.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:55
void CoinReadPrintit(const char *input)
void printOptions() const
Prints parameter options.
double CoinReadGetDoubleField(int argc, const char *argv[], int *valid)
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.
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)