Class StatisticsBasedConstraintCostFunction
java.lang.Object
tools.refinery.interpreter.localsearch.planner.cost.impl.StatisticsBasedConstraintCostFunction
- All Implemented Interfaces:
ICostFunction
- Direct Known Subclasses:
IndexerBasedConstraintCostFunction
Cost function which calculates cost based on the cardinality of items in the runtime model
To provide custom statistics, override
projectionSize(IConstraintEvaluationContext, IInputKey, TupleMask, Accuracy)
and bucketSize(IQueryReference, IConstraintEvaluationContext, TupleMask).
- Since:
- 1.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final doublestatic final doublestatic final doublestatic final doubleprotected static final double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected double_calculateCost(AggregatorConstraint aggregator, IConstraintEvaluationContext input) protected double_calculateCost(ExportedParameter exportedParam, IConstraintEvaluationContext input) protected double_calculateCost(ExpressionEvaluation evaluation, IConstraintEvaluationContext input) protected double_calculateCost(Inequality inequality, IConstraintEvaluationContext input) protected doubleprotected double_calculateCost(PatternMatchCounter counter, IConstraintEvaluationContext input) protected double_calculateCost(TypeFilterConstraint exportedParam, IConstraintEvaluationContext input) protected doubleprotected double_calculateCost(BinaryTransitiveClosure closure, IConstraintEvaluationContext input) protected double_calculateCost(ConstantValue constant, IConstraintEvaluationContext input) protected double_calculateCost(PositivePatternCall patternCall, IConstraintEvaluationContext input) protected double_calculateCost(TypeConstraint constraint, IConstraintEvaluationContext input) protected double_calculateCost(PConstraint constraint, IConstraintEvaluationContext input) Default cost calculation strategydoublebucketSize(IQueryReference patternCall, IConstraintEvaluationContext input, TupleMask projMask) Override this to provide custom estimates for match set sizes of called patterns.protected doublecalculateBinaryCost(IInputKey supplierKey, PVariable srcVariable, PVariable dstVariable, boolean isInverse, IConstraintEvaluationContext input) protected doublecalculateBinaryExtendCost(IInputKey supplierKey, PVariable srcVariable, PVariable dstVariable, boolean isInverse, long edgeCount, IConstraintEvaluationContext input) Deprecated.doublecalculateCost(PConstraint constraint, IConstraintEvaluationContext input) protected doublecalculateUnaryConstraintCost(TypeConstraint constraint, IConstraintEvaluationContext input) longcountTuples(IConstraintEvaluationContext input, IInputKey supplierKey) Deprecated.call and implementprojectionSize(IConstraintEvaluationContext, IInputKey, TupleMask, Accuracy)insteadprotected booleannavigatesThroughFunctionalDependency(IConstraintEvaluationContext input, PConstraint constraint) protected booleannavigatesThroughFunctionalDependency(IConstraintEvaluationContext input, PConstraint constraint, Collection<PVariable> determining, Collection<PVariable> determined) protected booleannavigatesThroughFunctionalDependencyInverse(IConstraintEvaluationContext input, PConstraint constraint) projectionSize(IConstraintEvaluationContext input, IInputKey supplierKey, TupleMask groupMask, Accuracy requiredAccuracy) Override this to provide custom statistics on edge/node counts.
-
Field Details
-
MAX_COST
protected static final double MAX_COST- See Also:
-
DEFAULT_COST
protected static final double DEFAULT_COST- See Also:
-
INVERSE_NAVIGATION_PENALTY_DEFAULT
public static final double INVERSE_NAVIGATION_PENALTY_DEFAULT- Since:
- 2.1
- See Also:
-
INVERSE_NAVIGATION_PENALTY_GENERIC
public static final double INVERSE_NAVIGATION_PENALTY_GENERIC- Since:
- 2.1
- See Also:
-
EVAL_UNWIND_EXTENSION_FACTOR
public static final double EVAL_UNWIND_EXTENSION_FACTOR- Since:
- 2.7
- See Also:
-
-
Constructor Details
-
StatisticsBasedConstraintCostFunction
public StatisticsBasedConstraintCostFunction(double inverseNavigationPenalty) - Since:
- 2.1
-
StatisticsBasedConstraintCostFunction
public StatisticsBasedConstraintCostFunction()
-
-
Method Details
-
countTuples
Deprecated.call and implementprojectionSize(IConstraintEvaluationContext, IInputKey, TupleMask, Accuracy)instead -
projectionSize
public Optional<Long> projectionSize(IConstraintEvaluationContext input, IInputKey supplierKey, TupleMask groupMask, Accuracy requiredAccuracy) Override this to provide custom statistics on edge/node counts. New implementors shall implement this instead ofcountTuples(IConstraintEvaluationContext, IInputKey)- Since:
- 2.1
-
bucketSize
public Optional<Double> bucketSize(IQueryReference patternCall, IConstraintEvaluationContext input, TupleMask projMask) Override this to provide custom estimates for match set sizes of called patterns.- Since:
- 2.1
-
apply
- Specified by:
applyin interfaceICostFunction
-
_calculateCost
-
_calculateCost
-
calculateBinaryExtendCost
@Deprecated protected double calculateBinaryExtendCost(IInputKey supplierKey, PVariable srcVariable, PVariable dstVariable, boolean isInverse, long edgeCount, IConstraintEvaluationContext input) Deprecated. -
calculateBinaryCost
protected double calculateBinaryCost(IInputKey supplierKey, PVariable srcVariable, PVariable dstVariable, boolean isInverse, IConstraintEvaluationContext input) - Since:
- 2.1
-
calculateUnaryConstraintCost
protected double calculateUnaryConstraintCost(TypeConstraint constraint, IConstraintEvaluationContext input) -
_calculateCost
protected double _calculateCost(ExportedParameter exportedParam, IConstraintEvaluationContext input) -
_calculateCost
protected double _calculateCost(TypeFilterConstraint exportedParam, IConstraintEvaluationContext input) -
_calculateCost
protected double _calculateCost(PositivePatternCall patternCall, IConstraintEvaluationContext input) -
_calculateCost
protected double _calculateCost(ExpressionEvaluation evaluation, IConstraintEvaluationContext input) - Since:
- 1.7
-
_calculateCost
- Since:
- 1.7
-
_calculateCost
protected double _calculateCost(AggregatorConstraint aggregator, IConstraintEvaluationContext input) - Since:
- 1.7
-
_calculateCost
- Since:
- 1.7
-
_calculateCost
- Since:
- 1.7
-
_calculateCost
protected double _calculateCost(BinaryTransitiveClosure closure, IConstraintEvaluationContext input) - Since:
- 1.7
-
_calculateCost
protected double _calculateCost(BinaryReflexiveTransitiveClosure closure, IConstraintEvaluationContext input) - Since:
- 2.0
-
_calculateCost
Default cost calculation strategy -
calculateCost
- Throws:
InterpreterRuntimeException
-
calculateBinaryCost(IInputKey, PVariable, PVariable, boolean, IConstraintEvaluationContext)instead