|
PPL C Language Interface 2.0
|
#include <stdio.h>#include <gmp.h>#include <stddef.h>#include "ppl_c_version.h"#include "ppl_c_domains.h"
Typedefs | |
| typedef size_t | ppl_dimension_type |
| An unsigned integral type for representing space dimensions. | |
| typedef const char * | ppl_io_variable_output_function_type(ppl_dimension_type var) |
| The type of output functions used for printing variables. | |
| typedef struct ppl_Coefficient_tag * | ppl_Coefficient_t |
| Opaque pointer. | |
| typedef struct ppl_Coefficient_tag const * | ppl_const_Coefficient_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Linear_Expression_tag * | ppl_Linear_Expression_t |
| Opaque pointer. | |
| typedef struct ppl_Linear_Expression_tag const * | ppl_const_Linear_Expression_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Constraint_tag * | ppl_Constraint_t |
| Opaque pointer. | |
| typedef struct ppl_Constraint_tag const * | ppl_const_Constraint_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Constraint_System_tag * | ppl_Constraint_System_t |
| Opaque pointer. | |
| typedef struct ppl_Constraint_System_tag const * | ppl_const_Constraint_System_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Constraint_System_const_iterator_tag * | ppl_Constraint_System_const_iterator_t |
| Opaque pointer. | |
| typedef struct ppl_Constraint_System_const_iterator_tag const * | ppl_const_Constraint_System_const_iterator_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Generator_tag * | ppl_Generator_t |
| Opaque pointer. | |
| typedef struct ppl_Generator_tag const * | ppl_const_Generator_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Generator_System_tag * | ppl_Generator_System_t |
| Opaque pointer. | |
| typedef struct ppl_Generator_System_tag const * | ppl_const_Generator_System_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Generator_System_const_iterator_tag * | ppl_Generator_System_const_iterator_t |
| Opaque pointer. | |
| typedef struct ppl_Generator_System_const_iterator_tag const * | ppl_const_Generator_System_const_iterator_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Congruence_tag * | ppl_Congruence_t |
| Opaque pointer. | |
| typedef struct ppl_Congruence_tag const * | ppl_const_Congruence_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Congruence_System_tag * | ppl_Congruence_System_t |
| Opaque pointer. | |
| typedef struct ppl_Congruence_System_tag const * | ppl_const_Congruence_System_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Congruence_System_const_iterator_tag * | ppl_Congruence_System_const_iterator_t |
| Opaque pointer. | |
| typedef struct ppl_Congruence_System_const_iterator_tag const * | ppl_const_Congruence_System_const_iterator_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Grid_Generator_tag * | ppl_Grid_Generator_t |
| Opaque pointer. | |
| typedef struct ppl_Grid_Generator_tag const * | ppl_const_Grid_Generator_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Grid_Generator_System_tag * | ppl_Grid_Generator_System_t |
| Opaque pointer. | |
| typedef struct ppl_Grid_Generator_System_tag const * | ppl_const_Grid_Generator_System_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Grid_Generator_System_const_iterator_tag * | ppl_Grid_Generator_System_const_iterator_t |
| Opaque pointer. | |
| typedef struct ppl_Grid_Generator_System_const_iterator_tag const * | ppl_const_Grid_Generator_System_const_iterator_t |
| Opaque pointer to const object. | |
| typedef struct ppl_MIP_Problem_tag * | ppl_MIP_Problem_t |
| Opaque pointer. | |
| typedef struct ppl_MIP_Problem_tag const * | ppl_const_MIP_Problem_t |
| Opaque pointer to const object. | |
| typedef struct ppl_PIP_Problem_tag * | ppl_PIP_Problem_t |
| Opaque pointer. | |
| typedef struct ppl_PIP_Problem_tag const * | ppl_const_PIP_Problem_t |
| Opaque pointer to const object. | |
| typedef struct ppl_PIP_Tree_Node_tag * | ppl_PIP_Tree_Node_t |
| Opaque pointer. | |
| typedef struct ppl_PIP_Tree_Node_tag const * | ppl_const_PIP_Tree_Node_t |
| Opaque pointer to const object. | |
| typedef struct ppl_PIP_Decision_Node_tag * | ppl_PIP_Decision_Node_t |
| Opaque pointer. | |
| typedef struct ppl_PIP_Decision_Node_tag const * | ppl_const_PIP_Decision_Node_t |
| Opaque pointer to const object. | |
| typedef struct ppl_PIP_Solution_Node_tag * | ppl_PIP_Solution_Node_t |
| Opaque pointer. | |
| typedef struct ppl_PIP_Solution_Node_tag const * | ppl_const_PIP_Solution_Node_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Artificial_Parameter_tag * | ppl_Artificial_Parameter_t |
| Opaque pointer. | |
| typedef struct ppl_Artificial_Parameter_tag const * | ppl_const_Artificial_Parameter_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Artificial_Parameter_Sequence_tag * | ppl_Artificial_Parameter_Sequence_t |
| Opaque pointer. | |
| typedef struct ppl_Artificial_Parameter_Sequence_tag const * | ppl_const_Artificial_Parameter_Sequence_t |
| Opaque pointer to const object. | |
| typedef struct ppl_Artificial_Parameter_Sequence_const_iterator_tag * | ppl_Artificial_Parameter_Sequence_const_iterator_t |
| Opaque pointer. | |
| typedef struct ppl_Artificial_Parameter_Sequence_const_iterator_tag const * | ppl_const_Artificial_Parameter_Sequence_const_iterator_t |
| Opaque pointer to const object. | |
Enumerations | |
| enum | ppl_enum_error_code { PPL_ERROR_OUT_OF_MEMORY , PPL_ERROR_INVALID_ARGUMENT , PPL_ERROR_DOMAIN_ERROR , PPL_ERROR_LENGTH_ERROR , PPL_ARITHMETIC_OVERFLOW , PPL_STDIO_ERROR , PPL_ERROR_INTERNAL_ERROR , PPL_ERROR_UNKNOWN_STANDARD_EXCEPTION , PPL_ERROR_UNEXPECTED_ERROR , PPL_TIMEOUT_EXCEPTION , PPL_ERROR_LOGIC_ERROR } |
| Defines the error codes that any function may return. More... | |
Input/Output Functions | |
| enum | ppl_enum_Constraint_Type { PPL_CONSTRAINT_TYPE_LESS_THAN , PPL_CONSTRAINT_TYPE_LESS_OR_EQUAL , PPL_CONSTRAINT_TYPE_EQUAL , PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL , PPL_CONSTRAINT_TYPE_GREATER_THAN } |
| Describes the relations represented by a constraint. More... | |
Functions | |
| int | ppl_initialize (void) |
| Initializes the Parma Polyhedra Library. This function must be called before any other function. | |
| int | ppl_finalize (void) |
| Finalizes the Parma Polyhedra Library. This function must be called after any other function. | |
| int | ppl_thread_initialize (void) |
| Performs thread specific initialization for the Parma Polyhedra Library. | |
| int | ppl_thread_finalize (void) |
| Performs thread specific finalization for the Parma Polyhedra Library. | |
| int | ppl_set_rounding_for_PPL (void) |
| Sets the FPU rounding mode so that the PPL abstractions based on floating point numbers work correctly. | |
| int | ppl_restore_pre_PPL_rounding (void) |
| Sets the FPU rounding mode as it was before initialization of the PPL. | |
| int | ppl_irrational_precision (unsigned *p) |
Writes to p the precision parameter used for irrational calculations. | |
| int | ppl_set_irrational_precision (unsigned p) |
| Sets the precision parameter used for irrational calculations. | |
| int | ppl_version_major (void) |
| Returns the major number of the PPL version. | |
| int | ppl_version_minor (void) |
| Returns the minor number of the PPL version. | |
| int | ppl_version_revision (void) |
| Returns the revision number of the PPL version. | |
| int | ppl_version_beta (void) |
| Returns the beta number of the PPL version. | |
| int | ppl_version (const char **p) |
Writes to *p a pointer to a character string containing the PPL version. | |
| int | ppl_banner (const char **p) |
Writes to *p a pointer to a character string containing the PPL banner. | |
| int | ppl_set_error_handler (void(*h)(enum ppl_enum_error_code code, const char *description)) |
Installs the user-defined error handler pointed at by h. | |
| int | ppl_set_timeout (unsigned csecs) |
| Sets the timeout for computations whose completion could require an exponential amount of time. | |
| int | ppl_reset_timeout (void) |
| Resets the timeout time so that the computation is not interrupted. | |
| int | ppl_set_deterministic_timeout (unsigned long unscaled_weight, unsigned scale) |
| Sets a threshold for computations whose completion could require an exponential amount of time. | |
| int | ppl_reset_deterministic_timeout (void) |
| Resets the deterministic timeout so that the computation is not interrupted. | |
| int | ppl_max_space_dimension (ppl_dimension_type *m) |
Writes to m the maximum space dimension this library can handle. | |
| int | ppl_not_a_dimension (ppl_dimension_type *m) |
Writes to m a value that does not designate a valid dimension. | |
| int | ppl_io_print_variable (ppl_dimension_type var) |
Pretty-prints var to stdout. | |
| int | ppl_io_fprint_variable (FILE *stream, ppl_dimension_type var) |
Pretty-prints var to the given output stream. | |
| int | ppl_io_asprint_variable (char **strp, ppl_dimension_type var) |
Pretty-prints var to a malloc-allocated string, a pointer to which is returned via strp. | |
| int | ppl_io_set_variable_output_function (ppl_io_variable_output_function_type *p) |
Sets the output function to be used for printing variables to p. | |
| int | ppl_io_get_variable_output_function (ppl_io_variable_output_function_type **pp) |
Writes a pointer to the current variable output function to pp. | |
| char * | ppl_io_wrap_string (const char *src, unsigned indent_depth, unsigned preferred_first_line_length, unsigned preferred_line_length) |
| Utility function for the wrapping of lines of text. | |
Constructors, Assignment and Destructor | |
Computing the Solution of the MIP_Problem | |
| int | ppl_is_mixed_integer_satisfiable (ppl_dimension_type dimension, ppl_const_Constraint_System_t cs, const ppl_dimension_type integers[], size_t n) |
Dereferencing, Incrementing and Equality Testing | |
| enum | ppl_enum_Generator_Type { PPL_GENERATOR_TYPE_LINE , PPL_GENERATOR_TYPE_RAY , PPL_GENERATOR_TYPE_POINT , PPL_GENERATOR_TYPE_CLOSURE_POINT } |
| Describes the different kinds of generators. More... | |
| enum | ppl_enum_Grid_Generator_Type { PPL_GRID_GENERATOR_TYPE_LINE , PPL_GRID_GENERATOR_TYPE_PARAMETER , PPL_GRID_GENERATOR_TYPE_POINT } |
| Describes the different kinds of grid generators. More... | |
| enum | ppl_enum_Bounded_Integer_Type_Width { PPL_BITS_8 , PPL_BITS_16 , PPL_BITS_32 , PPL_BITS_64 , PPL_BITS_128 } |
| Widths of bounded integer types. More... | |
| enum | ppl_enum_Bounded_Integer_Type_Representation { PPL_UNSIGNED , PPL_SIGNED_2_COMPLEMENT } |
| Representation of bounded integer types. More... | |
| enum | ppl_enum_Bounded_Integer_Type_Overflow { PPL_OVERFLOW_WRAPS , PPL_OVERFLOW_UNDEFINED , PPL_OVERFLOW_IMPOSSIBLE } |
| Overflow behavior of bounded integer types. More... | |
| unsigned int | PPL_COMPLEXITY_CLASS_POLYNOMIAL |
| Code of the worst-case polynomial complexity class. | |
| unsigned int | PPL_COMPLEXITY_CLASS_SIMPLEX |
| Code of the worst-case exponential but typically polynomial complexity class. | |
| unsigned int | PPL_COMPLEXITY_CLASS_ANY |
| Code of the universal complexity class. | |
| unsigned int | PPL_POLY_CON_RELATION_IS_DISJOINT |
| Individual bit saying that the polyhedron and the set of points satisfying the constraint are disjoint. | |
| unsigned int | PPL_POLY_CON_RELATION_STRICTLY_INTERSECTS |
| Individual bit saying that the polyhedron intersects the set of points satisfying the constraint, but it is not included in it. | |
| unsigned int | PPL_POLY_CON_RELATION_IS_INCLUDED |
| Individual bit saying that the polyhedron is included in the set of points satisfying the constraint. | |
| unsigned int | PPL_POLY_CON_RELATION_SATURATES |
| Individual bit saying that the polyhedron is included in the set of points saturating the constraint. | |
| unsigned int | PPL_POLY_GEN_RELATION_SUBSUMES |
| Individual bit saying that adding the generator would not change the polyhedron. | |
| typedef const char * ppl_io_variable_output_function_type(ppl_dimension_type var) |
The type of output functions used for printing variables.
An output function for variables must write a textual representation for var to a character buffer, null-terminate it, and return a pointer to the beginning of the buffer. In case the operation fails, 0 should be returned and perhaps errno should be set in a meaningful way. The library does nothing with the buffer, besides printing its contents.
| enum ppl_enum_error_code |
Defines the error codes that any function may return.
| int ppl_initialize | ( | void | ) |
Initializes the Parma Polyhedra Library. This function must be called before any other function.
The thread performing library initialization (typically, the main thread) should not explicitly call ppl_thread_initialize().
PPL_ERROR_INVALID_ARGUMENT if the library was already initialized. | int ppl_finalize | ( | void | ) |
Finalizes the Parma Polyhedra Library. This function must be called after any other function.
The thread performing library finalization (typically, the main thread) should not explicitly call ppl_thread_finalize().
PPL_ERROR_INVALID_ARGUMENT if the library was already finalized. | int ppl_thread_initialize | ( | void | ) |
Performs thread specific initialization for the Parma Polyhedra Library.
This function must be called before any other function whenever starting a new thread. The main thread is already initialized by the call to ppl_initialize().
PPL_ERROR_INVALID_ARGUMENT if the thread was already initialized. | int ppl_thread_finalize | ( | void | ) |
Performs thread specific finalization for the Parma Polyhedra Library.
This function must be called after any other library function whenever terminating a new thread. It should not be called by the main thread, since this is finalized by calling ppl_finalize().
PPL_ERROR_INVALID_ARGUMENT if the thread was already finalized. | int ppl_set_rounding_for_PPL | ( | void | ) |
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 been previously called.
| int ppl_restore_pre_PPL_rounding | ( | void | ) |
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.
| int ppl_irrational_precision | ( | unsigned * | p | ) |
Writes to p the precision parameter used for irrational calculations.
| p | The precision parameter limiting irrational rational calculations. |
| int ppl_set_irrational_precision | ( | unsigned | p | ) |
Sets the precision parameter used for irrational calculations.
If p is less than or equal to INT_MAX, sets the precision parameter used for irrational calculations to p. Then, in the 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.
| p | The precision parameter limiting irrational rational calculations. |
| int ppl_version_major | ( | void | ) |
Returns the major number of the PPL version.
| int ppl_version_minor | ( | void | ) |
Returns the minor number of the PPL version.
| int ppl_version_revision | ( | void | ) |
Returns the revision number of the PPL version.
| int ppl_version_beta | ( | void | ) |
Returns the beta number of the PPL version.
| int ppl_version | ( | const char ** | p | ) |
Writes to *p a pointer to a character string containing the PPL version.
| p | Receives a pointer to the library-owned static text; the caller must not free it. |
| int ppl_banner | ( | const char ** | p | ) |
Writes to *p a pointer to a character string containing the PPL banner.
The banner provides 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.
| p | Receives a pointer to the library-owned static text; the caller must not free it. |
| int ppl_set_error_handler | ( | void(* | h )(enum ppl_enum_error_code code, const char *description) | ) |
Installs the user-defined error handler pointed at by h.
The error handler takes an error code and a textual description that gives further information about the actual error. The C string containing the textual description is read-only and its existence is not guaranteed after the handler has returned.
| h | The callback that receives library errors. |
| int ppl_set_timeout | ( | unsigned | csecs | ) |
Sets the timeout for computations whose completion could require an exponential amount of time.
| csecs | The number of centiseconds sometimes after which a timeout will occur; it must be strictly greater than zero and must not exceed either UINT_MAX or LONG_MAX. |
PPL_ERROR_LOGIC_ERROR if the library was configured with --enable-thread-safe or watchdog timers are not supported; otherwise, PPL_ERROR_INVALID_ARGUMENT if csecs is zero or exceeds LONG_MAX.Setting a timeout cancels any previously set timeout, including when the replacement fails.
Computations taking exponential time will be interrupted some time after csecs centiseconds have elapsed since the call to the timeout setting function. If the computation is interrupted that way, the interrupted function will return error code PPL_TIMEOUT_EXCEPTION. Otherwise, if the computation completes without being interrupted, then the timeout should be reset by calling ppl_reset_timeout().
| int ppl_reset_timeout | ( | void | ) |
Resets the timeout time so that the computation is not interrupted.
| int ppl_set_deterministic_timeout | ( | unsigned long | unscaled_weight, |
| unsigned | scale ) |
Sets a threshold for computations whose completion could require an exponential amount of time.
PPL_ERROR_INVALID_ARGUMENT if unscaled_weight is zero or if the computed weight threshold exceeds the maximum allowed value.In a thread-safe build the budget belongs to the calling initialized thread. Other threads may independently compute, set or reset their own budgets. Thread and library finalization cancel the calling thread's deterministic timeout before native teardown.
| unscaled_weight | The unscaled maximum computational weight; it has to be non-zero. |
| scale | The scaling factor to be applied to unscaled_weight. |
If unscaled_weight has value 
scale has value 


