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 TypeMethodDescriptionaddAllVarIndex(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.build()clear()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.Descriptorcom.google.protobuf.Descriptors.DescriptorgetType()optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];intgetVarIndex(int index) Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.intVariable 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.doublegetWeight(int index) Optional: SOS weights.intOptional: SOS weights.Optional: SOS weights.booleanhasType()optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];protected com.google.protobuf.GeneratedMessage.FieldAccessorTablefinal booleanmergeFrom(MPSosConstraint other) mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) mergeFrom(com.google.protobuf.Message other) setType(MPSosConstraint.Type value) 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, setUnknownFieldsProto3Methods inherited from class com.google.protobuf.AbstractMessage.Builder
findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toStringMethods inherited from class com.google.protobuf.AbstractMessageLite.Builder
addAll, addAll, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, newUninitializedMessageExceptionMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.protobuf.Message.Builder
mergeDelimitedFrom, mergeDelimitedFromMethods inherited from interface com.google.protobuf.MessageLite.Builder
mergeFromMethods 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:
internalGetFieldAccessorTablein classcom.google.protobuf.GeneratedMessage.Builder<MPSosConstraint.Builder>
-
clear
- Specified by:
clearin interfacecom.google.protobuf.Message.Builder- Specified by:
clearin interfacecom.google.protobuf.MessageLite.Builder- Overrides:
clearin classcom.google.protobuf.GeneratedMessage.Builder<MPSosConstraint.Builder>
-
getDescriptorForType
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()- Specified by:
getDescriptorForTypein interfacecom.google.protobuf.Message.Builder- Specified by:
getDescriptorForTypein interfacecom.google.protobuf.MessageOrBuilder- Overrides:
getDescriptorForTypein classcom.google.protobuf.GeneratedMessage.Builder<MPSosConstraint.Builder>
-
getDefaultInstanceForType
- Specified by:
getDefaultInstanceForTypein interfacecom.google.protobuf.MessageLiteOrBuilder- Specified by:
getDefaultInstanceForTypein interfacecom.google.protobuf.MessageOrBuilder
-
build
- Specified by:
buildin interfacecom.google.protobuf.Message.Builder- Specified by:
buildin interfacecom.google.protobuf.MessageLite.Builder
-
buildPartial
- Specified by:
buildPartialin interfacecom.google.protobuf.Message.Builder- Specified by:
buildPartialin interfacecom.google.protobuf.MessageLite.Builder
-
mergeFrom
- Specified by:
mergeFromin interfacecom.google.protobuf.Message.Builder- Overrides:
mergeFromin classcom.google.protobuf.AbstractMessage.Builder<MPSosConstraint.Builder>
-
mergeFrom
-
isInitialized
public final boolean isInitialized()- Specified by:
isInitializedin interfacecom.google.protobuf.MessageLiteOrBuilder- Overrides:
isInitializedin classcom.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:
mergeFromin interfacecom.google.protobuf.Message.Builder- Specified by:
mergeFromin interfacecom.google.protobuf.MessageLite.Builder- Overrides:
mergeFromin classcom.google.protobuf.AbstractMessage.Builder<MPSosConstraint.Builder>- Throws:
IOException
-
hasType
public boolean hasType()optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];- Specified by:
hasTypein interfaceMPSosConstraintOrBuilder- Returns:
- Whether the type field is set.
-
getType
optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];- Specified by:
getTypein interfaceMPSosConstraintOrBuilder- 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
optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];- Returns:
- This builder for chaining.
-
getVarIndexList
Variable index (w.r.t. the "variable" field of MPModelProto) of the variables in the SOS.
repeated int32 var_index = 2;- Specified by:
getVarIndexListin interfaceMPSosConstraintOrBuilder- 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:
getVarIndexCountin interfaceMPSosConstraintOrBuilder- 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:
getVarIndexin interfaceMPSosConstraintOrBuilder- Parameters:
index- The index of the element to return.- Returns:
- The varIndex at the given index.
-
setVarIndex
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
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
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
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
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:
getWeightListin interfaceMPSosConstraintOrBuilder- 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:
getWeightCountin interfaceMPSosConstraintOrBuilder- 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:
getWeightin interfaceMPSosConstraintOrBuilder- Parameters:
index- The index of the element to return.- Returns:
- The weight at the given index.
-
setWeight
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
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
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
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.
-