-
Notifications
You must be signed in to change notification settings - Fork 0
PromotingMaskingRating
So far we have been dealing with the promoting morphing strategy. Morpheus however offers other strategies, which employ other approaches to choosing the winner alternative. We are going to learn two new strategies in this lesson:
- Masking strategy is used to reduce a morph model's list of alternatives by means of the so-called fragment mask
- Rating strategy assigns a rating to one or more alternatives. Only those alternatives with the highest rating are used to select the winner alternative.
The rating strategy has the highest authority, then the masking one, while the least important is the promoting one.
Before presenting the masking and rating strategy, we need to get more information on how the promoting strategy works.
Let us consider the following simple morph model
(Offline or Online) with (Raw or Pretty)
This model can be depicted as a tree shown on the following figure.
The model has two dimensions that correspond to the two disjunctors (or
) in the model. Each disjunctor contains two alternative fragments, thus the number of all alternatives defined by this model is 4. A very important aspect is the order of the alternatives in the list since the first alternative in the list is by default taken as the winner. According to the rules described here the list of the alternatives generated by the model will be sorted in this way:
{0, 2}
{1, 2}
{0, 3}
{1, 3}
Definition: Two fragments are independent if they belong to two different disjunctors (i.e. dimensions).
The goal of the promoting strategy is to 'promote' one or more independent fragments. It means to transform the morph model tree in such a way that the promoted fragments are present in the first alternative in the list generated from the tree, i.e. the default winning alternative.
We will use notation (contactCoord, printerCoord)
to denote the fragments to be promoted. Then (0, 0)
is the default promotion leading to choosing the {Offline, Raw}
alternative.
In order to promote fragments (1, 0)
, the promoting strategy must transform the tree as follows.
The new tree yields this list of alternatives.
{1, 2}
{0, 2}
{1, 3}
{0, 3}
We can continue by promoting (1, 1)
. The corresponding tree will then be this.
And the corresponding list of alternative is:
{1, 3}
{0, 3}
{1, 2}
{0, 2}
And finally the remaining combination is (0, 1)
, which gives this tree:
with these alternatives:
{0, 3}
{1, 3}
{0, 2}
{1, 2}
Masking allows us to suppress alternatives, which do not match the so-called fragment mask. The fragment mask specifies which fragments must be present in the winning alternative. It effectively reduces the set of the alternatives.
In order to make the explanation easier, let us introduce the following notation, which represents an alternative along with a bit vector indicating fragments contained in the alternative.
{fragments}[OfflineBit, OnlineBit, RawBit, PrettyBit]
The four alternatives from our model then look like this:
{0, 2}[1, 0, 1, 0]
{1, 2}[0, 1, 1, 0]
{0, 3}[1, 0, 0, 1]
{1, 3}[0, 1, 0, 1]
Now, the fragment mask for our model is a vector of four bits. A bit fN
set to 1 indicates that the corresponding fragment must be present.
mask = (f0 f1 f2 f3)
We can use this mask to reduce the original list of alternatives A
. The sublist S ⊂ A
consists of all alternatives whose bit vector a
masked with the fragment mask (bitwise AND) gives the fragment mask. It can be formulated more precisely by the following formula.
∀ a ∈ S; a & mask = mask
For a better manipulation with the fragment bits, let us construct the following matrix corresponding to the previous list of alternatives.
|1 0 1 0|
|0 1 1 0|
F = |1 0 0 1|
|0 1 0 1|
When no fragment is explicitly specified, the mask is (0 0 0 0)
. Masking matrix F
gives the zero matrix, where all raws matches the mask. Thus there is no reduction of the original list of alternatives.
|0 0 0 0|
|0 0 0 0|
F & mask = |0 0 0 0|
|0 0 0 0|
If we wish to constrain the list of alternatives only to those containing the Pretty
fragment, the mask will be (0 0 0 1)
. Masking matrix F
then will yield the following matrix.
|0 0 0 0|
|0 0 0 0|
F & mask = |0 0 0 1|
|0 0 0 1|
Here, only the last two rows match the mask. The first alternative in the sublist, which preserves the order of the original list, is the winner.
{0, 3}[1, 0, 0, 1]
{1, 3}[0, 1, 0, 1]
If we add an additional fragment to the mask, let us say Online
, the mask will be (0 1 0 1)
. Then the masked matrix F
will be
|0 0 0 0|
|0 1 0 0|
F & mask = |0 0 0 1|
|0 1 0 1|
where only the last row matches the mask. This single alternative becomes the winner.
{1, 3}[0, 1, 0, 1]
Note: Using an invalid mask is equivalent to that of the empty mask, i.e. no alternative is suppressed.
The rating strategy allows us to rate individual alternatives. Then the winner alternative is selected only from those alternatives having the highest rating. For a better understanding let us use the following notation, which depicts the rating of an alternative.
{fragments}:Rating
By default the alternatives have no rating, i.e. their rating is 0. The four alternatives from our model then look like this:
{0, 2}:0
{1, 2}:0
{0, 3}:0
{1, 3}:0
We can explicitly assign new rating to a selected sub-set of the original alternatives. Let's say we will rate alternatives 1 and 4 by 1. Then the sub-list will look like this
{0, 2}:1
{1, 3}:1
since only this two alternatives have the highest rating. The winner is the first alternative in this sub-list.
a mask-matching alternative, a suppressed alternative with a low rating, the winner alternative
Promoting fragment 1.
{1, 2}:0
{0, 2}:0
{1, 3}:0
{0, 3}:0
Masking fragment 3.
{1, 2}:0
{0, 2}:0
{1, 3}:0
{0, 3}:0
Rating alternatives {1, 2} and {0, 3}.
{1, 2}:1
{0, 2}:0
{1, 3}:0
{0, 3}:1
Masking fragment 2.
{1, 2}:1
{0, 2}:0
{1, 3}:0
{0, 3}:1
####Morpheus Tutorial####
- Modelling simple entity
- Adding some behavior
- Abstracting fragment
- Reusing fragment
- Using fragment in Java
- Multidimensional morphs
- Morphing strategies
- Mutable morphs
- Delegating and sharing
- Dimension wrappers
- Fragment wrappers
- Using a morph as a fragment
- Kernel references
- Kernel references use cases
- Promoting, masking and rating