Loading...
Searching...
No Matches
CglResidualCapacity.hpp
Go to the documentation of this file.
// LAST EDIT:
//-----------------------------------------------------------------------------
// Implementation of Residual Capacity Inequalities
// Francisco Barahona (barahon@us.ibm.com)
//
// date: May 18, 2006
//-----------------------------------------------------------------------------
// Copyright (C) 2004, International Business Machines Corporation and others.
// All Rights Reserved.
// This code is published under the Eclipse Public License.
#ifndef CglResidualCapacity_H
#define CglResidualCapacity_H
#include <iostream>
#include <fstream>
//#include <vector>
#include "CoinError.hpp"
#include "CglCutGenerator.hpp"
//=============================================================================
#ifndef CGL_DEBUG
#define CGL_DEBUG 0
#endif
//=============================================================================
//=============================================================================
class CglResidualCapacity : public CglCutGenerator {
friend void CglResidualCapacityUnitTest(const OsiSolverInterface * siP,
const std::string mpdDir );
private:
//---------------------------------------------------------------------------
// Enumeration constants that describe the various types of rows
enum RowType {
ROW_L,
ROW_G,
ROW_BOTH,
ROW_OTHER
};
public:
void setEpsilon(double value);
double getEpsilon() const;
void setTolerance(double value);
double getTolerance() const;
void setDoPreproc(int value);
bool getDoPreproc() const;
virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
const CglTreeInfo info = CglTreeInfo());
//---------------------------------------------------------------------------
CglResidualCapacity ();
CglResidualCapacity ( const double tolerance );
CglResidualCapacity (
const CglResidualCapacity &);
virtual CglCutGenerator * clone() const;
CglResidualCapacity &
operator=(
const CglResidualCapacity& rhs);
virtual
~CglResidualCapacity ();
virtual void refreshPrep();
private:
//--------------------------------------------------------------------------
// Private member methods
// Construct
void gutsOfConstruct ( const double tolerance);
// Delete
void gutsOfDelete();
// Copy
void gutsOfCopy (const CglResidualCapacity& rhs);
// Do preprocessing.
// It determines the type of each row.
// It may change sense and RHS for ranged rows
void resCapPreprocess(const OsiSolverInterface& si);
// Determine the type of a given row.
RowType determineRowType(const OsiSolverInterface& si,
const int rowLen, const int* ind,
const double* coef, const char sense,
const double rhs,
const double* colLowerBound,
const double* colUpperBound) const;
// helps the function above
bool treatAsLessThan(const OsiSolverInterface& si,
const int rowLen, const int* ind,
const double* coef,
const double rhs,
const double* colLowerBound,
const double* colUpperBound) const;
// Generate Residual Capacity cuts
void generateResCapCuts( const OsiSolverInterface& si,
const double* xlp,
const double* colUpperBound,
const double* colLowerBound,
const CoinPackedMatrix& matrixByRow,
const double* LHS,
const double* coefByRow,
const int* colInds,
const CoinBigIndex* rowStarts,
const int* rowLengths,
OsiCuts& cs ) const;
// Residual Capacity separation
bool resCapSeparation(const OsiSolverInterface& si,
const int rowLen, const int* ind,
const double* coef,
const double rhs,
const double *xlp,
const double* colUpperBound,
const double* colLowerBound,
OsiRowCut& resCapCut) const;
private:
//---------------------------------------------------------------------------
// Private member data
double EPSILON_;
double TOLERANCE_;
int doPreproc_;
// The number of rows of the problem.
int numRows_;
// The number columns of the problem.
int numCols_;
// Indicates whether preprocessing has been done.
bool doneInitPre_;
// Array with the row types of the rows in the model.
RowType* rowTypes_;
// The indices of the rows of the initial matrix
int* indRows_;
// Sense of rows (modified if ranges)
char * sense_;
// RHS of rows (modified if ranges)
double * RHS_;
// The number of rows of type ROW_L
int numRowL_;
// The indices of the rows of type ROW_L
int* indRowL_;
// The number of rows of type ROW_G
int numRowG_;
// The indices of the rows of type ROW_G
int* indRowG_;
};
//#############################################################################
void CglResidualCapacityUnitTest(const OsiSolverInterface * siP,
const std::string mpdDir);
#endif
CglCutGenerator.hpp
CglResidualCapacityUnitTest
void CglResidualCapacityUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglResidualCapacity class.
CglCutGenerator::CglCutGenerator
CglCutGenerator()
Default constructor.
CglResidualCapacity::indRowG_
int * indRowG_
Definition CglResidualCapacity.hpp:227
CglResidualCapacity::doPreproc_
int doPreproc_
Controls the preprocessing of the matrix to identify rows suitable for cut generation.
Definition CglResidualCapacity.hpp:205
CglResidualCapacity::setEpsilon
void setEpsilon(double value)
Set Epsilon.
CglResidualCapacity::operator=
CglResidualCapacity & operator=(const CglResidualCapacity &rhs)
Assignment operator.
CglResidualCapacity::resCapPreprocess
void resCapPreprocess(const OsiSolverInterface &si)
CglResidualCapacity::RHS_
double * RHS_
Definition CglResidualCapacity.hpp:219
CglResidualCapacity::getEpsilon
double getEpsilon() const
Get Epsilon.
CglResidualCapacity::getDoPreproc
bool getDoPreproc() const
Get doPreproc.
CglResidualCapacity::CglResidualCapacityUnitTest
friend void CglResidualCapacityUnitTest(const OsiSolverInterface *siP, const std::string mpdDir)
A function that tests the methods in the CglResidualCapacity class.
CglResidualCapacity::numRows_
int numRows_
Definition CglResidualCapacity.hpp:207
CglResidualCapacity::TOLERANCE_
double TOLERANCE_
If violation of a cut is greater that this number, the cut is accepted, default value: 1....
Definition CglResidualCapacity.hpp:197
CglResidualCapacity::setDoPreproc
void setDoPreproc(int value)
Set doPreproc.
CglResidualCapacity::doneInitPre_
bool doneInitPre_
Definition CglResidualCapacity.hpp:211
CglResidualCapacity::CglResidualCapacity
CglResidualCapacity(const CglResidualCapacity &)
Copy constructor.
CglResidualCapacity::sense_
char * sense_
Definition CglResidualCapacity.hpp:217
CglResidualCapacity::resCapSeparation
bool resCapSeparation(const OsiSolverInterface &si, const int rowLen, const int *ind, const double *coef, const double rhs, const double *xlp, const double *colUpperBound, const double *colLowerBound, OsiRowCut &resCapCut) const
CglResidualCapacity::gutsOfConstruct
void gutsOfConstruct(const double tolerance)
CglResidualCapacity::generateResCapCuts
void generateResCapCuts(const OsiSolverInterface &si, const double *xlp, const double *colUpperBound, const double *colLowerBound, const CoinPackedMatrix &matrixByRow, const double *LHS, const double *coefByRow, const int *colInds, const CoinBigIndex *rowStarts, const int *rowLengths, OsiCuts &cs) const
CglResidualCapacity::RowType
RowType
Definition CglResidualCapacity.hpp:56
CglResidualCapacity::ROW_G
@ ROW_G
row of the type -a_1 c_1 - - a_k c_k + d z_1 + + d z_p >= b, where c_i are continuous variables and z...
Definition CglResidualCapacity.hpp:64
CglResidualCapacity::ROW_L
@ ROW_L
row of the type a_1 c_1 + + a_k c_k - d z_1 - - d z_p <= b, where c_i are continuous variables and z_...
Definition CglResidualCapacity.hpp:60
CglResidualCapacity::ROW_OTHER
@ ROW_OTHER
Other types of rows.
Definition CglResidualCapacity.hpp:70
CglResidualCapacity::ROW_BOTH
@ ROW_BOTH
equation that can be treated as ROW_L and ROW_G
Definition CglResidualCapacity.hpp:67
CglResidualCapacity::gutsOfDelete
void gutsOfDelete()
CglResidualCapacity::CglResidualCapacity
CglResidualCapacity(const double tolerance)
Alternate Constructor.
CglResidualCapacity::indRowL_
int * indRowL_
Definition CglResidualCapacity.hpp:223
CglResidualCapacity::treatAsLessThan
bool treatAsLessThan(const OsiSolverInterface &si, const int rowLen, const int *ind, const double *coef, const double rhs, const double *colLowerBound, const double *colUpperBound) const
CglResidualCapacity::numRowG_
int numRowG_
Definition CglResidualCapacity.hpp:225
CglResidualCapacity::gutsOfCopy
void gutsOfCopy(const CglResidualCapacity &rhs)
CglResidualCapacity::generateCuts
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate Residual Capacity cuts for the model data contained in si.
CglResidualCapacity::rowTypes_
RowType * rowTypes_
Definition CglResidualCapacity.hpp:213
CglResidualCapacity::indRows_
int * indRows_
Definition CglResidualCapacity.hpp:215
CglResidualCapacity::determineRowType
RowType determineRowType(const OsiSolverInterface &si, const int rowLen, const int *ind, const double *coef, const char sense, const double rhs, const double *colLowerBound, const double *colUpperBound) const
CglResidualCapacity::CglResidualCapacity
CglResidualCapacity()
Default constructor.
CglResidualCapacity::refreshPrep
virtual void refreshPrep()
This is to refresh preprocessing.
CglResidualCapacity::setTolerance
void setTolerance(double value)
Set Tolerance.
CglResidualCapacity::numCols_
int numCols_
Definition CglResidualCapacity.hpp:209
CglResidualCapacity::numRowL_
int numRowL_
Definition CglResidualCapacity.hpp:221
CglResidualCapacity::clone
virtual CglCutGenerator * clone() const
Clone.
CglResidualCapacity::getTolerance
double getTolerance() const
Get Tolerance.
CglResidualCapacity::EPSILON_
double EPSILON_
Tolerance used for numerical purposes, default value: 1.e-6.
Definition CglResidualCapacity.hpp:194
CglResidualCapacity::~CglResidualCapacity
virtual ~CglResidualCapacity()
Destructor.
CglTreeInfo
Information about where the cut generator is invoked from.
Definition CglTreeInfo.hpp:15