|
PPL OCaml Language Interface 2.0
|
The Parma Polyhedra Library comes equipped with an interface for the OCaml language.
The main features of the library are described in Section OCaml Interface Features. Section OCamldoc Documentation explains the type and function references supplied with the configuration-independent and configuration-dependent manuals. Section Compilation and Installation explains how the OCaml interface is compiled and installed.
The configured libdir and the selected OCaml package root determine the installation paths; see Compilation and Installation.
The OCaml interface provides access to the numerical abstractions (convex polyhedra, BD shapes, octagonal shapes, etc.) implemented by the PPL library. A general introduction to the numerical abstractions, their representation in the PPL and the operations provided by the PPL is given in the main PPL user manual. Here we just describe those aspects that are specific to the OCaml interface.
Native conversion of a linear_expression uses an explicit work list and preserves the grouping and configured coefficient rules of the expression. Supply finite, acyclic expressions. Native stack usage is independent of tree depth. Large expressions require corresponding heap storage and processing time.
Native exception translation releases native temporaries before raising the corresponding OCaml exception. Exceptions with a string payload carry the native diagnostic. The called operation's failure guarantees govern whether its arguments remain usable after an exception.
Powerset iterators and disjunct views retain their owning powerset. A view is valid only while its owner has not been released or used by an operation that can change or normalize its disjunct sequence. Such operations may invalidate existing views even when they make no mathematical change or fail. Comparisons, property queries, conversions and string output can normalize the sequence. Space dimension, size, invariant checks, memory-size queries and ASCII dumps preserve views, as do iterator creation, copying, comparison and movement. Iterators from different owners cannot be compared or used as one range; movement past either boundary and dereferencing the end iterator raise an invalid-argument exception.
Disjunct views are read-only. Construct an owned copy to modify a disjunct. The copy has an independent lifetime. Dropping a single disjunct advances and refreshes the supplied iterator itself; other existing views are invalidated. Dropping a range invalidates all existing views, including its boundary iterators. Invalidated views raise an invalid-argument exception before native storage is accessed.
First, here is a list of notes with general information and advice on the use of the OCaml interface.
int8_t, int16_t, int32_t, int64_t, mpz_class, mpq_class, float, double or long_double. The last name is the interface spelling of C++ long double; floating-point instances require support for the corresponding format.Ppl_ocaml module contains only the valid instances selected with --enable-instantiations when PPL was configured. Consult its configuration-dependent OCamldoc reference for the available types and functions; see OCamldoc Documentation.Z.t type.${libdir}/ocaml. --with-ocaml-libdir=DIR overrides that root. See Compilation and Installation for discovery and linking examples. Findlib metadata supports ordinary bytecode, native clients and dynamic loading. The platform loader must be able to find the PPL and GMP libraries.k, the identifiers used for the PPL variables must lie between 0 and 
The configured OCamldoc reference describes every selected domain operation beside its OCaml signature. The native domain defines its mathematical, topological and approximation preconditions. Coefficients use Zarith Z.t; coordinate indices are zero-based and must fit the relevant ambient space. Constraint and generator lists have no separate ambient dimension field, so the dimensions carried by their expressions matter when constructing a value from a representation system.
Constructors return independently owned, garbage-collected native values. Copying an OCaml handle alone shares the same native object; use a copying constructor for an independent value. Representation getters return OCaml copies. Mutators update their indicated handle in place, commonly returning unit. Partitions return new owned result handles. There are no public domain-deletion functions: keep owners and thread/library state valid according to the overview lifetime rules. Borrowed PIP and powerset views retain their owners, but retention does not prevent mutation invalidation. A copied OCaml expression or list is distinct from a borrowed native view.
Boolean results must be interpreted by operation. A predicate tests a property; an exactness query reports whether exactness was established; an optimization or frequency query reports whether a result is available. Optimization returns (bounded, numerator, denominator, attained), with a fifth witness component in the witness overload. Read components after bounded only on true. False can indicate emptiness, an unbounded objective, or a native failure to obtain a bound under its approximation or overflow rules. A true result retains the precision guarantees of the native overload: bounded-difference and octagonal optimization without a witness can return outward approximations when arithmetic rounds or overflows. Integral octagonal closure can also round. The attainment flag concerns the actual extremum, not necessarily its approximate bound.
A widening or extrapolation function ending in _with_tokens takes a nonnegative delay counter and returns the remaining counter; the handle is still updated in place. Observe native widening and extrapolation preconditions. A complexity policy does not make an approximate operation exact.
Termination and ranking functions use the MS or PR methods. A single transition description has dimension 2n: after-state coordinates occupy 0 through n-1 and before-state coordinates n through 2n-1. The _2 forms take an n-dimensional before description and a 2n-dimensional after relation with the same after-first ordering. True certifies termination; false is inconclusive. One-witness functions return a boolean and a coefficient point, meaningful only on true. All-ranking functions return owned coefficient-space polyhedra: closed for MS and NNC for PR. MS quasi-ranking functions return the decreasing and bounded closed coefficient spaces. Functions returning these polyhedra require the Polyhedron instantiation; tests and one-witness functions remain available for the selected simple domains.
Below is a short description of many of the interface functions. For full definitions of terminology used here, see the main PPL user manual.
First we describe some domain independent functions included with all instantiations of the OCaml interfaces.
ppl_version_major Returns the major number of the PPL version.
ppl_version_minor Returns the minor number of the PPL version.
ppl_version_revision Returns the revision number of the PPL version.
ppl_version_beta Returns the beta number of the PPL version.
ppl_version Returns the PPL version.
ppl_banner Returns information about the PPL version, the licensing, the lack of any warranty whatsoever, the C++ compiler used to build the library, where to report bugs and where to look for further information.
ppl_max_space_dimension Returns the maximum space dimension the C++ interface can handle.
ppl_Coefficient_bits Returns the number of bits used in the C++ interface for PPL coefficients; 0 if unbounded.
ppl_Coefficient_is_bounded Returns true if and only if the coefficients in the C++ interface are bounded.
ppl_Coefficient_max If the coefficients are bounded, returns the maximum coefficient the C++ interface can handle.
ppl_Coefficient_min If the coefficients are bounded, returns the minimum coefficient the C++ interface can handle.
ppl_io_wrap_string source_string indent_depth
preferred_first_line_length preferred_line_length Utility function for the wrapping of lines of text. The function wraps the lines of text stored in its first string argument according to the next three integer arguments, which are interpreted as the indentation depth, the preferred length for the first line and the preferred length for all the other lines, respectively; it returns a string containing the wrapped text.
ppl_set_timeout csecs Computations taking exponential time will be interrupted some time after csecs centiseconds after that call. If the computation is interrupted that way, a timeout exception will be thrown. An exception is immediately thrown if csecs is not strictly greater than zero, or if the PPL Watchdog library is not enabled.
ppl_reset_timeout Resets the timeout time so that the computation is not interrupted. An exception is thrown if the PPL Watchdog library is not enabled.
ppl_set_deterministic_timeout unscaled_weight scaleComputations taking exponential time will be interrupted some time after reaching the complexity threshold 
unscaled_weight must be strictly greater than zero; scale must be non-negative; an exception is thrown if the computed weight threshold exceeds the maximum allowed value. NOTE: This "timeout" checking functionality is said to be deterministic because it is not based on actual elapsed time. Its behavior will only depend on (some of the) computations performed in the PPL library and it will be otherwise independent from the computation environment (CPU, operating system, compiler, etc.). The weight mechanism is under beta testing: client applications should be ready to reconsider the tuning of these weight thresholds when upgrading to newer version of the PPL.
ppl_reset_deterministic_timeout Resets the timeout time so that the computation is not interrupted. An exception is thrown if the PPL Watchdog library is not enabled.
ppl_set_rounding_for_PPL Sets the FPU rounding mode so that the PPL abstractions based on floating point numbers work correctly. This is performed automatically at initialization-time. Calling this function is needed only if restore_pre_PPL_rounding has previously been called.
ppl_restore_pre_PPL_rounding Sets the FPU rounding mode as it was before initialization of the PPL. After calling this function it is absolutely necessary to call set_rounding_for_PPL before using any PPL abstractions based on floating point numbers. This is performed automatically at finalization-time.
ppl_irrational_precision Returns the precision parameter for irrational calculations.
ppl_set_irrational_precision Sets the precision parameter p for irrational calculations. In the following irrational calculations returning an unbounded rational (e.g., when computing a square root), the lesser between numerator and denominator will be limited to 2**p.
Here we describe some functions available for PPL objects defining mixed integer (linear) programming problems.
A strict inequality is admitted exactly when every coordinate with a nonzero coefficient has already been declared integer. Unused continuous coordinates do not prevent admission. Admitted strict rows are stored in integer-equivalent closed form: for example, 


