Help save net neutrality! Learn more.
Close

ExtensionalSupport - Help

Help
2013-09-02
2013-10-02
  • Ernst Oberortner

    Hi...

    Currently I'm having 20 variables and for every variable ~400 values (those 400 values are the same for every variable)...
    I specify several ``positioning'' constraints (e.g. value 10 should appear at any position before value 20 appears and value 20 must appear next to value 10)...
    with my current JaCoP-based approach, it takes ages to calculate the solutions... so I'm mapping my constraints completely wrong onto JaCoP...

    I'm currently mapping such ``positioning'' constraints using JaCoP's IfThen constraints
    Example: If the value of variable xi (i=1,...,20) equals 10, then no variable xj (j=1,..,i) cannot have the value 20...

    Could anybody help me please how to map such ``positioning'' constraints onto JaCoP?
    I have no clue how ExtensionalSupport* could help? or can you provide me any examples? I haven't found any appropriated examples in the JaCoP examples...

    Many thanks in advance!

    Best,
    Ernst

     
  • kris

    kris - 2013-09-03

    Hi!

    IfThen constraint is not really a good solution. It basically watches "if" constraint and then if it is satisfied it enforces "then" constraint. If the first constraint is equality it is satisfied when the variable is ground. Before that nothing is done. This means that the search in your model is basically generate-and-test and does not use power of CP.

    I propose to use reified constraints instead of IfThen. they propagate in both directions and can improve search performance.

    ExtensionalSupport is probably not very helpful here since you need to specify all possible values for each tuple of variables. It can be very large, I guess. You can of course try this as well but need to think of which variables will be specified.

    Best regards,
    /Kris

     
    • Ernst Oberortner

      Kris...
      thanks for the hint on Reified constraints... I'll have a look into it...
      my follow up question, however, is: how can I combine (AND, OR) or negate constraints which are not of type PrimitiveConstraints? I would have to do this manually, right?

      Thanks,
      Ernst

      ps: I'm also trying to re-model my problem... i.e. changing the variables and values... then, I'm gonna have 400 variables each having a domain of 20 values... then I could easily specify such ``positioning'' constraints using XltY...

       
  • kris

    kris - 2013-09-04

    Hi!

    And, Or and Not ARE primitive constraints and you can nest them and use in reified and conditional constraints. The other questions is, of course, whether it will be efficient.

    A small remark do not use And for adding constraint to the store. All constraint added to the store are treated as conjunction of constraints.

    Good luck with your redefinitions.

    /Kris

     
  • Ernst Oberortner

    Kris...
    thanks a lot for your help...
    just one final question please... how can I transform IfThen constraints onto Reified Constraints... I'm a bit clueless on this...
    Thanks,
    Ernst

     
  • kris

    kris - 2013-09-04

    Basically you cannot replace IfThen with Reified constraint since IfThen represents an implication and Reified bi-derectional implication. However, from my experience I know that programmers usually use IfThen in place of Reified that is more efficient in propagation. You need to decide yourself and check the correctness of results.
    Best regards,
    Kris

     
  • kris

    kris - 2013-09-04

    BTW, the equivalent Reified for IfThen(c1, c2) is

    Reified(c1, b)
    Reified(c2, b)

    Kris

     
  • Ernst Oberortner

    this helps a lot Kris... Thanks!

     
  • Radoslaw Szymanek

    Hi Ernst,

    You could also use Element constraint.

    Element(i_10, list, var10), where i_10 is index of variable from list that has value equal to var10 that will be set to value 10.

    If your list has only one variable with value 10 then i_10 will only have one value possible. You could use i_10 and i_20 (position of value 20 in the list) to impose those constraints on the position of values for example i_10 + 1 = i_20.

    Hope that helps.

    best regards,
    Radek

     
  • Ernst Oberortner

    Radek...
    your hint regarding Element constraints helps a lot... Thanks!

    one follow up question please... how can you build the disjunction of two (or more) global constraints?

    Thanks,
    Ernst

     
  • kris

    kris - 2013-10-02

    Global constraint are not primitive constraints and cannot be used as arguments to other constraints, such as Or constraint.

    Kris

     
  • Radoslaw Szymanek

    Dear Ernst,

    We make distinction between PrimitiveConstraint and Constraint (global one) on purpose. For some constraints it is not possible to implement it efficiently as PrimitiveConstraint. This inescapable inefficiency would be severely impacting the search making the constraint based approach impractical. Thus, we decided to make the distinction between different types of constraints, making it impossible to use global constraint as PrimitiveConstraint. It helps us to use compiler to not allow our users to create very inefficient model.

    You need to figure out a different model and we just spared you time trying to figure out why your model is not performing well.

    best,
    Radek

     
  • Ernst Oberortner

    Radek and Kris...
    I really do appreciate your help... Many thanks!

    Best,
    Ernst

     

Log in to post a comment.