Hello,
I use the C interface of the Parma Polyhedra Library but I have some problems to build a linear expression. I want to build the linear expression "x_1 + 5x_3 - 100 >= 0" for example but I do not arrive.
I do "ppl_new_Linear_Expression _with_dimension(&ple, (ppl_dimension_type) 4);" and after I want to add the values to the variables by using the "ppl_Linear_Expression_add_to_coefficient(ple, coefficient_index[i], ppl_coeff);" function but that doesn't go.
I don't understand how we can build a linear expression just using this 2 functions.
Can you help me by giving me the code to build this linear expression with the C interface and to explain it ?
Thank you in advance.
Simon
Lambert Simon wrote:
I use the C interface of the Parma Polyhedra Library but I have some problems to build a linear expression. I want to build the linear expression "x_1 + 5x_3 - 100 >= 0" for example but I do not arrive.
Dear Simon,
I guess you meant `I want to build the linear expression "x_1 + 5x_3 - 100"'.
I do "ppl_new_Linear_Expression _with_dimension(&ple, (ppl_dimension_type) 4);" and after I want to add the values to the variables by using the "ppl_Linear_Expression_add_to_coefficient(ple, coefficient_index[i], ppl_coeff);" function but that doesn't go.
I don't understand how we can build a linear expression just using this 2 functions.
Why 2? You are overlooking several functions that allow building linear expressions: you will find them all in the user's manual (pages 34 and 35 of ppl-user-0.8.pdf).
Can you help me by giving me the code to build this linear expression with the C interface and to explain it ?
I attach under the signature some example code doing what you want. Use it as follows:
$ gcc sample.c -lppl_c -lppl -lgmpxx -lgmp $ ./a.out x_1 + 5*x_3 - 100
If, after reading the manual, you need further advice or explanations, please come back to us. All the best,
Roberto
participants (2)
-
Lambert Simon -
Roberto Bagnara