Invalid_argument.
The constructors taking a dimension and optionally constraints, objective and mode initially leave every coordinate real. To use nonconstant strict constraints, first create a problem with ppl_new_MIP_Problem_from_space_dimension, declare the required integer coordinates with ppl_MIP_Problem_add_to_integer_space_dimensions, then insert the constraints with ppl_MIP_Problem_add_constraint or ppl_MIP_Problem_add_constraints. The input constraint values are preserved. See Strict Constraints over Integer Coordinates for the native admission and normalization rules.
ppl_new_MIP_Problem_from_space_dimension dimension
Return a handle to an MIP Problem 
dimension, objective function 
max.
ppl_new_MIP_Problem dimension constraint_system lin_expr optimization_mode
Return a handle to an MIP Problem 
dimension, a feasible region represented by constraint_system, objective function lin_expr and optimization mode optimization_mode. No coordinates are declared integer by this constructor, so any strict rows in constraint_system must be constant. For nonconstant strict constraints, use the construction and declaration order in Strict Constraints over Integer Coordinates.
ppl_MIP_Problem_get_control_parameter handle param_name
Returns the value of the control parameter named param_name.
ppl_MIP_Problem_set_control_parameter handle param_value
Sets control parameter value param_value.
ppl_MIP_Problem_swap handle_1 handle_2
Swaps the MIP Problem referenced by handle_1 with the one referenced by handle_2.
ppl_MIP_Problem_space_dimension handle
Returns the dimension of the vector space in which the MIP Problem referenced by handle is embedded.
ppl_MIP_Problem_integer_space_dimensions handle
Returns a list of variables representing representing the integer space dimensions of the MIP Problem referenced by handle.
ppl_MIP_Problem_constraints handle
Returns a list of the constraints in the constraints system representing the feasible region for the MIP Problem referenced by handle. Admitted strict inequalities appear in their stored integer-equivalent closed form.
ppl_MIP_Problem_objective_function handle
Returns the objective function for the MIP Problem referenced by handle.
ppl_MIP_Problem_optimization_mode handle
Returns the optimization mode for the MIP Problem referenced by handle.
ppl_MIP_Problem_clear handle
Resets the MIP problem referenced by handle to be the trivial problem with the feasible region the 

