module Resolution:Naive implementation of the resolution algorithm of adaptability constraints. The goal of the implementation is to illustrate the algorithm presented in the article MPC 2012, not to provide an efficient implementation of the algorithm.sig
..end
exception Solve
Solve
exception is raised if a constraint system cannot be
solved.
Introduction of word variables c_n
and simplification of type
varaibles such that the subtyping constraint system is rewritten
into an equivalent adaptability constraint system.
val split_clock_type : Clock_type.clock_type ->
Clock_type.clock_type_variable * Clock_expression.word_expr
val adaptability_cstr_of_subtyping_cstr : Clock_type.subtype_cstr -> Clock_expression.adaptability_cstr
'a_x on p_x on p_x' on ... <: 'a_y on p_y on p_y' on ...
into
an adaptability constraint
c_x on p_x on p_x' on ... <: c_y on p_y on p_y' on ...
or into
p_x on p_x' on ... <: p_y on p_y' on ...
if 'a_x = 'a_y
.val adaptability_cstrs_of_subtyping_cstrs : Clock_type.subtype_cstr list -> Clock_expression.adaptability_cstr list
Computation of on
and simplification of p_x <: p_y
constraints
in an adaptability constraint system. The resulting system is an
equivalent adaptability constraint system where all the
constraints have the simple shape c_x on p_x <: c_y on p_y
.
val simplify_adaptability_cstr : Clock_expression.adaptability_cstr ->
Clock_expression.simplified_adaptability_cstr option
c_x on p_1 on p_1' on ... <: c_y on p_2 on p_2' on ...
into
c_x on p_x <: c_y on p_y
or check that an adaptability constraint
p_1 on p_1' on ... <: p_2 on p_2' on ...
is satisfied.val simplified_adaptability_cstrs_of_adaptability_cstrs : Clock_expression.adaptability_cstr list ->
Clock_expression.simplified_adaptability_cstr list
c_x on p_x <: c_y on p_y
.
This step takes as input a simplified adaptability constraint
system where the shape of the constraint is c_x on p_x <: c_y on p_y
.
It returns an equivalent adaptability constraint system where for
each c_n, the size of its samplers is equal.
val adjust_size : Clock_expression.word_variable * Pbword.periodic_binary_word ->
Clock_expression.simplified_adaptability_cstr list ->
Clock_expression.word_variable * Pbword.periodic_binary_word
c on p
into c on p'
such that p = p'
and
|p'.u| = max { |p''.u| | p'' \in samplers_c(A) }
and
|p'.v| = lcm { |p''.v| | p'' \in samplers_c(A) }
.val adjusted_adaptability_cstrs_of_simplified_adaptability_cstrs : Clock_expression.simplified_adaptability_cstr list ->
Clock_expression.simplified_adaptability_cstr list
In this step, we choose the number of 1s in each variable c_n
.
Then we transforme an adjusted adaptability constraint
system into the corresponding synchronizability and
precedence constraints.
val choose_nbones : Clock_expression.word_variable ->
Clock_expression.simplified_adaptability_cstr list -> int -> int -> int * int
|c_n.u|_1
) and in the periodic part (|c_n.v|_1
) such that
|c_n.u|_1 = |p_n.u| + k * |p_n.v| ( = |p'_n.u| + k * |p'_n.v| = ...)
and
|c_n.n|_1 = k' * |p_n.v| ( = k' * |p'_n.v| = ...)
with p_n \in samplers_{c_n}(A)
, p'_n \in samplers_{c_n}(A)
, ...val make_choice : int ->
int ->
Clock_expression.simplified_adaptability_cstr list ->
Clock_expression.choice_of_number_of_1
val split_adaptability_cstr : Clock_expression.simplified_adaptability_cstr ->
Clock_expression.synchronizability_cstr * Clock_expression.precedence_cstr
c_x on p_x <: c_y on p_y
into
a synchronizability constraint c_x on p_x |><| c_y on p_y
and
a precedence constraint c_x on p_x <= c_y on p_y
.val synchronizability_and_precedence_cstrs_of_adjusted_adaptability_cstrs : Clock_expression.simplified_adaptability_cstr list ->
Clock_expression.synchronizability_cstr list *
Clock_expression.precedence_cstr list
This translation depends on the choice of number on 1s in the
unknown words.
val simplify_synchronizability_cstr : Clock_expression.synchronizability_cstr -> Clock_expression.linear_cstr
c_x on p_x |><| c_y on p_y
into
a constraint on the size of the word variables:
|p_y.v|_1 * |c_x| = |p_x.v|_1 * |c_y|
.val simplify_synchronizability_cstrs : Clock_expression.synchronizability_cstr list ->
Clock_expression.linear_cstr list
val simplify_precedence_cstr : int ->
int -> Clock_expression.precedence_cstr -> Clock_expression.linear_cstr list
c_x on p_x <= c_y on p_y
into
constraints on the indexes of 1s:
for all 1 <= j <= h
,
I_{c_x}(I_{p_x}(j)) <= I_{c_x}(I_{p_x}(j))
with h = max (|p_x.u|_1 + k * |p_x.v|_1, |p_y.u|_1 + k * |p_y.v|_1) +
lcm (k' * |p_x.v|_1, k' * |p_y.v|_1)
.val simplify_precedence_cstrs : Clock_expression.choice_of_number_of_1 ->
Clock_expression.precedence_cstr list -> Clock_expression.linear_cstr list
val build_periodicity_cstr : Clock_expression.integer_variable ->
int * int -> Clock_expression.linear_cstr
I_{c_n}(j')
.
Suppose that j' = j + l * |c_n.v|_1
, the periodicity constraint is:
I_{c_n}(j') - I_{c_n}(j) = l * |c_n.v|
.val build_periodicity_cstrs : Clock_expression.linear_cstr list ->
Clock_expression.choice_of_number_of_1 -> Clock_expression.linear_cstr list
val build_sufficient_size_cstr : Clock_expression.word_variable -> int * int -> Clock_expression.linear_cstr
1 + I_{c_n}(|c_n.u|_1 + |c_n.u|_1) - I_{c_n}(|c_n.u|_1 + 1) <= |c_n.v|
.val build_sufficient_size_cstrs : Clock_expression.choice_of_number_of_1 -> Clock_expression.linear_cstr list
val build_sufficient_index_cstr : Clock_expression.integer_variable -> Clock_expression.linear_cstr
I_{c_n}(j)
:
I_{c_n}(j) >= j
.val build_sufficient_index_cstrs : Clock_expression.linear_cstr list ->
Clock_expression.linear_cstr list ->
Clock_expression.linear_cstr list -> Clock_expression.linear_cstr list
val build_increasing_index_cstrs_of_c_n : Clock_expression.Integer_var_set.t -> Clock_expression.linear_cstr list
I_{c_n}(j') - I_{c_n}(j) >= j' - j
.val build_increasing_index_cstrs : Clock_expression.linear_cstr list ->
Clock_expression.linear_cstr list ->
Clock_expression.linear_cstr list -> Clock_expression.linear_cstr list
val iof_and_size_cstrs_of_synchronizability_and_precedence_cstrs : Clock_expression.choice_of_number_of_1 ->
Clock_expression.synchronizability_cstr list ->
Clock_expression.precedence_cstr list -> Clock_expression.iof_and_size_cstrs
val iof_and_size_cstrs_of_adaptability_cstrs : ?verbose:bool ->
int ->
int ->
Clock_expression.adaptability_cstr list ->
Clock_expression.iof_and_size_cstrs
val iof_and_size_cstrs_solving : ?verbose:bool ->
Clock_expression.iof_and_size_cstrs -> int Clock_expression.Integer_var_map.t
val check_iof_and_size_sol : Clock_expression.iof_and_size_cstrs ->
int Clock_expression.Integer_var_map.t -> bool
val compute_size_c_n_u : Clock_expression.word_variable ->
int -> int Clock_expression.Integer_var_map.t -> int
val build_pbword : Clock_expression.word_variable ->
int ->
int -> int Clock_expression.Integer_var_map.t -> Pbword.periodic_binary_word
val pbwords_of_iof_and_size_sol : Clock_expression.choice_of_number_of_1 ->
int Clock_expression.Integer_var_map.t ->
Pbword.periodic_binary_word Clock_expression.Word_var_map.t
val check_adaptability_sol : Pbword.periodic_binary_word Clock_expression.Word_var_map.t ->
Clock_expression.adaptability_cstr list -> bool
val constraint_system_solving : ?verbose:bool ->
int ->
int ->
Clock_type.subtype_cstr list ->
Pbword.periodic_binary_word Clock_expression.Word_var_map.t
Let us transform the following subtyping constraint system
into linear constraints:
{ 'a_1 on 10(1) <: 'a_2 on (01) ;
'a_2 on (01) on (10) <: 'a_3 on (1) ;
'a_2 on (01) on (01) <: 'a_3 on (1) ; }
.
val subtyping_cstrs_C' : Clock_type.subtype_cstr list
val iof_and_size_cstrs_C' : Pbword.periodic_binary_word Clock_expression.Word_var_map.t