Gröbner basis project
Codebase for research into Gröbner basis computation
constraint Class Reference

a constraint \( c_1 x_1 + \ldots + c_n x_n \geq 0 \) More...

#include <lp_solver.hpp>

Public Member Functions

Construction
 constraint (NVAR_TYPE, CONSTR_TYPE [])
 Initialize constraint to the given coefficients. More...
 
 constraint (vector< CONSTR_TYPE > &)
 Initialize constraint to the given coefficients. More...
 
 constraint (const constraint &)
 Copies the coefficients of the other constraint, including the allocation of new memory.
 
Destruction
 ~constraint ()
 Deletes memory allocated by the constructor. More...
 

Friends

I/O
ostream & operator<< (ostream &, const constraint &)
 print a representation of the constraint to the stream More...
 

Basic properties

NVAR_TYPE get_number_of_variables () const
 Returns the number of variables in the constraint.
 
CONSTR_TYPE operator[] (NVAR_TYPE index) const
 Returns the coefficient indicated. Numbering starts at 0.
 
const CONSTR_TYPE * coeffs () const
 Returns the coefficients that determine this constraints.
 
bool operator< (const constraint &a, const constraint &b)
 Lexicographic comparison of constraints. More...
 
bool operator== (const constraint &a, const constraint &b)
 check for constraint equality More...
 
bool operator!= (const constraint &a, const constraint &b)
 check for constraint inequality More...
 
bool operator!= (constraint &a, constraint &b)
 check for constraint inequality More...
 

Detailed Description

a constraint \( c_1 x_1 + \ldots + c_n x_n \geq 0 \)

Author
John Perry
Version
1.0
Date
October 2014

This class encapsulates a simple constraint for a skeleton; that is, an inequality of the form \( c_1 x_1 + \ldots + c_n x_n \geq 0 \). Constraints can be ordered lexicographically using the less-than operator, allowing for their inclusion in ordered collections, such as sets.

Definition at line 36 of file lp_solver.hpp.

Constructor & Destructor Documentation

◆ constraint() [1/2]

constraint::constraint ( NVAR_TYPE  num_variables,
CONSTR_TYPE  coeffs[] 
)

Initialize constraint to the given coefficients.

The resulting constraint is \( c_1x_1 + \cdots + c_nx_n \geq 0, \) where \( c_i \) is the coefficient of \( x_i \).

Parameters
num_variableslength of coeffs
coeffscopies this array of coefficients
Precondition
the size of the array needs to be at least as long as the dimension!

Definition at line 6 of file lp_solver.cpp.

◆ constraint() [2/2]

constraint::constraint ( vector< CONSTR_TYPE > &  coeffs)

Initialize constraint to the given coefficients.

The resulting constraint is \( c_1x_1 + \cdots + c_nx_n \geq 0, \) where \( c_i \) is the coefficient of \( x_i \).

Parameters
coeffscopies thiis vector of coefficients
Postcondition
nvars will have the value equal to coeffs.size()

Definition at line 14 of file lp_solver.cpp.

◆ ~constraint()

constraint::~constraint ( )

Deletes memory allocated by the constructor.

Currently, that means it deletes an array created by the constructors.

Definition at line 94 of file lp_solver.cpp.

Friends And Related Function Documentation

◆ operator!= [1/2]

bool operator!= ( const constraint a,
const constraint b 
)
friend

check for constraint inequality

Warning
This is unsafe when number of variables is not the same. It does not check, since the assumption is that you know what you're doing.

◆ operator!= [2/2]

bool operator!= ( constraint a,
constraint b 
)
friend

check for constraint inequality

Warning
This is unsafe when number of variables is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 54 of file lp_solver.cpp.

◆ operator<

bool operator< ( const constraint a,
const constraint b 
)
friend

Lexicographic comparison of constraints.

Warning
This is unsafe when number of variables is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 31 of file lp_solver.cpp.

◆ operator<<

ostream& operator<< ( ostream &  ostr,
const constraint c 
)
friend

print a representation of the constraint to the stream

Output is of the form \( c_1 x_1 + \ldots + c_n x_n \) , where \( c_i \) is the coefficient of \( x_i \).

Definition at line 64 of file lp_solver.cpp.

◆ operator==

bool operator== ( const constraint a,
const constraint b 
)
friend

check for constraint equality

Warning
This is unsafe when number of variables is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 44 of file lp_solver.cpp.


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