Class RoutesConstraintProto.Builder

java.lang.Object
com.google.protobuf.AbstractMessageLite.Builder
com.google.protobuf.AbstractMessage.Builder<RoutesConstraintProto.Builder>
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 expects 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()
       DEPRECATED. These fields are no longer used. The solver ignores them.
       
      repeated int32 demands = 4;
      Specified by:
      getDemandsList in interface RoutesConstraintProtoOrBuilder
      Returns:
      A list containing the demands.
    • getDemandsCount

      public int getDemandsCount()
       DEPRECATED. These fields are no longer used. The solver ignores them.
       
      repeated int32 demands = 4;
      Specified by:
      getDemandsCount in interface RoutesConstraintProtoOrBuilder
      Returns:
      The count of demands.
    • getDemands

      public int getDemands(int index)
       DEPRECATED. These fields are no longer used. The solver ignores them.
       
      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)
       DEPRECATED. These fields are no longer used. The solver ignores them.
       
      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)
       DEPRECATED. These fields are no longer used. The solver ignores them.
       
      repeated int32 demands = 4;
      Parameters:
      value - The demands to add.
      Returns:
      This builder for chaining.
    • addAllDemands

      public RoutesConstraintProto.Builder addAllDemands(Iterable<? extends Integer> values)
       DEPRECATED. These fields are no longer used. The solver ignores them.
       
      repeated int32 demands = 4;
      Parameters:
      values - The demands to add.
      Returns:
      This builder for chaining.
    • clearDemands

      public RoutesConstraintProto.Builder clearDemands()
       DEPRECATED. These fields are no longer used. The solver ignores them.
       
      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.
    • getDimensionsList

      public List<RoutesConstraintProto.NodeExpressions> getDimensionsList()
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
      Specified by:
      getDimensionsList in interface RoutesConstraintProtoOrBuilder
    • getDimensionsCount

      public int getDimensionsCount()
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
      Specified by:
      getDimensionsCount in interface RoutesConstraintProtoOrBuilder
    • getDimensions

      public RoutesConstraintProto.NodeExpressions getDimensions(int index)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
      Specified by:
      getDimensions in interface RoutesConstraintProtoOrBuilder
    • setDimensions

      public RoutesConstraintProto.Builder setDimensions(int index, RoutesConstraintProto.NodeExpressions value)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • setDimensions

      public RoutesConstraintProto.Builder setDimensions(int index, RoutesConstraintProto.NodeExpressions.Builder builderForValue)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • addDimensions

       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • addDimensions

      public RoutesConstraintProto.Builder addDimensions(int index, RoutesConstraintProto.NodeExpressions value)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • addDimensions

       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • addDimensions

      public RoutesConstraintProto.Builder addDimensions(int index, RoutesConstraintProto.NodeExpressions.Builder builderForValue)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • addAllDimensions

       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • clearDimensions

      public RoutesConstraintProto.Builder clearDimensions()
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • removeDimensions

      public RoutesConstraintProto.Builder removeDimensions(int index)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • getDimensionsBuilder

      public RoutesConstraintProto.NodeExpressions.Builder getDimensionsBuilder(int index)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • getDimensionsOrBuilder

      public RoutesConstraintProto.NodeExpressionsOrBuilder getDimensionsOrBuilder(int index)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
      Specified by:
      getDimensionsOrBuilder in interface RoutesConstraintProtoOrBuilder
    • getDimensionsOrBuilderList

      public List<? extends RoutesConstraintProto.NodeExpressionsOrBuilder> getDimensionsOrBuilderList()
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
      Specified by:
      getDimensionsOrBuilderList in interface RoutesConstraintProtoOrBuilder
    • addDimensionsBuilder

      public RoutesConstraintProto.NodeExpressions.Builder addDimensionsBuilder()
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • addDimensionsBuilder

      public RoutesConstraintProto.NodeExpressions.Builder addDimensionsBuilder(int index)
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;
    • getDimensionsBuilderList

      public List<RoutesConstraintProto.NodeExpressions.Builder> getDimensionsBuilderList()
       Expressions associated with the nodes of the graph, such as the load of the
       vehicle arriving at a node, or the time at which a vehicle arrives at a
       node. Expressions with the same "dimension" (such as "load" or "time") must
       be listed together.
       This field is optional. If it is set, the linear constraints of size 1 or 2
       between the variables in these expressions will be used to derive cuts for
       this constraint. If it is not set, the solver will try to automatically
       derive it, from the linear constraints of size 1 or 2 in the model (this
       can fail in complex cases).
       
      repeated .operations_research.sat.RoutesConstraintProto.NodeExpressions dimensions = 6;