@@ -39,8 +39,6 @@ It is not mandatory to have n consecutive Integer as items. For example, the fol
In this example, the items are `{1,2,3,5}`. The first line of the value file represents the value of 1, the second line the value of 2, the third the value of 3 and the fourth the value of 5.
However, to work correctly, class items must have values inferior to that of no class items.
## Constraints
The following constraints are available:
...
...
@@ -161,3 +159,73 @@ The following measures are available (see the package `io.gitlab.chaver.mining.p
-`Max`
-`Min`
-`Mean`
## Code examples
The package `io.gitlab.chaver.mining.examples` contains examples on how to use constraints for specific tasks.
**ExampleAdequateClosure**
In this example, we want to mine the set of closed patterns w.r.t. the set of measures `{freq(x),max(x.freq)}`. We can analyse the code of the `main` method:
First, we create the data structures that we need to build our model. To build our set of measures (represented with a List), we can use the class `MeasureFactory` that is located in the package `io.gitlab.chaver.mining.patterns.measure` and which proposes different methods to instantiate measures.
Then, we create two integer variables `freq` and `length` which represent the frequency and the length (i.e. the number of items) of the pattern, and a BoolVar array that represents the pattern we are looking for (`x[i] = 1` means that item `i` belongs to the pattern).
We post a constraint that links the length variable to the the sum of `x` array. Then, we compute the frequency of each item in an array `itemFreq` such that `itemFreq[i]` represents the frequency of item `i`. We can now create an array of integer variables `itemFreqVar` such that:
-`itemFreqVar[i] = 0` if `x[i] = 0`
-`itemFreqVar[i] = itemFreq[i]` if `x[i] = 1`
We can finally compute the max frequency of the pattern in a variable named `maxFreq` by imposing a max constraint on the `itemFreqVar` array.
We post two constraints, **CoverSize** to compute the frequency of the pattern and **AdequateClosure** to ensure that `x` is closed w.r.t. the set of measures `{freq(x),max(x.freq)}`.