Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

8 Managing Derived Methods
 8.1 Info Class
 8.2 Derivation Objects
 8.3 Derivation Graphs
 8.4 Managing Derivations in a Category

8 Managing Derived Methods

8.1 Info Class

8.1-1 DerivationInfo
‣ DerivationInfo( info class )

Info class for derivations.

8.1-2 ActivateDerivationInfo
‣ ActivateDerivationInfo( arg )( function )

8.1-3 DeactivateDerivationInfo
‣ DeactivateDerivationInfo( arg )( function )

8.2 Derivation Objects

8.2-1 IsDerivedMethod
‣ IsDerivedMethod( arg )( filter )

Returns: true or false

A derivation object describes a derived method. It contains information about which operation the derived method implements, and which other operations it relies on.

8.2-2 CreateDerivation
‣ CreateDerivation( target_op_name, description, used_ops_with_multiples, func, weight, category_filter, loop_multiplier, category_getters )( function )

Creates a new derivation object. The argument target_op_name is the name of the operation which the derived method implements. The argument description should describe the derivation. The argument used_ops_with_multiples contains

This is given as a list of lists, where each sublist has as first entry the name of an operation, as second entry an integer and as third entry either a function or fail. This function should accept the category for which this derivation will be installed, and return a category for which the operation in the first entry must be installed for the derivation to be considered applicable. The argument func contains the actual implementation of the derived method. The argument weight is an additional number to add when calculating the resulting weight of the target operation using this derivation. Unless there is any particular reason to regard the derivation as exceedingly expensive, this number should be 1. The argument category_filter is a filter (or function) describing which categories the derivation is valid for. If it is valid for all categories, then this argument should have the value IsCapCategory. The output of category_filter must not change during the installation of operations. In particular, it must not rely on CanCompute to check conditions.

8.2-3 Description
‣ Description( d )( attribute )

A description of the derivation.

8.2-4 AdditionalWeight
‣ AdditionalWeight( d )( attribute )

Additional weight for the derivation.

8.2-5 DerivationFunction
‣ DerivationFunction( d )( attribute )

The implementation of the derivation.

8.2-6 CategoryFilter
‣ CategoryFilter( d )( attribute )

Filter describing which categories the derivation is valid for.

8.2-7 IsApplicableToCategory
‣ IsApplicableToCategory( d, C )( operation )

Returns: true if the category C is known to satisfy the category filter of the derivation d.

Checks if the derivation is known to be valid for a given category.

8.2-8 TargetOperation
‣ TargetOperation( d )( attribute )

Returns: The name (as a string) of the operation implemented by the derivation d

8.2-9 UsedOperationsWithMultiplesAndCategoryGetters
‣ UsedOperationsWithMultiplesAndCategoryGetters( d )( attribute )

Returns: The names of the operations used by the derivation d, together with their multiplicities and category getters. The result is a list consisting of lists of the form [op_name, mult, getter], where op_name is a string, mult a positive integer and getter is a function or fail.

8.2-10 InstallDerivationForCategory
‣ InstallDerivationForCategory( d, weight, C )( operation )

Install the derived method d for the category C. The integer weight is the computed weight of the operation implemented by this derivation.

8.2-11 FunctionCalledBeforeInstallation
‣ FunctionCalledBeforeInstallation( d )( attribute )

Input is a derived method. Output is a unary function that takes as an input a category and does not output anything. This function is always called before the installation of the derived method for a concrete instance of a category.

8.3 Derivation Graphs

8.3-1 IsDerivedMethodGraph
‣ IsDerivedMethodGraph( arg )( filter )

Returns: true or false

A derivation graph consists of a set of operations and a set of derivations specifying how some operations can be implemented in terms of other operations.

8.3-2 MakeDerivationGraph
‣ MakeDerivationGraph( operations )( operation )

Make a derivation graph containing the given set of operations and no derivations. The argument operations should be a list of strings, the names of the operations. The set of operations is fixed once the graph is created. Derivations can be added to the graph by calling AddDerivation.

8.3-3 AddOperationsToDerivationGraph
‣ AddOperationsToDerivationGraph( graph, operations )( operation )

