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 */