Loading...
Searching...
No Matches
CglSimpleRounding Class Reference

Simple Rounding Cut Generator Class. More...

`#include <CglSimpleRounding.hpp>`

Inheritance diagram for CglSimpleRounding:
[legend]
Collaboration diagram for CglSimpleRounding:
[legend]

## Public Member Functions

Generate Cuts
virtual void | generateCuts (const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
| Generate simple rounding cuts for the model accessed through the solver interface.
Constructors and destructors
| CglSimpleRounding ()
| Default constructor.
| CglSimpleRounding (const CglSimpleRounding &)
| Copy constructor.
virtual CglCutGenerator * | clone () const
| Clone.
CglSimpleRounding & | operator= (const CglSimpleRounding &rhs)
| Assignment operator.
virtual | ~CglSimpleRounding ()
| Destructor.
virtual std::string | generateCpp (FILE *fp)
| Create C++ lines to get to current state.
Public Member Functions inherited from CglCutGenerator
| CglCutGenerator ()
| Default constructor.
| CglCutGenerator (const CglCutGenerator &)
| Copy constructor.
CglCutGenerator & | operator= (const CglCutGenerator &rhs)
| Assignment operator.
virtual | ~CglCutGenerator ()
| Destructor.
virtual void | refreshSolver (OsiSolverInterface *)
| This can be used to refresh any information.
int | getAggressiveness () const
| Get Aggressiveness - 0 = neutral, 100 is normal root node.
void | setAggressiveness (int value)
| Set Aggressiveness - 0 = neutral, 100 is normal root node.
void | setGlobalCuts (bool trueOrFalse)
| Set whether can do global cuts.
bool | canDoGlobalCuts () const
| Say whether can do global cuts.
virtual bool | mayGenerateRowCutsInTree () const
| Returns true if may generate Row cuts in tree (rather than root node).
virtual bool | needsOptimalBasis () const
| Return true if needs optimal basis to do cuts.
virtual int | maximumLengthOfCutInTree () const
| Return maximum length of cut in tree.

## Private Member Functions

Private methods
bool | deriveAnIntegerRow (const OsiSolverInterface &si, int rowIndex, const CoinShallowPackedVector &matrixRow, CoinPackedVector &irow, double &b, bool *negative) const
| Derive a <= inequality in integer variables from the rowIndex-th constraint.
int | power10ToMakeDoubleAnInt (int size, const double *x, double dataTol) const
| Given a vector of doubles, x, with size elements and a positive tolerance, dataTol, this method returns the smallest power of 10 needed so that x[i]*10**power "is integer" for all i=0,...,size-1.
Greatest common denominators methods
int | gcd (int a, int b) const
| Returns the greatest common denominator of two positive integers, a and b.
int | gcdv (int n, const int *const vi) const
| Returns the greatest common denominator of a vector of positive integers, vi, of length n.

## Private Attributes

Private member data
double | epsilon_
| A value within an epsilon_ neighborhood of 0 is considered to be 0.

## Friends

void | CglSimpleRoundingUnitTest (const OsiSolverInterface *siP, const std::string mpdDir)
| A function that tests the methods in the CglSimpleRounding class.

## Additional Inherited Members

int | aggressive_
| Aggressiveness - 0 = neutral, 100 is normal root node.
bool | canDoGlobalCuts_
| True if can do global cuts i.e. no general integers.

## Detailed Description

Simple Rounding Cut Generator Class.

This class generates simple rounding cuts via the following method: For each contraint, attempt to derive a <= inequality in all integer variables by netting out any continuous variables. Divide the resulting integer inequality through by the greatest common denomimator (gcd) of the lhs coefficients. Round down the rhs.

Warning: Use with careful attention to data precision.

(Reference: Nemhauser and Wolsey, Integer and Combinatorial Optimization, 1988, pg 211.)

Definition at line 29 of file CglSimpleRounding.hpp.

## Constructor & Destructor Documentation

## CglSimpleRounding() [1/2]

CglSimpleRounding::CglSimpleRounding | ( |  | ) |

Default constructor.

## CglSimpleRounding() [2/2]

CglSimpleRounding::CglSimpleRounding | ( | const CglSimpleRounding & |  | ) |

Copy constructor.

## ~CglSimpleRounding()

virtual CglSimpleRounding::~CglSimpleRounding | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## generateCuts()

virtual void CglSimpleRounding::generateCuts | ( | const OsiSolverInterface & | si,
|  | OsiCuts & | cs,
|  | const CglTreeInfo | info = CglTreeInfo() )

virtual

Generate simple rounding cuts for the model accessed through the solver interface.

Insert generated cuts into the cut set cs.

Implements CglCutGenerator.

## clone()

virtual CglCutGenerator * CglSimpleRounding::clone | ( |  | ) | const

virtual

Clone.

Implements CglCutGenerator.

## operator=()

CglSimpleRounding & CglSimpleRounding::operator= | ( | const CglSimpleRounding & | rhs | ) |

Assignment operator.

## generateCpp()

virtual std::string CglSimpleRounding::generateCpp | ( | FILE * | fp | ) |

virtual

Create C++ lines to get to current state.

Reimplemented from CglCutGenerator.

## deriveAnIntegerRow()

bool CglSimpleRounding::deriveAnIntegerRow | ( | const OsiSolverInterface & | si,
|  | int | rowIndex,
|  | const CoinShallowPackedVector & | matrixRow,
|  | CoinPackedVector & | irow,
|  | double & | b,
|  | bool * | negative ) const

private

Derive a <= inequality in integer variables from the rowIndex-th constraint.

## power10ToMakeDoubleAnInt()

int CglSimpleRounding::power10ToMakeDoubleAnInt | ( | int | size,
|  | const double * | x,
|  | double | dataTol ) const

private

Given a vector of doubles, x, with size elements and a positive tolerance, dataTol, this method returns the smallest power of 10 needed so that x[i]*10**power "is integer" for all i=0,...,size-1.

change of definition of dataTol so that it refers to original data, not to scaled data as that seems to lead to problems.

So if xScaled is x[i]*10**power and xInt is rounded(xScaled) then fabs(xScaled-xInt) <= dataTol*10**power. This means that dataTol should be smaller - say 1.0e-12 rather tahn 1.0e-8

Returns -number of times overflowed if the power is so big that it will cause overflow (i.e. integer stored will be bigger than 2**31). Test in cut generator.

## gcd()

int CglSimpleRounding::gcd | ( | int | a,
|  | int | b ) const

inline private

Returns the greatest common denominator of two positive integers, a and b.

Definition at line 132 of file CglSimpleRounding.hpp.

## gcdv()

int CglSimpleRounding::gcdv | ( | int | n,
|  | const int *const | vi ) const

inline private

Returns the greatest common denominator of a vector of positive integers, vi, of length n.

Definition at line 150 of file CglSimpleRounding.hpp.

## Friends And Related Symbol Documentation

## CglSimpleRoundingUnitTest

void CglSimpleRoundingUnitTest | ( | const OsiSolverInterface * | siP,
|  | const std::string | mpdDir )

friend

A function that tests the methods in the CglSimpleRounding class.

The only reason for it not to be a member method is that this way it doesn't have to be compiled into the library. And that's a gain, because the library should be compiled with optimization on, but this method should be compiled with debugging.

## Member Data Documentation

## epsilon_

double CglSimpleRounding::epsilon_

private

A value within an epsilon_ neighborhood of 0 is considered to be 0.

Definition at line 122 of file CglSimpleRounding.hpp.

The documentation for this class was generated from the following file:

- Cgl/src/CglSimpleRounding/CglSimpleRounding.hpp