PPL_TIMEOUT_EXCEPTION. Otherwise, if the computation completes without being interrupted, then the deterministic timeout should be reset by calling ppl_reset_deterministic_timeout().
| int ppl_reset_deterministic_timeout | ( | void | ) |
Resets the deterministic timeout so that the computation is not interrupted.
| int ppl_max_space_dimension | ( | ppl_dimension_type * | m | ) |
Writes to m the maximum space dimension this library can handle.
| m | The number of space dimensions to add. |
| int ppl_not_a_dimension | ( | ppl_dimension_type * | m | ) |
Writes to m a value that does not designate a valid dimension.
| m | The number of space dimensions to add. |
| int ppl_io_print_variable | ( | ppl_dimension_type | var | ) |
Pretty-prints var to stdout.
| var | The index of the selected space dimension. |
| int ppl_io_fprint_variable | ( | FILE * | stream, |
| ppl_dimension_type | var ) |
Pretty-prints var to the given output stream.
| stream | The file stream to which output is written. |
| var | The index of the selected space dimension. |
| int ppl_io_asprint_variable | ( | char ** | strp, |
| ppl_dimension_type | var ) |
Pretty-prints var to a malloc-allocated string, a pointer to which is returned via strp.
| strp | Receives the newly malloc-allocated string; the caller must release it with free(). |
| var | The index of the selected space dimension. |
var to a malloc-allocated string, a pointer to which is returned via strp. | int ppl_io_set_variable_output_function | ( | ppl_io_variable_output_function_type * | p | ) |
Sets the output function to be used for printing variables to p.
| p | The callback used to print variable names. |
| int ppl_io_get_variable_output_function | ( | ppl_io_variable_output_function_type ** | pp | ) |
Writes a pointer to the current variable output function to pp.
| pp | The address receiving the current variable-output callback. |
| char * ppl_io_wrap_string | ( | const char * | src, |
| unsigned | indent_depth, | ||
| unsigned | preferred_first_line_length, | ||
| unsigned | preferred_line_length ) |
Utility function for the wrapping of lines of text.
| src | The source string holding the text to wrap. |
| indent_depth | The indentation depth. |
| preferred_first_line_length | The preferred length for the first line of text. |
| preferred_line_length | The preferred length for all the lines but the first one. |
| int ppl_is_mixed_integer_satisfiable | ( | ppl_dimension_type | dimension, |
| ppl_const_Constraint_System_t | cs, | ||
| const ppl_dimension_type | integers[], | ||
| size_t | n ) |
Tests exact strict mixed-integer feasibility in an explicit ambient space. Inputs are preserved. Returns 1/0 for feasible/infeasible and a negative error code for invalid dimensions or native exceptions.
| dimension | The dimension of the enclosing vector space. |
| cs | The borrowed handle to the input object. |
| integers | The dimensions whose coordinates must be integer. |
| n | The number of elements or space dimensions selected by the operation. |