Class StatisticsBasedConstraintCostFunction
- java.lang.Object
-
- org.eclipse.viatra.query.runtime.localsearch.planner.cost.impl.StatisticsBasedConstraintCostFunction
-
- All Implemented Interfaces:
ICostFunction
- Direct Known Subclasses:
IndexerBasedConstraintCostFunction
public abstract class StatisticsBasedConstraintCostFunction extends java.lang.Object implements ICostFunction
Cost function which calculates cost based on the cardinality of items in the runtime modelTo provide custom statistics, override
projectionSize(IConstraintEvaluationContext, IInputKey, TupleMask, Accuracy)
andbucketSize(IQueryReference, IConstraintEvaluationContext, TupleMask)
.- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description protected static double
DEFAULT_COST
static double
EVAL_UNWIND_EXTENSION_FACTOR
static double
INVERSE_NAVIGATION_PENALTY_DEFAULT
static double
INVERSE_NAVIGATION_PENALTY_GENERIC
protected static double
MAX_COST
-
Constructor Summary
Constructors Constructor Description StatisticsBasedConstraintCostFunction()
StatisticsBasedConstraintCostFunction(double inverseNavigationPenalty)
-
Method Summary
-
-
-
Field Detail
-
MAX_COST
protected static final double MAX_COST
- See Also:
- Constant Field Values
-
DEFAULT_COST
protected static final double DEFAULT_COST
- See Also:
- Constant Field Values
-
INVERSE_NAVIGATION_PENALTY_DEFAULT
public static final double INVERSE_NAVIGATION_PENALTY_DEFAULT
- Since:
- 2.1
- See Also:
- Constant Field Values
-
INVERSE_NAVIGATION_PENALTY_GENERIC
public static final double INVERSE_NAVIGATION_PENALTY_GENERIC
- Since:
- 2.1
- See Also:
- Constant Field Values
-
EVAL_UNWIND_EXTENSION_FACTOR
public static final double EVAL_UNWIND_EXTENSION_FACTOR
- Since:
- 2.7
- See Also:
- Constant Field Values
-
-
Method Detail
-
countTuples
@Deprecated public long countTuples(IConstraintEvaluationContext input, IInputKey supplierKey)
Deprecated.call and implementprojectionSize(IConstraintEvaluationContext, IInputKey, TupleMask, Accuracy)
instead
-
projectionSize
public java.util.Optional<java.lang.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 java.util.Optional<java.lang.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
public double apply(IConstraintEvaluationContext input)
- Specified by:
apply
in interfaceICostFunction
-
_calculateCost
protected double _calculateCost(ConstantValue constant, IConstraintEvaluationContext input)
-
_calculateCost
protected double _calculateCost(TypeConstraint constraint, IConstraintEvaluationContext input)
-
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
-
navigatesThroughFunctionalDependency
protected boolean navigatesThroughFunctionalDependency(IConstraintEvaluationContext input, PConstraint constraint)
- Since:
- 1.7
-
navigatesThroughFunctionalDependencyInverse
protected boolean navigatesThroughFunctionalDependencyInverse(IConstraintEvaluationContext input, PConstraint constraint)
- Since:
- 2.1
-
navigatesThroughFunctionalDependency
protected boolean navigatesThroughFunctionalDependency(IConstraintEvaluationContext input, PConstraint constraint, java.util.Collection<PVariable> determining, java.util.Collection<PVariable> determined)
- 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
protected double _calculateCost(Inequality inequality, IConstraintEvaluationContext input)
- Since:
- 1.7
-
_calculateCost
protected double _calculateCost(AggregatorConstraint aggregator, IConstraintEvaluationContext input)
- Since:
- 1.7
-
_calculateCost
protected double _calculateCost(NegativePatternCall call, IConstraintEvaluationContext input)
- Since:
- 1.7
-
_calculateCost
protected double _calculateCost(PatternMatchCounter counter, IConstraintEvaluationContext input)
- 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
protected double _calculateCost(PConstraint constraint, IConstraintEvaluationContext input)
Default cost calculation strategy
-
calculateCost
public double calculateCost(PConstraint constraint, IConstraintEvaluationContext input)
- Throws:
ViatraQueryRuntimeException
-
-