20 #include "ppl_solver.hpp" 22 #ifndef __PPL_SOLVER_CPP 23 #define __PPL_SOLVER_CPP 26 using PPL::Generator_System;
27 using PPL::Linear_Expression;
28 using PPL::Polyhedron;
29 using PPL::NNC_Polyhedron;
30 using PPL::Constraint_System;
33 typedef PPL::Constraint PPL_Constraint;
34 typedef PPL::Generator PPL_Generator;
40 if (not
lp->is_empty()) {
41 const Generator_System & G =
lp->generators();
42 for (
const PPL_Generator & g : G) {
44 for (NVAR_TYPE i = 0; i <
n; ++i)
45 ray_data[i] = g.coefficient(*(
X[i])).get_ui();
56 Parma_Polyhedra_Library::initialize();
58 lp =
new NNC_Polyhedron(
n);
59 X = (Variable **)malloc(
sizeof(Variable *)*
n);
60 for (NVAR_TYPE i = 0; i <
n; ++i)
61 X[i] =
new Variable(i);
63 for (NVAR_TYPE i = 0; i <
n; ++i) {
64 cs.insert(*(
X[i]) >= 0);
66 lp->refine_with_constraints(cs);
75 lp =
new NNC_Polyhedron(*(other.
lp));
76 X = (Variable **)malloc(
sizeof(Variable *)*
n);
77 for (NVAR_TYPE i = 0; i <
n; ++i)
78 X[i] =
new Variable(i);
84 if (other !=
nullptr) {
93 lp =
new NNC_Polyhedron(*(other->
lp));
99 return (other !=
nullptr);
102 PPL_Solver::~PPL_Solver() {
105 for (NVAR_TYPE i = 0; i <
n; ++i)
110 Parma_Polyhedra_Library::finalize();
114 Linear_Expression ineq;
115 for (NVAR_TYPE i = 0; i <
n; ++i) {
117 ineq += Linear_Expression(c[i]*(*
X[i]));
119 PPL_Constraint pc(ineq >= 0);
120 lp->refine_with_constraint(pc);
122 return (
rays.size() > 0);
126 Constraint_System cs;
128 Linear_Expression ineq;
129 for (NVAR_TYPE i = 0; i <
n; ++i) {
131 ineq += Linear_Expression(c[i]*(*
X[i]));
133 PPL_Constraint pc(ineq >= 0);
136 lp->refine_with_constraints(cs);
138 return (
rays.size() > 0);
virtual bool solve(constraint &)
Adds the indicated constraint (singular!) and re-computes the solution.
approximate skeleton of a polyhedral cone, using PPL linear solver
NVAR_TYPE n
number of variables
exact or approximate polyhedral cone solution, with methods allowing definition and refinement ...
RAYENT_TYPE * ray_data
used to retrieve rays
unsigned m
number of constraints
PPL_Solver(NVAR_TYPE n)
initializes solver for variables
PPL::Variable ** X
array of variables
static unsigned instances
number of PPL instances
virtual bool copy(const LP_Solver *)
performs a deep copy, similar to a copy constructor
PPL::NNC_Polyhedron * lp
PPL problem interface.
virtual void setup_rays()
clear the current set of rays and extracts the ones contained in lp