Maximization.
ppl_MIP_Problem_add_space_dimensions_and_embed
handle dimension
Embeds the MIP problem referenced by handle in a space that is enlarged by dimension dimensions,
ppl_MIP_Problem_add_to_integer_space_dimensions handle vars_list
Updates the MIP Problem referenced by handle so that the variables in vars_list are added to the set of integer space dimensions. Declare these dimensions before inserting strict inequalities that depend on them; see Strict Constraints over Integer Coordinates.
ppl_MIP_Problem_add_constraint handle constraint
Updates the MIP Problem referenced by handle so that the feasible region is represented by the original constraint system together with the constraint constraint. A strict inequality must satisfy the integer-support condition in Strict Constraints over Integer Coordinates and is stored in equivalent closed form. A strict row depending on a continuous coordinate raises Invalid_argument. The input constraint value is preserved.
ppl_MIP_Problem_add_constraints handle constraint_system
Updates the MIP Problem referenced by handle so that the feasible region is represented by the original constraint system together with all the constraints in constraint_system. Every strict inequality must satisfy the integer-support condition in Strict Constraints over Integer Coordinates and is stored in equivalent closed form. A strict row depending on a continuous coordinate raises Invalid_argument. The input constraint values are preserved.
ppl_MIP_Problem_set_objective_function handle lin_expr
Updates the MIP Problem referenced by handle so that the objective function is changed to lin_expr.
ppl_MIP_Problem_set_optimization_mode handle optimization_mode
Updates the MIP Problem referenced by handle so that the optimization mode is changed to optimization_mode.
ppl_MIP_Problem_is_satisfiable handle
Returns true if the MIP Problem referenced by handle is satisfiable and false otherwise.
ppl_MIP_Problem_solve handle
Solves the MIP problem referenced by handle and returns a value of type mip_problem_status: Unfeasible_Mip_Problem if the problem is not satisfiable; Unbounded_Mip_Problem if it is satisfiable but its objective has no finite optimum; or Optimized_Mip_Problem if it admits an optimal solution.
ppl_MIP_Problem_feasible_point handle
Returns a feasible point for the MIP problem referenced by handle.
ppl_MIP_Problem_optimizing_point handle
Returns an optimizing point for the MIP problem referenced by handle.
ppl_MIP_Problem_optimal_value handle
Returns a pair of numbers, the first being the numerator and the second the denominator, for the optimal value for the MIP problem referenced by handle.
ppl_MIP_Problem_evaluate_objective_function handle generator
Evaluates the objective function of the MIP problem referenced by handle at point generator. Returns a pair of numbers, the first being the numerator and the second the denominator, for the objective function value for the MIP problem referenced by handle.
ppl_MIP_Problem_OK handle
Returns true if the MIP Problem referenced by handle is well formed, i.e., if it satisfies all its implementation invariants and false, otherwise. Useful for debugging purposes.
ppl_MIP_Problem_ascii_dump handle
Returns a string containing an ASCII dump of the internal representation of the MIP_Problem referenced by handle. Useful for debugging purposes.
Here we describe some functions available for PPL objects defining parametric integer programming problems.
All problem variables and parameters range over nonnegative integers. Constraints involving only parameters define the initial context. For each parameter assignment in that context, the solver computes the lexicographic minimum of the feasible variable vectors, when one exists. The solution tree describes these parameter-dependent minima and the parameter regions with no feasible solution.
Tree handles retain their owning problem: a root or child handle remains usable after the problem's OCaml handle or its parent-node handle is garbage collected. Calls to problem mutators invalidate existing tree handles before the native update is attempted, including both sets of handles in a swap. Even a no-op or failed update may invalidate handles. Every tree operation, including predicates and operations on bottom handles, raises Invalid_argument for an invalidated handle. Obtain a new solution handle after an update. Repeated solving queries without updates preserve existing handles.
ppl_new_PIP_Problem_from_space_dimension dimension
Return a handle to a PIP Problem 
dimension, with no explicit constraints and no parameters. Every coordinate is a nonnegative integer, and the lexicographic minimum is the origin.
ppl_new_PIP_Problem dimension constraint_system vars_list
Return a handle to a PIP Problem 
dimension, with constraints constraint_system and parameter dimensions selected by vars_list. All coordinates, including parameters, are implicitly restricted to nonnegative integers.
ppl_PIP_Problem_get_control_parameter handle param_name
Returns the value of the control parameter named param_name.
ppl_PIP_Problem_set_control_parameter handle param_value
Sets control parameter value param_value.
ppl_PIP_Problem_swap handle_1 handle_2
Swaps the PIP Problem referenced by handle_1 with the one referenced by handle_2.
ppl_PIP_Problem_space_dimension handle
Returns the dimension of the vector space in which the PIP Problem referenced by handle is embedded.
ppl_PIP_Problem_parameter_space_dimensions handle
Returns a list of variables representing representing the parameter space dimensions of the PIP Problem referenced by handle.
ppl_PIP_Problem_constraints handle
Returns a list of the constraints in the constraints system representing the feasible region for the PIP Problem referenced by handle.
ppl_PIP_Problem_clear handle
Resets the PIP problem referenced by handle to be the trivial problem with space dimension 
ppl_PIP_Problem_add_space_dimensions_and_embed
handle dimension_0 dimension_1
Embeds the PIP problem referenced by handle in a space that is enlarged by dimension_0 non-parameter dimensions and dimension_1 parameter dimensions,
ppl_PIP_Problem_add_to_parameter_space_dimensions handle vars_list
Sets the space dimensions whose indexes are in vars_list to be parameter space dimensions.
ppl_PIP_Problem_add_constraint handle constraint
Updates the PIP Problem referenced by handle so that the feasible region is represented by the original constraint system together with the constraint constraint.
ppl_PIP_Problem_add_constraints handle constraint_system
Updates the PIP Problem referenced by handle so that the feasible region is represented by the original constraint system together with all the constraints in constraint_system.
ppl_PIP_Problem_set_big_parameter_dimension handle dimension
Sets the dimension for the big parameter to dimension.
ppl_PIP_Problem_get_big_parameter_dimension handle
Returns the dimension for the big parameter. Exception is thrown if no big parameter dimension has been set.
ppl_PIP_Problem_has_big_parameter_dimension handle
Returns true if and only if the dimension for the big parameter has been set.
ppl_PIP_Problem_is_satisfiable handle
Returns true if the PIP Problem referenced by handle is satisfiable and false otherwise.
ppl_PIP_Problem_solve handle
Solves the PIP problem referenced by handle and returns a status flag indicating the outcome of the optimization attempt: Optimized_Pip_Problem if the optimization attempt succeeds; Unfeasible_Pip_Problem otherwise.
ppl_PIP_Problem_solution handle
Solves the PIP problem referenced by handle and returns a handle to a PIP_Tree representing a feasible solution, if it exists and bottom otherwise.
ppl_PIP_Problem_optimizing_solution handle
Solves the PIP problem referenced by handle and returns a handle to a PIP_Tree representing an optimizing_solution, if it exists and bottom otherwise.
ppl_PIP_Problem_OK handle
Returns true if the PIP Problem referenced by handle is well formed, i.e., if it satisfies all its implementation invariants and false, otherwise. Useful for debugging purposes.
ppl_PIP_Problem_ascii_dump handle
Returns a string containing an ASCII dump of the internal representation of the PIP_Problem referenced by handle. Useful for debugging purposes.
ppl_PIP_Tree_Node_OK handle
Returns true if the PIP tree node referenced by handle is well formed, i.e., if it satisfies all its implementation invariants and false, otherwise. Useful for debugging purposes.
ppl_PIP_Tree_Node_ascii_dump handle
Returns a string containing an ASCII dump of the internal representation of the Pip tree node referenced by handle. Useful for debugging purposes.
ppl_PIP_Tree_Node_constraints handle
Returns a list of the parameter constraints in the PIP tree node referenced by handle.
ppl_PIP_Tree_Node_artificials handle
Returns a list of the artificial parameters in the PIP tree node referenced by handle, in introduction order. Their coordinate indices follow the original coordinates and the artificial parameters inherited from ancestor nodes.
ppl_PIP_Tree_Node_is_bottom handle
Returns true if and only if handle represents bottom.
ppl_PIP_Tree_Node_is_decision handle
Returns true if and only if handle represents a decision node.
ppl_PIP_Tree_Node_is_solution handle
Returns true if and only if handle represents a solution node.
ppl_PIP_Tree_Node_parametric_values handle var
Returns a linear expression representing the values of problem variable var in the solution node represented by handle. The returned linear expression may involve problem parameters as well as artificial parameters.
ppl_PIP_Tree_Node_true_child handle
Returns a handle to the child on the true branch of the PIP decision node represented by handle. Raises Invalid_argument if handle represents bottom or a solution node.
ppl_PIP_Tree_Node_false_child handle
Returns a handle to the child on the false branch of the PIP decision node represented by handle. If the false branch is absent, the returned handle represents bottom. Raises Invalid_argument if handle represents bottom or a solution node.
Here we describe the main functions available for PPL objects defining convex and closed polyhedra.
ppl_new_C_Polyhedron_from_space_dimension space_dimension universe_or_empty
Returns a handle to a C polyhedron 
space_dimension dimensions; it is empty or the universe polyhedron depending on whether universe_or_empty is Empty or Universe, respectively.
ppl_new_C_Polyhedron_from_C_Polyhedron handle
If handle refers to a C polyhedron 


