Linear constraint solving example with floating point co-efficients

Hi all,
Please don't feel annoyed by this request. I did try for looking for examples in the folder I downloaded and in the manual. But couldnt find what I was looking for.
I'm looking for a simple example where a linear constraint system with floating point coefficients (variables can also take floating point values) is solved and output is printed to either file or stdout. I don't have strict requirement to number of decimal points it has to be accurately computed. I'm fine with just 2 decimal points.
The system can be as simple as this,
1.2*x + 2.3y <= 8.2 2.2*x + 1.4*y <= 7.1
This one example I tried out but with integer coefficients. #include <ppl.hh> #include "ppl_c.h"
using namespace Parma_Polyhedra_Library;
int main() {
Variable x(0); Variable y(1); Constraint_System CS;
Linear_Expression LE1 = 1*x + 2*y; Linear_Expression LE2 = 2*x + 1*y;
CS.insert(LE1 <= 7); CS.insert(LE2 <= 5);
C_Polyhedron P(CS);
return 0; }
It would be great if someone can help me out with this by providing an example or code for the system I described earlier.
Thanks in advance, Mahesh

On 08/23/11 15:31, Mahesh Nanjundappa wrote:
Hi all,
Please don't feel annoyed by this request. I did try for looking for examples in the folder I downloaded and in the manual. But couldnt find what I was looking for.
I'm looking for a simple example where a linear constraint system with floating point coefficients (variables can also take floating point values) is solved and output is printed to either file or stdout. I don't have strict requirement to number of decimal points it has to be accurately computed. I'm fine with just 2 decimal points.
The system can be as simple as this,
1.2*x + 2.3y <= 8.2 2.2*x + 1.4*y <= 7.1
This one example I tried out but with integer coefficients. #include <ppl.hh> #include "ppl_c.h"
using namespace Parma_Polyhedra_Library;
int main() {
Variable x(0); Variable y(1); Constraint_System CS;
Linear_Expression LE1 = 1*x + 2*y; Linear_Expression LE2 = 2*x + 1*y;
CS.insert(LE1 <= 7); CS.insert(LE2 <= 5);
C_Polyhedron P(CS);
return 0; }
It would be great if someone can help me out with this by providing an example or code for the system I described earlier.
Thanks in advance, Mahesh
Hi Mahesh.
There is really no way you can use the PPL without even looking at its documentation. Good luck,
Roberto
participants (2)
-
Mahesh Nanjundappa
-
Roberto Bagnara