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 double
static final double
static final double
static final double
protected 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 double
protected double
_calculateCost
(PatternMatchCounter counter, IConstraintEvaluationContext input) protected double
_calculateCost
(TypeFilterConstraint exportedParam, IConstraintEvaluationContext input) protected double
protected 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 strategydouble
bucketSize
(IQueryReference patternCall, IConstraintEvaluationContext input, TupleMask projMask) Override this to provide custom estimates for match set sizes of called patterns.protected double
calculateBinaryCost
(IInputKey supplierKey, PVariable srcVariable, PVariable dstVariable, boolean isInverse, IConstraintEvaluationContext input) protected double
calculateBinaryExtendCost
(IInputKey supplierKey, PVariable srcVariable, PVariable dstVariable, boolean isInverse, long edgeCount, IConstraintEvaluationContext input) Deprecated.double
calculateCost
(PConstraint constraint, IConstraintEvaluationContext input) protected double
calculateUnaryConstraintCost
(TypeConstraint constraint, IConstraintEvaluationContext input) long
countTuples
(IConstraintEvaluationContext input, IInputKey supplierKey) Deprecated.call and implementprojectionSize(IConstraintEvaluationContext, IInputKey, TupleMask, Accuracy)
insteadprotected boolean
navigatesThroughFunctionalDependency
(IConstraintEvaluationContext input, PConstraint constraint) protected boolean
navigatesThroughFunctionalDependency
(IConstraintEvaluationContext input, PConstraint constraint, Collection<PVariable> determining, Collection<PVariable> determined) protected boolean
navigatesThroughFunctionalDependencyInverse
(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:
apply
in 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