Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  {
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
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_;
538  int display_;
542  double doubleValue_;
544  std::string stringValue_;
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 */
int displayThis() const
whether to display
void gutsOfConstructor()
gutsOfConstructor
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)
int intValue_
Integer parameter - current value.
double doubleValue() const
std::string CoinReadGetCommand(int argc, const char *argv[])
double doubleValue_
Double parameter - current value.
int intParameter(CbcModel &model) const
Gets a int parameter.
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.
int display_
Display on ?
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 printIt(const char *msg)
Utility to print a long message as filled lines of text.
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
Abstract Base Class for describing an interface to a solver.
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.
int whereUsed_
7 if used everywhere, 1 - used by clp 2 - used by cbc 4 - used by ampl
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.
int whichParam(const CbcOrClpParameterType &name, const std::vector< CbcOrClpParam > &parameters)
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:106
double upperDoubleValue() const
Returns the upper bound for a double-valued parameter.
int currentKeyWord_
Current keyWord (if a keyword parameter)
void CoinReadPrintit(const char *input)
std::vector< std::string > definedKeyWords_
set of valid strings
double lowerDoubleValue_
If double == okay.
void printOptions() const
Prints parameter options.
int fakeValue_
Return this as main value if an integer.
const std::vector< std::string > & definedKeywords() const
Returns set of valid strings.
double lowerDoubleValue() const
Returns the lower bound for a double-valued parameter.
double CoinReadGetDoubleField(int argc, const char *argv[], int *valid)
int fakeKeyWord() const
Gets value of fake keyword.
unsigned int lengthMatch_
std::string shortHelp_
Short help.
std::string longHelp_
Long help.
void establishParams(std::vector< CbcOrClpParam > &params)
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
double upperDoubleValue_
int CoinReadGetIntField(int argc, const char *argv[], int *valid)
int intValue() const
unsigned int lengthName_
void setLonghelp(const std::string help)
Set Long help.
int fakeKeyWord_
If &gt;=0 then integers allowed as a fake keyword So minusnnnn would got to -nnnn in currentKeyword_ and...
CbcOrClpParameterType
Parameter codes.
CbcOrClpParam()
Constructors.
double doubleParameter(CbcModel &model) const
Gets a double parameter.
void restoreSolution(ClpSimplex *lpSolver, std::string fileName, int mode)
int lowerIntValue_
If int == okay.
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.
CbcOrClpParameterType action_
Action.
std::string currentOption() const
Returns current parameter option.
std::string name_
Name.
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 lowerIntValue() const
Returns the lower bound for an int-valued parameter.
int currentOptionAsInteger() const
Returns current parameter option position.
Simple Branch and bound class.
Definition: CbcModel.hpp:100
void printString() const
Print action and string.
std::string longHelp() const
Returns long help.
int setIntParameter(CbcModel &model, int value)
Sets a int parameter (nonzero code if error)
std::string stringValue_
String parameter - current value.
const char * setIntValueWithMessage(int value)
Sets int value with message.
CbcOrClpParameterType type_
int upperIntValue() const
Returns the upper bound for an int-valued parameter.