ppl_new_C_Polyhedron_from_NNC_Polyhedron handle
If handle refers to an NNC polyhedron 


When using ppl_new_C_Polyhedron_from_NNC_Polyhedron/2, care must be taken that the source polyhedron referenced by handle is topologically closed.
ppl_new_C_Polyhedron_from_constraints constraint_system
Returns a handle to a C polyhedron 
constraint_system.
ppl_new_C_Polyhedron_from_generators generator_system
Returns a handle to a C polyhedron 
generator_system.
ppl_Polyhedron_swap handle_1 handle_2 Swaps the polyhedron 
handle_1 with the polyhedron 
handle_2. The polyhedra 

ppl_Polyhedron_space_dimension handle Returns the dimension of the vector space in which the polyhedron referenced by handle is embedded.
ppl_Polyhedron_affine_dimension handle
Returns the actual dimension of the polyhedron referenced by handle.
ppl_Polyhedron_get_constraints handle
Return a list of the constraints in the constraints system representing the polyhedron referenced by handle.
ppl_Polyhedron_get_minimized_constraints handle
Returns a minimized list of the constraints in the constraints system representing the polyhedron referenced by handle.
ppl_Polyhedron_get_generators handle
Returns a list of the generators in the generators system representing the polyhedron referenced by handle.
ppl_Polyhedron_get_minimized_generators handle
Returns a minimized list of the generators in the generators system representing the polyhedron referenced by handle.
ppl_Polyhedron_relation_with_constraint handle constraint
Returns the list of relations the polyhedron referenced by handle has with constraint. The possible relations and their meaning is given in Section Relation-With Operators of the main PPL user manual.
ppl_Polyhedron_relation_with_generator handle generator
Returns the list of relations the polyhedron referenced by handle has with generator. The possible relations and their meaning is given in Section Relation-With Operators of the main PPL user manual.
ppl_Polyhedron_is_empty handle Returns true if the polyhedron referenced by handle is empty and false, otherwise.
ppl_Polyhedron_is_universe handle Returns true if the polyhedron referenced by handle is the universe and false, otherwise.
ppl_Polyhedron_is_bounded handle Returns true if the polyhedron referenced by handle is bounded and false, otherwise.
ppl_Polyhedron_contains_integer_point handle Returns true if the polyhedron referenced by handle contains at least one integer point and false, otherwise.
ppl_Polyhedron_bounds_from_above handle lin_expr Returns true if the polyhedron referenced by handle is bounded from above by lin_expr and false, otherwise.
ppl_Polyhedron_bounds_from_below handle lin_expr Returns true if the polyhedron referenced by handle is bounded from below by lin_expr and false, otherwise.
ppl_Polyhedron_maximize handle lin_expr Returns a tuple of type bool * Z.t * Z.t * bool, written (bounded, numerator, denominator, attained). bounded is true exactly when the polyhedron referenced by handle is nonempty and lin_expr is bounded above on it. In that case, numerator/denominator is its supremum, and attained is true exactly when that value is attained. If bounded is false, do not interpret the other components.
ppl_Polyhedron_maximize_with_point handle lin_expr
Returns a five-element tuple of type bool * Z.t * Z.t * bool * linear_generator. The first four components have the same meaning as for ppl_Polyhedron_maximize. When bounded is true, the fifth component, witness, is a Point if the supremum is attained or a Closure_Point if it is not. The objective has the supremum value at that generator. If bounded is false, do not interpret the other components, including the generator.
ppl_Polyhedron_minimize handle lin_expr
Returns a tuple of type bool * Z.t * Z.t * bool, written (bounded, numerator, denominator, attained). bounded is true exactly when the polyhedron referenced by handle is nonempty and lin_expr is bounded below on it. In that case, numerator/denominator is its infimum, and attained is true exactly when that value is attained. If bounded is false, do not interpret the other components.
ppl_Polyhedron_minimize_with_point handle lin_expr
Returns a five-element tuple of type bool * Z.t * Z.t * bool * linear_generator. The first four components have the same meaning as for ppl_Polyhedron_minimize. When bounded is true, the fifth component, witness, is a Point if the infimum is attained or a Closure_Point if it is not. The objective has the infimum value at that generator. If bounded is false, do not interpret the other components, including the generator.
ppl_Polyhedron_is_topologically_closed handle Returns true if the polyhedron referenced by handle is topologically closed and false, otherwise.
ppl_Polyhedron_contains_Polyhedron handle_1 handle_2
Returns true if the polyhedron referenced by handle_2 is included in or equal to the polyhedron referenced by handle_1 and false, otherwise.
ppl_Polyhedron_strictly_contains_Polyhedron handle_1 handle_2
Returns true if the polyhedron referenced by handle_2 is included in but not equal to the polyhedron referenced by handle_1 and false, otherwise.
ppl_Polyhedron_is_disjoint_from_Polyhedron handle_1 handle_2
Returns true if the polyhedron referenced by handle_1 is disjoint from the polyhedron referenced by handle_2 and false, otherwise.
ppl_Polyhedron_equals_Polyhedron handle_1 handle_2 Returns true if the polyhedron referenced by handle_1 is equal to the polyhedron referenced by handle_2 and false, otherwise.
ppl_Polyhedron_OK handle Returns true if the polyhedron referenced by handle is well formed, i.e., if it satisfies all its implementation invariants and false, otherwise. Useful for debugging purposes.
ppl_Polyhedron_add_constraint handle constraint Updates the polyhedron referenced by handle to one obtained by adding constraint to its constraint system.
ppl_Polyhedron_add_generator handle generator Updates the polyhedron referenced by handle to one obtained by adding generator to its generator system.
ppl_Polyhedron_add_constraints handle constraint_system
Updates the polyhedron referenced by handle to one obtained by adding to its constraint system the constraints in constraint_system.
ppl_C_Polyhedron_add_generators handle generator_system
Updates the polyhedron referenced by handle to one obtained by adding to its generator system the generators in generator_system.
ppl_Polyhedron_intersection_assign handle_1 handle_2
Assigns to the polyhedron referenced by handle_1 its intersection with the polyhedron referenced by handle_2.
ppl_Polyhedron_poly_hull_assign handle_1 handle_2 Assigns to the polyhedron referenced by handle_1 its poly-hull with the polyhedron referenced by handle_2.
ppl_Polyhedron_poly_difference_assign handle_1 handle_2
Assigns to the polyhedron referenced by handle_1 its poly-difference with the polyhedron referenced by handle_2.
ppl_Polyhedron_affine_image handle var
lin_expr coefficient
Transforms the polyhedron referenced by handle assigning the affine expression lin_expr/coefficient to var.
ppl_Polyhedron_affine_preimage handle var
lin_expr coefficient
This is the inverse transformation to that for ppl_affine_image.
ppl_Polyhedron_bounded_affine_image handle
var
lin_expr_1
lin_expr_2
coefficient
Transforms the polyhedron referenced by handle assigning the image with respect to the transfer relation lin_expr_1/coefficient <= var <= lin_expr_2/coefficient.
ppl_Polyhedron_generalized_affine_image handle
var
Relation_Symbol
lin_expr
coefficient
Transforms the polyhedron referenced by handle assigning the generalized affine image with respect to the transfer function var Relation_Symbol lin_expr/coefficient.
ppl_Polyhedron_generalized_affine_image_lhs_rhs handle
lin_expr_1
Relation_Symbol
lin_expr_2
Transforms the polyhedron referenced by handle assigning the generalized affine image with respect to the transfer function lin_expr_1 Relation_Symbol lin_expr_2.
ppl_Polyhedron_time_elapse_assign handle_1 handle_2 Assigns to the polyhedron 
handle_1 the time-elapse 

