1 #ifndef __LP_SOLVER_HPP_ 2 #define __LP_SOLVER_HPP_ 26 using std::ostream;
using std::cout;
using std::endl;
28 #include "system_constants.hpp" 30 #include "monomial.hpp" 113 inline CONSTR_TYPE
operator[](NVAR_TYPE index)
const {
return coefficients[index]; };
116 inline const CONSTR_TYPE *
coeffs()
const {
return coefficients; }
169 CONSTR_TYPE * coefficients;
209 ray(NVAR_TYPE,
long = -1);
217 ray(NVAR_TYPE,
const RAYENT_TYPE []);
225 ray(NVAR_TYPE,
const EXP_TYPE []);
232 ray(
const vector<RAYENT_TYPE> &);
262 inline RAYENT_TYPE
operator[](NVAR_TYPE index)
const {
return coords[index]; };
265 inline const RAYENT_TYPE *
weights()
const {
return coords; };
268 inline const RAYENT_TYPE
coordinate(NVAR_TYPE index) {
return coords[index]; };
281 return 0 == obtain_dot_product(hyperplane);
295 return 0 < obtain_dot_product(hyperplane);
309 return 0 > obtain_dot_product(hyperplane);
364 DOTPROD_TYPE obtain_dot_product(
const constraint &)
const;
383 ray & operator=(
const ray &);
407 RAYENT_TYPE * coords;
515 virtual bool copy(
const LP_Solver *) = 0;
555 virtual bool solve(vector<constraint> &) = 0;
567 virtual NVAR_TYPE get_dimension()
const = 0;
571 virtual const set<ray> & get_rays();
572 virtual unsigned long get_number_of_constraints() = 0;
581 bool inconsistent =
true;
583 auto riter = rays.begin();
584 inconsistent and riter != rays.end();
588 for (
int i = 0; i < riter->get_dimension(); ++i)
591 inconsistent =
false;
594 if (!inconsistent) cout << *riter << endl;
597 if (show_data) cout << endl;
598 return not inconsistent;
ray ray_sum(const set< ray > &)
Add all the rays in a set.
ray operator-(const ray &, const ray &)
Subtract the two rays.
friend bool operator!=(ray &r, ray &s)
Indicates whether the two rays are unequal.
RAYENT_TYPE operator[](NVAR_TYPE index) const
Returns the entry indicated. Numbering starts at 0.
ray operator+(ray &, ray &)
Add the two rays.
friend bool operator!=(const constraint &a, const constraint &b)
check for constraint inequality
friend bool operator<(const constraint &a, const constraint &b)
Lexicographic comparison of constraints.
~constraint()
Deletes memory allocated by the constructor.
friend ostream & operator<<(ostream &, const constraint &)
print a representation of the constraint to the stream
virtual ~LP_Solver()
the default destructor does nothing (this is an abstract class)
ray operator*(RAYENT_TYPE, ray &)
Multiply every coordinate in the given ray by the given scalar.
constraint(NVAR_TYPE, CONSTR_TYPE [])
Initialize constraint to the given coefficients.
DOTPROD_TYPE obtain_dot_product(const constraint &) const
Convenience function to compute dot product between ray and the given constraint. ...
NVAR_TYPE get_number_of_variables() const
Returns the number of variables in the constraint.
virtual unsigned long get_number_of_rays()
Returns the number of rays defining the skeleton.
const RAYENT_TYPE coordinate(NVAR_TYPE index)
Synonym for []. I have no idea why I added this.
bool is_above(constraint &hyperplane)
Returns true if and only if this ray is above the hyperplane.
exact or approximate polyhedral cone solution, with methods allowing definition and refinement ...
friend bool operator==(const constraint &a, const constraint &b)
check for constraint equality
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.
Implementation of monomials.
const CONSTR_TYPE * coeffs() const
Returns the coefficients that determine this constraints.
NVAR_TYPE get_dimension() const
Returns the dimension of this ray.
DEG_TYPE degree(NVAR_TYPE i) const
Degree of th variable.
CONSTR_TYPE operator[](NVAR_TYPE index) const
Returns the coefficient indicated. Numbering starts at 0.
bool is_below(constraint &hyperplane)
Returns true if and only if this ray is below the hyperplane.
const RAYENT_TYPE * weights() const
Returns the weights.
bool is_active_at(const constraint &hyperplane) const
Returns true if and only if the hyperplane is active at this ray.
a ray defined by nonnegative coordinates