Class AbstractChainedReasoner

  • All Implemented Interfaces:
    IChainingReasoner, IReasoner

    public abstract class AbstractChainedReasoner
    extends java.lang.Object
    implements IChainingReasoner
    Implements an abstract chained reasoner. This reasoner does not perform upgrades. Chained reasoners shall be registered with the reasoner factory. Consider ChainedReasonerState for implementing the passed on reasoner state.
    Author:
    Holger Eichelberger
    • Method Detail

      • deriveDescriptor

        private static ReasonerDescriptor deriveDescriptor​(java.lang.String name,
                                                           java.lang.String version,
                                                           ReasonerDescriptor[] chain)
        Derives the descriptor from the descriptor chain.
        Parameters:
        name - the name of the reasoner
        version - the version of the reasoner
        chain - the chain of reasoners
        Returns:
        the derived reasoner descriptor
      • concatenate

        private static java.lang.String concatenate​(java.lang.String s1,
                                                    java.lang.String s2)
        Concatenates two strings regarding null for s2.
        Parameters:
        s1 - the first string
        s2 - the second string
        Returns:
        the concatenated string
      • upgrade

        public ReasoningResult upgrade​(java.net.URI url,
                                       ProgressObserver observer)
        Description copied from interface: IReasoner
        Updates the installation of this reasoner, e.g., in order to obtain a licensed reasoner version.
        Specified by:
        upgrade in interface IReasoner
        Parameters:
        url - The location of the implementation of the reasoner which should be upgraded
        observer - an optional progress observer, shall be ProgressObserver.NO_OBSERVER if unused
        Returns:
        The result of this upgrade process.
      • getDescriptor

        public ReasonerDescriptor getDescriptor()
        Description copied from interface: IReasoner
        Returns a descriptor stating common information about this reasoner.
        Specified by:
        getDescriptor in interface IReasoner
        Returns:
        the descriptor
      • isConsistent

        public ReasoningResult isConsistent​(Project project,
                                            ReasonerConfiguration reasonerConfiguration,
                                            ProgressObserver observer)
        Description copied from interface: IReasoner
        Checks whether a given variability model (project) is satisfiable.
        Specified by:
        isConsistent in interface IReasoner
        Parameters:
        project - The project which should be tested whether it is satisfiable.
        reasonerConfiguration - the reasoner configuration to be used for reasoning (e.g. taken from the UI, may be null)
        observer - an optional progress observer, shall be ProgressObserver.NO_OBSERVER if unused
        Returns:
        The result of this reasoning step. Can have the status Status.UNSUPPORTED if the concrete reasoner does not support this operation.
      • check

        public ReasoningResult check​(Configuration cfg,
                                     ReasonerConfiguration reasonerConfiguration,
                                     ProgressObserver observer)
        Description copied from interface: IReasoner
        Checks the configuration according to the given project structure and does not affect the configuration.
        Specified by:
        check in interface IReasoner
        Parameters:
        cfg - The current configuration to reason on.
        reasonerConfiguration - the reasoner configuration to be used for reasoning (e.g. taken from the UI, may be null)
        observer - an optional progress observer, shall be ProgressObserver.NO_OBSERVER if unused
        Returns:
        The result of this reasoning step. Can have the status Status.UNSUPPORTED if the concrete reasoner does not support this operation.
      • propagate

        public ReasoningResult propagate​(Configuration cfg,
                                         ReasonerConfiguration reasonerConfiguration,
                                         ProgressObserver observer)
        Description copied from interface: IReasoner
        Checks the configuration according to the given model and propagates values, if possible.
        Specified by:
        propagate in interface IReasoner
        Parameters:
        cfg - The configuration to reason on (may be modified as a side effect of value propagation)
        reasonerConfiguration - the reasoner configuration to be used for reasoning (e.g. taken from the UI, may be null)
        observer - an optional progress observer, shall be ProgressObserver.NO_OBSERVER if unused
        Returns:
        The result of this reasoning step. Can have the status Status.UNSUPPORTED if the concrete reasoner does not support this operation.
      • evaluate

        public EvaluationResult evaluate​(Configuration cfg,
                                         java.util.List<Constraint> constraints,
                                         ReasonerConfiguration reasonerConfiguration,
                                         ProgressObserver observer)
        Description copied from interface: IReasoner
        Evaluates a given list of constraints (in the sense of boolean conditions) which are related to and valid in the context of the given project and configuration.
        Specified by:
        evaluate in interface IReasoner
        Parameters:
        cfg - the configuration as a basis for the evaluation
        constraints - the constraints (expressions which evaluate to a boolean value)
        reasonerConfiguration - the reasoner configuration to be used for reasoning (e.g. taken from the UI, may be null)
        observer - an optional progress observer, shall be ProgressObserver.NO_OBSERVER if unused
        Returns:
        The result of this reasoning step. Can have the status Status.UNSUPPORTED if the concrete reasoner does not support this operation.
      • notify

        public void notify​(IReasonerMessage message)
        Description copied from interface: IReasoner
        Is called when a reasoner message is issued.
        Specified by:
        notify in interface IReasoner
        Parameters:
        message - the message sent
      • createInstance

        public IReasonerInstance createInstance​(Configuration cfg,
                                                ReasonerConfiguration reasonerConfiguration)
        Description copied from interface: IReasoner
        Creates a reasoner instance for repeated reasoning on the same model (no structural changes allowed during two subsequent reasoning runs).
        Specified by:
        createInstance in interface IReasoner
        Parameters:
        cfg - the configuration as a basis for the evaluation
        reasonerConfiguration - the reasoner configuration to be used for reasoning (e.g. taken from the UI, may be null)
        Returns:
        a reusable reasoner instance, return a DelegatingReasonerInstance on this reasoner to avoid null pointer checking.
      • setState

        public void setState​(Configuration config,
                             ReasoningResult result)
        Description copied from interface: IChainingReasoner
        Sets the state determined by the last reasoner. If not null, project and configuration passed in through the interface of IReasoner shall be ignored.
        Specified by:
        setState in interface IChainingReasoner
        Parameters:
        config - the configuration (may be null, shall be ignored then). config may be an internal result
        result - the last reasoning result (may be null, shall be ignored then, identifies beginning of chain). It is assumed that the constraints and variables mentioned in reasoning result fit to configuration