handle_2.
ppl_Polyhedron_BHRZ03_widening_assign handle_1 handle_2
If the polyhedron 
handle_1 contains the polyhedron 
handle_2, then handle_1 will refer to the BHRZ03-widening of 

ppl_Polyhedron_BHRZ03_widening_assign_with_tokens handle_1
handle_2
c_unsigned_1
It is assumed that the polyhedron 
handle_1 contains the polyhedron 
handle_2; let 



c_unsigned_1 is the number of tokens available, Then this function will return the number of tokens remaining at the end of the operation.
ppl_Polyhedron_limited_BHRZ03_extrapolation_assign handle_1
handle_2
constraint_system
If the polyhedron 
handle_1 contains the polyhedron 
handle_2, then handle_1 will refer to the BHRZ03-extrapolation of 

constraint_system.
ppl_Polyhedron_limited_BHRZ03_extrapolation_assign_with_tokens
handle_1
handle_2
constraint_system
c_unsigned_1 It is assumed that the polyhedron 
handle_1 contains the polyhedron 
handle_2; let 


constraint_system.
Assuming that the quantity 
c_unsigned_1 is the number of tokens available, then this function will return the number of tokens 
ppl_Polyhedron_bounded_BHRZ03_extrapolation_assign
handle_1
handle_2
constraint_system
If the polyhedron 
handle_1 contains the polyhedron 
handle_2, then handle_1 will refer to the BHRZ03-extrapolation of 

