public class ReasoningUtils
extends java.lang.Object
Resolver.| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
private static net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger |
LOGGER |
static net.ssehub.easy.basics.pool.Pool<java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound>> |
SET_COMPOUND_POOL
A set pool for instances of
Set. |
| Constructor and Description |
|---|
ReasoningUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T,S extends T> |
addAll(java.util.Collection<T> target,
S[] source)
Adds all elements from
source to target. |
static void |
addRefines(net.ssehub.easy.varModel.model.datatypes.Compound cmp,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
Adds all refines of
cmp to result. |
private static void |
collectRefines(net.ssehub.easy.varModel.model.datatypes.Compound cmp,
net.ssehub.easy.varModel.model.datatypes.IDatatype exclude,
boolean add,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
Collects all refines from
cmp excluding all originating at exclude, adding
or removing following compounds based on add storing the results in result. |
static java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> |
collectRefines(net.ssehub.easy.varModel.model.datatypes.IDatatype start,
net.ssehub.easy.varModel.model.datatypes.IDatatype exclude)
Collects all refines from
start excluding all originating at exclude. |
static int |
countSlots(net.ssehub.easy.varModel.model.datatypes.Compound cmp,
java.lang.String name,
boolean stopGreater1)
Counts the number of slots with given
name in the refines hierarchy
of cmp. |
static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
createAsTypeCast(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree exp,
net.ssehub.easy.varModel.model.datatypes.IDatatype targetType)
Creates a type cast ("asType" operation, if needed) from the type of
exp to targetType
applied to exp. |
static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
createAsTypeCast(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree exp,
net.ssehub.easy.varModel.model.datatypes.IDatatype sourceType,
net.ssehub.easy.varModel.model.datatypes.IDatatype targetType)
Creates a type cast ("asType" operation, if needed) from
sourceType to targetType
applied to exp. |
static net.ssehub.easy.varModel.cst.ContainerOperationCall |
createContainerCall(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree container,
net.ssehub.easy.varModel.model.datatypes.Operation op,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree iterEx,
net.ssehub.easy.varModel.model.DecisionVariableDeclaration... decl)
Creates a container operation call ("shortcut").
|
static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
createParentExpression(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Creates an expression representing the parent of
variable. |
static net.ssehub.easy.varModel.model.values.Value |
createTypeValue(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
Creates a type value.
|
static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
createTypeValueConstant(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
Creates a type value constraint tree node.
|
static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
createTypeValueConstantSafe(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
Creates a type value constraint tree node and logs occurring exceptions.
|
static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree |
getConstraintValueConstraintExpression(net.ssehub.easy.varModel.model.values.Value value)
Returns the expression for a constraint to be created for a constraint variable.
|
static net.ssehub.easy.varModel.model.datatypes.IDatatype |
getDeepestContainedType(net.ssehub.easy.varModel.model.datatypes.Container cnt)
Returns the deepest contained type, i.e., for a nested container the deeply nested (base) type.
|
static net.ssehub.easy.varModel.model.values.Value |
getRelevantValue(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
boolean incremental)
Returns the relevant value for reasoning.
|
static <D extends net.ssehub.easy.varModel.model.values.Value> |
getRelevantValue(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
boolean incremental,
java.lang.Class<D> filter)
Returns the relevant value for reasoning.
|
static boolean |
getUsedCompoundTypes(net.ssehub.easy.varModel.model.values.Value val,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
Returns the used types if
value is a container value. |
static net.ssehub.easy.varModel.model.datatypes.IDatatype |
inferTypeSafe(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst,
net.ssehub.easy.varModel.model.datatypes.IDatatype dflt)
Infers the type of
cst using dflt as fallback. |
static boolean |
isNestedContainer(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
Returns whether
type is a type-nested container. |
static boolean |
isOverriddenSlot(net.ssehub.easy.varModel.model.AbstractVariable decl)
Returns whether
decl is an overridden slot. |
static void |
printConstraintEvaluationResult(net.ssehub.easy.varModel.model.Constraint constraint,
net.ssehub.easy.varModel.cstEvaluation.EvaluationVisitor evaluator)
Prints a constraint evaluation result (for debugging).
|
static void |
printConstraints(java.lang.String text,
java.lang.Iterable<net.ssehub.easy.varModel.model.Constraint> constraints)
Prints a constraints collection, each constraint including top-levle parent and system identity
hashcodes [DEBUGGING].
|
static void |
printFailedElements(FailedElements failedElements)
Method for displaying failed constraints and assignments.
|
static void |
printModelElement(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Method for printing info about
IDecisionVariable. |
static void |
printModelElements(net.ssehub.easy.varModel.confModel.Configuration config,
java.lang.String comment)
Method for printing all variables, their states and values.
|
static void |
printProblemPoints(java.util.Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> problemVariables)
Method for printing all problem points.
|
private static void |
purgeRefines(net.ssehub.easy.varModel.model.datatypes.Compound comp,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
Purges all refined compounds of
comp from result. |
static void |
purgeRefines(java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> compounds,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
Purges all refined compounds mentioned in
compounds. |
static void |
removeAll(java.util.Collection<net.ssehub.easy.varModel.model.Constraint> collection,
java.util.Collection<net.ssehub.easy.varModel.model.Constraint> remove)
Removes constraints from a constraints collection printing those constraints that have been removed.
|
static <K> void |
removeAll(java.util.Map<K,?> map,
java.util.Collection<K> remove)
Removes all elements in
remove as keys from map. |
static void |
setValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var,
net.ssehub.easy.varModel.model.Constraint value)
Sets a constraint value.
|
static java.lang.String |
toIvmlString(net.ssehub.easy.varModel.model.Constraint constraint)
Turns a constraint into a string.
|
static java.lang.String |
toIvmlString(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst)
Turns a constraint syntax tree into a string.
|
static java.lang.String |
toStringAttributes(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
Method for displaying all variable attributes.
|
public static final boolean DEBUG
public static final net.ssehub.easy.basics.pool.Pool<java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound>> SET_COMPOUND_POOL
Set.private static final net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger LOGGER
public static net.ssehub.easy.varModel.model.datatypes.IDatatype inferTypeSafe(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst,
net.ssehub.easy.varModel.model.datatypes.IDatatype dflt)
cst using dflt as fallback.cst - the expression to infer the type fordflt - the defaultdflt in case of failurespublic static net.ssehub.easy.varModel.model.values.Value createTypeValue(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
throws net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException
type - the datatypenet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - if the value cannot be createdpublic static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createTypeValueConstant(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
throws net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException
type - the datatypenet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException - if the value cannot be createdpublic static void setValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var,
net.ssehub.easy.varModel.model.Constraint value)
var - the variable to set the value on.value - the value to setpublic static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createTypeValueConstantSafe(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
type - the datatypepublic static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createAsTypeCast(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree exp,
net.ssehub.easy.varModel.model.datatypes.IDatatype targetType)
exp to targetType
applied to exp.exp - the expression to apply the type cast operation totargetType - the target typepublic static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createAsTypeCast(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree exp,
net.ssehub.easy.varModel.model.datatypes.IDatatype sourceType,
net.ssehub.easy.varModel.model.datatypes.IDatatype targetType)
sourceType to targetType
applied to exp.exp - the expression to apply the type cast operation tosourceType - the source typetargetType - the target type (nothing happens if targetType is null or
sourceType is identical to targetType)public static void printProblemPoints(java.util.Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> problemVariables)
problemVariables - the variables to printpublic static java.lang.String toStringAttributes(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
variable - variablepublic static void printModelElement(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
IDecisionVariable.variable - Variable to be printed out.public static java.lang.String toIvmlString(net.ssehub.easy.varModel.model.Constraint constraint)
constraint - the constraintpublic static java.lang.String toIvmlString(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree cst)
cst - may be null, print "-" thenpublic static void printModelElements(net.ssehub.easy.varModel.confModel.Configuration config,
java.lang.String comment)
config - Configuration to work with.comment - Comment for printing.public static void printConstraints(java.lang.String text,
java.lang.Iterable<net.ssehub.easy.varModel.model.Constraint> constraints)
text - text to be printed before (may be null, ignored then)constraints - the constraints to be printedpublic static void printFailedElements(FailedElements failedElements)
failedElements - the failed elementspublic static net.ssehub.easy.varModel.cst.ContainerOperationCall createContainerCall(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree container,
net.ssehub.easy.varModel.model.datatypes.Operation op,
net.ssehub.easy.varModel.cst.ConstraintSyntaxTree iterEx,
net.ssehub.easy.varModel.model.DecisionVariableDeclaration... decl)
container - the container to operate onop - the operationiterEx - the iterator expressiondecl - the declaratorspublic static boolean isOverriddenSlot(net.ssehub.easy.varModel.model.AbstractVariable decl)
decl is an overridden slot.decl - the declaration of the slot to search fortrue if overridden, false elsepublic static int countSlots(net.ssehub.easy.varModel.model.datatypes.Compound cmp,
java.lang.String name,
boolean stopGreater1)
name in the refines hierarchy
of cmp.cmp - the compound to start searchingname - the name of the slot to search forstopGreater1 - stop searching if we have more than one matching slotpublic static boolean isNestedContainer(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
type is a type-nested container.type - the typetrue for a nested collection, false elsepublic static net.ssehub.easy.varModel.model.values.Value getRelevantValue(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
boolean incremental)
decl - the declarationvar - the decision variableincremental - are we in incremental modepublic static <D extends net.ssehub.easy.varModel.model.values.Value> D getRelevantValue(net.ssehub.easy.varModel.model.AbstractVariable decl,
net.ssehub.easy.varModel.confModel.IDecisionVariable var,
boolean incremental,
java.lang.Class<D> filter)
D - the value typedecl - the declarationvar - the decision variableincremental - are we in incremental modefilter - in case that only a value of the specific type shall be returnedpublic static void addRefines(net.ssehub.easy.varModel.model.datatypes.Compound cmp,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
cmp to result.cmp - the compound to derive the refined compound hierarchy fromresult - the set of refined compoundspublic static boolean getUsedCompoundTypes(net.ssehub.easy.varModel.model.values.Value val,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
value is a container value.val - the valueresult - the result set to be modified as a side effecttrue if val is a container value, false elsepublic static void purgeRefines(java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> compounds,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
compounds.compounds - the compounds to purgeresult - the purged compounds (to be modified as a side effect)private static void purgeRefines(net.ssehub.easy.varModel.model.datatypes.Compound comp,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
comp from result.comp - the compound to purge the refined ones forresult - modified as a side effectpublic static <T,S extends T> void addAll(java.util.Collection<T> target,
S[] source)
source to target.T - the target typeS - the source type, a subtype of <T>target - the target collectionsource - the source array (may be null, then nothing happens)public static net.ssehub.easy.varModel.model.datatypes.IDatatype getDeepestContainedType(net.ssehub.easy.varModel.model.datatypes.Container cnt)
cnt - the container typepublic static void printConstraintEvaluationResult(net.ssehub.easy.varModel.model.Constraint constraint,
net.ssehub.easy.varModel.cstEvaluation.EvaluationVisitor evaluator)
constraint - the constraintevaluator - the evaluatorpublic static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree getConstraintValueConstraintExpression(net.ssehub.easy.varModel.model.values.Value value)
value - the value to create the constraint forpublic static void removeAll(java.util.Collection<net.ssehub.easy.varModel.model.Constraint> collection,
java.util.Collection<net.ssehub.easy.varModel.model.Constraint> remove)
collection - the collections to remove the constraints fromremove - the constraints to removepublic static <K> void removeAll(java.util.Map<K,?> map,
java.util.Collection<K> remove)
remove as keys from map.K - the key typemap - the map to remove fromremove - the elements to removepublic static java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> collectRefines(net.ssehub.easy.varModel.model.datatypes.IDatatype start,
net.ssehub.easy.varModel.model.datatypes.IDatatype exclude)
start excluding all originating at exclude.start - the start type (an empty set will be returned if start is not a Compound)exclude - an optional type excluding the entire refinement hierarchy originating at
exclude if exclude is a compound, ignored if nullSET_COMPOUND_POOLprivate static void collectRefines(net.ssehub.easy.varModel.model.datatypes.Compound cmp,
net.ssehub.easy.varModel.model.datatypes.IDatatype exclude,
boolean add,
java.util.Set<net.ssehub.easy.varModel.model.datatypes.Compound> result)
cmp excluding all originating at exclude, adding
or removing following compounds based on add storing the results in result.cmp - the type to collect forexclude - an optional type excluding the entire refinement hierarchy originating at
exclude if exclude is a compound, ignored if nulladd - whether datatypes shall be added or removed from result.result - incrementally built up result, may be modified as a side effectpublic static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createParentExpression(net.ssehub.easy.varModel.confModel.IDecisionVariable variable)
variable.variable - the variableCopyright © 2009 - 2018 SSE. All Rights Reserved.