typedef enum ap_constyp_t { AP_CONS_EQ, /* equality constraint */ AP_CONS_SUPEQ, /* >= constraint */ AP_CONS_SUP, /* > constraint */ AP_CONS_EQMOD, /* congruence equality constraint */ AP_CONS_DISEQ /* disequality constraint */ } ap_constyp_t;
Datatype for type of constraints.
typedef struct ap_lincons0_t { ap_linexpr0_t* linexpr0; /* expression */ ap_constyp_t constyp; /* type of constraint */ ap_scalar_t* scalar; /* maybe NULL. For EQMOD constraint, indicates the modulo */ } ap_lincons0_t;
Datatype for constraints.
Constraints are meant to be manipulated freely via their components. Creating the constraint [1,2]x0 + 5/2x1 >=0
and then freeing it can be done with
ap_lincons0_t cons = ap_lincons0_make(AP_CONS_SUPEQ, ap_linexpr0_alloc(AP_LINEXPR_SPARSE,2), NULL); ap_linexpr0_set_list(cons.linexpr0, AP_COEFF_I_INT, 1,2, 0, AP_COEFF_S_FRAC, 5,2, 1, AP_END); ap_lincons0_clear(&cons);
typedef struct ap_lincons0_array_t { ap_lincons0_t* p; size_t size; } ap_lincons0_array_t;
Datatype for arrays of constraints.
Arrays are accessed directly, for example by writing
array->p[i]
(of type ap_lincons0_t
),
array->p[i].constyp
and array->p[i].linexpr0
.
One can assign a constraint to the index index by writing:
array->p[index] = ap_lincons0_make(constyp,expr)
.
ap_lincons0_t
ap_lincons0_make (ap_constyp_t constyp, ap_linexpr0_t* linexpr, ap_scalar_t* mod)
¶Create a constraint of type constyp with the expression
linexpr, and the modulo mod in case of a congruence
constraint (constyp==AP_CONS_EQMOD
).
The expression is not duplicated, just pointed to, so it becomes managed via the constraint.
ap_lincons0_t
ap_lincons0_make_unsat ()
¶Create the constraint -1>=0
.
ap_lincons0_t
ap_lincons0_copy (ap_lincons0_t* cons)
¶Duplication
void
ap_lincons0_clear (ap_lincons0_t* cons)
¶Clear the constraint.
void
ap_lincons0_fprint (FILE* stream, ap_lincons0_t* cons, char** name_of_dim);
¶Print the linear constraint on stream stream, using the array
name_of_dim to convert dimensions to variable names. If
name_of_dim is NULL
, the dimensions are named
x0,x1,...
.
bool
ap_lincons0_is_unsat (ap_lincons0_t* cons)
¶Return true
if the constraint is not satisfiable.
ap_lincons0_array_t
ap_lincons0_array_make (size_t size)
¶Allocate an array of size constraints.
The constraints are initialized with NULL pointers for underlying expressions.
void
ap_lincons0_array_clear (ap_lincons0_array_t* array)
¶Clear the constraints of the array, and then the array itself.
void
ap_lincons0_array_fprint (FILE* stream, ap_lincons0_array_t* array, char** name_of_dim)
¶Print the array on the stream.
void
ap_lincons0_add_dimensions_with (ap_lincons0_t* cons, ap_dimchange_t* dimchange)
¶ap_lincons0_t
ap_lincons0_add_dimensions (ap_lincons0_t* cons, ap_dimchange_t* dimchange)
¶These two functions add dimensions to the constraint, following
the semantics of dimchange (see the type definition of ap_dimchange_t
).
void
ap_lincons0_permute_dimensions_with (ap_lincons0_t* cons, ap_dimperm_t* perm)
¶ap_lincons0_t
ap_lincons0_permute_dimensions (ap_lincons0_t* cons, ap_dimperm_t* perm)
¶These two functions apply the given permutation to the dimensions of cons.
void
ap_lincons0_array_add_dimensions_with (ap_lincons0_array_t* cons, ap_dimchange_t* dimchange)
¶ap_lincons0_array_t
ap_lincons0_array_add_dimensions (ap_lincons0_array_t* cons, ap_dimchange_t* dimchange)
¶void
ap_lincons0_array_permute_dimensions_with (ap_lincons0_array_t* cons, ap_dimperm_t* perm)
¶ap_lincons0_array_t
ap_lincons0_array_permute_dimensions (ap_lincons0_array_t* cons, ap_dimperm_t* perm)
¶Extension to arrays of the corresponding functions on constraints.