final class Resolver extends java.lang.Object implements net.ssehub.easy.varModel.cstEvaluation.IResolutionListener, TypeCache.IConstraintTarget
markForReuse() before the first call to
resolve() and after reasoning completed, call clear(). When performing a further reasoning on this
instance, call reInit().| Modifier and Type | Class and Description |
|---|---|
private class |
Resolver.CompoundAnnotationMapper
Implements a compound annotation mapper.
|
private class |
Resolver.ConstraintTranslationVisitor
Visits the contents of a project for translation.
|
private static class |
Resolver.DefaultConstraints
Storage for two sub-types of default constraints, namely primary default constraints that can be evaluated
directly, e.g., constants (
Resolver.DefaultConstraints.defaultConstraints) and more complex constraints with
dependencies (Resolver.DefaultConstraints.deferredDefaultConstraints). |
private class |
Resolver.OtherConstraintsProcessor
Implements a processor for constraints, for which variables (including the variable mapping) shall be substituted
and the result shall be added to
otherConstraints. |
private static class |
Resolver.ReasonerState
Represents the state of the resolver/reasoner to be kept in case of incremental reasoning.
|
| Modifier and Type | Field and Description |
|---|---|
private Resolver.CompoundAnnotationMapper |
annotationMapper |
private net.ssehub.easy.varModel.confModel.IAssignmentState |
assignmentState |
private net.ssehub.easy.varModel.confModel.Configuration |
config |
private net.ssehub.easy.reasoning.core.reasoner.ConstraintBase |
constraintBase |
private int |
constraintCounter |
private ContextStack |
contexts |
private Resolver.ReasonerState |
copiedState |
private Resolver.DefaultConstraints |
defaultConstraints |
private java.util.Set<net.ssehub.easy.varModel.model.Project> |
doneProjects |
private long |
endTimestamp |
private long |
evaluationTime |
private EvalVisitor |
evaluator |
private FailedElements |
failedElements |
private boolean |
hasTimeout |
private boolean |
incremental |
private CheckInitializerVisitor |
initChecker |
private boolean |
inRescheduling |
private boolean |
inTopLevelEvals |
private boolean |
isRunning |
private static net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger |
LOGGER |
private static int |
MODE_COMPOUND_NONE |
private static int |
MODE_COMPOUND_REGISTER |
private static int |
MODE_COMPOUND_TRANSLATE |
private net.ssehub.easy.reasoning.core.reasoner.ConstraintList |
otherConstraints |
private Resolver.OtherConstraintsProcessor |
otherConstraintsProc |
private net.ssehub.easy.varModel.model.Project |
project |
private java.util.List<net.ssehub.easy.varModel.model.Project> |
projects |
private Resolver.ConstraintTranslationVisitor |
projectVisitor |
private net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration |
reasonerConfig |
private int |
reevaluationCounter |
private RescheduleValueChangeVisitor |
rescheduler |
private boolean |
reuseInstance |
private ScopeAssignments |
scopeAssignments |
private VariablesInNotSimpleAssignmentConstraintsFinder |
simpleAssignmentFinder |
private SubstitutionVisitor |
substVisitor |
private java.util.Stack<net.ssehub.easy.reasoning.core.reasoner.ConstraintBase> |
tmpBase |
private net.ssehub.easy.reasoning.core.reasoner.ConstraintList |
topLevelConstraints |
private long |
translationTime |
private java.util.Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> |
usedVariables |
private int |
variablesCounter |
private VariablesInConstraintFinder |
variablesFinder |
private int |
variablesInConstraintsCounter |
private VariablesMap |
variablesMap |
private boolean |
wasStopped |
| Constructor and Description |
|---|
Resolver(net.ssehub.easy.varModel.confModel.Configuration config,
net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration reasonerConfig)
Main constructor that activates Resolver constructor.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addAssignedVariableToScope(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Adds an assigned variable to the current scope.
|
void |
addConstraint(net.ssehub.easy.reasoning.core.reasoner.ConstraintList target,
boolean first,
net.ssehub.easy.varModel.model.Constraint constraint,
net.ssehub.easy.varModel.confModel.IDecisionVariable register)
Adds a constraint to the (preliminary) constraint base.
|
private void |
addConstraint(net.ssehub.easy.reasoning.core.reasoner.ConstraintList target,
net.ssehub.easy.varModel.model.Constraint constraint,
boolean checkForInitializers,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.confModel.IDecisionVariable register)
Adding a constraint to a constraint set, checking for contained container/compound initializers if
requested.
|
private void |
addDefaultConstraint(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree defaultValue,
Resolver.DefaultConstraints tmp,
boolean enable,
net.ssehub.easy.varModel.confModel.IDecisionVariable var)
Adds a default constraint.
|
private void |
analyzeEvaluationResult(net.ssehub.easy.varModel.model.Constraint constraint)
Records information about the evaluation result, failed evaluation messages.
|
private static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
checkTypeCast(net.ssehub.easy.varModel.model.datatypes.IDatatype declType,
net.ssehub.easy.varModel.model.datatypes.IDatatype actType,
net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
Inserts a type cast if needed.
|
(package private) java.util.List<net.ssehub.easy.varModel.model.Constraint> |
cleanupConstraints(net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
boolean clear,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> deleteFilter)
Obtains and if specified clears old constraints in the internal reasoner data structures.
|
(package private) void |
clear()
Clears this instance for reuse to free most of the resources.
|
private void |
conflictingDefault(net.ssehub.easy.varModel.model.AbstractVariable decl)
Will be called after a failure was detected in a default constraint of an
AbstractVariable. |
(package private) int |
constraintCount()
Method for returning the overall count of evaluated constraints in the model.
|
(package private) boolean |
contextContainsMapping(net.ssehub.easy.varModel.model.AbstractVariable var)
Returns whether the current context contains a mapping for
var. |
(package private) void |
contextRegisterMapping(net.ssehub.easy.varModel.model.AbstractVariable var,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree acc)
Registers a mapping between the variable
var and its actual access expression acc into
the current top-most context. |
(package private) net.ssehub.easy.varModel.model.Constraint |
createConstraintVariableConstraint(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst,
net.ssehub.easy.varModel.model.AbstractVariable self,
boolean checkForInitializers,
net.ssehub.easy.varModel.model.IModelElement parent,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Creates a constraint for a (nested) constraint variable adding the result to
otherConstraints. |
(package private) net.ssehub.easy.varModel.model.Constraint |
createConstraintVariableConstraint(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.model.IModelElement parent,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Creates a constraint for a (nested) constraint variable adding the result to
#constraintVariablesConstraints. |
(package private) void |
createContainerConstraintValueConstraints(net.ssehub.easy.varModel.model.values.ContainerValue val,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.model.IModelElement parent,
net.ssehub.easy.varModel.confModel.IDecisionVariable nestedVariable)
Checks a container value for nested constraint values, i.e., values of nested constraint variables.
|
protected net.ssehub.easy.varModel.cstEvaluation.EvaluationVisitor |
createEvaluationVisitor()
Factory method for creating the evaluation visitor.
|
private void |
evaluateConstraint(net.ssehub.easy.varModel.model.Constraint constraint,
boolean top)
Evaluates
constraint and if available, in case of default constraints, also all related initializing
default constraints as one block. |
private void |
evaluateConstraint(net.ssehub.easy.varModel.model.Constraint constraint,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst)
Evaluates a single constraint.
|
private void |
evaluateConstraintBase(long start,
net.ssehub.easy.varModel.model.Project project)
Evaluates all constraints in the constraint base.
|
private void |
evaluateConstraints(net.ssehub.easy.varModel.model.Project project)
Evaluates and reschedules failed constraints.
|
(package private) net.ssehub.easy.varModel.confModel.IDecisionVariable |
getConstraintVariable(net.ssehub.easy.varModel.model.Constraint constraint)
Returns the variable currently assigned to
constraint. |
(package private) long |
getEvaluationTime()
Returns the time used for evaluation.
|
private net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
getFailedConstraintPart()
Method for checking part of a failed constraints against null.
|
(package private) FailedElements |
getFailedElements()
|
private net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
getNestedAccessor(net.ssehub.easy.varModel.model.AbstractVariable nestedDecl,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
Returns the accessor for a nested variable declaration.
|
(package private) long |
getTranslationTime()
Returns the time used for translation.
|
(package private) boolean |
hasTimeout()
Returns whether reasoning stopped due to a timeout.
|
boolean |
inRescheduling()
Returns whether the constraint target is currently in re-scheduling and, thus, e.g., default constraints
shall not be added.
|
(package private) boolean |
isRunning()
Returns whether the reasoner is (still) operating.
|
void |
localVariableCreated(net.ssehub.easy.varModel.cstEvaluation.LocalDecisionVariable var) |
void |
localVariableDisposed(net.ssehub.easy.varModel.cstEvaluation.LocalDecisionVariable var) |
(package private) void |
markForReuse()
Marks this instance for re-use.
|
(package private) void |
moveOtherConstraintsToConstraintBase(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Moves (temporary) constraints in
otherConstraints as created by constraint translation to the constraint
base. |
(package private) void |
notifyRescheduling(boolean inRescheduling)
Notifies the resolver that following translations happen as part of constraint re-scheduling (or not).
|
void |
notifyResolved(net.ssehub.easy.varModel.model.AbstractVariable declaration,
net.ssehub.easy.varModel.confModel.IDecisionVariable resolved) |
void |
notifyResolved(net.ssehub.easy.varModel.confModel.IDecisionVariable compound,
java.lang.String slotName,
net.ssehub.easy.varModel.confModel.IDecisionVariable resolved) |
private void |
processCompoundEvals(net.ssehub.easy.varModel.model.datatypes.Compound cmpType,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Method for extracting constraints from compounds eval blocks (also refined compounds).
|
private void |
processEvalConstraints(net.ssehub.easy.varModel.model.PartialEvaluationBlock evalBlock,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Method for handling eval blocks - searching for nested eval blocks and extracting constraints.
|
(package private) int |
reevaluationCount()
Method for returning the overall number of reevaluations in the model.
|
private void |
registerCompoundMapping(net.ssehub.easy.varModel.model.datatypes.Compound type,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc,
net.ssehub.easy.varModel.cst.Variable declVar)
Registers the mapping for a compound type.
|
private void |
registerCompoundSlotMapping(net.ssehub.easy.varModel.model.datatypes.Compound type,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc,
net.ssehub.easy.varModel.cst.Variable declVar)
Registers the slot mappings for compound slots of
type. |
(package private) void |
reInit()
Re-initializes this resolver instance to allocated resources only if really needed.
|
(package private) void |
reschedule(net.ssehub.easy.varModel.model.AbstractVariable declaration)
Tries rescheduling the given constraints.
|
private void |
reschedule(java.util.Collection<net.ssehub.easy.varModel.model.Constraint> constraints)
Tries rescheduling the given constraints.
|
(package private) void |
reschedule(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
Tries rescheduling the given constraints.
|
void |
resolve()
Resolves the (initial) values of the configuration.
|
(package private) void |
setAssignmentState(net.ssehub.easy.varModel.confModel.IAssignmentState state)
Sets the desired assignment state.
|
(package private) boolean |
setIncremental(boolean incremental)
Sets whether reasoning shall happen incrementally.
|
(package private) boolean |
stop()
Stops/terminates reasoning.
|
(package private) net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
substituteVariables(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree acc)
Method for using
SubstitutionVisitor for constraint transformation. |
private net.ssehub.easy.reasoning.core.reasoner.DefaultConstraint |
transfer(net.ssehub.easy.reasoning.core.reasoner.DefaultConstraint constraint,
Resolver.DefaultConstraints tmp,
boolean enable)
Temporarily transfers the default constraint lists between
defaultConstraints and tmp. |
private void |
translateAnnotationAssignment(net.ssehub.easy.varModel.model.AttributeAssignment.Assignment assignment,
net.ssehub.easy.varModel.model.DecisionVariableDeclaration element,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree compound)
Method for creating attribute constraint for a specific element.
|
private void |
translateAnnotationAssignments(net.ssehub.easy.varModel.model.AttributeAssignment assignment,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
java.util.List<net.ssehub.easy.varModel.model.AttributeAssignment.Assignment> effectiveAssignments,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree compound)
Translates attribute assignments.
|
private void |
translateAnnotationDeclaration(net.ssehub.easy.varModel.model.Attribute decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc,
boolean qualifyAttribute)
Translates an annotation declaration.
|
private void |
translateAnnotationDeclarations(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
Translates annotation declarations.
|
private void |
translateCompoundContainer(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.model.datatypes.Compound type,
net.ssehub.easy.varModel.model.datatypes.IDatatype declaredContainedType,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
Translates an entire compound container
decl including defaults and constraints for the specific
type cmpType (iterate through all relevant types). |
private void |
translateCompoundContent(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.model.datatypes.Compound type,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
Translates the compound content.
|
private int |
translateCompoundDeclaration(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc,
net.ssehub.easy.varModel.model.datatypes.Compound type,
int mode)
Translates translating compound type declarations, but only if not
ContextStack.alreadyProcessed(IDatatype) in nested collection/compound types. |
private void |
translateConstraints(net.ssehub.easy.varModel.model.Project project)
Translates and collects all constraints in
project by adding the collected constraints to the
constraintBase. |
private void |
translateContainerDeclaration(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
net.ssehub.easy.varModel.model.datatypes.IDatatype type,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
Translates the (transitive) defaults and type constraints for a container declaration.
|
private void |
translateDeclaration(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
Translates the (transitive) defaults and type constraints for a declaration.
|
private void |
translateDerivedDatatypeConstraints(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.model.datatypes.IDatatype type,
net.ssehub.easy.varModel.model.DecisionVariableDeclaration localDecl,
net.ssehub.easy.varModel.model.IModelElement parent,
int refCounter,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
Extracts, translates and collects the internal constraints of
type (if derived or, transitively, a
reference datatype) and stores the constraints in #derivedTypeConstraints. |
(package private) void |
translateValueTypeChange(net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.model.values.Value newValue,
net.ssehub.easy.varModel.model.values.Value oldValue)
Translates/reschedules a change of value types for compound values.
|
(package private) int |
variableCount()
Method for returning the overall number of variables in the model.
|
(package private) int |
variableInConstraintCount()
Method for returning the number of variables involved in constraints.
|
(package private) boolean |
wasStopped()
Returns whether reasoning was stopped due to a user-request.
|
private static final net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger LOGGER
private static final int MODE_COMPOUND_REGISTER
private static final int MODE_COMPOUND_TRANSLATE
private static final int MODE_COMPOUND_NONE
private net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration reasonerConfig
private net.ssehub.easy.varModel.confModel.Configuration config
private boolean incremental
private boolean reuseInstance
private net.ssehub.easy.varModel.confModel.IAssignmentState assignmentState
private boolean inRescheduling
private EvalVisitor evaluator
private FailedElements failedElements
private ScopeAssignments scopeAssignments
private VariablesMap variablesMap
private Resolver.ReasonerState copiedState
private java.util.Stack<net.ssehub.easy.reasoning.core.reasoner.ConstraintBase> tmpBase
private net.ssehub.easy.reasoning.core.reasoner.ConstraintBase constraintBase
private Resolver.DefaultConstraints defaultConstraints
private net.ssehub.easy.reasoning.core.reasoner.ConstraintList topLevelConstraints
private net.ssehub.easy.reasoning.core.reasoner.ConstraintList otherConstraints
private java.util.List<net.ssehub.easy.varModel.model.Project> projects
private int constraintCounter
private int variablesInConstraintsCounter
private int reevaluationCounter
private int variablesCounter
private boolean hasTimeout
private boolean isRunning
private boolean wasStopped
private long translationTime
private long evaluationTime
private net.ssehub.easy.varModel.model.Project project
private transient java.util.Set<net.ssehub.easy.varModel.model.Project> doneProjects
private transient java.util.Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> usedVariables
private transient SubstitutionVisitor substVisitor
private transient ContextStack contexts
private transient VariablesInNotSimpleAssignmentConstraintsFinder simpleAssignmentFinder
private transient Resolver.ConstraintTranslationVisitor projectVisitor
private transient VariablesInConstraintFinder variablesFinder
private transient Resolver.OtherConstraintsProcessor otherConstraintsProc
private transient Resolver.CompoundAnnotationMapper annotationMapper
private transient RescheduleValueChangeVisitor rescheduler
private transient CheckInitializerVisitor initChecker
private transient long endTimestamp
private transient boolean inTopLevelEvals
public Resolver(net.ssehub.easy.varModel.confModel.Configuration config,
net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration reasonerConfig)
config - Configuration to reason on.reasonerConfig - the reasoner configuration to be used for reasoning (e.g. taken from the UI,
may be null)public void localVariableCreated(net.ssehub.easy.varModel.cstEvaluation.LocalDecisionVariable var)
localVariableCreated in interface net.ssehub.easy.varModel.cstEvaluation.IResolutionListenerpublic void localVariableDisposed(net.ssehub.easy.varModel.cstEvaluation.LocalDecisionVariable var)
localVariableDisposed in interface net.ssehub.easy.varModel.cstEvaluation.IResolutionListenervoid translateValueTypeChange(net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.model.values.Value newValue,
net.ssehub.easy.varModel.model.values.Value oldValue)
oldValue != newValue and both, oldValue and newValue are not null.variable - the variablenewValue - the new value (in variableoldValue - the old valuejava.util.List<net.ssehub.easy.varModel.model.Constraint> cleanupConstraints(net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
boolean clear,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> deleteFilter)
variable - the variable to return the constraints forclear - true for clear variables, false for leave them as they aredeleteFilter - compound types dictating those constraints having them as attached object
that shall be deleted while others shall be left untouched (may be null for delete
all constraints if clear is true.variable, may be nullvoid moveOtherConstraintsToConstraintBase(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
otherConstraints as created by constraint translation to the constraint
base. Relates constraints with #variable.variable - the variable to relate constraints to (may be null, ignored then)void reschedule(net.ssehub.easy.varModel.model.AbstractVariable declaration)
declaration - the variable declaration to reschedulevoid reschedule(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
var - the variable to rescheduleprivate void reschedule(java.util.Collection<net.ssehub.easy.varModel.model.Constraint> constraints)
constraints - the constraints to reschedule (may be null)public void notifyResolved(net.ssehub.easy.varModel.confModel.IDecisionVariable compound,
java.lang.String slotName,
net.ssehub.easy.varModel.confModel.IDecisionVariable resolved)
notifyResolved in interface net.ssehub.easy.varModel.cstEvaluation.IResolutionListenerpublic void notifyResolved(net.ssehub.easy.varModel.model.AbstractVariable declaration,
net.ssehub.easy.varModel.confModel.IDecisionVariable resolved)
notifyResolved in interface net.ssehub.easy.varModel.cstEvaluation.IResolutionListenerpublic void resolve()
Utils.discoverImports(net.ssehub.easy.basics.modelManagement.IModel),
translateConstraints(Project),
evaluateConstraintBase(long, Project),
Configuration.freeze(net.ssehub.easy.varModel.confModel.IFreezeSelector)private void evaluateConstraintBase(long start,
net.ssehub.easy.varModel.model.Project project)
start - the start point in time for reasoning statisticsproject - the project to evaluateevaluateConstraints(Project)private void evaluateConstraints(net.ssehub.easy.varModel.model.Project project)
project - the project to evaluate the constraints forresolve()private void evaluateConstraint(net.ssehub.easy.varModel.model.Constraint constraint,
boolean top)
constraint and if available, in case of default constraints, also all related initializing
default constraints as one block. This combination allows to have an initializing value assignment, to consider
the default constraints, e.g., in refined compounds, and to allow the default constraints to consist of
dependent, complex expressions, that can only be evaluated by a reasoner.constraint - the constraint to be evaluatedtop - is this a top-level or a nested callevaluateConstraint(Constraint, ConstraintSyntaxTree)private void evaluateConstraint(net.ssehub.easy.varModel.model.Constraint constraint,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst)
constraint - the constraintcst - the constraint syntax tree already extracted from constraintprivate void translateDerivedDatatypeConstraints(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.model.datatypes.IDatatype type,
net.ssehub.easy.varModel.model.DecisionVariableDeclaration localDecl,
net.ssehub.easy.varModel.model.IModelElement parent,
int refCounter,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
type (if derived or, transitively, a
reference datatype) and stores the constraints in #derivedTypeConstraints.decl - VariableDeclaration of DerivedDatatypetype - the type to translatelocalDecl - the declaration of an iterator variable if quantified constraints shall be created,
null for normal constraintsparent - the parent model element for creating constraint instancesrefCounter - the number of intermediary reference types on the path from the top-most call (call with
0)cAcc - compound access to be used instead of decl, may be nullprivate void translateAnnotationDeclarations(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
decl - AbstractVariable with annotations.variable - IDecisionVariable with annotations.cAcc - CompoundAccess null if variable is not nested, else accessor expression to
variable.private void translateAnnotationDeclaration(net.ssehub.easy.varModel.model.Attribute decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc,
boolean qualifyAttribute)
decl - AbstractVariable with annotations.variable - IDecisionVariable with annotations.cAcc - CompoundAccess null if variable is not nested, else accessor expression to
variable.qualifyAttribute - whether the attribute must be explicitly qualified via cAccprivate void translateDeclaration(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
decl - The AbstractVariable for which the default value should be resolved.var - the instance of decl (may be null for type-based translation).cAcc - if variable is a nested compound.private void addDefaultConstraint(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree defaultValue,
Resolver.DefaultConstraints tmp,
boolean enable,
net.ssehub.easy.varModel.confModel.IDecisionVariable var)
decl - The AbstractVariable for which the default value should be resolved.defaultValue - the default value expressiontmp - temporary storage structure for default value constraints (usually given, may be null) if no
transfer (default constraints to block evaluation) shall happenenable - whether transfer (default constraints to block evaluation) shall happen at allvar - the instance of decl (may be null for type-based translation).private net.ssehub.easy.reasoning.core.reasoner.DefaultConstraint transfer(net.ssehub.easy.reasoning.core.reasoner.DefaultConstraint constraint,
Resolver.DefaultConstraints tmp,
boolean enable)
defaultConstraints and tmp. After
transferring the lists to constraint (and #defaultConstraints temporarily into {@code tmp})
default constraints to be registered afterwards will be collected in {@link constraint} (rather than in
{@link #defaultConstraints}) be evaluated as a batch before {@constraint}, e.g., in case of a (refined) compound.
If {@code constraint} is null, {@link #defaultConstraints} will set with the lists in {@code tmp} and
become active again for collecting further default constraints. If {@code enable} is {@code} false, no transfer
will happen at all.constraint - the constraint to hold/holding the actual default constraints lists. If given, the transfer
to tmp may happen (dependent on enable), if not, backward-transfer to
defaultConstraints will happen if tmp is not nulltmp - a temporary structure for storing defaultConstraints, may be nullenable - generally enables or disable the transferconstraintprivate static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree checkTypeCast(net.ssehub.easy.varModel.model.datatypes.IDatatype declType,
net.ssehub.easy.varModel.model.datatypes.IDatatype actType,
net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
declType - the declared typeactType - the actual typedecl - the variable declaration (for the access if cAcc is null)cAcc - the actual access expressioncAcc if no cast is needed, a cast to actType based on cAcc or
decl if cAcc is nullprivate void translateContainerDeclaration(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
net.ssehub.easy.varModel.model.datatypes.IDatatype type,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
decl - The AbstractVariable for which the default value should be resolved.var - the instance of decl (may be null for type-based translation).type - the (specific) datatype (Container)cAcc - compound access expressionprivate void translateCompoundContainer(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.model.datatypes.Compound type,
net.ssehub.easy.varModel.model.datatypes.IDatatype declaredContainedType,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
decl including defaults and constraints for the specific
type cmpType (iterate through all relevant types).decl - the declarationtype - the compound type to translate fordeclaredContainedType - the declared contained type of declcAcc - compound access to decl if needed (may be null)private int translateCompoundDeclaration(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc,
net.ssehub.easy.varModel.model.datatypes.Compound type,
int mode)
ContextStack.alreadyProcessed(IDatatype) in nested collection/compound types.decl - The AbstractVariable for which the default value should be resolved.variable - the instance of decl (may be null for based-type translation).cAcc - if variable is a nested compound, the access expression to
decl/variabletype - specific Compound type.mode - the processing mode, either MODE_COMPOUND_REGISTER for just registering the compound slot
accessor expressions, which must either be followed with MODE_COMPOUND_TRANSLATE or
ContextStack.popContext() on
the same nesting level. Not processing a complete compound allows keeping the registered scope open
for processing related (default) value expressions that may refer to compound slots. May also
be MODE_COMPOUND_NONE for not processing anything.MODE_COMPOUND_NONE or MODE_COMPOUND_TRANSLATE if mode was
MODE_COMPOUND_REGISTERprivate void registerCompoundMapping(net.ssehub.easy.varModel.model.datatypes.Compound type,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc,
net.ssehub.easy.varModel.cst.Variable declVar)
type - the compound typecAcc - the accessor expression (may be null)declVar - the compound variable as expressionregisterCompoundSlotMapping(Compound, ConstraintSyntaxTree, Variable)private void registerCompoundSlotMapping(net.ssehub.easy.varModel.model.datatypes.Compound type,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc,
net.ssehub.easy.varModel.cst.Variable declVar)
type. Considers shadowed slots and maps them
to the most specific (non-shadowed) slot.type - the compound typecAcc - the accessor expression (may be null)declVar - the compound variable as expressionprivate void translateCompoundContent(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.model.datatypes.Compound type,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
decl - the compound variable (self, instead of cAcc)variable - the decision variable holding decl, may be null - ignored thentype - the (specific) compound typecAcc - the compound access expressionprivate net.ssehub.easy.varModel.cst.ConstraintSyntaxTree getNestedAccessor(net.ssehub.easy.varModel.model.AbstractVariable nestedDecl,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cAcc)
cAcc based accessor if given,
else use a cached one from contexts. In particular, this is required to have type cast in the accessor
if given from outside.nestedDecl - the nested declarationcAcc - the actual compound accessornesteDeclprivate void processCompoundEvals(net.ssehub.easy.varModel.model.datatypes.Compound cmpType,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
cmpType - Compound to be analyzedselfEx - an expression representing self (ignored if null, self and
selfEx shall never both be specified/not null).self - an variable declaration representing self (ignored if null).variable - optional variable for registering constraintsprivate void processEvalConstraints(net.ssehub.easy.varModel.model.PartialEvaluationBlock evalBlock,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
evalBlock - Eval block to be processed.selfEx - an expression representing self (ignored if null, self and
selfEx shall never both be specified/not null).self - an variable declaration representing self (ignored if null).variable - optional variable for registering constraintsvoid createContainerConstraintValueConstraints(net.ssehub.easy.varModel.model.values.ContainerValue val,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.model.IModelElement parent,
net.ssehub.easy.varModel.confModel.IDecisionVariable nestedVariable)
val - the container valueselfEx - expression representing self, must never be not null in conjunction with selfself - the variable declaration representing self, must never be not null in conjunction
with selfparent - the parent for new constraintsnestedVariable - the variable holding the constraint valueprivate void translateAnnotationAssignments(net.ssehub.easy.varModel.model.AttributeAssignment assignment,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
java.util.List<net.ssehub.easy.varModel.model.AttributeAssignment.Assignment> effectiveAssignments,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree compound)
assignment - Attribute assignments on top-level.var - variable holding the assignment, may be null for translating typeseffectiveAssignments - the list of effective current assignments, use null if not recursive.compound - Parent CompoundAccess.private void translateAnnotationAssignment(net.ssehub.easy.varModel.model.AttributeAssignment.Assignment assignment,
net.ssehub.easy.varModel.model.DecisionVariableDeclaration element,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree compound)
assignment - Attribute assignment constraint.element - Elements to which the attribute is assigned.compound - Nesting compound if there is one, may be null for none.private void translateConstraints(net.ssehub.easy.varModel.model.Project project)
project by adding the collected constraints to the
constraintBase.project - the project to translate the constraints forresolve()private void addConstraint(net.ssehub.easy.reasoning.core.reasoner.ConstraintList target,
net.ssehub.easy.varModel.model.Constraint constraint,
boolean checkForInitializers,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable,
net.ssehub.easy.varModel.confModel.IDecisionVariable register)
target - the target container for assignment constraints (higher priority)constraint - the constraint (may be modified as a side effect)checkForInitializers - check also for initializers if (true), add only if (false)variable - the actually (nested) variable, used to relate the created constraint to, may be null.
This information is particularly relevant for constraints arising from constraint variables.register - variable to register against, may be nullpublic final void addConstraint(net.ssehub.easy.reasoning.core.reasoner.ConstraintList target,
boolean first,
net.ssehub.easy.varModel.model.Constraint constraint,
net.ssehub.easy.varModel.confModel.IDecisionVariable register)
TypeCache.IConstraintTargetaddConstraint in interface TypeCache.IConstraintTargettarget - the target constraint setfirst - at to front/endconstraint - the constraint to be addedregister - register the constraint with VariablesMap for the given variable (ignored
if null)net.ssehub.easy.varModel.model.Constraint createConstraintVariableConstraint(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.model.IModelElement parent,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
#constraintVariablesConstraints. Performs initializers check upon adding if cst is not
a ConstantValue.cst - the constraintselfEx - the expression representing self in cst, both, self and
selfEx must not be different from null at the same time (may be null for none)self - the declaration of the variable representing self in cst (may be null
for none)parent - the parent for new constraintsvariable - the actually (nested) variable, used to relate the created constraint to, may be nullcreateConstraintVariableConstraint(ConstraintSyntaxTree, AbstractVariable, boolean, IModelElement,
IDecisionVariable)net.ssehub.easy.varModel.model.Constraint createConstraintVariableConstraint(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst,
net.ssehub.easy.varModel.model.AbstractVariable self,
boolean checkForInitializers,
net.ssehub.easy.varModel.model.IModelElement parent,
net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
otherConstraints. Registers the constraint if needed.cst - the constraintself - the declaration of the variable representing self in cst (may be null
for none), just used for loggingcheckForInitializers - whether initializers shall be checked (recursively) when adding a constraintparent - the parent for new constraintsvariable - the actually (nested) variable, used to relate the created constraint to, may be nulladdConstraint(ConstraintList, Constraint, boolean, IDecisionVariable, IDecisionVariable)private void analyzeEvaluationResult(net.ssehub.easy.varModel.model.Constraint constraint)
constraint - the constraint to record the actual messages fornet.ssehub.easy.varModel.cst.ConstraintSyntaxTree substituteVariables(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree selfEx,
net.ssehub.easy.varModel.model.AbstractVariable self,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree acc)
SubstitutionVisitor for constraint transformation. Uses the actual
variable mapping in #varMap and may consider a mapping for self.cst - Constraint to be transformed.selfEx - an expression representing self (ignored if null, self and
selfEx shall never both be specified/not null).self - an variable declaration representing self (ignored if null).acc - optional accessor expression that shall be excluded from mapping (ignored if null)private void conflictingDefault(net.ssehub.easy.varModel.model.AbstractVariable decl)
AbstractVariable.decl - The conflicting declaration of an AbstractVariable.
Call AbstractVariable.getDefaultValue() to retrieve the conflicting constraint.private net.ssehub.easy.varModel.cst.ConstraintSyntaxTree getFailedConstraintPart()
net.ssehub.easy.varModel.confModel.IDecisionVariable getConstraintVariable(net.ssehub.easy.varModel.model.Constraint constraint)
constraint.constraint - the constraint to look forint constraintCount()
int variableCount()
int variableInConstraintCount()
int reevaluationCount()
FailedElements getFailedElements()
FailedElementsboolean setIncremental(boolean incremental)
incremental - if reasoning shall happen incrementallyincremental#setConsiderFrozenConstraints(boolean)protected net.ssehub.easy.varModel.cstEvaluation.EvaluationVisitor createEvaluationVisitor()
boolean hasTimeout()
true for timeout, false elseboolean wasStopped()
true for stopped, false elseboolean isRunning()
true for operating, false elseboolean stop()
true if the reasoner tries to stop, false else
(operation not implemented)void markForReuse()
resolve().
Works intentionally only once.void clear()
markForReuse(),
reInit()void reInit()
markForReuse(),
reInit()long getEvaluationTime()
long getTranslationTime()
void setAssignmentState(net.ssehub.easy.varModel.confModel.IAssignmentState state)
AssignmentState.DERIVED, but specific reasoning
operations such as configuration initialization may require a different state.state - the state to usefinal void addAssignedVariableToScope(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
variable - the variable to add to the scopefinal boolean contextContainsMapping(net.ssehub.easy.varModel.model.AbstractVariable var)
var.var - the variable to look fortrue if there is a mapping, false elsefinal void contextRegisterMapping(net.ssehub.easy.varModel.model.AbstractVariable var,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree acc)
var and its actual access expression acc into
the current top-most context. Overrides any existing mapping in the top-most context. Preceeds any
existing mapping in a previous still active context.var - the variableacc - the access expressionfinal void notifyRescheduling(boolean inRescheduling)
inRescheduling - are we in re-schedulingpublic boolean inRescheduling()
TypeCache.IConstraintTargetinRescheduling in interface TypeCache.IConstraintTargettrue for re-scheduling, false elseCopyright © 2009 - 2018 SSE. All Rights Reserved.