Module org.maxicp

Class Distance

java.lang.Object
org.maxicp.modeling.constraints.seqvar.Distance
All Implemented Interfaces:
Constraint

public class Distance extends Object implements Constraint
Modeling-level distance constraint on a sequence variable (SeqVar), maintaining the total travel distance between consecutive visited nodes in the sequence.
  • Field Details

    • seqVar

      public final SeqVar seqVar
    • distanceMatrix

      public final int[][] distanceMatrix
    • distance

      public final IntExpression distance
  • Constructor Details

    • Distance

      public Distance(SeqVar seqVar, int[][] distanceMatrix, IntExpression distance)
      Creates a constraint maintaining that distance equals the sum of transition distances between consecutive nodes visited in seqVar.
      Parameters:
      seqVar - the sequence variable
      distanceMatrix - the distance matrix between nodes (must satisfy the triangle inequality)
      distance - the expression representing the total travel distance
  • Method Details

    • scope

      public Collection<? extends Expression> scope()
      Description copied from interface: Constraint
      Returns the scope of the constraint, preferably as an immutable, unique collection.
      Specified by:
      scope in interface Constraint
      Returns:
      the scope of the constraint, i.e. all the Expressions it uses. The collection should be immutable.