
Dear Sir/Madam
I see that there is very little example programs for beginners to start coding using PPL library, It would be of great help if you can kindly help me in this direction.
I managed to write a simple code to create a PPL NNC_Polyhedron object named myPoly and assigned linear constraints (values of the form Ax <= b) where A is the coefficient matrix (boost library) and vector b is the bound values of the linear constraints.
PPL_Polyhedron(math::matrix<double> A, std::vector<double> b, int sgn){
int noOfCons = A.size1();
int dim = A.size2(); PPL::NNC_Polyhedron myPoly = PPL:: NNC_Polyhedron(dim); for(int j=0;j<noOfCons;j++) { PPL :: Linear_Expression expr; PPL :: Linear_Expression ex; for (int i=0;i<dim;i++) { PPL :: Variable var(i); PPL :: Linear_Expression ep=var; ep.set_coefficient(var,A(j,i)); if(i==0) expr=ep; else { PPL :: Linear_Expression e(expr+ep); expr=e; } } if(sgn==1){ //sgn==1 for <= PPL :: Constraint c= operator<=(expr, b[j]); myPoly.add_constraint(c); } else if(sgn==2){ //sgn==2 for >= PPL :: Constraint c= operator>=(expr, b[j]); myPoly.add_constraint(c); } else if(sgn==0){ //sgn==0 for = PPL :: Constraint c= operator==(expr, b[j]); myPoly.add_constraint(c); } } }
I see that after this I was able to perform some of the operation such as *contains, poly_hull_assign, etc.* However, I observe that this works only for *INTEGER* coefficients values. *But it is incorrect when the supplied A and b values are of type double.* Could you please direct what am I missing? Or am I going on the wrong direction in this creation?
I would appreciates for any help in this direction.
Thanking you Regards
participants (1)
-
Amit Gurung