Class RoutesConstraintProto.Builder

java.lang.Object
com.google.protobuf.AbstractMessageLite.Builder
com.google.protobuf.AbstractMessage.Builder<BuilderT>
com.google.protobuf.GeneratedMessage.Builder<RoutesConstraintProto.Builder>
com.google.ortools.sat.RoutesConstraintProto.Builder
All Implemented Interfaces:
RoutesConstraintProtoOrBuilder, com.google.protobuf.Message.Builder, com.google.protobuf.MessageLite.Builder, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, Cloneable
Enclosing class:
RoutesConstraintProto

public static final class RoutesConstraintProto.Builder extends com.google.protobuf.GeneratedMessage.Builder<RoutesConstraintProto.Builder> implements RoutesConstraintProtoOrBuilder
 The "VRP" (Vehicle Routing Problem) constraint.

 The direct graph where arc #i (from tails[i] to head[i]) is present iff
 literals[i] is true must satisfy this set of properties:
 - #incoming arcs == 1 except for node 0.
 - #outgoing arcs == 1 except for node 0.
 - for node zero, #incoming arcs == #outgoing arcs.
 - There are no duplicate arcs.
 - Self-arcs are allowed except for node 0.
 - There is no cycle in this graph, except through node 0.

 Note: Currently this constraint expect all the nodes in [0, num_nodes) to
 have at least one incident arc. The model will be considered invalid if it
 is not the case. You can add self-arc fixed to one to ignore some nodes if
 needed.

 TODO(user): It is probably possible to generalize this constraint to a
 no-cycle in a general graph, or a no-cycle with sum incoming <= 1 and sum
 outgoing <= 1 (more efficient implementation). On the other hand, having this
 specific constraint allow us to add specific "cuts" to a VRP problem.
 
