Module org.maxicp

Class XCallbacksDecomp

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
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected int
     
    protected String
     
     
    protected ArrayList<String>
     
    protected HashMap<String,org.xcsp.parser.entries.XVariables.XVarInteger>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    buildCtrAllDifferent(String id, org.xcsp.parser.entries.XVariables.XVarSymbolic[] lists)
    All Different constraint on Symbolic variables.
    void
    buildCtrAllDifferentList(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] lists)
    AllDifferentList constraint.
    void
    buildCtrAllDifferentMatrix(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] matrix)
    All Diff Matrix.
    void
    buildCtrCumulative(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] origins, int[] lengths, int[] heights, org.xcsp.common.Condition condition)
    Cumulative constraint.
    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.
    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.
    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.
    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
    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
    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
    void
    buildCtrLexMatrix(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] matrix, org.xcsp.common.Types.TypeOperatorRel operator)
    Lex-matrix constraint.
    void
    buildCtrNoOverlap(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] origins, int[][] lengths, boolean zeroIgnored)
     
    void
    buildCtrNoOverlap(String id, org.xcsp.parser.entries.XVariables.XVarInteger[][] origins, org.xcsp.parser.entries.XVariables.XVarInteger[][] lengths, boolean zeroIgnored)
     
    void
    buildCtrNoOverlap2D(String id, org.xcsp.parser.entries.XVariables.XVarInteger[] x, int[] dx, org.xcsp.parser.entries.XVariables.XVarInteger[] y, int[] dy)
     
    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)
     
    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
    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
    void
    buildVarSymbolic(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 String
    Generate a variable id that is unique and will not be sent in the solution
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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, repost

    Methods 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

      protected HashMap<String,Integer> symbolicValues
    • symbolicValuesReversed

      protected ArrayList<String> symbolicValuesReversed
    • symbolicVariables

      protected HashMap<String,org.xcsp.parser.entries.XVariables.XVarInteger> symbolicVariables
    • reservedArray

      protected String reservedArray
    • currentReservedArrayIdx

      protected int currentReservedArrayIdx
  • Constructor Details

    • XCallbacksDecomp

      public XCallbacksDecomp()
  • Method Details

    • generateReservedArrayIdx

      protected String generateReservedArrayIdx()
      Generate a variable id that is unique and will not be sent in the solution
    • buildVarSymbolic

      public void buildVarSymbolic(org.xcsp.parser.entries.XVariables.XVarSymbolic x, String[] values)
      Builds a new symbolic variable. This particular version automatically maps to buildVarInteger if CONVERT_SYMBOLIC is true
      Specified by:
      buildVarSymbolic in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildVarSymbolic in interface org.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:
      buildCtrAllDifferent in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrAllDifferent in interface org.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:
      buildCtrExtension in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrExtension in interface org.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:
      buildCtrIntension in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrIntension in interface org.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:
      buildCtrExtension in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrExtension in interface org.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:
      buildCtrAllDifferentMatrix in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrAllDifferentMatrix in interface org.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:
      buildCtrCumulative in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrCumulative in interface org.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:
      buildCtrCumulative in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrCumulative in interface org.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:
      buildCtrCumulative in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrCumulative in interface org.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:
      buildCtrCumulative in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrCumulative in interface org.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:
      buildCtrLexMatrix in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrLexMatrix in interface org.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:
      buildCtrNoOverlap in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrNoOverlap in interface org.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:
      buildCtrNoOverlap in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrNoOverlap in interface org.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:
      buildCtrAllDifferentList in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      buildCtrAllDifferentList in interface org.xcsp.parser.callbacks.XCallbacks2
      Parameters:
      id -
      lists -
    • generateInstantiationWithSymbolic

      public String generateInstantiationWithSymbolic(String[] allVariables, int[] allValues)
      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 id
      allValues - values[i] is the value assigned to variables[i]
    • unimplementedCase

      public Object unimplementedCase(Object... objects)
      Specified by:
      unimplementedCase in interface org.xcsp.parser.callbacks.XCallbacks
      Specified by:
      unimplementedCase in interface org.xcsp.parser.callbacks.XCallbacks2