Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

abacus::Row Class Reference

Representation of constraints in the row format. More...

#include <ogdf/lib/abacus/row.h>

+ Inheritance diagram for abacus::Row:

Public Member Functions

 Row (AbacusGlobal *glob, int nnz, const Array< int > &s, const Array< double > &c, const CSense &sense, double r)
 Creates a row and initializes it. More...
 
 Row (AbacusGlobal *glob, int nnz, const Array< int > &s, const Array< double > &c, const CSense::SENSE sense, double r)
 Creates a row and initializes it. More...
 
 Row (AbacusGlobal *glob, int nnz, int *s, double *c, CSense::SENSE sense, double r)
 Creates a row and initializes it using C-style arrays. More...
 
 Row (AbacusGlobal *glob, int size)
 Creates a row without initialization of the nonzeros of the row. More...
 
 ~Row ()
 The destructor. More...
 
void copy (const Row &row)
 Copies row. More...
 
void delInd (ArrayBuffer< int > &buf, double rhsDelta)
 Removes the indices listed in buf from the support of the row and subtracts rhsDelta from its right hand side. More...
 
double rhs () const
 Returns the right hand side stored in the row format. More...
 
void rhs (double r)
 Sets the right hand side of the row to r. More...
 
CSensesense ()
 Returns a pointer to the sense of the row. More...
 
const CSensesense () const
 Returns a const pointer to the sense of the row. More...
 
void sense (CSense &s)
 Sets the sense of the row to s. More...
 
void sense (CSense::SENSE s)
 Sets the sense of the row to s. More...
 
- Public Member Functions inherited from abacus::SparVec
 SparVec (AbacusGlobal *glob, int size, const Array< int > &s, const Array< double > &c, double reallocFac=10.0)
 Creates a sparse vector and initializes support and coefficients. More...
 
 SparVec (AbacusGlobal *glob, int size, double reallocFac=10.0)
 Creates an empty sparse vector. More...
 
 SparVec (AbacusGlobal *glob, int size, int *s, double *c, double reallocFac=10.0)
 Creates a sparse vector and initializes support and coefficients. More...
 
 SparVec (const SparVec &rhs)
 Copy constructor. More...
 
 ~SparVec ()
 The destructor. More...
 
void clear ()
 Removes all nonzeros from the sparse vector. More...
 
double coeff (int i) const
 
void copy (const SparVec &vec)
 Copies vector vec. More...
 
void insert (int s, double c)
 Adds a new support/coefficient pair to the vector. More...
 
void leftShift (ArrayBuffer< int > &del)
 Deletes the elements listed in a buffer from the sparse vector. More...
 
int nnz () const
 Returns the number of nonzero elements. More...
 
double norm ()
 Returns the Euclidean norm of the sparse vector. More...
 
SparVecoperator= (const SparVec &rhs)
 The assignment operator. More...
 
double origCoeff (int i) const
 
void realloc ()
 Increases the size of the sparse vector by reallocFac_ percent of the original size. More...
 
void realloc (int newSize)
 Reallocates the sparse vector to a given length. More...
 
void rename (Array< int > &newName)
 Replaces the index of the support by new names. More...
 
int size () const
 Returns the maximal length of the sparse vector. More...
 
int support (int i) const
 
- Public Member Functions inherited from abacus::AbacusRoot
virtual ~AbacusRoot ()
 The destructor. More...
 

Protected Attributes

double rhs_
 The right hand side of the row. More...
 
CSense sense_
 The sense of the row. More...
 
- Protected Attributes inherited from abacus::SparVec
double * coeff_
 The array storing the corresponding nonzero coefficients. More...
 
AbacusGlobalglob_
 A pointer to the corresponding global object. More...
 
int nnz_
 The number of stored elements ("nonzeros"). More...
 
double reallocFac_
 If a new element is inserted but the sparse vector is full, then its size is increased by reallocFac_ percent. More...
 
int size_
 The maximal number of nonzero coefficients which can be stored without reallocation. More...
 
int * support_
 The array storing the nonzero variables. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const Row &rhs)
 The output operator. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from abacus::AbacusRoot
static bool ascii2bool (const string &str)
 Converts the string str to a boolean value. More...
 
static bool endsWith (const string &str, const string &end)
 Returns true if str ends with end, false otherwise. More...
 
static double fracPart (double x)
 Returns the absolute value of the fractional part of x. More...
 
static const char * onOff (bool value)
 Converts a boolean variable to the strings "on" and "off". More...
 
- Protected Member Functions inherited from abacus::SparVec
void rangeCheck (int i) const
 Checks whether i is a valid index. More...
 

Detailed Description

Representation of constraints in the row format.

