Class AbstractChainedReasoner
- java.lang.Object
-
- net.ssehub.easy.reasoning.core.frontend.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. ConsiderChainedReasonerStatefor implementing the passed on reasoner state.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAbstractChainedReasoner.DerivedReasonerDescriptorImplements a derived reasoner descriptor taking over capabilities.
-
Field Summary
Fields Modifier and Type Field Description private Configurationconfigprivate ReasonerDescriptordescriptorprivate EvaluationResultevaluationResultprivate IChainingReasoner[]reasonersprivate ReasoningResultreasoningResult
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractChainedReasoner(java.lang.String name, java.lang.String version, ReasonerDescriptor... chain)Creates an reasoner chain with given name and version.protectedAbstractChainedReasoner(ReasonerDescriptor descriptor, ReasonerDescriptor... chain)Creates an reasoner chain with given descriptor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReasoningResultcheck(Configuration cfg, ReasonerConfiguration reasonerConfiguration, ProgressObserver observer)Checks the configuration according to the given project structure and does not affect the configuration.private static java.lang.Stringconcatenate(java.lang.String s1, java.lang.String s2)Concatenates two strings regarding null fors2.IReasonerInstancecreateInstance(Configuration cfg, ReasonerConfiguration reasonerConfiguration)Creates a reasoner instance for repeated reasoning on the same model (no structural changes allowed during two subsequent reasoning runs).private static ReasonerDescriptorderiveDescriptor(java.lang.String name, java.lang.String version, ReasonerDescriptor[] chain)Derives the descriptor from the descriptor chain.EvaluationResultevaluate(Configuration cfg, java.util.List<Constraint> constraints, ReasonerConfiguration reasonerConfiguration, ProgressObserver observer)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.ReasonerDescriptorgetDescriptor()Returns a descriptor stating common information about this reasoner.ConfigurationgetLastConfiguration()Returns the last, potentially internal configuration.ReasoningResultisConsistent(Project project, ReasonerConfiguration reasonerConfiguration, ProgressObserver observer)Checks whether a given variability model (project) is satisfiable.voidnotify(IReasonerMessage message)Is called when a reasoner message is issued.ReasoningResultpropagate(Configuration cfg, ReasonerConfiguration reasonerConfiguration, ProgressObserver observer)Checks the configuration according to the given model and propagates values, if possible.voidsetState(Configuration config, EvaluationResult result)Sets the state determined by the last reasoner.voidsetState(Configuration config, ReasoningResult result)Sets the state determined by the last reasoner.ReasoningResultupgrade(java.net.URI url, ProgressObserver observer)Updates the installation of this reasoner, e.g., in order to obtain a licensed reasoner version.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.reasoning.core.reasoner.IReasoner
createValue, initialize, setInterceptor
-
-
-
-
Field Detail
-
descriptor
private ReasonerDescriptor descriptor
-
reasoners
private IChainingReasoner[] reasoners
-
config
private Configuration config
-
reasoningResult
private ReasoningResult reasoningResult
-
evaluationResult
private EvaluationResult evaluationResult
-
-
Constructor Detail
-
AbstractChainedReasoner
protected AbstractChainedReasoner(java.lang.String name, java.lang.String version, ReasonerDescriptor... chain) throws java.lang.IllegalArgumentExceptionCreates an reasoner chain with given name and version. The descriptor is constructed from the descriptors in the chain.- Parameters:
name- the name of the reasonerversion- a version description of the integrated reasoner (may be null)chain- the reasoners to be chained (must be implementations ofIChainingReasoner)- Throws:
java.lang.IllegalArgumentException- in case that one of the given reasoner descriptors is null, the reasoner is not registered in the reasoner frontend, the first reasoner does not provideGeneralReasonerCapabilities.STANDALONE_REASONINGor at least one of the reasoners does not implementIChainingReasoner/ReasonerFrontend.isChainingReasoner(ReasonerDescriptor)
-
AbstractChainedReasoner
protected AbstractChainedReasoner(ReasonerDescriptor descriptor, ReasonerDescriptor... chain)
Creates an reasoner chain with given descriptor.- Parameters:
descriptor- the descriptor of the reasonerchain- the reasoners to be chained (must be implementations ofIChainingReasoner)- Throws:
java.lang.IllegalArgumentException- in case that one of the given reasoner descriptors is null, the reasoner is not registered in the reasoner frontend, the first reasoner does not provideGeneralReasonerCapabilities.STANDALONE_REASONINGor at least one of the reasoners does not implementIChainingReasoner/ReasonerFrontend.isChainingReasoner(ReasonerDescriptor)
-
-
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 reasonerversion- the version of the reasonerchain- 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 fors2.- Parameters:
s1- the first strings2- the second string- Returns:
- the concatenated string
-
upgrade
public ReasoningResult upgrade(java.net.URI url, ProgressObserver observer)
Description copied from interface:IReasonerUpdates the installation of this reasoner, e.g., in order to obtain a licensed reasoner version.- Specified by:
upgradein interfaceIReasoner- Parameters:
url- The location of the implementation of the reasoner which should be upgradedobserver- an optional progress observer, shall beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this upgrade process.
-
getDescriptor
public ReasonerDescriptor getDescriptor()
Description copied from interface:IReasonerReturns a descriptor stating common information about this reasoner.- Specified by:
getDescriptorin interfaceIReasoner- Returns:
- the descriptor
-
isConsistent
public ReasoningResult isConsistent(Project project, ReasonerConfiguration reasonerConfiguration, ProgressObserver observer)
Description copied from interface:IReasonerChecks whether a given variability model (project) is satisfiable.- Specified by:
isConsistentin interfaceIReasoner- 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 beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this reasoning step. Can have the status
Status.UNSUPPORTEDif the concrete reasoner does not support this operation.
-
check
public ReasoningResult check(Configuration cfg, ReasonerConfiguration reasonerConfiguration, ProgressObserver observer)
Description copied from interface:IReasonerChecks the configuration according to the given project structure and does not affect the configuration.- Specified by:
checkin interfaceIReasoner- 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 beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this reasoning step. Can have the status
Status.UNSUPPORTEDif the concrete reasoner does not support this operation.
-
propagate
public ReasoningResult propagate(Configuration cfg, ReasonerConfiguration reasonerConfiguration, ProgressObserver observer)
Description copied from interface:IReasonerChecks the configuration according to the given model and propagates values, if possible.- Specified by:
propagatein interfaceIReasoner- 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 beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this reasoning step. Can have the status
Status.UNSUPPORTEDif 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:IReasonerEvaluates 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:
evaluatein interfaceIReasoner- Parameters:
cfg- the configuration as a basis for the evaluationconstraints- 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 beProgressObserver.NO_OBSERVERif unused- Returns:
- The result of this reasoning step. Can have the status
Status.UNSUPPORTEDif the concrete reasoner does not support this operation.
-
notify
public void notify(IReasonerMessage message)
Description copied from interface:IReasonerIs called when a reasoner message is issued.
-
createInstance
public IReasonerInstance createInstance(Configuration cfg, ReasonerConfiguration reasonerConfiguration)
Description copied from interface:IReasonerCreates a reasoner instance for repeated reasoning on the same model (no structural changes allowed during two subsequent reasoning runs).- Specified by:
createInstancein interfaceIReasoner- Parameters:
cfg- the configuration as a basis for the evaluationreasonerConfiguration- the reasoner configuration to be used for reasoning (e.g. taken from the UI, may be null)- Returns:
- a reusable reasoner instance, return a
DelegatingReasonerInstanceon this reasoner to avoid null pointer checking.
-
setState
public void setState(Configuration config, ReasoningResult result)
Description copied from interface:IChainingReasonerSets the state determined by the last reasoner. If not null, project and configuration passed in through the interface ofIReasonershall be ignored.- Specified by:
setStatein interfaceIChainingReasoner- Parameters:
config- the configuration (may be null, shall be ignored then).configmay be an internal resultresult- 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 toconfiguration
-
setState
public void setState(Configuration config, EvaluationResult result)
Description copied from interface:IChainingReasonerSets the state determined by the last reasoner. If not null, project and configuration passed in through the interface ofIReasonershall be ignored. Shall be used for#evaluate(net.ssehub.easy.varModel.model.Project, Configuration, java.util.List, ReasonerConfiguration, net.ssehub.easy.basics.progress.ProgressObserver)only.- Specified by:
setStatein interfaceIChainingReasoner- Parameters:
config- the configuration (may be null, shall be ignored then).configmay be an internal resultresult- 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 toconfiguration
-
getLastConfiguration
public Configuration getLastConfiguration()
Description copied from interface:IChainingReasonerReturns the last, potentially internal configuration. Shall be past intoIChainingReasoner.setState(Configuration, ReasoningResult)of the next reasoner. Shall clear the attribute holding the last config.- Specified by:
getLastConfigurationin interfaceIChainingReasoner- Returns:
- the last, potentially internal configuration
-
-