Adds a list of operation names operations to a given derivation graph graph. This is used in extensions of CAP which want to have their own basic operations, but do not want to pollute the CAP kernel any more. Please use it with caution. If a weight list/category was created before it will not be aware of the operations.

8.3-4 AddDerivation
‣ AddDerivation( graph, target_op, description, used_ops_with_multiples_and_category_getters, func, weight, category_filter, loop_multiplier, category_getters, function_called_before_installation )( function )

Add a derivation to a derivation graph.

8.3-5 AddDerivationToCAP
‣ AddDerivationToCAP( arg )( function )

8.3-6 Operations
‣ Operations( G )( attribute )

Gives the operations in the graph G, as a list of strings.

8.3-7 DerivationsUsingOperation
‣ DerivationsUsingOperation( G, op_name )( operation )

Finds all the derivations in the graph G that use the operation named op_name, and returns them as a list.

8.3-8 DerivationsOfOperation
‣ DerivationsOfOperation( G, op_name )( operation )

Finds all the derivations in the graph G targeting the operation named op_name (that is, the derivations that provide implementations of this operation), and returns them as a list.

8.4 Managing Derivations in a Category

8.4-1 IsOperationWeightList
‣ IsOperationWeightList( arg )( filter )

Returns: true or false

An operation weight list manages the use of derivations in a single category \(C\). For every operation, it keeps a weight value which indicates how costly it is to perform that operation in the category \(C\). Whenever a new operation is implemented in \(C\), the operation weight list should be notified about this and given a weight to assign to this operation. It will then automatically install all possible derived methods for \(C\) in such a way that every operation has the smallest possible weight (the weight of a derived method is computed by using the weights of the operations it uses).

8.4-2 MakeOperationWeightList
‣ MakeOperationWeightList( C, G )( operation )

Create the operation weight list for a category. This should only be done once for every category, and the category should afterwards remember the returned object. The argument C is the CAP category this operation weight list is associated to, and the argument G is a derivation graph containing operation names and derivations.

8.4-3 DerivationGraph
‣ DerivationGraph( owl )( attribute )

Returns the derivation graph used by the operation weight list owl.

8.4-4 CategoryOfOperationWeightList
‣ CategoryOfOperationWeightList( owl )( attribute )

Returns the CAP category associated to the operation weight list owl.

8.4-5 CurrentOperationWeight
‣ CurrentOperationWeight( owl, op_name )( operation )

Returns the current weight of the operation named op_name.

8.4-6 OperationWeightUsingDerivation
‣ OperationWeightUsingDerivation( owl, d )( operation )

Finds out what the weight of the operation implemented by the derivation d would be if we had used that derivation.

8.4-7 DerivationOfOperation
‣ DerivationOfOperation( owl, op_name )( operation )

Returns the derivation which is currently used to implement the operation named op_name. If the operation is not implemented by a derivation (that is, either implemented directly or not implemented at all), then fail is returned.

8.4-8 TriggerDerivationsUsingOperation
‣ TriggerDerivationsUsingOperation( owl, op_name )( operation )

Performs a search from the operation op_name, and triggers all derivations that give improvements over the current state. This is used internally by InstallDerivations and Reevaluate. It should normally not be necessary to call this function directly.

8.4-9 Reevaluate
‣ Reevaluate( owl )( operation )

Reevaluate the installed derivations, installing better derivations if possible. This should be called if new derivations become available for the category, either because the category has acquired more knowledge about itself (e.g. it is told that it is abelian) or because new derivations have been added to the graph.

8.4-10 Saturate
‣ Saturate( owl )( operation )

Saturates the derivation graph, i.e., calls reevaluate until no more changes in the derivation graph occur.

8.4-11 AddPrimitiveOperation
‣ AddPrimitiveOperation( owl, op_name, weight )( operation )

Add the operation named op_name to the operation weight list owl with weight weight.

8.4-12 PrintDerivationTree
‣ PrintDerivationTree( owl, op_name )( operation )

Print a tree representation of the way the operation named op_name is implemented in the category of the operation weight list owl.

8.4-13 PrintTree
‣ PrintTree( arg1, arg2, arg3 )( operation )

Prints a tree structure.

8.4-14 PrintTreeRec
‣ PrintTreeRec( arg1, arg2, arg3, arg4 )( operation )
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Ind

generated by GAPDoc2HTML