• No results found

5.3 Implementation

5.3.6 Pathfinding

The pathfinder consists of the main class Pathfinder and its subclasses MustPath- finder, AuthorPathfinder, AlternativePathfinder, DecreasePathfinder, and IncreasePathfinder. Therefore it first starts the MustPathfinder that creates paths containing only content-sections that must be presented. After this, all the other pathfinders are started. They get the must-be-presented paths as input parameter.

Pathfinder

The Pathfinder class provides the functionality that is needed by all or most of the pathfinding algorithms. It adds conditions from the end of repeats to the paths, rates steps and whole paths, and merges paths.

addConditions The pathfinding algorithms create paths without taking care about the conditions of the repeats. This method adds the conditions at the right place of the path as conditionSteps.

rateStep Before the whole path can be rated, each step has to be rated. There- fore each needContext of all steps is compared to the current state. That is any setContext that might have occurred beforehand. As an example, two nearness and one overlapping comparing algorithms have been implemented.

Two possibilities to check the nearness are implemented: One that uses a limited value range and can compare in a linear way:

5.3. Implementation n =                minp−maxn

maxl−minl maxn< minp

minn−maxp

maxl−minl maxp < minn

1 for all other cases

(5.1)

maxl: limit maximum value

minl: limit minimum value

maxn: need maximum value

minn: need minimum value

maxp: set maximum value

minp: set minimum value

n: nearness

However, in cases where no limit can be given, the following algorithm is used:

n =                1

1+minp−maxn maxn< minp

1

1+minn−maxp maxp < minn

1 for all other cases

(5.2)

maxn: need maximum value

minn: need minimum value

maxp: set maximum value

minp: set minimum value

The overlapping algorithm investigates how much the set context and the needed area overlap: I =                       

maxn− minn minn> minp∧ maxn < maxp

maxp− minp minn< minp∧ maxn > maxp

maxn− minp minn≤ minp∧ maxn≤ maxp

maxp− minn minn≥ minp∧ maxn≥ maxp

(5.3) i =               

0 maxn ≤ minp∨ maxp ≤ minn

1 maxn = maxp∧ minn= minp

2I

maxn−minn+maxp−minp for all other cases

(5.4)

maxn: need maximum value

minn: need minimum value

maxp: set maximum value

minp: set minimum value

I: overlapping

i: standardised overlapping

rateAndCreate This method rates the whole path, creates a Path-record and sorts the paths regarding the outcome of the rating.

As a first possibility, all the parameters that have to be taken into account are averaged using the arithmetic mean. The algorithm itself is not focus of this work, but as one is needed for evaluating the approach, the following algorithm has been developed as an example. It must be evaluated in further research.

The rating formula determines the so-called path quality q for every path. First, the content-types are looked at. All the content-types’ weights W are cumulated:

5.3. Implementation

nt

X

i=1

Wi (5.5)

nt: Number of the content-types within the whole path

W: The content-type’s weight

The result of all context-comparisons K of each content-type is taken into considera- tion. Therefore these values are also cumulated for each content-type. The better the single context comparisons are and the higher the weight of the respective content is, the better this value becomes. Last, the result is divided by the number of content types nt to normalise it. If there are five content-types within a path, then all the

content-type weights are cumulated and divided by five. The greater the weights of the single content-types are, the greater the value gets. However, if there are negative weighted content-types, thus they are better-not-in-path, this value decreases.

Pnt i=1  Wi+ PnK j=1Kij nK  2nt (5.6)

nK: Number of the weighted contexts of a content-type

A similar calculation is needed for the content-sections: Pnc i=1  wi+ Pnk j=1kij nk  2nc (5.7)

nc: Number of the whole path’s content-sections

w: The content-sections’s weight

nk: Number of the weighted contexts of the respective content-section

k: Weighted context, thus the result of a context-comparison

The last factor is the content’s overall duration for a specific path. Every content- section defines a minimum, a maximum, and an average duration. While minimum and maximum duration are used as limitations for the path generation, the average duration is used in this formula. All the single duration t of each content-type regarding a specific path are cumulated and divided by the desired overall duration T. Because the best result (1) should be reached if the path’s duration is the same as the desired overall duration, some corrections are done:

1 − 1 − Pnc i=1ti T (5.8)

t: The respective content-section’s duration T: Desired average whole duration

The overall path quality is the sum that is divided by 3 to get a 1 as the best possible result:

5.3. Implementation q = 1 3    Pnt i=1  Wi+ PnK j=1Kij nK  2nt + Pnc i=1  wi+ Pnk j=1kij nk  2nc + 1 − 1 − Pnc i=1ti T    (5.9) q: The path-quality

nt: Number of the content types within the whole path

W: The content type’s weight

nK: Number of the weighted contexts of a content-type

K: Weighted context, thus the result of a context-comparison nc: Number of the whole path’s content-sections

w: The content’s weight

nk: Number of the weighted contexts of the respective content-section

k: Weighted context, thus the result of a context-comparison t: The respective content’s duration

T: Desired average whole contents’ duration

After this calculation, the path is sorted into one of the following categories: good: Everything is o.k., the path is presented to the user

too short: The path’s duration is less than the minimum Coherence duration

too long: The path’s duration is more than the maximum Coherence duration

impossible: One or more precondition tests failed

mergePaths Each pathfinder needs to merge in the content-sections that have been found by the mustPathfinder. Additionally, the increasePathfinder also needs to merge the found content-sections into the path that it should increase. To get a

coherent result, this methods adds these content-sections grouped by authors at the end of their corresponding repeats.

MustPathfinder

This pathfinder is started at first. It finds content-sections that must be presented but have not been already shown. These are content-sections with a weight of 1 or at least one content-section of content-types with a weight of 1. The result is treated as a normal complete path. However, because it is too short in most cases, it will not normally be shown directly but used as the input path for the IncreasePathfinder. AuthorPathfinder

The AuthorPathfinder collects all content-sections that still need to be presented and groups them by authors. These collections are sorted by the content-sections’ position.

AlternativePathfinder

Some of the paths created by the preceding pathfinders are not possible because at least one condition could not be fulfilled. First, this pathfinders find the step where this happened. Then it looks for content-sections with contexts that fulfil the condition. These content-sections are grouped by their authors, and all remaining content-sections of these authors that are part of a repeat are concatenated to paths. DecreasePathfinder

This pathfinder removes steps from the path until its duration is less than the Coherence’s maximum duration. Therefore it removes as many of the worst rated content-sections as needed to go below the duration limit.

5.3. Implementation IncreasePathfinder

The IncreasePathfinder is the opposite to the DecreasePathfinder: it adds steps to the path, until its duration is more than the Coherence’s minimum duration. It rates all the remaining content-sections and collects as many of the best rated content-sections as needed. These content-sections are grouped by authors and repeats. These collections are added to the path using the method mergePaths of the Pathinder (see page 147).