constraint_system together with all constraints of the form 


ppl_Polyhedron_bounded_BHRZ03_extrapolation_assign_with_tokens
handle_1
handle_2
constraint_system
c_unsigned_1
It is assumed that the polyhedron 
handle_1 contains the polyhedron 
handle_2; let 


constraint_system together with all constraints of the form 


Assuming that the quantity 
c_unsigned_1 is the number of tokens available, this function will return the number of tokens 
ppl_Polyhedron_H79_widening_assign handle_1 handle_2
If the polyhedron 
handle_1 contains the polyhedron 
handle_2, then handle_1 will refer to the H79-widening of 

ppl_Polyhedron_H79_widening_assign_with_tokens handle_1
handle_2
c_unsigned_1
It is assumed that the polyhedron 
handle_1 contains the polyhedron 
handle_2; let 



c_unsigned_1 is the number of tokens available, Then this function will return the number of tokens remaining at the end of the operation.
ppl_Polyhedron_limited_H79_extrapolation_assign handle_1
handle_2
constraint_system
If the polyhedron 
handle_1 contains the polyhedron 
handle_2, then handle_1 will refer to the H79-extrapolation of 

constraint_system.
ppl_Polyhedron_limited_H79_extrapolation_assign_with_tokens
handle_1
handle_2
constraint_system
c_unsigned_1 It is assumed that the polyhedron 
handle_1 contains the polyhedron 
handle_2; let 


