Clp  1.17.3
CbcOrClpParam.hpp
Go to the documentation of this file.
1 
2 /* $Id: CbcOrClpParam.hpp 2468 2019-05-03 04:31:14Z 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;
49 
50 {
53 
63 
71 
83 
85 #ifndef COIN_HAS_CBC
87 #endif
109 
140 #ifdef COIN_HAS_CBC
142 #endif
150 
177 
229 
281 
290 
293 
295 };
296 #include <vector>
297 #include <string>
298 
300 
302 public:
305  CbcOrClpParam();
307  CbcOrClpParam(std::string name, std::string help,
308  double lower, double upper, CbcOrClpParameterType type, int display = 2);
309  CbcOrClpParam(std::string name, std::string help,
310  int lower, int upper, CbcOrClpParameterType type, int display = 2);
311  // Other strings will be added by insert
312  CbcOrClpParam(std::string name, std::string help, std::string firstValue,
313  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
314  // Action
315  CbcOrClpParam(std::string name, std::string help,
316  CbcOrClpParameterType type, int whereUsed = 7, int display = 2);
318  CbcOrClpParam(const CbcOrClpParam &);
322  ~CbcOrClpParam();
324 
327  void append(std::string keyWord);
330  void addHelp(std::string keyWord);
332  inline std::string name() const
333  {
334  return name_;
335  }
337  inline std::string shortHelp() const
338  {
339  return shortHelp_;
340  }
342  inline std::string longHelp() const
343  {
344  return longHelp_;
345  }
347  inline const std::vector<std::string>& definedKeywords() const
348  {
349  return definedKeyWords_;
350  }
352  inline double lowerDoubleValue() const
353  {
354  return lowerDoubleValue_;
355  }
357  inline double upperDoubleValue() const
358  {
359  return upperDoubleValue_;
360  }
362  inline int lowerIntValue() const
363  {
364  return lowerIntValue_;
365  }
367  inline int upperIntValue() const
368  {
369  return upperIntValue_;
370  }
372  int setDoubleParameter(CbcModel &model, double value);
374  const char *setDoubleParameterWithMessage(CbcModel &model, double value, int &returnCode);
376  double doubleParameter(CbcModel &model) const;
378  int setIntParameter(CbcModel &model, int value);
380  const char *setIntParameterWithMessage(CbcModel &model, int value, int &returnCode);
382  int intParameter(CbcModel &model) const;
384  int setDoubleParameter(ClpSimplex *model, double value);
386  double doubleParameter(ClpSimplex *model) const;
388  const char *setDoubleParameterWithMessage(ClpSimplex *model, double value, int &returnCode);
390  int setIntParameter(ClpSimplex *model, int value);
392  const char *setIntParameterWithMessage(ClpSimplex *model, int value, int &returnCode);
394  int intParameter(ClpSimplex *model) const;
396  int setDoubleParameter(OsiSolverInterface *model, double value);
398  const char *setDoubleParameterWithMessage(OsiSolverInterface *model, double value, int &returnCode);
400  double doubleParameter(OsiSolverInterface *model) const;
402  int setIntParameter(OsiSolverInterface *model, int value);
404  const char *setIntParameterWithMessage(OsiSolverInterface *model, int value, int &returnCode);
406  int intParameter(OsiSolverInterface *model) const;
408  int checkDoubleParameter(double value) const;
410  std::string matchName() const;
412  int lengthMatchName() const;
414  int parameterOption(std::string check) const;
416  void printOptions() const;
418  inline std::string currentOption() const
419  {
420  return definedKeyWords_[currentKeyWord_];
421  }
423  void setCurrentOption(int value, bool printIt = false);
425  const char *setCurrentOptionWithMessage(int value);
427  void setCurrentOption(const std::string value);
429  const char *setCurrentOptionWithMessage(const std::string value);
431  int currentOptionAsInteger() const;
436  int currentOptionAsInteger(int &fakeInteger) const;
438  void setIntValue(int value);
440  const char *setIntValueWithMessage(int value);
441  inline int intValue() const
442  {
443  return intValue_;
444  }
446  void setDoubleValue(double value);
448  const char *setDoubleValueWithMessage(double value);
449  inline double doubleValue() const
450  {
451  return doubleValue_;
452  }
454  void setStringValue(std::string value);
455  inline std::string stringValue() const
456  {
457  return stringValue_;
458  }
460  int matches(std::string input) const;
463  {
464  return type_;
465  }
467  inline int displayThis() const
468  {
469  return display_;
470  }
472  inline void setLonghelp(const std::string help)
473  {
474  longHelp_ = help;
475  }
477  void printLongHelp() const;
479  void printString() const;
485  inline int whereUsed() const
486  {
487  return whereUsed_;
488  }
490  inline int fakeKeyWord() const
491  {
492  return fakeKeyWord_;
493  }
495  inline void setFakeKeyWord(int value, int fakeValue)
496  {
497  fakeKeyWord_ = value;
498  fakeValue_ = fakeValue;
499  }
501  void setFakeKeyWord(int fakeValue);
502 
503 private:
505  void gutsOfConstructor();
507 private:
513  // Type see CbcOrClpParameterType
514  CbcOrClpParameterType type_;
516  double lowerDoubleValue_;
517  double upperDoubleValue_;
519  int lowerIntValue_;
520  int upperIntValue_;
521  // Length of name
522  unsigned int lengthName_;
523  // Minimum match
524  unsigned int lengthMatch_;
526  std::vector< std::string > definedKeyWords_;
528  std::string name_;
530  std::string shortHelp_;
532  std::string longHelp_;
534  CbcOrClpParameterType action_;
536  int currentKeyWord_;
538  int display_;
540  int intValue_;
542  double doubleValue_;
544  std::string stringValue_;
550  int whereUsed_;
555  int fakeKeyWord_;
557  int fakeValue_;
559 };
561 std::string CoinReadNextField();
562 
563 std::string CoinReadGetCommand(int argc, const char *argv[]);
564 std::string CoinReadGetString(int argc, const char *argv[]);
565 // valid 0 - okay, 1 bad, 2 not there
566 int CoinReadGetIntField(int argc, const char *argv[], int *valid);
567 double CoinReadGetDoubleField(int argc, const char *argv[], int *valid);
568 void CoinReadPrintit(const char *input);
569 void setCbcOrClpPrinting(bool yesNo);
570 #define CBCMAXPARAMETERS 250
571 /*
572  Subroutine to establish the cbc parameter array. See the description of
573  class CbcOrClpParam for details. Pulled from C..Main() for clarity.
574 */
575 void establishParams(std::vector< CbcOrClpParam > &params);
576 // Given a parameter type - returns its number in list
577 int whichParam(const CbcOrClpParameterType &name,
578  const std::vector< CbcOrClpParam > &parameters);
579 // Dump/restore a solution to file
580 void saveSolution(const ClpSimplex *lpSolver, std::string fileName);
581 void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode);
582 #endif /* CbcOrClpParam_H */
583 
584 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
585 */
std::string CoinReadNextField()
Simple read stuff.
void setCbcOrClpPrinting(bool yesNo)
int intParameter(CbcModel &model) const
Gets a int parameter.
std::string CoinReadGetCommand(int argc, const char *argv[])
std::string CoinReadGetString(int argc, const char *argv[])
double upperDoubleValue() const
Returns the upper bound for a double-valued parameter.
CbcOrClpParameterType type() const
type
const char * setCurrentOptionWithMessage(int value)
Sets current parameter option and returns printable string.
std::string stringValue() const
void printLongHelp() const
Print Long help.
Very simple class for setting parameters.
int checkDoubleParameter(double value) const
Checks a double parameter (nonzero code if error)
void printOptions() const
Prints parameter options.
int fakeKeyWord() const
Gets value of fake keyword.
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.
const char * setDoubleParameterWithMessage(CbcModel &model, double value, int &returnCode)
Sets double parameter and returns printable string and error code.
int lengthMatchName() const
Returns length of name for ptinting.
void printString() const
Print action and string.
std::string name() const
Returns name.
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.
int displayThis() const
whether to display
void setFakeKeyWord(int value, int fakeValue)
Sets value of fake keyword.
void setDoubleValue(double value)
Sets double value.
std::string shortHelp() const
Returns short help.
int whichParam(const CbcOrClpParameterType &name, const std::vector< CbcOrClpParam > &parameters)
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:106
int whereUsed() const
7 if used everywhere, 1 - used by clp 2 - used by cbc 4 - used by ampl
void CoinReadPrintit(const char *input)
int lowerIntValue() const
Returns the lower bound for an int-valued parameter.
std::string matchName() const
Returns name which could match.
double CoinReadGetDoubleField(int argc, const char *argv[], int *valid)
void establishParams(std::vector< CbcOrClpParam > &params)
double doubleParameter(CbcModel &model) const
Gets a double parameter.
int upperIntValue() const
Returns the upper bound for an int-valued parameter.
void append(std::string keyWord)
Insert string (only valid for keywords)
std::string currentOption() const
Returns current parameter option.
std::string longHelp() const
Returns long help.
int CoinReadGetIntField(int argc, const char *argv[], int *valid)
int currentOptionAsInteger() const
Returns current parameter option position.
double doubleValue() const
void setLonghelp(const std::string help)
Set Long help.
int intValue() const
CbcOrClpParameterType
Parameter codes.
CbcOrClpParam()
Constructors.
void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode)
~CbcOrClpParam()
Destructor.
int setDoubleParameter(CbcModel &model, double value)
Sets a double parameter (nonzero code if error)
void setStringValue(std::string value)
Sets string value.
int matches(std::string input) const
Returns 1 if matches minimum, 2 if matches less, 0 if not matched.
void saveSolution(const ClpSimplex *lpSolver, std::string fileName)
const std::vector< std::string > & definedKeywords() const
Returns set of valid strings.
int parameterOption(std::string check) const
Returns parameter option which matches (-1 if none)
double lowerDoubleValue() const
Returns the lower bound for a double-valued parameter.
int setIntParameter(CbcModel &model, int value)
Sets a int parameter (nonzero code if error)
const char * setIntValueWithMessage(int value)
Sets int value with message.