Re: [PPL-devel] Another question
 
            Dear PPL developers,
I forward the message that I sent to Roberto. Since he is traveling, maybe some of you can help us...
Thanks a lot
Best Regards
Ezio
On Thu, May 3, 2012 at 4:42 PM, Ezio Bartocci ezio.bartocci@gmail.com wrote:
Dear Roberto,
I have another question. This time in English so that also Radu and Gregory can read. I have the following points, describing a polytope:
1 0.005 0.007883 0.9967750 0.004769 0.007988 1 0.000250 0.007883 0.9967750 1.900e-05 0.007988 1 0.005000 0.004225 0.9967750 0.004769 0.004331 1 0.000250 0.004225 0.9967750 1.900e-05 0.004331 1 0.0050000 0.007883 0.4194590 0.0047690 0.007988 1 0.0002500 0.007883 0.4194590 1.9000e-05 0.007988 1 0.0050000 0.004225 0.4194590 0.0047690 0.004331 1 0.0002500 0.004225 0.4194590 1.90000e-05 0.004331
From this points stored in a matrix P with rows_P = 16 and cols_P = 3.
I call this function that I developed to generate a C_Polyhedron (or Polytope), that uses
add_generator
as you suggested and assign to P the result that is private member of the class ppl_wrap
ppl_wrap::ppl_wrap (double * Points, int rows_P, int cols_P):rows_P(rows_P), cols_P(cols_P) {
int debug = 1; int i, j, k;
// Convert the standard double representation to a much // accurate representation vector<mpf_class> *P1_row = double2mpzclass(Points, &rows_P, &cols_P); vector<vector<mpf_class> > *P1 = vec2mat(P1_row, &rows_P, &cols_P); vector<mpf_class> single_point;
list<Variable> VarList; list<Variable>::iterator it; Linear_Expression lin_exp[rows_P]; if (debug) cout << "Cols num: " << cols_P << "\n";
for(i=0; i< cols_P; i++) // create a list of n_col_C "Variable" objects VarList.push_back(Variable(i));
C_Polyhedron ph (cols_P, EMPTY);
if (debug) cout << "Rows num: " << rows_P << "\n"; for (j = 0; j < rows_P; j++) { if (debug) cout << " j = " << j << "\n"; single_point.clear();
/*Create linear expression for expressing the point*/ if (debug) cout << " k = "; for (k = 0; k < cols_P; k++){ // pick the needed row of matrix C if (debug) cout << "(" << k << ") " << (*P1)[k][j] << " "; single_point.push_back((*P1)[k][j]);
} if (debug) cout << ";\n";
int m; for ( it=VarList.begin() ; it != VarList.end(); it++ ) // creates linear expression "lin_exp_temp" by using the iterator of the Variable-List { m = it->id(); if (debug) cout << " m = " << m <<"\n"; lin_exp[j]+=single_point[m]*(*it); }
ph.add_generator(point(lin_exp[j])); } P = ph; }
After obtaining a polytope I need to have the following representation to store the polytope back in matlab C * x <= d.
Now as I wrote in a previous email I saw that with:
Constraint_System ConSys_P; ConSys_P = P.constraints();
we can actually obtain the representation: C * x >= d
but if I print the constraints:
ConSys_P.print();
-A + C >= 0, -C >= -1, A >= 0, B >= 0, -B >= -1
This does not seem to match with the points and it seems an over approximation. I would expected constraints more tight constraints.
Why is like that ?
Thanks,
Best
Ezio
-- Dr. Ezio Bartocci, Assistant Professor Dependable Systems Group Department of Computer Engineering Faculty of informatics TU Wien, Vienna University of Technology, Austria Treitlstraße 3, 1040 Vienna, Austria E-Mail: ezio.bartocci@tuwien.ac.at Phone: +43 (1) 58801 - 18210 Webiste: http://www.eziobartocci.com
 
            On 05/03/2012 06:13 PM, Ezio Bartocci wrote:
Dear PPL developers,
I forward the message that I sent to Roberto. Since he istraveling, maybe some of you can help us...
Thanks a lot
Best Regards
Ezio
Hello Ezio.
I suspect the main problem is in the right hand side of the line:
lin_exp[j]+=single_point[m]*(*it);
Here single_point[m] has type mpf_class. However, the PPL only supports *integral* coefficients.
When a generator has non-integral coordinates, it can be expressed using integral coefficients and providing a common divisor.
For instance, if you need to specify a point in 3d having coordinates (1.5, 0.5, 2.5) you can express it as (3, 1, 5) / 2
In C++, something like the following:
Variable A(0); Variable B(1); Variable C(2); Linear_Expression le = 3*A + B + 5*C; ph.add_generator(point(le, 2));
where the second argument to `point' is the divisor (that gets applied to all the coefficients of `le').
Hope this helps.
Regards, Enea.
 
            so for integral you mean integers ? So it mean that accept only rational number in the set of Q ?
