aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/objectives/IGlobalConstraint.java
blob: 2f7f03477ec2a30931bffafce69949a98e88b47d (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
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2010-2014, Miklos Foldenyi, Andras Szabolcs Nagy, Abel Hegedus, Akos Horvath, Zoltan Ujhelyi and Daniel Varro
 * 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 org.eclipse.viatra.dse.objectives;

import org.eclipse.viatra.dse.base.ThreadContext;

/**
 * 
 * Implementation of this interface represents a global constraint of the DSE problem, which can halt an exploration
 * continuing from a state which dissatisfies the global constraint.
 * <p>
 * Certain global constraints can have inner state for the validation. In this case a new instance is necessary for
 * every new thread, and the {@code createNew} method should not return the same instance more than once.
 * 
 * @author Andras Szabolcs Nagy
 *
 */
public interface IGlobalConstraint {

    /**
     * Returns the name of the global constraint.
     * 
     * @return The name of the global constraint.
     */
    String getName();

    /**
     * Checks whether the current state satisfies the global constraint.
     * 
     * @param context
     *            The {@link ThreadContext} which contains the necessary information.
     * @return True if the state is valid and exploration can be continued from the actual state.
     */
    boolean checkGlobalConstraint(ThreadContext context);

    /**
     * Initializes the global constraint. It is called exactly once for every thread starts.
     * 
     * @param context
     *            The {@link ThreadContext}.
     */
    void init(ThreadContext context);

    /**
     * Returns an instance of the {@link IGlobalConstraint}. If it returns the same instance, all the methods has to be
     * thread save as they are called concurrently.
     * 
     * @return An instance of the global constraint.
     */
    IGlobalConstraint createNew();

}