Gröbner basis project
Codebase for research into Gröbner basis computation
Constrained Linear System Solvers

classes that solve constrained linear systems More...

Classes

class  constraint
 a constraint \( c_1 x_1 + \ldots + c_n x_n \geq 0 \) More...
 
class  edge
 an edge \((r_1,r_2)\) connecting the two rays \( r_1 \) and \( r_2 \) More...
 
class  GLPK_Solver
 approximate skeleton of a polyhedral cone, using GLPK linear solver More...
 
class  LP_Solver
 exact or approximate polyhedral cone solution, with methods allowing definition and refinement More...
 
class  PPL_Solver
 approximate skeleton of a polyhedral cone, using PPL linear solver More...
 
class  ray
 a ray defined by nonnegative coordinates \((a_1,\ldots,a_n)\) More...
 
class  skeleton
 skeleton of a polyhedral cone, with methods allowing definition and refinement More...
 

Functions

vector< bool > intersections_of_active_constraints (bool *, bool *, unsigned)
 
bool is_first_subset_of_second (bool *, bool *, unsigned)
 
int number_of_common_constraints (bool *, bool *, unsigned)
 
ray operator* (RAYENT_TYPE, ray &)
 Multiply every coordinate in the given ray by the given scalar. More...
 
RAYENT_TYPE operator* (const ray &, const ray &)
 Compute the dot product on the rays. More...
 
DOTPROD_TYPE operator* (const ray &r, const constraint &c)
 Compute the dot product between the ray and the constraint. More...
 
DOTPROD_TYPE operator* (constraint &c, ray &r)
 Compute the dot product between the ray and the constraint. More...
 
ray operator+ (ray &, ray &)
 Add the two rays. More...
 
ray operator- (const ray &, const ray &)
 Subtract the two rays. More...
 
ray ray_sum (const set< ray > &)
 Add all the rays in a set. More...
 
set< edgeunion_of_edge_sets (const set< edge > &, const set< edge > &)
 

Detailed Description

classes that solve constrained linear systems

Classes in this group solve constrained linear systems; that is, they solve systems of the form \(\left\{\sum_{j=1}^na_{ij}x_j\leq b_i\right\}_{i=1}^m\) (where the inequality may or may not be strict).


Class Documentation

◆ constraint

class constraint

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 53 of file 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...
 

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 23 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 31 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 111 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

Parameters
aa constraint
ba constraint
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

Parameters
aa constraint
ba constraint
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 71 of file lp_solver.cpp.

◆ operator<

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

Lexicographic comparison of constraints.

Parameters
aa constraint
ba constraint
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 48 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 81 of file lp_solver.cpp.

◆ operator==

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

check for constraint equality

Parameters
aa constraint
ba constraint
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 61 of file lp_solver.cpp.

◆ edge

class edge

an edge \((r_1,r_2)\) connecting the two rays \( r_1 \) and \( r_2 \)

Author
John Perry
Version
1.0
Date
October 2014

This class encapsulates an edge, the other major part of a skeleton. Edges describe how the rays of the skeleton are connected. Edges are ordered, so that the smaller ray always comes first.

