java.lang.Object
org.maxicp.modeling.xcsp3.XCallbacksDecomp
- All Implemented Interfaces:
org.xcsp.parser.callbacks.XCallbacks,org.xcsp.parser.callbacks.XCallbacks2
- Direct Known Subclasses:
XCSP3
public abstract class XCallbacksDecomp
extends Object
implements org.xcsp.parser.callbacks.XCallbacks2
An extension of the default XCallback parser that provides default decompositions for the most complex constraints.
Taken from the source code of OscaR (the file having been written by the same author)
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.xcsp.parser.callbacks.XCallbacks
org.xcsp.parser.callbacks.XCallbacks.Implem, org.xcsp.parser.callbacks.XCallbacks.XCallbacksParameters -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildCtrAllDifferent(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic[] lists) All Different constraint on Symbolic variables.voidbuildCtrAllDifferentList(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] lists) AllDifferentList constraint.voidbuildCtrAllDifferentMatrix(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] matrix) All Diff Matrix.voidbuildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, int[] lengths, int[] heights, org.xcsp.common.Condition condition) Cumulative constraint.voidbuildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, int[] lengths, org.xcsp.parser.entries.XVariables.XVarInteger[] heights, org.xcsp.common.Condition condition) Cumulative constraint.voidbuildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, org.xcsp.parser.entries.XVariables.XVarInteger[] lengths, int[] heights, org.xcsp.common.Condition condition) Cumulative constraint.voidbuildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, org.xcsp.parser.entries.XVariables.XVarInteger[] lengths, org.xcsp.parser.entries.XVariables.XVarInteger[] heights, org.xcsp.common.Condition condition) Cumulative constraint.voidbuildCtrExtension(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic[] list, String[][] tuples, boolean positive, Set<org.xcsp.common.Types.TypeFlag> flags) Extension constraint for Symbolic Variables Maps to buildCtrExtension with Integer variables if CONVERT_SYMBOLIC is truevoidbuildCtrExtension(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic x, String[] values, boolean positive, Set<org.xcsp.common.Types.TypeFlag> flags) Extension constraint for Symbolic Variables Maps to buildCtrExtension with Integer variables if CONVERT_SYMBOLIC is truevoidbuildCtrIntension(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic[] scope, org.xcsp.common.predicates.XNodeParent<org.xcsp.parser.entries.XVariables.XVarSymbolic> syntaxTreeRoot) Intension constraint for Symbolic Variables Maps to buildCtrIntension with Integer variables if CONVERT_SYMBOLIC is truevoidbuildCtrLexMatrix(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] matrix, org.xcsp.common.Types.TypeOperatorRel operator) Lex-matrix constraint.voidbuildCtrNoOverlap(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] origins, int[][] lengths, boolean zeroIgnored) voidbuildCtrNoOverlap(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] origins, org.xcsp.parser.entries.XVariables.XVarInteger[][] lengths, boolean zeroIgnored) voidbuildCtrNoOverlap2D(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] x, int[] dx, org.xcsp.parser.entries.XVariables.XVarInteger[] y, int[] dy) voidbuildCtrNoOverlap2D(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] x, org.xcsp.parser.entries.XVariables.XVarInteger[] dx, org.xcsp.parser.entries.XVariables.XVarInteger[] y, org.xcsp.parser.entries.XVariables.XVarInteger[] dy) protected org.xcsp.parser.entries.XVariables.XVarInteger[]buildEndsFromStartAndLength(org.xcsp.parser.entries.XVariables.XVarInteger[] starts, int[] lengths) Compute possible ends for given job starts and lenghtsprotected org.xcsp.parser.entries.XVariables.XVarInteger[]buildEndsFromStartAndLength(org.xcsp.parser.entries.XVariables.XVarInteger[] starts, org.xcsp.parser.entries.XVariables.XVarInteger[] lengths) Compute possible ends for given job starts and lenghtsvoidbuildVarSymbolic(org.xcsp.parser.entries.XVariables.XVarSymbolic x, String[] values) Builds a new symbolic variable.protected org.xcsp.common.predicates.XNodeParent<org.xcsp.parser.entries.XVariables.XVarInteger> convertSymbolicTree(org.xcsp.common.predicates.XNodeParent<org.xcsp.parser.entries.XVariables.XVarSymbolic> syntaxTreeRoot) protected org.xcsp.common.predicates.XNodeLeaf<org.xcsp.parser.entries.XVariables.XVarInteger> convertSymbolicTreeLeaf(org.xcsp.common.predicates.XNodeLeaf<org.xcsp.parser.entries.XVariables.XVarSymbolic> leaf) generateInstantiationWithSymbolic(String[] allVariables, int[] allValues) Generate an instantiation constraint that is the solution given in values.protected StringGenerate a variable id that is unique and will not be sent in the solutionunimplementedCase(Object... objects) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xcsp.parser.callbacks.XCallbacks
buildCtrFalse, buildCtrTrue, implem, loadAnnotations, loadArray, loadBlock, loadConstraints, loadConstraints, loadCtr, loadCtrs, loadDocument, loadGroup, loadInstance, loadInstance, loadLogic, loadObj, loadObjectives, loadSlide, loadVar, loadVariables, repostMethods inherited from interface org.xcsp.parser.callbacks.XCallbacks2
beginAnnotations, beginArray, beginBlock, beginConstraints, beginGroup, beginInstance, beginLogic, beginObjectives, beginSlide, beginVariables, buildAnnotationDecision, buildCtrAllDifferent, buildCtrAllDifferent, buildCtrAllDifferentExcept, buildCtrAllDifferentMatrix, buildCtrAllEqual, buildCtrAllEqual, buildCtrAmong, buildCtrAmong, buildCtrAtLeast, buildCtrAtMost, buildCtrBinPacking, buildCtrBinPacking, buildCtrCardinality, buildCtrCardinality, buildCtrCardinality, buildCtrCardinality, buildCtrCardinality, buildCtrCardinality, buildCtrChannel, buildCtrChannel, buildCtrChannel, buildCtrCircuit, buildCtrCircuit, buildCtrCircuit, buildCtrClause, buildCtrCount, buildCtrCount, buildCtrCount, buildCtrCumulative, buildCtrCumulative, buildCtrCumulative, buildCtrCumulative, buildCtrElement, buildCtrElement, buildCtrElement, buildCtrElement, buildCtrElement, buildCtrExactly, buildCtrExactly, buildCtrExtension, buildCtrExtension, buildCtrExtension, buildCtrInstantiation, buildCtrIntension, buildCtrLex, buildCtrLogic, buildCtrLogic, buildCtrLogic, buildCtrLogic, buildCtrMaximum, buildCtrMaximum, buildCtrMaximum, buildCtrMDD, buildCtrMinimum, buildCtrMinimum, buildCtrMinimum, buildCtrNoOverlap, buildCtrNoOverlap, buildCtrNotAllEqual, buildCtrNValues, buildCtrNValues, buildCtrNValuesExcept, buildCtrOrdered, buildCtrOrdered, buildCtrOrdered, buildCtrPrecedence, buildCtrPrimitive, buildCtrPrimitive, buildCtrPrimitive, buildCtrPrimitive, buildCtrPrimitive, buildCtrPrimitive, buildCtrPrimitive, buildCtrPrimitive, buildCtrRegular, buildCtrStretch, buildCtrStretch, buildCtrSum, buildCtrSum, buildCtrSum, buildCtrSum, buildCtrSum, buildCtrSum, buildObjToMaximize, buildObjToMaximize, buildObjToMaximize, buildObjToMaximize, buildObjToMaximize, buildObjToMaximize, buildObjToMinimize, buildObjToMinimize, buildObjToMinimize, buildObjToMinimize, buildObjToMinimize, buildObjToMinimize, buildVarInteger, buildVarInteger, endAnnotations, endArray, endBlock, endConstraints, endGroup, endInstance, endLogic, endObjectives, endSlide, endVariables
-
Field Details
-
CONVERT_SYMBOLIC
protected boolean CONVERT_SYMBOLIC -
symbolicValues
-
symbolicValuesReversed
-
symbolicVariables
-
reservedArray
-
currentReservedArrayIdx
protected int currentReservedArrayIdx
-
-
Constructor Details
-
XCallbacksDecomp
public XCallbacksDecomp()
-
-
Method Details
-
generateReservedArrayIdx
Generate a variable id that is unique and will not be sent in the solution -
buildVarSymbolic
Builds a new symbolic variable. This particular version automatically maps to buildVarInteger if CONVERT_SYMBOLIC is true- Specified by:
buildVarSymbolicin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildVarSymbolicin interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrAllDifferent
public void buildCtrAllDifferent(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic[] lists) All Different constraint on Symbolic variables. Maps to buildCtrAllDifferent with Integer variables if CONVERT_SYMBOLIC is true- Specified by:
buildCtrAllDifferentin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrAllDifferentin interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrExtension
public void buildCtrExtension(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic x, String[] values, boolean positive, Set<org.xcsp.common.Types.TypeFlag> flags) Extension constraint for Symbolic Variables Maps to buildCtrExtension with Integer variables if CONVERT_SYMBOLIC is true- Specified by:
buildCtrExtensionin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrExtensionin interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
convertSymbolicTreeLeaf
protected org.xcsp.common.predicates.XNodeLeaf<org.xcsp.parser.entries.XVariables.XVarInteger> convertSymbolicTreeLeaf(org.xcsp.common.predicates.XNodeLeaf<org.xcsp.parser.entries.XVariables.XVarSymbolic> leaf) -
convertSymbolicTree
protected org.xcsp.common.predicates.XNodeParent<org.xcsp.parser.entries.XVariables.XVarInteger> convertSymbolicTree(org.xcsp.common.predicates.XNodeParent<org.xcsp.parser.entries.XVariables.XVarSymbolic> syntaxTreeRoot) -
buildCtrIntension
public void buildCtrIntension(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic[] scope, org.xcsp.common.predicates.XNodeParent<org.xcsp.parser.entries.XVariables.XVarSymbolic> syntaxTreeRoot) Intension constraint for Symbolic Variables Maps to buildCtrIntension with Integer variables if CONVERT_SYMBOLIC is true- Specified by:
buildCtrIntensionin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrIntensionin interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrExtension
public void buildCtrExtension(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic[] list, String[][] tuples, boolean positive, Set<org.xcsp.common.Types.TypeFlag> flags) Extension constraint for Symbolic Variables Maps to buildCtrExtension with Integer variables if CONVERT_SYMBOLIC is true- Specified by:
buildCtrExtensionin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrExtensionin interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrAllDifferentMatrix
public void buildCtrAllDifferentMatrix(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] matrix) All Diff Matrix. This particular version maps all the line/columns to buildCtrAllDifferent.- Specified by:
buildCtrAllDifferentMatrixin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrAllDifferentMatrixin interfaceorg.xcsp.parser.callbacks.XCallbacks2- Parameters:
id-matrix-
-
buildEndsFromStartAndLength
protected org.xcsp.parser.entries.XVariables.XVarInteger[] buildEndsFromStartAndLength(org.xcsp.parser.entries.XVariables.XVarInteger[] starts, org.xcsp.parser.entries.XVariables.XVarInteger[] lengths) Compute possible ends for given job starts and lenghts -
buildEndsFromStartAndLength
protected org.xcsp.parser.entries.XVariables.XVarInteger[] buildEndsFromStartAndLength(org.xcsp.parser.entries.XVariables.XVarInteger[] starts, int[] lengths) Compute possible ends for given job starts and lenghts -
buildCtrCumulative
public void buildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, int[] lengths, int[] heights, org.xcsp.common.Condition condition) Cumulative constraint. Infer the parameters ends from origins and length- Specified by:
buildCtrCumulativein interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrCumulativein interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrCumulative
public void buildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, int[] lengths, org.xcsp.parser.entries.XVariables.XVarInteger[] heights, org.xcsp.common.Condition condition) Cumulative constraint. Infer the parameters ends from origins and length- Specified by:
buildCtrCumulativein interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrCumulativein interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrCumulative
public void buildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, org.xcsp.parser.entries.XVariables.XVarInteger[] lengths, int[] heights, org.xcsp.common.Condition condition) Cumulative constraint. Infer the parameters ends from origins and length- Specified by:
buildCtrCumulativein interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrCumulativein interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrCumulative
public void buildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, org.xcsp.parser.entries.XVariables.XVarInteger[] lengths, org.xcsp.parser.entries.XVariables.XVarInteger[] heights, org.xcsp.common.Condition condition) Cumulative constraint. Infer the parameters ends from origins and length- Specified by:
buildCtrCumulativein interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrCumulativein interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrLexMatrix
public void buildCtrLexMatrix(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] matrix, org.xcsp.common.Types.TypeOperatorRel operator) Lex-matrix constraint. Map to the std. Lex constraint, on the columns and on the rows- Specified by:
buildCtrLexMatrixin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrLexMatrixin interfaceorg.xcsp.parser.callbacks.XCallbacks2- Parameters:
id-matrix-operator-
-
buildCtrNoOverlap
public void buildCtrNoOverlap(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] origins, int[][] lengths, boolean zeroIgnored) - Specified by:
buildCtrNoOverlapin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrNoOverlapin interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrNoOverlap
public void buildCtrNoOverlap(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] origins, org.xcsp.parser.entries.XVariables.XVarInteger[][] lengths, boolean zeroIgnored) - Specified by:
buildCtrNoOverlapin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrNoOverlapin interfaceorg.xcsp.parser.callbacks.XCallbacks2
-
buildCtrNoOverlap2D
public void buildCtrNoOverlap2D(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] x, org.xcsp.parser.entries.XVariables.XVarInteger[] dx, org.xcsp.parser.entries.XVariables.XVarInteger[] y, org.xcsp.parser.entries.XVariables.XVarInteger[] dy) -
buildCtrNoOverlap2D
public void buildCtrNoOverlap2D(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] x, int[] dx, org.xcsp.parser.entries.XVariables.XVarInteger[] y, int[] dy) -
buildCtrAllDifferentList
public void buildCtrAllDifferentList(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] lists) AllDifferentList constraint. For each pair of tuple (x,y), maps to Or(ne(x[0],y[0]), ne(x[1],y[1]), ne(x[2],y[2]), ...)- Specified by:
buildCtrAllDifferentListin interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
buildCtrAllDifferentListin interfaceorg.xcsp.parser.callbacks.XCallbacks2- Parameters:
id-lists-
-
generateInstantiationWithSymbolic
Generate an instantiation constraint that is the solution given in values. The main purpose of this function is to parse back XVarInteger to XVarSymbolic if it was previously converted- Parameters:
allVariables- list of variables in the solution, given by their idallValues- values[i] is the value assigned to variables[i]
-
unimplementedCase
- Specified by:
unimplementedCasein interfaceorg.xcsp.parser.callbacks.XCallbacks- Specified by:
unimplementedCasein interfaceorg.xcsp.parser.callbacks.XCallbacks2
-