Class MPSosConstraint.Builder

java.lang.Object
com.google.protobuf.AbstractMessageLite.Builder
com.google.protobuf.AbstractMessage.Builder<MPSosConstraint.Builder>
com.google.protobuf.GeneratedMessage.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.GeneratedMessage.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 Summary

    Modifier and Type
    Method
    Description
    addAllVarIndex(Iterable<? extends Integer> values)
    Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.
    addAllWeight(Iterable<? extends Double> values)
    Optional: SOS weights.
    addVarIndex(int value)
    Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.
    addWeight(double value)
    Optional: SOS weights.
     
     
     
    optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
    Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.
    Optional: SOS weights.
     
    static final com.google.protobuf.Descriptors.Descriptor
     
    com.google.protobuf.Descriptors.Descriptor
     
    optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
    int
    getVarIndex(int index)
    Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.
    int
    Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.
    Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.
    double
    getWeight(int index)
    Optional: SOS weights.
    int
    Optional: SOS weights.
    Optional: SOS weights.
    boolean
    optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
     
    final boolean
     
     
    mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     
    mergeFrom(com.google.protobuf.Message other)
     
    optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
    setVarIndex(int index, int value)
    Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.
    setWeight(int index, double value)
    Optional: SOS weights.

    Methods inherited from class com.google.protobuf.GeneratedMessage.Builder

    addRepeatedField, clearField, clearOneof, clone, getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, getUnknownFieldSetBuilder, hasField, hasOneof, internalGetMapField, internalGetMapFieldReflection, internalGetMutableMapField, internalGetMutableMapFieldReflection, isClean, markClean, mergeUnknownFields, mergeUnknownLengthDelimitedField, mergeUnknownVarintField, newBuilderForField, onBuilt, onChanged, parseUnknownField, setField, setRepeatedField, setUnknownFields, setUnknownFieldSetBuilder, setUnknownFieldsProto3

    Methods inherited from class com.google.protobuf.AbstractMessage.Builder

    findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toString

    Methods inherited from class com.google.protobuf.AbstractMessageLite.Builder

    addAll, addAll, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, newUninitializedMessageException

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.google.protobuf.Message.Builder

    mergeDelimitedFrom, mergeDelimitedFrom

    Methods inherited from interface com.google.protobuf.MessageLite.Builder

    mergeFrom

    Methods inherited from interface com.google.protobuf.MessageOrBuilder

    findInitializationErrors, getAllFields, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof
  • 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<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.GeneratedMessage.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.GeneratedMessage.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
    • 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.GeneratedMessage.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.