coin-Bcp
CbcOrClpParam.hpp
Go to the documentation of this file.
1 
2 /* $Id: CbcOrClpParam.hpp 2389 2019-02-07 19:48:00Z unxusr $ */
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 
62 
70 
82 
84 #ifndef COIN_HAS_CBC
86 #endif
108 
139 #ifdef COIN_HAS_CBC
141 #endif
149 
176 
228 
280 
289 
292 
294 };
295 #include <vector>
296 #include <string>
297 
299 
301 public:
304  CbcOrClpParam();
306  CbcOrClpParam(std::string name, std::string help,
307  double lower, double upper, CbcOrClpParameterType type, int display = 2);
308  CbcOrClpParam(std::string name, std::string help,
309  int lower, int upper, CbcOrClpParameterType type, int display = 2);
310  // Other strings will be added by insert
311  CbcOrClpParam(std::string name, std::string help, std::string firstValue,
312  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
313  // Action
314  CbcOrClpParam(std::string name, std::string help,
315  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
317  CbcOrClpParam(const CbcOrClpParam &);
321  ~CbcOrClpParam();
323 
326  void append(std::string keyWord);
329  void addHelp(std::string keyWord);
331  inline std::string name() const
332  {
333  return name_;
334  }
336  inline std::string shortHelp() const
337  {
338  return shortHelp_;
339  }
341  int setDoubleParameter(CbcModel &model, double value);
343  const char *setDoubleParameterWithMessage(CbcModel &model, double value, int &returnCode);
345  double doubleParameter(CbcModel &model) const;
347  int setIntParameter(CbcModel &model, int value);
349  const char *setIntParameterWithMessage(CbcModel &model, int value, int &returnCode);
351  int intParameter(CbcModel &model) const;
353  int setDoubleParameter(ClpSimplex *model, double value);
355  double doubleParameter(ClpSimplex *model) const;
357  const char *setDoubleParameterWithMessage(ClpSimplex *model, double value, int &returnCode);
359  int setIntParameter(ClpSimplex *model, int value);
361  const char *setIntParameterWithMessage(ClpSimplex *model, int value, int &returnCode);
363  int intParameter(ClpSimplex *model) const;
365  int setDoubleParameter(OsiSolverInterface *model, double value);
367  const char *setDoubleParameterWithMessage(OsiSolverInterface *model, double value, int &returnCode);
369  double doubleParameter(OsiSolverInterface *model) const;
371  int setIntParameter(OsiSolverInterface *model, int value);
373  const char *setIntParameterWithMessage(OsiSolverInterface *model, int value, int &returnCode);
375  int intParameter(OsiSolverInterface *model) const;
377  int checkDoubleParameter(double value) const;
379  std::string matchName() const;
381  int lengthMatchName() const;
383  int parameterOption(std::string check) const;
385  void printOptions() const;
387  inline std::string currentOption() const
388  {
390  }
392  void setCurrentOption(int value, bool printIt = false);
394  const char *setCurrentOptionWithMessage(int value);
396  void setCurrentOption(const std::string value);
398  const char *setCurrentOptionWithMessage(const std::string value);
400  int currentOptionAsInteger() const;
405  int currentOptionAsInteger(int &fakeInteger) const;
407  void setIntValue(int value);
409  const char *setIntValueWithMessage(int value);
410  inline int intValue() const
411  {
412  return intValue_;
413  }
415  void setDoubleValue(double value);
417  const char *setDoubleValueWithMessage(double value);
418  inline double doubleValue() const
419  {
420  return doubleValue_;
421  }
423  void setStringValue(std::string value);
424  inline std::string stringValue() const
425  {
426  return stringValue_;
427  }
429  int matches(std::string input) const;
432  {
433  return type_;
434  }
436  inline int displayThis() const
437  {
438  return display_;
439  }
441  inline void setLonghelp(const std::string help)
442  {
443  longHelp_ = help;
444  }
446  void printLongHelp() const;
448  void printString() const;
454  inline int whereUsed() const
455  {
456  return whereUsed_;
457  }
459  inline int fakeKeyWord() const
460  {
461  return fakeKeyWord_;
462  }
464  inline void setFakeKeyWord(int value, int fakeValue)
465  {
466  fakeKeyWord_ = value;
467  fakeValue_ = fakeValue;
468  }
470  void setFakeKeyWord(int fakeValue);
471 
472 private:
474  void gutsOfConstructor();
476 private:
482  // Type see CbcOrClpParameterType
490  // Length of name
491  unsigned int lengthName_;
492  // Minimum match
493  unsigned int lengthMatch_;
495  std::vector< std::string > definedKeyWords_;
497  std::string name_;
499  std::string shortHelp_;
501  std::string longHelp_;
507  int display_;
511  double doubleValue_;
513  std::string stringValue_;
528 };
530 std::string CoinReadNextField();
531 
532 std::string CoinReadGetCommand(int argc, const char *argv[]);
533 std::string CoinReadGetString(int argc, const char *argv[]);
534 // valid 0 - okay, 1 bad, 2 not there
535 int CoinReadGetIntField(int argc, const char *argv[], int *valid);
536 double CoinReadGetDoubleField(int argc, const char *argv[], int *valid);
537 void CoinReadPrintit(const char *input);
538 void setCbcOrClpPrinting(bool yesNo);
539 #define CBCMAXPARAMETERS 250
540 /*
541  Subroutine to establish the cbc parameter array. See the description of
542  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
543 */
544 void establishParams(std::vector< CbcOrClpParam > &params);
545 // Given a parameter type - returns its number in list
546 int whichParam(const CbcOrClpParameterType &name,
547  const std::vector< CbcOrClpParam > &parameters);
548 // Dump/restore a solution to file
549 void saveSolution(const ClpSimplex *lpSolver, std::string fileName);
550 void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode);
551 #endif /* CbcOrClpParam_H */
552 
553 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
554 */
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.
void establishParams(std::vector< CbcOrClpParam > &params)
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 whichParam(const CbcOrClpParameterType &name, const std::vector< CbcOrClpParam > &parameters)
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:106
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 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 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.