On Thu, May 3, 2012 at 11:10 PM, Enea Zaffanella zaffanella@cs.unipr.it wrote:
On 05/03/2012 06:13 PM, Ezio Bartocci wrote:
Dear PPL developers,
I forward the message that I sent to Roberto. Since he is traveling, maybe some of you can help us...
Thanks a lot
Best Regards
Ezio
Hello Ezio.
I suspect the main problem is in the right hand side of the line:
lin_exp[j]+=single_point[m]*(*it);
Here single_point[m] has type mpf_class. However, the PPL only supports *integral* coefficients.
When a generator has non-integral coordinates, it can be expressed using integral coefficients and providing a common divisor.
For instance, if you need to specify a point in 3d having coordinates (1.5, 0.5, 2.5) you can express it as (3, 1, 5) / 2
In C++, something like the following:
Variable A(0); Variable B(1); Variable C(2); Linear_Expression le = 3*A + B + 5*C; ph.add_generator(point(le, 2));
where the second argument to `point' is the divisor (that gets applied to all the coefficients of `le').
Hope this helps.
Regards, Enea.
 
            Can i use the mpz_class instead of mpf_class for an arbitrary integer precision ?
On Fri, May 4, 2012 at 5:25 PM, Ezio Bartocci ezio.bartocci@gmail.com wrote:
so for integral you mean integers ? So it mean that accept only rational number in the set of Q ?
On Thu, May 3, 2012 at 11:10 PM, Enea Zaffanella zaffanella@cs.unipr.it wrote:
On 05/03/2012 06:13 PM, Ezio Bartocci wrote:
Dear PPL developers,
I forward the message that I sent to Roberto. Since he is traveling, maybe some of you can help us...
Thanks a lot
Best Regards
Ezio
Hello Ezio.
I suspect the main problem is in the right hand side of the line:
lin_exp[j]+=single_point[m]*(*it);
Here single_point[m] has type mpf_class. However, the PPL only supports *integral* coefficients.
When a generator has non-integral coordinates, it can be expressed using integral coefficients and providing a common divisor.
For instance, if you need to specify a point in 3d having coordinates (1.5, 0.5, 2.5) you can express it as (3, 1, 5) / 2
In C++, something like the following:
Variable A(0); Variable B(1); Variable C(2); Linear_Expression le = 3*A + B + 5*C; ph.add_generator(point(le, 2));
where the second argument to `point' is the divisor (that gets applied to all the coefficients of `le').
Hope this helps.
Regards, Enea.
-- Dr. Ezio Bartocci, Assistant Professor Dependable Systems Group Department of Computer Engineering Faculty of informatics TU Wien, Vienna University of Technology, Austria Treitlstraße 3, 1040 Vienna, Austria E-Mail: ezio.bartocci@tuwien.ac.at Phone: +43 (1) 58801 - 18210 Webiste: http://www.eziobartocci.com
 
            On 05/04/2012 05:31 PM, Ezio Bartocci wrote:
Can i use the mpz_class instead of mpf_class for an arbitrary integer precision ?
Yes.
When using the default configuration, the type of the constraint/generator coefficients of the PPL is exactly mpz_class (we have a typedef named "Coefficient").
Enea.
 
            Thanks I'll try
On Fri, May 4, 2012 at 6:17 PM, Enea Zaffanella zaffanella@cs.unipr.it wrote:
On 05/04/2012 05:31 PM, Ezio Bartocci wrote:
Can i use the mpz_class instead of mpf_class for an arbitrary integer precision ?
Yes.
When using the default configuration, the type of the constraint/generator coefficients of the PPL is exactly mpz_class (we have a typedef named "Coefficient").
Enea.
 
            On 05/04/2012 05:25 PM, Ezio Bartocci wrote:
so for integral you mean integers ?
Yes.
So it mean that accept only rational number in the set of Q ?
Yes. There is no way to specify a polyhedron having a vertex with irrational coordinates.
Enea.
On Thu, May 3, 2012 at 11:10 PM, Enea Zaffanellazaffanella@cs.unipr.it wrote:
On 05/03/2012 06:13 PM, Ezio Bartocci wrote:
Dear PPL developers,
I forward the message that I sent to Roberto. Since he istraveling, maybe some of you can help us...
Thanks a lot
Best Regards
Ezio
Hello Ezio.
I suspect the main problem is in the right hand side of the line:
lin_exp[j]+=single_point[m]*(*it);Here single_point[m] has type mpf_class. However, the PPL only supports *integral* coefficients.
When a generator has non-integral coordinates, it can be expressed using integral coefficients and providing a common divisor.
For instance, if you need to specify a point in 3d having coordinates (1.5, 0.5, 2.5) you can express it as (3, 1, 5) / 2
In C++, something like the following:
Variable A(0); Variable B(1); Variable C(2); Linear_Expression le = 3*A + B + 5*C; ph.add_generator(point(le, 2));
where the second argument to `point' is the divisor (that gets applied to all the coefficients of `le').
Hope this helps.
Regards, Enea.
participants (2)
- 
                 Enea Zaffanella Enea Zaffanella
- 
                 Ezio Bartocci Ezio Bartocci