Protobuf type operations_research.sat.RoutesConstraintProto
  • Method Details

    • getDescriptor

      public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
    • internalGetFieldAccessorTable

      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
      Specified by:
      internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessage.Builder<RoutesConstraintProto.Builder>
    • clear

      Specified by:
      clear in interface com.google.protobuf.Message.Builder
      Specified by:
      clear in interface com.google.protobuf.MessageLite.Builder
      Overrides:
      clear in class com.google.protobuf.GeneratedMessage.Builder<RoutesConstraintProto.Builder>
    • getDescriptorForType

      public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
      Specified by:
      getDescriptorForType in interface com.google.protobuf.Message.Builder
      Specified by:
      getDescriptorForType in interface com.google.protobuf.MessageOrBuilder
      Overrides:
      getDescriptorForType in class com.google.protobuf.GeneratedMessage.Builder<RoutesConstraintProto.Builder>
    • getDefaultInstanceForType

      public RoutesConstraintProto getDefaultInstanceForType()
      Specified by:
      getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
      Specified by:
      getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder
    • build

      public RoutesConstraintProto build()
      Specified by:
      build in interface com.google.protobuf.Message.Builder
      Specified by:
      build in interface com.google.protobuf.MessageLite.Builder
    • buildPartial

      public RoutesConstraintProto buildPartial()
      Specified by:
      buildPartial in interface com.google.protobuf.Message.Builder
      Specified by:
      buildPartial in interface com.google.protobuf.MessageLite.Builder
    • mergeFrom

      public RoutesConstraintProto.Builder mergeFrom(com.google.protobuf.Message other)
      Specified by:
      mergeFrom in interface com.google.protobuf.Message.Builder
      Overrides:
      mergeFrom in class com.google.protobuf.AbstractMessage.Builder<RoutesConstraintProto.Builder>
    • mergeFrom

    • isInitialized

      public final boolean isInitialized()
      Specified by:
      isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
      Overrides:
      isInitialized in class com.google.protobuf.GeneratedMessage.Builder<RoutesConstraintProto.Builder>
    • mergeFrom

      public RoutesConstraintProto.Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
      Specified by:
      mergeFrom in interface com.google.protobuf.Message.Builder
      Specified by:
      mergeFrom in interface com.google.protobuf.MessageLite.Builder
      Overrides:
      mergeFrom in class com.google.protobuf.AbstractMessage.Builder<RoutesConstraintProto.Builder>
      Throws:
      IOException
    • getTailsList

      public List<Integer> getTailsList()
      repeated int32 tails = 1;
      Specified by:
      getTailsList in interface RoutesConstraintProtoOrBuilder
      Returns:
      A list containing the tails.
    • getTailsCount

      public int getTailsCount()
      repeated int32 tails = 1;
      Specified by:
      getTailsCount in interface RoutesConstraintProtoOrBuilder
      Returns:
      The count of tails.
    • getTails

      public int getTails(int index)
      repeated int32 tails = 1;
      Specified by:
      getTails in interface RoutesConstraintProtoOrBuilder
      Parameters:
      index - The index of the element to return.
      Returns:
      The tails at the given index.
    • setTails

      public RoutesConstraintProto.Builder setTails(int index, int value)
      repeated int32 tails = 1;
      Parameters:
      index - The index to set the value at.
      value - The tails to set.
      Returns:
      This builder for chaining.
    • addTails

      public RoutesConstraintProto.Builder addTails(int value)
      repeated int32 tails = 1;
      Parameters:
      value - The tails to add.
      Returns:
      This builder for chaining.
    • addAllTails

      public RoutesConstraintProto.Builder addAllTails(Iterable<? extends Integer> values)
      repeated int32 tails = 1;
      Parameters:
      values - The tails to add.
      Returns:
      This builder for chaining.
    • clearTails

      public RoutesConstraintProto.Builder clearTails()
      repeated int32 tails = 1;
      Returns:
      This builder for chaining.
    • getHeadsList

      public List<Integer> getHeadsList()
      repeated int32 heads = 2;
      Specified by:
      getHeadsList in interface RoutesConstraintProtoOrBuilder
      Returns:
      A list containing the heads.
    • getHeadsCount

      public int getHeadsCount()
      repeated int32 heads = 2;
      Specified by:
      getHeadsCount in interface RoutesConstraintProtoOrBuilder
      Returns:
      The count of heads.
    • getHeads

      public int getHeads(int index)
      repeated int32 heads = 2;
      Specified by:
      getHeads in interface RoutesConstraintProtoOrBuilder
      Parameters:
      index - The index of the element to return.
      Returns:
      The heads at the given index.
    • setHeads

      public RoutesConstraintProto.Builder setHeads(int index, int value)
      repeated int32 heads = 2;
      Parameters:
      index - The index to set the value at.
      value - The heads to set.
      Returns:
      This builder for chaining.
    • addHeads

      public RoutesConstraintProto.Builder addHeads(int value)
      repeated int32 heads = 2;
      Parameters:
      value - The heads to add.
      Returns:
      This builder for chaining.
    • addAllHeads

      public RoutesConstraintProto.Builder addAllHeads(Iterable<? extends Integer> values)
      repeated int32 heads = 2;
      Parameters:
      values - The heads to add.
      Returns:
      This builder for chaining.
    • clearHeads

      public RoutesConstraintProto.Builder clearHeads()
      repeated int32 heads = 2;
      Returns:
      This builder for chaining.
    • getLiteralsList

      public List<Integer> getLiteralsList()
      repeated int32 literals = 3;
      Specified by:
      getLiteralsList in interface RoutesConstraintProtoOrBuilder
      Returns:
      A list containing the literals.
    • getLiteralsCount

      public int getLiteralsCount()
      repeated int32 literals = 3;
      Specified by:
      getLiteralsCount in interface RoutesConstraintProtoOrBuilder
      Returns:
      The count of literals.
    • getLiterals

      public int getLiterals(int index)
      repeated int32 literals = 3;
      Specified by:
      getLiterals in interface RoutesConstraintProtoOrBuilder
      Parameters:
      index - The index of the element to return.
      Returns:
      The literals at the given index.
    • setLiterals

      public RoutesConstraintProto.Builder setLiterals(int index, int value)
      repeated int32 literals = 3;
      Parameters:
      index - The index to set the value at.
      value - The literals to set.
      Returns:
      This builder for chaining.
    • addLiterals

      public RoutesConstraintProto.Builder addLiterals(int value)
      repeated int32 literals = 3;
      Parameters:
      value - The literals to add.
      Returns:
      This builder for chaining.
    • addAllLiterals

      public RoutesConstraintProto.Builder addAllLiterals(Iterable<? extends Integer> values)
      repeated int32 literals = 3;
      Parameters:
      values - The literals to add.
      Returns:
      This builder for chaining.
    • clearLiterals

      public RoutesConstraintProto.Builder clearLiterals()
      repeated int32 literals = 3;
      Returns:
      This builder for chaining.
    • getDemandsList

      public List<Integer> getDemandsList()
       EXPERIMENTAL. The demands for each node, and the maximum capacity for each
       route. Note that this is currently only used for the LP relaxation and one
       need to add the corresponding constraint to enforce this outside of the LP.
      
       TODO(user): Ideally, we should be able to extract any dimension like these
       (i.e. capacity, route_length, etc..) automatically from the encoding. The
       classical way to encode that is to have "current_capacity" variables along
       the route and linear equations of the form:
       arc_literal => (current_capacity_tail + demand <= current_capacity_head)
       
      repeated int32 demands = 4;
      Specified by:
      getDemandsList in interface RoutesConstraintProtoOrBuilder
      Returns:
      A list containing the demands.
    • getDemandsCount

      public int getDemandsCount()
       EXPERIMENTAL. The demands for each node, and the maximum capacity for each
       route. Note that this is currently only used for the LP relaxation and one
       need to add the corresponding constraint to enforce this outside of the LP.
      
       TODO(user): Ideally, we should be able to extract any dimension like these
       (i.e. capacity, route_length, etc..) automatically from the encoding. The
       classical way to encode that is to have "current_capacity" variables along
       the route and linear equations of the form:
       arc_literal => (current_capacity_tail + demand <= current_capacity_head)
       
      repeated int32 demands = 4;
      Specified by:
      getDemandsCount in interface RoutesConstraintProtoOrBuilder
      Returns:
      The count of demands.
    • getDemands

      public int getDemands(int index)
       EXPERIMENTAL. The demands for each node, and the maximum capacity for each
       route. Note that this is currently only used for the LP relaxation and one
       need to add the corresponding constraint to enforce this outside of the LP.
      
       TODO(user): Ideally, we should be able to extract any dimension like these
       (i.e. capacity, route_length, etc..) automatically from the encoding. The
       classical way to encode that is to have "current_capacity" variables along
       the route and linear equations of the form:
       arc_literal => (current_capacity_tail + demand <= current_capacity_head)
       
      repeated int32 demands = 4;
      Specified by:
      getDemands in interface RoutesConstraintProtoOrBuilder
      Parameters:
      index - The index of the element to return.
      Returns:
      The demands at the given index.
    • setDemands

      public RoutesConstraintProto.Builder setDemands(int index, int value)
       EXPERIMENTAL. The demands for each node, and the maximum capacity for each
       route. Note that this is currently only used for the LP relaxation and one
       need to add the corresponding constraint to enforce this outside of the LP.
      
       TODO(user): Ideally, we should be able to extract any dimension like these
       (i.e. capacity, route_length, etc..) automatically from the encoding. The
       classical way to encode that is to have "current_capacity" variables along
       the route and linear equations of the form:
       arc_literal => (current_capacity_tail + demand <= current_capacity_head)
       
      repeated int32 demands = 4;
      Parameters:
      index - The index to set the value at.
      value - The demands to set.
      Returns:
      This builder for chaining.
    • addDemands

      public RoutesConstraintProto.Builder addDemands(int value)
       EXPERIMENTAL. The demands for each node, and the maximum capacity for each
       route. Note that this is currently only used for the LP relaxation and one
       need to add the corresponding constraint to enforce this outside of the LP.
      
       TODO(user): Ideally, we should be able to extract any dimension like these
       (i.e. capacity, route_length, etc..) automatically from the encoding. The
       classical way to encode that is to have "current_capacity" variables along
       the route and linear equations of the form:
       arc_literal => (current_capacity_tail + demand <= current_capacity_head)
       
      repeated int32 demands = 4;
      Parameters:
      value - The demands to add.
      Returns:
      This builder for chaining.
    • addAllDemands

      public RoutesConstraintProto.Builder addAllDemands(Iterable<? extends Integer> values)
       EXPERIMENTAL. The demands for each node, and the maximum capacity for each
       route. Note that this is currently only used for the LP relaxation and one
       need to add the corresponding constraint to enforce this outside of the LP.
      
       TODO(user): Ideally, we should be able to extract any dimension like these
       (i.e. capacity, route_length, etc..) automatically from the encoding. The
       classical way to encode that is to have "current_capacity" variables along
       the route and linear equations of the form:
       arc_literal => (current_capacity_tail + demand <= current_capacity_head)
       
      repeated int32 demands = 4;
      Parameters:
      values - The demands to add.
      Returns:
      This builder for chaining.
    • clearDemands

      public RoutesConstraintProto.Builder clearDemands()
       EXPERIMENTAL. The demands for each node, and the maximum capacity for each
       route. Note that this is currently only used for the LP relaxation and one
       need to add the corresponding constraint to enforce this outside of the LP.
      
       TODO(user): Ideally, we should be able to extract any dimension like these
       (i.e. capacity, route_length, etc..) automatically from the encoding. The
       classical way to encode that is to have "current_capacity" variables along
       the route and linear equations of the form:
       arc_literal => (current_capacity_tail + demand <= current_capacity_head)
       
      repeated int32 demands = 4;
      Returns:
      This builder for chaining.
    • getCapacity

      public long getCapacity()
      int64 capacity = 5;
      Specified by:
      getCapacity in interface RoutesConstraintProtoOrBuilder
      Returns:
      The capacity.
    • setCapacity

      public RoutesConstraintProto.Builder setCapacity(long value)
      int64 capacity = 5;
      Parameters:
      value - The capacity to set.
      Returns:
      This builder for chaining.
    • clearCapacity

      public RoutesConstraintProto.Builder clearCapacity()
      int64 capacity = 5;
      Returns:
      This builder for chaining.