13 Parma_Polyhedra_Library::C_Polyhedron
mPPLpoly;
26 Parma_Polyhedra_Library::C_Polyhedron& ppoly = pdata->
mPPLpoly;
27 ppoly.add_space_dimensions_and_embed(fpoly.
Dimension());
28 for(
Idx i = 0; i < fpoly.
Size(); i++) {
29 Parma_Polyhedra_Library::Linear_Expression e;
30 for(
int j = 0; j < fpoly.
Dimension(); j++) {
31 Parma_Polyhedra_Library::Variable xj(j);
32 e += fpoly.
A().
At(i,j) * xj;
34 ppoly.add_constraint(e <= fpoly.
B().
At(i));
41 std::stringstream errstr;
42 errstr <<
"Internal Computaional Error (Convert to PPL).";
43 throw Exception(
"UserData", errstr.str(), 700);
57 Parma_Polyhedra_Library::C_Polyhedron& ppoly=
UserData(fpoly);
58 Parma_Polyhedra_Library::Constraint_System consys=ppoly.minimized_constraints();
61 if(ppoly.space_dimension()!= ((
unsigned int) fpoly.
Dimension())) {
62 std::stringstream errstr;
63 errstr <<
"Internal Computaional Error (Conversion from PPL, dimension mismatch).";
64 throw Exception(
"PolyFinalise", errstr.str(), 700);
73 if(consys.has_strict_inequalities()){
74 std::stringstream errstr;
75 errstr <<
"Internal Computaional Error (Conversion from PPL, cannot hanlde strict inequalities).";
76 throw Exception(
"PolyFinalise", errstr.str(), 700);
79 Parma_Polyhedra_Library::Constraint_System::const_iterator cit = consys.begin();
80 Parma_Polyhedra_Library::Constraint_System::const_iterator cit_end = consys.end();
82 for(;cit!=cit_end;++cit) { ++count;
if(cit->is_equality()) ++count; }
83 Matrix A(count,ppoly.space_dimension());
86 for(cit = consys.begin();cit!=cit_end;++cit) {
87 if(cit->is_nonstrict_inequality()) {
88 for(
unsigned int j = 0; j < ppoly.space_dimension(); j++) {
89 Parma_Polyhedra_Library::Variable xj(j);
90 A.
At(i,j,-1* cit->coefficient(xj).get_d());
92 B.
At(i,cit->inhomogeneous_term().get_d());
95 if(cit->is_equality()) {
96 for(
unsigned int j = 0; j < ppoly.space_dimension(); j++) {
97 Parma_Polyhedra_Library::Variable xj(j);
98 A.
At(i,j,-1*cit->coefficient(xj).get_d());
99 A.
At(i+1,j,cit->coefficient(xj).get_d());
101 B.
At(i,cit->inhomogeneous_term().get_d());
102 B.
At(i+1,-1* cit->inhomogeneous_term().get_d());
124 Parma_Polyhedra_Library::C_Polyhedron& prelation = rdata->
mPPLrelation;
125 prelation.add_space_dimensions_and_embed(2*dim);
126 for(
Idx i = 0; i < frelation.
Size(); i++) {
127 Parma_Polyhedra_Library::Linear_Expression e;
128 for(
int j = 0; j < dim; j++) {
129 Parma_Polyhedra_Library::Variable xj(j);
130 e += frelation.
A1().
At(i,j) * xj;
132 for(
int j = 0; j < dim; j++) {
133 Parma_Polyhedra_Library::Variable xjprime(dim+j);
134 e += frelation.
A2().
At(i,j) * xjprime;
136 prelation.add_constraint(e <= frelation.
B().
At(i));
142 std::stringstream errstr;
143 errstr <<
"Internal Computaional Error (Convert to PPL).";
144 throw Exception(
"UserData", errstr.str(), 700);
155 Parma_Polyhedra_Library::C_Polyhedron& ppoly=
UserData(fpoly);
156 Parma_Polyhedra_Library::Generator_System gensys = ppoly.minimized_generators();
177 Parma_Polyhedra_Library::C_Polyhedron& ppoly=
UserData(poly);
178 Parma_Polyhedra_Library::C_Polyhedron& pres=
UserData(res);
179 pres.intersection_assign(ppoly);
187 Parma_Polyhedra_Library::C_Polyhedron& ppoly=
UserData(poly);
188 return ppoly.is_empty();
193 Parma_Polyhedra_Library::C_Polyhedron& ppoly=
UserData(poly);
194 Parma_Polyhedra_Library::C_Polyhedron& opoly=
UserData(other);
195 return opoly.contains(ppoly);
202 Parma_Polyhedra_Library::C_Polyhedron ppoly(2);
203 Parma_Polyhedra_Library::Variable x1(0);
204 Parma_Polyhedra_Library::Variable x2(1);
205 ppoly.add_constraint(x2 <= x1 + 2);
206 ppoly.add_constraint(x2 >= x1 );
207 ppoly.add_constraint(x2 <= -x1 + 2);
208 ppoly.add_constraint(x2 >= -x1 );
209 Parma_Polyhedra_Library::Generator_System gensys = ppoly.minimized_generators();
212 Parma_Polyhedra_Library::C_Polyhedron preset = ppoly;
213 preset.add_space_dimensions_and_embed(4);
214 Parma_Polyhedra_Library::Variable z1(2);
215 Parma_Polyhedra_Library::Variable z2(3);
216 preset.add_constraint(z1 - 2*x1 <= 2 +100);
217 preset.add_constraint(-z1 + 2*x1 <= 2 - 100);
218 preset.add_constraint(z2 - 2*x2 <= 2 - 2 );
219 preset.add_constraint(-z2 + 2*x2 <= 2 + 2 );
221 preset.remove_space_dimensions(Parma_Polyhedra_Library::Variables_Set(x1,x2));
222 preset.remove_higher_space_dimensions(2);
223 gensys = preset.minimized_generators();
231 Parma_Polyhedra_Library::C_Polyhedron& preset=
UserData(reset);
232 Parma_Polyhedra_Library::C_Polyhedron& ppoly=
UserData(poly);
234 unsigned int dim=ppoly.space_dimension();
235 if(preset.space_dimension() != 2 * dim) {
236 std::stringstream errstr;
237 errstr <<
"Internal Computaional Error (dimension mismatch).";
238 throw Exception(
"PolyLinearRelation", errstr.str(), 700);
241 ppoly.add_space_dimensions_and_embed(dim);
242 ppoly.add_constraints(preset.constraints());
244 Parma_Polyhedra_Library::Variables_Set xvars;
245 for(
unsigned int j=0; j<dim;++j) xvars.insert(Parma_Polyhedra_Library::Variable(j));
246 ppoly.remove_space_dimensions(xvars);
247 ppoly.remove_higher_space_dimensions(dim);
252 Parma_Polyhedra_Library::C_Polyhedron& prate=
UserData(rate);
253 Parma_Polyhedra_Library::C_Polyhedron& ppoly=
UserData(poly);
254 if(prate.is_empty()) {
257 ppoly.time_elapse_assign(prate);
#define FD_WARN(message)
Debug: always report warnings.
const Vector & B(void) const
Get B vector.
Idx Size(void) const
Get size.
const Matrix & A2(void) const
Get A2 matrix.
bool Identity(void) const
Test for data format.
int Dimension(void) const
Get dimension.
void UserData(Type *data) const
Set user data.
const Matrix & A1(void) const
Get A1 matrix.
const Scalar::Type & At(int i, int j) const
Get entry.
Idx Size(void) const
Get size.
void UserData(Type *data) const
Set user data.
const Matrix & A(void) const
Get A matrix.
int Dimension(void) const
Get dimension.
const Vector & B(void) const
Get B vector.
Base class of all libFAUDES objects that participate in the run-time interface.
virtual Type & Assign(const Type &rSrc)
Assign configuration data from other object.
const Scalar::Type & At(int i) const
Get entry.
user data type for polyhedra
Parma_Polyhedra_Library::C_Polyhedron mPPLpoly
user data type for reset relation (fake faudes type)
Parma_Polyhedra_Library::C_Polyhedron mPPLrelation
void PolyFinalise(const Polyhedron &fpoly)
convert PPL polyhedron back to faudes data structures; this is required if we manipulate a polyhedron...
bool PolyInclusion(const Polyhedron &poly, const Polyhedron &other)
inclusion
void PolyTimeElapse(const Polyhedron &rate, Polyhedron &poly)
time elapse
void PolyDWrite(const Polyhedron &fpoly)
poly dump
void PolyCopy(const Polyhedron &src, Polyhedron &dst)
copy method
void PolyIntersection(const Polyhedron &poly, Polyhedron &res)
intersection
bool PolyIsEmpty(const Polyhedron &poly)
test emptyness
void PolyLinearRelation(const LinearRelation &reset, Polyhedron &poly)
apply reset relation A'x' + Ax <= B
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)
Parma_Polyhedra_Library::C_Polyhedron & UserData(const Polyhedron &fpoly)
convert a faudes style polyhedron "A x <= B" to a PPL polyhedron, and keep the conversion result in t...
void PolyScratch(void)
scratch