A toolbox for analysing weakly-hard constraints in Julia.
To install, in the Julia REPL:
using Pkg; Pkg.add("WeaklyHard")
All functions have docstrings which can be viewed from the REPL, using for example ?build_automaton
.
We provide a number of weakly-hard constraint structs, used as input to different analysis functions.
AnyHitConstraint(x, k)
: For any window ofk
consecutive job activations, at leastx
jobs hit their corresponding deadline;AnyMissConstraint(x, k)
: For any window ofk
consecutive job activations, at mostx
jobs miss their corresponding deadline;RowHitConstraint(x, k)
: For any window ofk
consecutive job activations, at leastx
consecutive jobs hit their corresponding deadline;RowMissConstraint(x)
: For any window ofk
consecutive job activations, at mostx
consecutive jobs miss their corresponding deadline.
An automaton representation of a weakly-hard constraint is a struct consisting of a record containing X
amount of integers as:
Automaton{Int} with X vertices:
{
WordVertex{Int}(x => y, z)
...
} with head: WordVertex{Int}(x => y, z)
Here, WordVertex{Int}(x => y, z)
indicates a vertex represented by an Integer
type, where x
is the word the vertex is representating and y
, z
are the direct successors corresponding to respectively a deadline miss and a deadline hit.
using WeaklyHard
# Constraints
lambda1 = AnyHitConstraint(1, 3)
lambda2 = RowHitConstraint(2, 6)
# Check dominance
is_dominant(lambda1, lambda2) # false
is_dominant(lambda2, lambda1) # false
# Generate automaton for lambda1
G1 = build_automaton(lambda1)
# This generates the automaton:
# Automaton{Int64} with 3 vertices:
# {
# WordVertex{Int64}(100 => ---, 001) # --- is an infeasible vertex
# WordVertex{Int64}(010 => 100, 001)
# WordVertex{Int64}(001 => 010, 001)
# } with head: WordVertex{Int64}(1 => 10, 1)
G2 = build_automaton(lambda2)
# This generates the automaton:
# Automaton{Int64} with 6 vertices:
# {
# WordVertex{Int64}(01100 => 11000, 00001)
# WordVertex{Int64}(11000 => -----, 00001)
# WordVertex{Int64}(01101 => 11000, 00011)
# WordVertex{Int64}(00011 => 00110, 00011)
# WordVertex{Int64}(00110 => 01100, 01101)
# WordVertex{Int64}(00001 => -----, 00011)
# } with head: WordVertex{Int64}(11 => 110, 11)
# Generate a random sequence of length N satisfying the constraint represented by G2
N = 100_000
seq = random_sequence(G2, N)
bitstring(seq)
# The bit representation of the integer
if the bitstring has M < N
characters, it implies that the first N-M
characters are misses (since julia interpret zeros before the MSB in a bit
string as non-existent)
See the examples folder