Class RoutesConstraintProto.Builder

  • All Implemented Interfaces:
    RoutesConstraintProtoOrBuilder, com.google.protobuf.Message.Builder, com.google.protobuf.MessageLite.Builder, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, java.lang.Cloneable
    Enclosing class:
    RoutesConstraintProto

    public static final class RoutesConstraintProto.Builder
    extends com.google.protobuf.GeneratedMessageV3.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 Detail

      • getDescriptor

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

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

        public 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.GeneratedMessageV3.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.GeneratedMessageV3.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
      • clone

        public RoutesConstraintProto.Builder clone()
        Specified by:
        clone in interface com.google.protobuf.Message.Builder
        Specified by:
        clone in interface com.google.protobuf.MessageLite.Builder
        Overrides:
        clone in class com.google.protobuf.GeneratedMessageV3.Builder<RoutesConstraintProto.Builder>
      • setField

        public RoutesConstraintProto.Builder setField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                                      java.lang.Object value)
        Specified by:
        setField in interface com.google.protobuf.Message.Builder
        Overrides:
        setField in class com.google.protobuf.GeneratedMessageV3.Builder<RoutesConstraintProto.Builder>
      • clearField

        public RoutesConstraintProto.Builder clearField​(com.google.protobuf.Descriptors.FieldDescriptor field)
        Specified by:
        clearField in interface com.google.protobuf.Message.Builder
        Overrides:
        clearField in class com.google.protobuf.GeneratedMessageV3.Builder<RoutesConstraintProto.Builder>
      • clearOneof

        public RoutesConstraintProto.Builder clearOneof​(com.google.protobuf.Descriptors.OneofDescriptor oneof)
        Specified by:
        clearOneof in interface com.google.protobuf.Message.Builder
        Overrides:
        clearOneof in class com.google.protobuf.GeneratedMessageV3.Builder<RoutesConstraintProto.Builder>
      • setRepeatedField

        public RoutesConstraintProto.Builder setRepeatedField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                                              int index,
                                                              java.lang.Object value)
        Specified by:
        setRepeatedField in interface com.google.protobuf.Message.Builder
        Overrides:
        setRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<RoutesConstraintProto.Builder>
      • addRepeatedField

        public RoutesConstraintProto.Builder addRepeatedField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                                              java.lang.Object value)
        Specified by:
        addRepeatedField in interface com.google.protobuf.Message.Builder
        Overrides:
        addRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<RoutesConstraintProto.Builder>
      • isInitialized

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

        public RoutesConstraintProto.Builder mergeFrom​(com.google.protobuf.CodedInputStream input,
                                                       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                                throws java.io.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:
        java.io.IOException
      • 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​(java.lang.Iterable<? extends java.lang.Integer> values)
        repeated int32 tails = 1;
        Parameters:
        values - The tails to add.
        Returns:
        This builder for chaining.
      • 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​(java.lang.Iterable<? extends java.lang.Integer> values)
        repeated int32 heads = 2;
        Parameters:
        values - The heads to add.
        Returns:
        This builder for chaining.
      • 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​(java.lang.Iterable<? extends java.lang.Integer> values)
        repeated int32 literals = 3;
        Parameters:
        values - The literals to add.
        Returns:
        This builder for chaining.
      • getDemandsList

        public java.util.List<java.lang.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​(java.lang.Iterable<? extends java.lang.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.
      • setCapacity

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

        public final RoutesConstraintProto.Builder setUnknownFields​(com.google.protobuf.UnknownFieldSet unknownFields)
        Specified by:
        setUnknownFields in interface com.google.protobuf.Message.Builder
        Overrides:
        setUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<RoutesConstraintProto.Builder>
      • mergeUnknownFields

        public final RoutesConstraintProto.Builder mergeUnknownFields​(com.google.protobuf.UnknownFieldSet unknownFields)
        Specified by:
        mergeUnknownFields in interface com.google.protobuf.Message.Builder
        Overrides:
        mergeUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<RoutesConstraintProto.Builder>