constraint_system.
Assuming that the quantity 
c_unsigned_1 is the number of tokens available, then this function will return the number of tokens 
ppl_Polyhedron_bounded_H79_extrapolation_assign
handle_1
handle_2
constraint_system
If the polyhedron 
handle_1 contains the polyhedron 
handle_2, then handle_1 will refer to the H79-extrapolation of 

constraint_system together with all constraints of the form 


ppl_Polyhedron_bounded_H79_extrapolation_assign_with_tokens
handle_1
handle_2
constraint_system
c_unsigned_1
It is assumed that the polyhedron 
handle_1 contains the polyhedron 
handle_2; let 


constraint_system together with all constraints of the form 


Assuming that the quantity 
c_unsigned_1 is the number of tokens available, this function will return the number of tokens 
ppl_Polyhedron_topological_closure_assign handle Assigns to the polyhedron referenced by handle its topological closure.
ppl_Polyhedron_add_space_dimensions_and_embed handle
space_dimension
Embeds the polyhedron referenced by handle in a space that is enlarged by space_dimension dimensions,
ppl_Polyhedron_concatenate_assign handle_1 handle_2 Updates the polyhedron 
handle_1 by first embedding 

handle_2, and then adds to its system of constraints a renamed-apart version of the constraints of 
ppl_Polyhedron_add_space_dimensions_and_project handle
space_dimension
Projects the polyhedron referenced by handle onto a space that is enlarged by space_dimension dimensions,
ppl_Polyhedron_remove_space_dimensions handle
Int_List
Removes the space dimensions given by the identifiers of the PPL variables in list Int_List from the polyhedron referenced by handle. The identifiers for the remaining PPL variables are renumbered so that they are consecutive and the maximum index is less than the number of dimensions.
ppl_Polyhedron_remove_higher_space_dimensions handle
space_dimension
Projects the polyhedron referenced to by handle onto the first space_dimension dimensions.
ppl_Polyhedron_expand_space_dimension handle var space_dimension
space_dimension copies of the space dimension referenced by variable var are added to the polyhedron referenced to by handle.
ppl_Polyhedron_fold_space_dimensions handle list_of_vars var
The space dimensions referenced by the PPL variables in list list_of_vars are folded into the dimension referenced by var and removed. The result is undefined if list_of_vars does not have the properties described in Section Folding Multiple Dimensions of the Vector Space into One Dimension of the main PPL user manual.
ppl_Polyhedron_map_space_dimensions handle p_func Maps the space dimensions of the polyhedron referenced by handle using the partial function defined by a list of pairs of integers p_func. The result is undefined if p_func does not encode a partial function with the properties described in Section Mapping the Dimensions of the Vector Space of the main PPL user manual.
ppl_Polyhedron_wrap_assign handle
list_of_vars
width
representation
overflow
constraint_system
complexity_threshold
wrap_indicator
Transforms the polyhedron referenced by handle by wrapping the dimensions given by list_of_vars while respecting the specified width, representation and overflow behavior of all these variables. The parameter constraint_system represents the conditional or looping construct guard with respect to which wrapping is performed. The non-negative integer complexity_threshold and Boolean wrap_indicator allow control of the complexity/precision ratio; higher values for complexity_threshold will lead to possibly greater precision while a true value for wrap_indicator indicates that the space dimensions should be wrapped individually. See Section Wrapping Operator for a more detailed description of this operator.
ppl_Polyhedron_ascii_dump handle
Returns a string containing an ASCII dump of the internal representation of the polyhedron referenced by handle. Useful for debugging purposes.
Open the OCamldoc reference shipped with this manual.
The OCamldoc reference in a configuration-independent manual documents Ppl_ocaml_globals: the domain-independent types and functions that are always enabled. The configuration-dependent reference documents the installed Ppl_ocaml module, including the numerical-domain instances selected during configuration. Ppl_ocaml includes Ppl_ocaml_globals automatically. Consult the reference matching your installed configuration for available domain operations and their signatures.
The PPL OCaml interface provides the Ppl_ocaml module and uses Zarith for arbitrary-precision integers. Use Zarith built for the selected OCaml compiler. Configure verifies the numerical module and public C conversion API, and requires a matching ocamlmklib.
Configure discovers Zarith with ocamlfind when available, then checks the compiler's standard zarith directory. Use --with-zarith=DIR to select a package directory containing zarith.cma, z.cmi and zarith.h. Native-code support also requires zarith.cmxa for the same toolchain. MLGMP and MPFR are no longer required by this interface.
The selected OCaml package root defaults to ${libdir}/ocaml, where libdir is the configured PPL library directory. --with-ocaml-libdir=DIR selects another root, such as an OCaml installation's site-library directory. The PPL package is installed under <root>/ppl and shared stubs under <root>/stublibs, including when the root is overridden.
The package contains META, .cmi/.mli files, bytecode archives and, when the native compiler is available, native archives. Shared builds provide the C stub library and, where native Dynlink is supported, ppl_ocaml.cmxs.
Set PPL_LIBDIR to the configured PPL library directory and PPL_OCAML_ROOT to the selected OCaml package root. The following POSIX-shell example uses the defaults for an installation under /usr/local. Replace the root assignment with the directory supplied to --with-ocaml-libdir when that option was used:
Zarith must also be discoverable by Findlib and the OCaml runtime. If Zarith is installed separately, add its package parent to OCAMLPATH and the directory containing its shared stubs to CAML_LD_LIBRARY_PATH. The platform loader must find libppl and GMP. Native or custom-runtime linking from a nonstandard or relocated prefix may need the flags reported by ppl-config --interface=C++ --application --ldflags.
Save the following program as my_program.ml. It uses Zarith's Z.t coefficients to construct a MIP problem with a constant objective, solves it, and formats the resulting rational value with Q.make and Q.to_string. It prints the native PPL version and the optimal value 7. Check the version against those supported by your application. These domain-independent MIP functions are available regardless of the selected numerical-domain instances.
open Ppl_ocaml
let () =
let objective = Coefficient (Z.of_int 7) in
let problem = ppl_new_MIP_Problem 1 [] objective Maximization in
match ppl_MIP_Problem_solve problem with
| Optimized_Mip_Problem ->
let numerator, denominator = ppl_MIP_Problem_optimal_value problem in
Printf.printf "PPL %s\nOptimal value: %s\n"
(ppl_version ()) (Q.to_string (Q.make numerator denominator))
| _ -> failwith "Expected an optimized MIP problem"
With Findlib and the package on its search path, build and run a bytecode client:
For a native client:
Use the C++ compiler configured for PPL as the -cc driver for native or custom-runtime linking; c++ in these examples denotes that driver. The -I "$PPL_LIBDIR" option makes the installed core library available during linking. The package metadata loads Zarith before PPL and records the C library dependencies. This driver selection also preserves C++ exception handling with older OCaml toolchains on macOS whose default linker commands disable compact unwind information.
Make Findlib's support files visible:
Then enter:
#use "topfind";; #require "ppl";; #use "my_program.ml";;
Without Findlib, set ZARITH_DIR to the matching installed Zarith package directory, ensure its shared stubs are discoverable, and supply the archives explicitly:
Shared builds use an ordinary OCaml runtime. Builds configured with --disable-shared retain the custom-runtime/static-stub path. Use ocamlc -custom -cc c++ for an explicitly custom-runtime client. Native archives are available when ocamlopt and native Zarith are present.
See interfaces/OCaml/README.ocaml.md for migration from MLGMP, borrowed-view lifetime rules and installed-client checks.