aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/viatra-runtime-localsearch/src/main/java/tools/refinery/viatra/runtime/localsearch/planner/cost/impl/IndexerBasedConstraintCostFunction.java
blob: 9e2c86806c973a3a39877d71c54c90670706d651 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/** 
 * Copyright (c) 2010-2016, Grill Balázs, IncQuery Labs Ltd.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-v20.html.
 * 
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.viatra.runtime.localsearch.planner.cost.impl;

import java.util.Optional;

import tools.refinery.viatra.runtime.localsearch.planner.cost.IConstraintEvaluationContext;
import tools.refinery.viatra.runtime.matchers.context.IInputKey;
import tools.refinery.viatra.runtime.matchers.tuple.TupleMask;
import tools.refinery.viatra.runtime.matchers.util.Accuracy;

/**
 * Cost function which calculates cost based on the cardinality of items in the runtime model, provided by the base indexer
 * 
 * @author Grill Balázs
 * @since 1.4
 */
public class IndexerBasedConstraintCostFunction extends StatisticsBasedConstraintCostFunction {
    
    
    

    /**
     * 
     */
    public IndexerBasedConstraintCostFunction() {
        super();
    }

    /**
     * @param inverseNavigationPenalty
     * @since 2.1
     */
    public IndexerBasedConstraintCostFunction(double inverseNavigationPenalty) {
        super(inverseNavigationPenalty);
    }

    @Override
    public Optional<Long> projectionSize(IConstraintEvaluationContext input, IInputKey supplierKey, TupleMask groupMask, Accuracy requiredAccuracy) {
        return input.getRuntimeContext().estimateCardinality(supplierKey, groupMask, requiredAccuracy);
    }
    
}