This class refines its base class SparVec for the representation of constraints in the row format. This class plays an essential role in the interface with the LP-solver.

This class should not be confused with the class Constraint, which is an abstract class for the representation of constraints within the framework. Moreover, the class RowCon derived from the class Constraint provides a constraint representation in row format, but there are also other representations of constraints.

Definition at line 51 of file row.h.

Constructor & Destructor Documentation

◆ Row() [1/4]

abacus::Row::Row ( AbacusGlobal glob,
int  nnz,
const Array< int > &  s,
const Array< double > &  c,
const CSense sense,
double  r 
)
inline

Creates a row and initializes it.

Parameters
globA pointer to the corresponding global object.
nnzThe number of nonzero elements of the row.
sThe array storing the nonzero elements.
cThe array storing the nonzero coefficients of the elements of s.
senseThe sense of the row.
rThe right hand side of the row.

Definition at line 63 of file row.h.

◆ Row() [2/4]

abacus::Row::Row ( AbacusGlobal glob,
int  nnz,
const Array< int > &  s,
const Array< double > &  c,
const CSense::SENSE  sense,
double  r 
)
inline

Creates a row and initializes it.

Parameters
globA pointer to the corresponding global object.
nnzThe number of nonzero elements of the row.
sThe array storing the nonzero elements.
cThe array storing the nonzero coefficients of the elements of s.
senseThe sense of the row.
rThe right hand side of the row.

Definition at line 80 of file row.h.

◆ Row() [3/4]

abacus::Row::Row ( AbacusGlobal glob,
int  nnz,
int *  s,
double *  c,
CSense::SENSE  sense,
double  r 
)
inline

Creates a row and initializes it using C-style arrays.

Parameters
globA pointer to the corresponding global object.
nnzThe number of nonzero elements of the row.
sThe array storing the nonzero elements.
cThe array storing the nonzero coefficients of the elements of s.
senseThe sense of the row.
rThe right hand side of the row.

Definition at line 97 of file row.h.

◆ Row() [4/4]

abacus::Row::Row ( AbacusGlobal glob,
int  size 
)
inline

Creates a row without initialization of the nonzeros of the row.

Parameters
globA pointer to the corresponding global object.
sizeThe maximal numbers of nonzeros.

Definition at line 110 of file row.h.

◆ ~Row()

abacus::Row::~Row ( )
inline

The destructor.

Definition at line 113 of file row.h.

Member Function Documentation

◆ copy()

void abacus::Row::copy ( const Row row)

Copies row.

Behaves like an assignment operator, however, the maximal number of the elements of this row only has to be at least the number of nonzeros of row.

Parameters
rowThe row that is copied.

◆ delInd()

void abacus::Row::delInd ( ArrayBuffer< int > &  buf,
double  rhsDelta 
)
inline

Removes the indices listed in buf from the support of the row and subtracts rhsDelta from its right hand side.

Parameters
bufThe components being removed from the row.
rhsDeltaThe correction of the right hand side of the row.

Definition at line 172 of file row.h.

◆ rhs() [1/2]

double abacus::Row::rhs ( ) const
inline

Returns the right hand side stored in the row format.

Definition at line 132 of file row.h.

◆ rhs() [2/2]

void abacus::Row::rhs ( double  r)
inline

Sets the right hand side of the row to r.

Parameters
rThe new value of the right hand side.

Definition at line 138 of file row.h.

◆ sense() [1/4]

CSense* abacus::Row::sense ( )
inline

Returns a pointer to the sense of the row.

Definition at line 141 of file row.h.

◆ sense() [2/4]

const CSense* abacus::Row::sense ( ) const
inline

Returns a const pointer to the sense of the row.

Definition at line 144 of file row.h.

◆ sense() [3/4]

void abacus::Row::sense ( CSense s)
inline

Sets the sense of the row to s.

Parameters
sThe new sense of the row.

Definition at line 150 of file row.h.

◆ sense() [4/4]

void abacus::Row::sense ( CSense::SENSE  s)
inline

Sets the sense of the row to s.

Parameters
sThe new sense of the row.

Definition at line 156 of file row.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const Row rhs 
)
friend

The output operator.

Writes the row on an output stream in format like -2.5 x1 + 3 x3 <= 7.

Only variables with nonzero coefficients are output. The output operator does neither output a '+' before the first coefficient of a row, if it is positive, nor outputs coefficients with absolute value 1.

Parameters
outThe output stream.
rhsThe row being output.
Returns
A reference to the output stream.

Member Data Documentation

◆ rhs_

double abacus::Row::rhs_
protected

The right hand side of the row.

Definition at line 180 of file row.h.

◆ sense_

CSense abacus::Row::sense_
protected

The sense of the row.

Definition at line 179 of file row.h.


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