Warning
An edge's rays should have the same dimension. To start with, it doesn't make mathematical sense to “join” two rays of different dimension. Moreover, comparison of edges requires comparison of rays,which requires that the rays have the same dimension. (But you wouldn't be dumb enough to do this in the first place.)

Definition at line 58 of file skeleton.hpp.

Public Member Functions

Construction
 edge (const ray &, const ray &)
 Creates a new edge that joins the two rays.
 
 edge (const edge &)
 Copies the rays in other to two new rays.
 
Destruction
 ~edge ()
 
Basic properties
ray get_first_ray () const
 Returns the first ray listed in this edge.
 
ray get_second_ray () const
 Returns the second ray listed in this edge.
 
Modification
edgeoperator= (const edge &)
 Assignment operator.
 

Friends

Comparison
bool operator== (const edge &e1, const edge &e2)
 Equal if and only if. More...
 
bool operator< (const edge &, const edge &)
 Compares two edges lexicographically. More...
 
I/O
ostream & operator<< (ostream &, const edge &)
 Output has the form \( \{ \mathbf{r}_1, \mathbf{r}_2 \} \) where \( \mathbf{r}_1 \) is the first ray in this edge, etc.
 

Constructor & Destructor Documentation

◆ ~edge()

edge::~edge ( )
inline

Does nothing beyond what the compiler would do.

Definition at line 76 of file skeleton.hpp.

Friends And Related Function Documentation

◆ operator<

bool operator< ( const edge first,
const edge second 
)
friend

Compares two edges lexicographically.

If the first ray in this edge is smaller, then this edge is smaller. Otherwise, if the first rays are equal, and the second ray in this edge is smaller, then this edge is smaller.

Definition at line 58 of file skeleton.cpp.

◆ operator==

bool operator== ( const edge e1,
const edge e2 
)
friend

Equal if and only if.

Parameters
e1an edge
e2an edge
Returns
true if and only if the linked rays are identical

Definition at line 100 of file skeleton.hpp.

◆ GLPK_Solver

class GLPK_Solver

approximate skeleton of a polyhedral cone, using GLPK linear solver

Author
John Perry
Version
1.0
Date
January 2017

This class serves as an interface to GLPK [8], which we can use to find an approximate skeleton to a polyhedral cone.

Definition at line 37 of file glpk_solver.hpp.

Inheritance diagram for GLPK_Solver:
LP_Solver

Public Member Functions

Construction
 GLPK_Solver (NVAR_TYPE n)
 initializes solver for \( n \) variables
 
 GLPK_Solver (const GLPK_Solver &)
 copy constructor (deep copy)
 
virtual bool copy (const LP_Solver *)
 performs a deep copy, similar to a copy constructor More...
 
Destruction
virtual ~GLPK_Solver ()
 
Basic properties
virtual NVAR_TYPE get_dimension () const
 Returns the dimension of the underlying vector space.
 
virtual unsigned long get_number_of_rays ()
 Returns the number of rays defining the skeleton.
 
virtual const set< ray > & get_rays ()
 Returns the rays that define the skeleton.
 
virtual unsigned long get_number_of_constraints ()
 
Modification
virtual bool solve (constraint &)
 Adds the indicated constraint (singular!) and re-computes the solution. More...
 
virtual bool solve (vector< constraint > &)
 Adds the indicated constraints (plural!) and re-computes the solution. More...
 
Computation
virtual bool makes_consistent_constraint (const Monomial &t, const Monomial &u, bool show_data=false)
 tests for consistency of a constraint generated by two monomials.
 
- Public Member Functions inherited from LP_Solver
virtual ~LP_Solver ()
 the default destructor does nothing (this is an abstract class)
 

Additional Inherited Members

- Protected Attributes inherited from LP_Solver
set< rayrays
 

Member Function Documentation

◆ copy()

bool GLPK_Solver::copy ( const LP_Solver )
virtual

performs a deep copy, similar to a copy constructor

Returns
true iff copying was successful
Warning
Do not mix-and-match solvers. At the present time, a PPL_Solver is not equipped to copy a GLPK_Solver, or vice versa. (This doesn't even make sense between exact and approximate solvers.)

Implements LP_Solver.

Definition at line 58 of file glpk_solver.cpp.

◆ solve() [1/2]

bool GLPK_Solver::solve ( constraint )
virtual

Adds the indicated constraint (singular!) and re-computes the solution.

Returns
true if and only if the new constraint is consistent with the current constraints
Warning
Checking the return value is crucial! If the function returns false, you have an inconsistent system! While the present cone will remain consistent, the function will not roll back previous changes you have made, so if you want to iterate again, your best bet is to copy the skeleton, and try that copy. Accept the new constraints only if that copy succeeds, in which case, you might as well discard the original, and keep the copy.

Implements LP_Solver.

Definition at line 116 of file glpk_solver.cpp.

◆ solve() [2/2]

bool GLPK_Solver::solve ( vector< constraint > &  )
virtual

Adds the indicated constraints (plural!) and re-computes the solution.

Returns
true if and only if the new constraints are consistent with the current constraints
Warning
Checking the return value is crucial! If the function returns false, you have an inconsistent system! While the present cone will remain consistent, the function will not roll back previous changes you have made, so if you want to iterate again, your best bet is to copy the skeleton, and try that copy. Accept the new constraints only if that copy succeeds, in which case, you might as well discard the original, and keep the copy.

Implements LP_Solver.

Definition at line 85 of file glpk_solver.cpp.

◆ LP_Solver

class LP_Solver

exact or approximate polyhedral cone solution, with methods allowing definition and refinement

Author
John Perry
Version
1.0
Date
January 2017

This class encapsulates the skeleton of a polyhedral cone, defined by a sequence of inequalities of the form \( c_1 x_1 + \cdots c_n x_n \geq 0 \).

Warning
Some classes may provide only an approximate cone; see, for example, GLPK_Solver. In addition, Clients must ensure two things.
  1. The rays must have the same number \( m \) of dimensions, constraints must have the same number \( n \) of variables, and \( m=n \). Violating any of these three conditions will lead to undesirable behavior.
  2. When refining the cone, it is essential to check that the return value of solve() is true; for if it is not, then the cone is no longer be consistent. Please read the relevant documentation.

Definition at line 504 of file lp_solver.hpp.

Inheritance diagram for LP_Solver:
GLPK_Solver PPL_Solver skeleton

Public Member Functions

Construction
virtual bool copy (const LP_Solver *)=0
 performs a deep copy, similar to a copy constructor More...
 
Destruction
virtual ~LP_Solver ()
 the default destructor does nothing (this is an abstract class)
 
Modification
virtual bool solve (constraint &)=0
 Adds the indicated constraint (singular!) and re-computes the solution. More...
 
virtual bool solve (vector< constraint > &)=0
 Adds the indicated constraints (plural!) and re-computes the solution. More...
 
Basic properies

Returns rays that define a skeleton.

When using an approximate solver such as GLPK_Solver, this will give only an approximate skeleton.

virtual NVAR_TYPE get_dimension () const =0
 Returns the dimension of the underlying vector space.
 
virtual unsigned long get_number_of_rays ()
 Returns the number of rays defining the skeleton.
 
virtual const set< ray > & get_rays ()
 Returns the rays that define the skeleton.
 
virtual unsigned long get_number_of_constraints ()=0
 
Computation
virtual bool makes_consistent_constraint (const Monomial &t, const Monomial &u, bool show_data=false)
 tests for consistency of a constraint generated by two monomials.
 

Protected Attributes

set< rayrays
 

Member Function Documentation

◆ copy()

virtual bool LP_Solver::copy ( const LP_Solver )
pure virtual

performs a deep copy, similar to a copy constructor

Returns
true iff copying was successful
Warning
Do not mix-and-match solvers. At the present time, a PPL_Solver is not equipped to copy a GLPK_Solver, or vice versa. (This doesn't even make sense between exact and approximate solvers.)

Implemented in skeleton, PPL_Solver, and GLPK_Solver.

◆ solve() [1/2]

virtual bool LP_Solver::solve ( constraint )
pure virtual

Adds the indicated constraint (singular!) and re-computes the solution.

Returns
true if and only if the new constraint is consistent with the current constraints
Warning
Checking the return value is crucial! If the function returns false, you have an inconsistent system! While the present cone will remain consistent, the function will not roll back previous changes you have made, so if you want to iterate again, your best bet is to copy the skeleton, and try that copy. Accept the new constraints only if that copy succeeds, in which case, you might as well discard the original, and keep the copy.

Implemented in skeleton, GLPK_Solver, and PPL_Solver.

◆ solve() [2/2]

virtual bool LP_Solver::solve ( vector< constraint > &  )
pure virtual

Adds the indicated constraints (plural!) and re-computes the solution.

Returns
true if and only if the new constraints are consistent with the current constraints
Warning
Checking the return value is crucial! If the function returns false, you have an inconsistent system! While the present cone will remain consistent, the function will not roll back previous changes you have made, so if you want to iterate again, your best bet is to copy the skeleton, and try that copy. Accept the new constraints only if that copy succeeds, in which case, you might as well discard the original, and keep the copy.

Implemented in skeleton, GLPK_Solver, and PPL_Solver.

Member Data Documentation

◆ rays

set<ray> LP_Solver::rays
protected

the skeleton (may be approximate, depending on solver)

Definition at line 602 of file lp_solver.hpp.

◆ PPL_Solver

class PPL_Solver

approximate skeleton of a polyhedral cone, using PPL linear solver

Author
John Perry
Version
1.0
Date
January 2017

This class serves as an interface to PPL [1], which we can use to find the skeleton to a polyhedral cone.

Definition at line 38 of file ppl_solver.hpp.

Inheritance diagram for PPL_Solver:
LP_Solver

Public Member Functions

Construction
 PPL_Solver (NVAR_TYPE n)
 initializes solver for \( n \) variables
 
 PPL_Solver (const PPL_Solver &)
 copy constructor (deep copy)
 
virtual bool copy (const LP_Solver *)
 performs a deep copy, similar to a copy constructor More...
 
Destruction
virtual ~PPL_Solver ()
 
Basic properties
virtual NVAR_TYPE get_dimension () const
 Returns the dimension of the underlying vector space.
 
virtual unsigned long get_number_of_constraints ()
 
Modification
virtual bool solve (constraint &)
 Adds the indicated constraint (singular!) and re-computes the solution. More...
 
virtual bool solve (vector< constraint > &)
 Adds the indicated constraints (plural!) and re-computes the solution. More...
 
virtual void setup_rays ()
 clear the current set of rays and extracts the ones contained in lp
 
- Public Member Functions inherited from LP_Solver
virtual ~LP_Solver ()
 the default destructor does nothing (this is an abstract class)
 
virtual unsigned long get_number_of_rays ()
 Returns the number of rays defining the skeleton.
 
virtual const set< ray > & get_rays ()
 Returns the rays that define the skeleton.
 
virtual bool makes_consistent_constraint (const Monomial &t, const Monomial &u, bool show_data=false)
 tests for consistency of a constraint generated by two monomials.
 

Protected Attributes

PPL::NNC_Polyhedron * lp
 PPL problem interface.
 
unsigned m
 number of constraints
 
NVAR_TYPE n
 number of variables
 
RAYENT_TYPE * ray_data
 used to retrieve rays
 
PPL::Variable ** X
 array of variables
 
- Protected Attributes inherited from LP_Solver
set< rayrays
 

Static Protected Attributes

static unsigned instances = 0
 number of PPL instances
 

Member Function Documentation

◆ copy()

bool PPL_Solver::copy ( const LP_Solver )
virtual

performs a deep copy, similar to a copy constructor

Returns
true iff copying was successful
Warning
Do not mix-and-match solvers. At the present time, a PPL_Solver is not equipped to copy a GLPK_Solver, or vice versa. (This doesn't even make sense between exact and approximate solvers.)

Implements LP_Solver.

Definition at line 82 of file ppl_solver.cpp.

◆ solve() [1/2]

bool PPL_Solver::solve ( constraint )
virtual

Adds the indicated constraint (singular!) and re-computes the solution.

Returns
true if and only if the new constraint is consistent with the current constraints
Warning
Checking the return value is crucial! If the function returns false, you have an inconsistent system! While the present cone will remain consistent, the function will not roll back previous changes you have made, so if you want to iterate again, your best bet is to copy the skeleton, and try that copy. Accept the new constraints only if that copy succeeds, in which case, you might as well discard the original, and keep the copy.

Implements LP_Solver.

Definition at line 113 of file ppl_solver.cpp.

◆ solve() [2/2]

bool PPL_Solver::solve ( vector< constraint > &  )
virtual

Adds the indicated constraints (plural!) and re-computes the solution.

Returns
true if and only if the new constraints are consistent with the current constraints
Warning
Checking the return value is crucial! If the function returns false, you have an inconsistent system! While the present cone will remain consistent, the function will not roll back previous changes you have made, so if you want to iterate again, your best bet is to copy the skeleton, and try that copy. Accept the new constraints only if that copy succeeds, in which case, you might as well discard the original, and keep the copy.

Implements LP_Solver.

Definition at line 125 of file ppl_solver.cpp.

◆ ray

class ray

a ray defined by nonnegative coordinates \((a_1,\ldots,a_n)\)

Author
John Perry
Version
1.0
Date
October 2014

This class encapsulates a ray, one major part of the definition of a skeleton. Rays can be initialized to a particular set of coefficients, or to a particular axis (which is then translated into the corresponding coefficients).

A special feature is that a rays can track the constraints known to be active at the ray, allowing for more efficient computation in the double description method. Adding known constraints can be done with or without checking whether the constraint actually is active, so this should be done with care.

Definition at line 190 of file lp_solver.hpp.

Public Member Functions

Construction
 ray (NVAR_TYPE, long=-1)
 Creates a ray with the given number of variables, all set to 0. More...
 
 ray (NVAR_TYPE, const RAYENT_TYPE [])
 Creates a ray with the given number of variables, with coordinates set to the value of the array. More...
 
 ray (NVAR_TYPE, const EXP_TYPE [])
 Creates a ray with the given number of variables, with coordinates set to the value of the array. More...
 
 ray (const vector< RAYENT_TYPE > &)
 Creates a ray whose coordinates are given by the vector. More...
 
 ray (const ray &)
 Copies the coordinates of the other ray. More...
 
Destruction
 ~ray ()
 Deletes memory allocated by the constructor. More...
 
Basic properies
NVAR_TYPE get_dimension () const
 Returns the dimension of this ray.
 
RAYENT_TYPE operator[] (NVAR_TYPE index) const
 Returns the entry indicated. Numbering starts at 0.
 
const RAYENT_TYPE * weights () const
 Returns the weights.
 
const RAYENT_TYPE coordinate (NVAR_TYPE index)
 Synonym for []. I have no idea why I added this.
 
bool is_active_at (const constraint &hyperplane) const
 Returns true if and only if the hyperplane is active at this ray. More...
 
bool is_above (constraint &hyperplane)
 Returns true if and only if this ray is above the hyperplane. More...
 
bool is_below (constraint &hyperplane)
 Returns true if and only if this ray is below the hyperplane. More...
 
Computation
DOTPROD_TYPE obtain_dot_product (const constraint &) const
 Convenience function to compute dot product between ray and the given constraint. More...
 
Modification
void simplify_ray ()
 Simplifies the ray by dividing its components by the least common denominator.
 
rayoperator= (const ray &)
 Assignment operator; assigns the value of other to this. More...
 
void swap (ray &)
 Swap two rays of equal dimension by swapping their data, avoiding memory reallocation. More...
 

Friends

Comparison
bool operator== (const ray &, const ray &)
 Indicates whether the two rays are equal. More...
 
bool operator!= (const ray &, const ray &)
 Indicates whether the two rays are unequal. More...
 
bool operator!= (ray &r, ray &s)
 Indicates whether the two rays are unequal. More...
 
bool operator== (const ray &, const ray &)
 Returns true if and only if the coordinates of the two rays are equal. More...
 
bool operator< (const ray &, const ray &)
 Lexicographic comparison of rays. More...
 
I/O
ostream & operator<< (ostream &, const ray &)
 Output is of the form \((r_1, \ldots, r_n)\).
 

Constructor & Destructor Documentation

◆ ray() [1/5]

ray::ray ( NVAR_TYPE  dimension,
long  direction = -1 
)

Creates a ray with the given number of variables, all set to 0.

The optional second argument specifies a direction, and sets that coordinate to 1. In this case, there is no need to set the ray's known active constraints, as this is known and populated automatically.

Precondition
The dimension should be greater than zero. While the direction need not be specified… (see postcondition)
Postcondition
…the result when the direction is zero is a zero ray. If the direction is \( i \), then the result is the \(i\)th canonical vector.

Definition at line 132 of file lp_solver.cpp.

◆ ray() [2/5]

ray::ray ( NVAR_TYPE  dimension,
const RAYENT_TYPE  entries[] 
)

Creates a ray with the given number of variables, with coordinates set to the value of the array.

Precondition
the size of the array needs to be at least as long as the number of variables!

Definition at line 143 of file lp_solver.cpp.

◆ ray() [3/5]

ray::ray ( NVAR_TYPE  dimension,
const EXP_TYPE  entries[] 
)

Creates a ray with the given number of variables, with coordinates set to the value of the array.

Precondition
the size of the array needs to be at least as long as the number of variables!

Definition at line 152 of file lp_solver.cpp.

◆ ray() [4/5]

ray::ray ( const vector< RAYENT_TYPE > &  entries)

Creates a ray whose coordinates are given by the vector.

Postcondition
The dimension of this ray will equal the number of entries in the vector, and the values of their entries will be equal.

Definition at line 161 of file lp_solver.cpp.

◆ ray() [5/5]

ray::ray ( const ray old_ray)

Copies the coordinates of the other ray.

Allocates new memory, and copies the active constraints.

Definition at line 170 of file lp_solver.cpp.

◆ ~ray()

ray::~ray ( )

Deletes memory allocated by the constructor.

Currently, that means it deletes coords.

Definition at line 180 of file lp_solver.cpp.

Member Function Documentation

◆ is_above()

bool ray::is_above ( constraint hyperplane)
inline

Returns true if and only if this ray is above the hyperplane.

Parameters
hyperplanea constraint; we would like to know whether this is above it
Returns
true if and only if this is above constraint

Practically speaking, if the hyperplane is defined by the vector \( \mathbf c \) and the ray is defined by \( \mathbf r \) , this function returns true if and only if \( c\cdot r > 0 \).

Definition at line 293 of file lp_solver.hpp.

◆ is_active_at()

bool ray::is_active_at ( const constraint hyperplane) const
inline

Returns true if and only if the hyperplane is active at this ray.

Parameters
hyperplanea constraint; we would like to know whether this lies on it
Returns
true if and only if this lies on constraint

Practically speaking, if the hyperplane is defined by the vector \( \mathbf c \) and the ray is defined by \( \mathbf r \) , this function returns true if and only if \( c\cdot r = 0 \).

Definition at line 279 of file lp_solver.hpp.

◆ is_below()

bool ray::is_below ( constraint hyperplane)
inline

Returns true if and only if this ray is below the hyperplane.

Parameters
hyperplanea constraint; we would like to know whether this is below it
Returns
true if and only if this is below constraint

Practically speaking, if the hyperplane is defined by the vector \( \mathbf c \) and the ray is defined by \( \mathbf r \) , this function returns true if and only if \( c\cdot r < 0 \).

Definition at line 307 of file lp_solver.hpp.

◆ obtain_dot_product()

DOTPROD_TYPE ray::obtain_dot_product ( const constraint hyperplane) const

Convenience function to compute dot product between ray and the given constraint.

Returns
the dot product of this and constraint
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 212 of file lp_solver.cpp.

◆ operator=()

ray & ray::operator= ( const ray other)

Assignment operator; assigns the value of other to this.

Returns
this
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 330 of file lp_solver.cpp.

◆ swap()

void ray::swap ( ray other)

Swap two rays of equal dimension by swapping their data, avoiding memory reallocation.

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

Definition at line 350 of file lp_solver.cpp.

Friends And Related Function Documentation

◆ operator!= [1/2]

bool operator!= ( const ray r1,
const ray r2 
)
friend

Indicates whether the two rays are unequal.

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 312 of file lp_solver.cpp.

◆ operator!= [2/2]

bool operator!= ( ray r,
ray s 
)
friend

Indicates whether the two rays are unequal.

Parameters
ra ray
sa ray
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 337 of file lp_solver.hpp.

◆ operator<

bool operator< ( const ray first_ray,
const ray second_ray 
)
friend

Lexicographic comparison of rays.

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

Definition at line 361 of file lp_solver.cpp.

◆ operator== [1/2]

bool operator== ( const ray r1,
const ray r2 
)
friend

Indicates whether the two rays are equal.

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 304 of file lp_solver.cpp.

◆ operator== [2/2]

bool operator== ( const ray r1,
const ray r2 
)
friend

Returns true if and only if the coordinates of the two rays are equal.

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 304 of file lp_solver.cpp.

◆ skeleton

class skeleton

skeleton of a polyhedral cone, with methods allowing definition and refinement

Author
John Perry
Version
1.1
Date
October 2014

This class implements the Double Description Method, an iterative algorithm for computing the skeleton of a cone. This particular version uses Zolotykh's GraphAdj criterion [11]. The iterative nature means that the cone can be updated with new constraints, passed to that algorithm, and the skeleton will be automatically recomputed.

Definition at line 178 of file skeleton.hpp.

Inheritance diagram for skeleton:
LP_Solver

Public Member Functions

Construction
void common_initialization (NVAR_TYPE)
 Initialization common to all constructors.
 
 skeleton (NVAR_TYPE)
 Constructs a basic skeleton in the given number of dimensions, initialized to the axes, or (equivalently) to the set of constraints \( x_i \geq 0 \). More...
 
 skeleton (NVAR_TYPE, vector< constraint > &)
 Constructs a skeleton described by the given system of constraints. More...
 
 skeleton (skeleton &)
 Performs a deep copy of other.
 
virtual bool copy (const LP_Solver *)
 performs a deep copy, similar to a copy constructor More...
 
Destruction
virtual ~skeleton ()
 Currently does nothing the compiler wouldn't do.
 
Basic properties
NVAR_TYPE get_dimension () const
 Returns the dimension of the underlying vector space.
 
unsigned long get_number_of_edges ()
 Returns the number of edges defining the skeleton.
 
set< edgeget_edges ()
 Returns the edges that define the skeleton.
 
unsigned long get_number_of_constraints ()
 Returns the number of constraints defining the skeleton.
 
const vector< constraint > & get_constraints ()
 Returns the constraints that define the skeleton.
 
constraint get_constraint (int index)
 Returns the indicated constraint. Numbering starts at 0.
 
Computation
void which_constraints_active_at (const ray &u, bool *result) const
 returns the set of constraints in the skeleton active at u
 
bool is_consistent (const constraint &c) const
 tests for consistency of a potentially new constraint.
 
Modification
virtual bool solve (vector< constraint > &)
 Adds the indicated constraints (plural!) and re-computes the skeleton. More...
 
virtual bool solve (constraint &)
 Adds the indicated constraint (singular!) and re-computes the skeleton. More...
 
set< edgeadjacencies_by_graphs (set< ray >)
 Re-computes the edges in the skeleton using Zolotych's GraphAdj algorithm and returns the result.
 
skeletonoperator= (const skeleton &)
 Assignment operator; empties current set & copies from other.
 
- Public Member Functions inherited from LP_Solver
virtual ~LP_Solver ()
 the default destructor does nothing (this is an abstract class)
 
virtual unsigned long get_number_of_rays ()
 Returns the number of rays defining the skeleton.
 
virtual const set< ray > & get_rays ()
 Returns the rays that define the skeleton.
 
virtual bool makes_consistent_constraint (const Monomial &t, const Monomial &u, bool show_data=false)
 tests for consistency of a constraint generated by two monomials.
 

Friends

I/O
ostream & operator<< (ostream &, const skeleton &)
 prints out the constraints, then the rays, then the edges.
 

Additional Inherited Members

- Protected Attributes inherited from LP_Solver
set< rayrays
 

Constructor & Destructor Documentation

◆ skeleton() [1/2]

skeleton::skeleton ( NVAR_TYPE  dimension)

Constructs a basic skeleton in the given number of dimensions, initialized to the axes, or (equivalently) to the set of constraints \( x_i \geq 0 \).

The rays are informed of their active constraints.

Precondition
the argument should be at least two
Postcondition
the skeleton of the positive orthant

Definition at line 119 of file skeleton.cpp.

◆ skeleton() [2/2]

skeleton::skeleton ( NVAR_TYPE  dimension,
vector< constraint > &  constraints 
)

Constructs a skeleton described by the given system of constraints.

Practically speaking, it first generates a basic skeleton, then iterates on the given constraints.

Precondition
u.size() == v.size() for all u, v in the vector
Postcondition
unless the system supplied was inconsistent, a valid skeleton of the corresponding polyhedral cone
Warning
Your program will almost certainly fail if you do not respect the precondition.

Definition at line 124 of file skeleton.cpp.

Member Function Documentation

◆ copy()

bool skeleton::copy ( const LP_Solver )
virtual

performs a deep copy, similar to a copy constructor

Returns
true iff copying was successful
Warning
Do not mix-and-match solvers. At the present time, a PPL_Solver is not equipped to copy a GLPK_Solver, or vice versa. (This doesn't even make sense between exact and approximate solvers.)

Implements LP_Solver.

Definition at line 140 of file skeleton.cpp.

◆ solve() [1/2]

bool skeleton::solve ( vector< constraint > &  new_constraints)
virtual

Adds the indicated constraints (plural!) and re-computes the skeleton.

Returns
true if and only if the new constraints are consistent with the current constraints
Warning
Checking the return value is crucial! If the function returns false, you have an inconsistent system! While the present cone will remain consistent, the function will not roll back previous changes you have made, so if you want to iterate again, your best bet is to copy the skeleton, and try that copy. Accept the new constraints only if that copy succeeds, in which case, you might as well discard the original, and keep the copy.

Implements LP_Solver.

Definition at line 270 of file skeleton.cpp.

◆ solve() [2/2]

bool skeleton::solve ( constraint constraint)
virtual

Adds the indicated constraint (singular!) and re-computes the skeleton.

Returns
true if and only if the new constraint is consistent with the current constraints
Warning
Checking the return value is crucial! If the function returns false, you have an inconsistent system! While the present cone will remain consistent, the function will not roll back previous changes you have made, so if you want to iterate again, your best bet is to copy the skeleton, and try that copy. Accept the new constraints only if that copy succeeds, in which case, you might as well discard the original, and keep the copy.

Implements LP_Solver.

Definition at line 162 of file skeleton.cpp.

Function Documentation

◆ intersections_of_active_constraints()

vector<bool> intersections_of_active_constraints ( bool *  ,
bool *  ,
unsigned   
)
Returns
the intersection between the given sets of constraints.

◆ is_first_subset_of_second()

bool is_first_subset_of_second ( bool *  ,
bool *  ,
unsigned   
)
Returns
true if and only if the first set is a subset of the second.

Definition at line 330 of file skeleton.cpp.

◆ number_of_common_constraints()

int number_of_common_constraints ( bool *  ,
bool *  ,
unsigned   
)
Returns
the number of constraints common to both sets.

Definition at line 297 of file skeleton.cpp.

◆ operator*() [1/4]

ray operator* ( RAYENT_TYPE  ,
ray  
)

Multiply every coordinate in the given ray by the given scalar.

Returns
a copy of the ray, scaled by the requesed amount
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 222 of file lp_solver.cpp.

◆ operator*() [2/4]

RAYENT_TYPE operator* ( const ray ,
const ray  
)

Compute the dot product on the rays.

Returns
the dot product of the rays
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 235 of file lp_solver.cpp.

◆ operator*() [3/4]

DOTPROD_TYPE operator* ( const ray r,
const constraint c 
)
inline

Compute the dot product between the ray and the constraint.

Parameters
ra ray
ca constraint
Returns
the dot product of the ray and the constraint
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 465 of file lp_solver.hpp.

◆ operator*() [4/4]

DOTPROD_TYPE operator* ( constraint c,
ray r 
)
inline

Compute the dot product between the ray and the constraint.

Parameters
ca constraint
ra ray
Returns
the dot product of the ray and the constraint
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 477 of file lp_solver.hpp.

◆ operator+()

ray operator+ ( ray ,
ray  
)

Add the two rays.

Returns
the sum of the two rays
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 259 of file lp_solver.cpp.

◆ operator-()

ray operator- ( const ray ,
const ray  
)

Subtract the two rays.

Returns
the difference of the two rays
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 270 of file lp_solver.cpp.

◆ ray_sum()

ray ray_sum ( const set< ray > &  )

Add all the rays in a set.

Returns
a ray that is the sum of all rays in the given set
Warning
This is unsafe when dimension is not the same. It does not check, since the assumption is that you know what you're doing.

Definition at line 281 of file lp_solver.cpp.

◆ union_of_edge_sets()

set<edge> union_of_edge_sets ( const set< edge > &  ,
const set< edge > &   
)
Returns
union of the specified edge sets

Definition at line 342 of file skeleton.cpp.