ocaml interface issues

Hellos, "Out_of_memory" exceptions are thrown using the ocaml interface when doing very very simple tasks, like below. I have yet to find an example on the use of linear_partition using the ocaml interface so I hope I'm not embarrassing myself by using it incorrectly. Also, the ppl_Polyhedron_OK returns false right before get_minimized_constraints (or most other polyhedron functions) result in the exception.
The same task is performed just fine using the C++ interface. Any info regarding this issue would be greatly appreciated.
open Printf open Gmp open Ppl_ocaml
let v1 = Variable 0;;
let p1 = ppl_new_C_Polyhedron_from_space_dimension 1 Universe;; ppl_Polyhedron_add_constraint p1 (Less_Or_Equal (v1, (Coefficient (Z.of_int 2))));; ppl_Polyhedron_add_constraint p1 (Greater_Or_Equal (v1, (Coefficient (Z.of_int 1))));;
let p2 = ppl_new_C_Polyhedron_from_space_dimension 1 Universe;; ppl_Polyhedron_add_constraint p2 (Less_Or_Equal (v1, (Coefficient (Z.of_int 3))));; ppl_Polyhedron_add_constraint p1 (Greater_Or_Equal (v1, (Coefficient (Z.of_int 2))));;
let (pinter, parts_of_p2) = ppl_Polyhedron_linear_partition p1 p2 in
let it = ppl_Pointset_Powerset_NNC_Polyhedron_begin_iterator parts_of_p2 in let itend = ppl_Pointset_Powerset_NNC_Polyhedron_end_iterator parts_of_p2 in
while (not (ppl_Pointset_Powerset_NNC_Polyhedron_iterator_equals_iterator it itend)) do
let p = ppl_Pointset_Powerset_NNC_Polyhedron_get_disjunct it in printf "ok = %s\n" (string_of_bool (ppl_Polyhedron_OK p)); flush stdout;
ignore (ppl_Polyhedron_get_minimized_constraints p); (* Out_of_memory exception here *);
ppl_Pointset_Powerset_NNC_Polyhedron_increment_iterator it done ;;

Il 05/02/2011 00:50, piotrm ha scritto:
Hellos, "Out_of_memory" exceptions are thrown using the ocaml interface when doing very very simple tasks, like below.
Hello.
Just to confirm that something wrong is going on. I have no time to check the details right now, but the first impression is that our OCaml interface function
ppl_Pointset_Powerset_*_get_disjunct
is buggy and returns a totally invalid value (so that accessing it later yields arbitrary behavior).
Thanks for reporting!
I have yet to find an example on the use of linear_partition using the ocaml interface so I hope I'm not embarrassing myself by using it incorrectly. Also, the ppl_Polyhedron_OK returns false right before get_minimized_constraints (or most other polyhedron functions) result in the exception.
The same task is performed just fine using the C++ interface. Any info regarding this issue would be greatly appreciated.
open Printf open Gmp open Ppl_ocaml
let v1 = Variable 0;;
let p1 = ppl_new_C_Polyhedron_from_space_dimension 1 Universe;; ppl_Polyhedron_add_constraint p1 (Less_Or_Equal (v1, (Coefficient (Z.of_int 2))));; ppl_Polyhedron_add_constraint p1 (Greater_Or_Equal (v1, (Coefficient (Z.of_int 1))));;
let p2 = ppl_new_C_Polyhedron_from_space_dimension 1 Universe;; ppl_Polyhedron_add_constraint p2 (Less_Or_Equal (v1, (Coefficient (Z.of_int 3))));;
This is unrelated to the reported bug, but probably here below you meant p2 and not p1.
Cheers, Enea Zaffanella.
ppl_Polyhedron_add_constraint p1 (Greater_Or_Equal (v1, (Coefficient (Z.of_int 2))));;
let (pinter, parts_of_p2) = ppl_Polyhedron_linear_partition p1 p2 in
let it = ppl_Pointset_Powerset_NNC_Polyhedron_begin_iterator parts_of_p2 in let itend = ppl_Pointset_Powerset_NNC_Polyhedron_end_iterator parts_of_p2 in
while (not (ppl_Pointset_Powerset_NNC_Polyhedron_iterator_equals_iterator it itend)) do
let p = ppl_Pointset_Powerset_NNC_Polyhedron_get_disjunct it in printf "ok = %s\n" (string_of_bool (ppl_Polyhedron_OK p)); flush stdout; ignore (ppl_Polyhedron_get_minimized_constraints p); (*
Out_of_memory exception here *);
ppl_Pointset_Powerset_NNC_Polyhedron_increment_iterator it
done ;; _______________________________________________ PPL-devel mailing list PPL-devel@cs.unipr.it http://www.cs.unipr.it/mailman/listinfo/ppl-devel

Il 05/02/2011 00:50, piotrm ha scritto:
Hellos, "Out_of_memory" exceptions are thrown using the ocaml interface when doing very very simple tasks, like below. I have yet to find an example on the use of linear_partition using the ocaml interface so I hope I'm not embarrassing myself by using it incorrectly. Also, the ppl_Polyhedron_OK returns false right before get_minimized_constraints (or most other polyhedron functions) result in the exception.
The same task is performed just fine using the C++ interface. Any info regarding this issue would be greatly appreciated.
Function ppl_Pointset_Powerset_NNC_Polyhedron_get_disjunct should be working as expected now. Can you please retry and tell us how it goes?
Thanks again, Enea.
PS: a warning on the use of powerset's disjuncts. The elements (in this case, NNC polyhedra) retrieved from a powerset using function ppl_Pointset_Powerset_*_get_disjunct are meant to be *read-only* (because their resources are still owned by the powerset). It is perfectly fine to query them so as, e.g., to obtain their (minimized) constraints/generators, but other operations that may actually change the disjuncts should be avoided. If needed, you can take a copy of the disjunct and modify the copy. If you need to modify the disjunct itself (i.e., the very same element *in* the powerset), then you should first remove it from the powerset (using ppl_Pointset_Powerset_NNC_Polyhedron_drop_disjunct) and then add back the modified version (using ppl_Pointset_Powerset_NNC_Polyhedron_add_disjunct).
participants (2)
-
Enea Zaffanella
-
piotrm