Class MPSosConstraint.Builder

java.lang.Object
com.google.protobuf.AbstractMessageLite.Builder
com.google.protobuf.AbstractMessage.Builder<BuilderT>
com.google.protobuf.GeneratedMessageV3.Builder<MPSosConstraint.Builder>
com.google.ortools.linearsolver.MPSosConstraint.Builder
All Implemented Interfaces:
MPSosConstraintOrBuilder, com.google.protobuf.Message.Builder, com.google.protobuf.MessageLite.Builder, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, Cloneable
Enclosing class:
MPSosConstraint

public static final class MPSosConstraint.Builder extends com.google.protobuf.GeneratedMessageV3.Builder<MPSosConstraint.Builder> implements MPSosConstraintOrBuilder
 Special Ordered Set (SOS) constraints of type 1 or 2.
 See https://en.wikipedia.org/wiki/Special_ordered_set
 As of 2019/04, only SCIP and Gurobi support this constraint type.
 
Protobuf type operations_research.MPSosConstraint
  • Method Details

    • 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<MPSosConstraint.Builder>
    • clear

      public MPSosConstraint.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<MPSosConstraint.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<MPSosConstraint.Builder>
    • getDefaultInstanceForType

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

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

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

      public MPSosConstraint.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<MPSosConstraint.Builder>
    • setField

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

      public MPSosConstraint.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<MPSosConstraint.Builder>
    • clearOneof

      public MPSosConstraint.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<MPSosConstraint.Builder>
    • setRepeatedField

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

      public MPSosConstraint.Builder addRepeatedField(com.google.protobuf.Descriptors.FieldDescriptor field, Object value)
      Specified by:
      addRepeatedField in interface com.google.protobuf.Message.Builder
      Overrides:
      addRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<MPSosConstraint.Builder>
    • mergeFrom

      public MPSosConstraint.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<MPSosConstraint.Builder>
    • mergeFrom

      public MPSosConstraint.Builder mergeFrom(MPSosConstraint other)
    • isInitialized

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

      public MPSosConstraint.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<MPSosConstraint.Builder>
      Throws:
      IOException
    • hasType

      public boolean hasType()
      optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
      Specified by:
      hasType in interface MPSosConstraintOrBuilder
      Returns:
      Whether the type field is set.
    • getType

      public MPSosConstraint.Type getType()
      optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
      Specified by:
      getType in interface MPSosConstraintOrBuilder
      Returns:
      The type.
    • setType

      optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
      Parameters:
      value - The type to set.
      Returns:
      This builder for chaining.
    • clearType

      public MPSosConstraint.Builder clearType()
      optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
      Returns:
      This builder for chaining.
    • getVarIndexList

      public List<Integer> getVarIndexList()
       Variable index (w.r.t. the "variable" field of MPModelProto) of the
       variables in the SOS.
       
      repeated int32 var_index = 2;
      Specified by:
      getVarIndexList in interface MPSosConstraintOrBuilder
      Returns:
      A list containing the varIndex.
    • getVarIndexCount

      public int getVarIndexCount()
       Variable index (w.r.t. the "variable" field of MPModelProto) of the
       variables in the SOS.
       
      repeated int32 var_index = 2;
      Specified by:
      getVarIndexCount in interface MPSosConstraintOrBuilder
      Returns:
      The count of varIndex.
    • getVarIndex

      public int getVarIndex(int index)
       Variable index (w.r.t. the "variable" field of MPModelProto) of the
       variables in the SOS.
       
      repeated int32 var_index = 2;
      Specified by:
      getVarIndex in interface MPSosConstraintOrBuilder
      Parameters:
      index - The index of the element to return.
      Returns:
      The varIndex at the given index.
    • setVarIndex

      public MPSosConstraint.Builder setVarIndex(int index, int value)
       Variable index (w.r.t. the "variable" field of MPModelProto) of the
       variables in the SOS.
       
      repeated int32 var_index = 2;
      Parameters:
      index - The index to set the value at.
      value - The varIndex to set.
      Returns:
      This builder for chaining.
    • addVarIndex

      public MPSosConstraint.Builder addVarIndex(int value)
       Variable index (w.r.t. the "variable" field of MPModelProto) of the
       variables in the SOS.
       
      repeated int32 var_index = 2;
      Parameters:
      value - The varIndex to add.
      Returns:
      This builder for chaining.
    • addAllVarIndex

      public MPSosConstraint.Builder addAllVarIndex(Iterable<? extends Integer> values)
       Variable index (w.r.t. the "variable" field of MPModelProto) of the
       variables in the SOS.
       
      repeated int32 var_index = 2;
      Parameters:
      values - The varIndex to add.
      Returns:
      This builder for chaining.
    • clearVarIndex

      public MPSosConstraint.Builder clearVarIndex()
       Variable index (w.r.t. the "variable" field of MPModelProto) of the
       variables in the SOS.
       
      repeated int32 var_index = 2;
      Returns:
      This builder for chaining.
    • getWeightList

      public List<Double> getWeightList()
       Optional: SOS weights. If non-empty, must be of the same size as
       "var_index", and strictly increasing. If empty and required by the
       underlying solver, the 1..n sequence will be given as weights.
       SUBTLE: The weights can help the solver make branch-and-bound decisions
       that fit the underlying optimization model: after each LP relaxation, it
       will compute the "average weight" of the SOS variables, weighted by value
       (this is confusing: here we're using the values as weights), and the binary
       branch decision will be: is the non-zero variable above or below that?
       (weights are strictly monotonous, so the "cutoff" average weight
       corresponds to a "cutoff" index in the var_index sequence).
       
      repeated double weight = 3;
      Specified by:
      getWeightList in interface MPSosConstraintOrBuilder
      Returns:
      A list containing the weight.
    • getWeightCount

      public int getWeightCount()
       Optional: SOS weights. If non-empty, must be of the same size as
       "var_index", and strictly increasing. If empty and required by the
       underlying solver, the 1..n sequence will be given as weights.
       SUBTLE: The weights can help the solver make branch-and-bound decisions
       that fit the underlying optimization model: after each LP relaxation, it
       will compute the "average weight" of the SOS variables, weighted by value
       (this is confusing: here we're using the values as weights), and the binary
       branch decision will be: is the non-zero variable above or below that?
       (weights are strictly monotonous, so the "cutoff" average weight
       corresponds to a "cutoff" index in the var_index sequence).
       
      repeated double weight = 3;
      Specified by:
      getWeightCount in interface MPSosConstraintOrBuilder
      Returns:
      The count of weight.
    • getWeight

      public double getWeight(int index)
       Optional: SOS weights. If non-empty, must be of the same size as
       "var_index", and strictly increasing. If empty and required by the
       underlying solver, the 1..n sequence will be given as weights.
       SUBTLE: The weights can help the solver make branch-and-bound decisions
       that fit the underlying optimization model: after each LP relaxation, it
       will compute the "average weight" of the SOS variables, weighted by value
       (this is confusing: here we're using the values as weights), and the binary
       branch decision will be: is the non-zero variable above or below that?
       (weights are strictly monotonous, so the "cutoff" average weight
       corresponds to a "cutoff" index in the var_index sequence).
       
      repeated double weight = 3;
      Specified by:
      getWeight in interface MPSosConstraintOrBuilder
      Parameters:
      index - The index of the element to return.
      Returns:
      The weight at the given index.
    • setWeight

      public MPSosConstraint.Builder setWeight(int index, double value)
       Optional: SOS weights. If non-empty, must be of the same size as
       "var_index", and strictly increasing. If empty and required by the
       underlying solver, the 1..n sequence will be given as weights.
       SUBTLE: The weights can help the solver make branch-and-bound decisions
       that fit the underlying optimization model: after each LP relaxation, it
       will compute the "average weight" of the SOS variables, weighted by value
       (this is confusing: here we're using the values as weights), and the binary
       branch decision will be: is the non-zero variable above or below that?
       (weights are strictly monotonous, so the "cutoff" average weight
       corresponds to a "cutoff" index in the var_index sequence).
       
      repeated double weight = 3;
      Parameters:
      index - The index to set the value at.
      value - The weight to set.
      Returns:
      This builder for chaining.
    • addWeight

      public MPSosConstraint.Builder addWeight(double value)
       Optional: SOS weights. If non-empty, must be of the same size as
       "var_index", and strictly increasing. If empty and required by the
       underlying solver, the 1..n sequence will be given as weights.
       SUBTLE: The weights can help the solver make branch-and-bound decisions
       that fit the underlying optimization model: after each LP relaxation, it
       will compute the "average weight" of the SOS variables, weighted by value
       (this is confusing: here we're using the values as weights), and the binary
       branch decision will be: is the non-zero variable above or below that?
       (weights are strictly monotonous, so the "cutoff" average weight
       corresponds to a "cutoff" index in the var_index sequence).
       
      repeated double weight = 3;
      Parameters:
      value - The weight to add.
      Returns:
      This builder for chaining.
    • addAllWeight

      public MPSosConstraint.Builder addAllWeight(Iterable<? extends Double> values)
       Optional: SOS weights. If non-empty, must be of the same size as
       "var_index", and strictly increasing. If empty and required by the
       underlying solver, the 1..n sequence will be given as weights.
       SUBTLE: The weights can help the solver make branch-and-bound decisions
       that fit the underlying optimization model: after each LP relaxation, it
       will compute the "average weight" of the SOS variables, weighted by value
       (this is confusing: here we're using the values as weights), and the binary
       branch decision will be: is the non-zero variable above or below that?
       (weights are strictly monotonous, so the "cutoff" average weight
       corresponds to a "cutoff" index in the var_index sequence).
       
      repeated double weight = 3;
      Parameters:
      values - The weight to add.
      Returns:
      This builder for chaining.
    • clearWeight

      public MPSosConstraint.Builder clearWeight()
       Optional: SOS weights. If non-empty, must be of the same size as
       "var_index", and strictly increasing. If empty and required by the
       underlying solver, the 1..n sequence will be given as weights.
       SUBTLE: The weights can help the solver make branch-and-bound decisions
       that fit the underlying optimization model: after each LP relaxation, it
       will compute the "average weight" of the SOS variables, weighted by value
       (this is confusing: here we're using the values as weights), and the binary
       branch decision will be: is the non-zero variable above or below that?
       (weights are strictly monotonous, so the "cutoff" average weight
       corresponds to a "cutoff" index in the var_index sequence).
       
      repeated double weight = 3;
      Returns:
      This builder for chaining.
    • setUnknownFields

      public final MPSosConstraint.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<MPSosConstraint.Builder>
    • mergeUnknownFields

      public final MPSosConstraint.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<MPSosConstraint.Builder>