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.Descriptor
com.google.protobuf.Descriptors.Descriptor
getType()
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
hasType()
optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
final boolean
mergeFrom
(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, 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 classcom.google.protobuf.GeneratedMessage.Builder<MPSosConstraint.Builder>
-
clear
- Specified by:
clear
in interfacecom.google.protobuf.Message.Builder
- Specified by:
clear
in interfacecom.google.protobuf.MessageLite.Builder
- Overrides:
clear
in classcom.google.protobuf.GeneratedMessage.Builder<MPSosConstraint.Builder>
-
getDescriptorForType
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()- Specified by:
getDescriptorForType
in interfacecom.google.protobuf.Message.Builder
- Specified by:
getDescriptorForType
in interfacecom.google.protobuf.MessageOrBuilder
- Overrides:
getDescriptorForType
in classcom.google.protobuf.GeneratedMessage.Builder<MPSosConstraint.Builder>
-
getDefaultInstanceForType
- Specified by:
getDefaultInstanceForType
in interfacecom.google.protobuf.MessageLiteOrBuilder
- Specified by:
getDefaultInstanceForType
in interfacecom.google.protobuf.MessageOrBuilder
-
build
- Specified by:
build
in interfacecom.google.protobuf.Message.Builder
- Specified by:
build
in interfacecom.google.protobuf.MessageLite.Builder
-
buildPartial
- Specified by:
buildPartial
in interfacecom.google.protobuf.Message.Builder
- Specified by:
buildPartial
in interfacecom.google.protobuf.MessageLite.Builder
-
mergeFrom
- Specified by:
mergeFrom
in interfacecom.google.protobuf.Message.Builder
- Overrides:
mergeFrom
in classcom.google.protobuf.AbstractMessage.Builder<MPSosConstraint.Builder>
-
mergeFrom
-
isInitialized
public final boolean isInitialized()- Specified by:
isInitialized
in interfacecom.google.protobuf.MessageLiteOrBuilder
- Overrides:
isInitialized
in 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:
mergeFrom
in interfacecom.google.protobuf.Message.Builder
- Specified by:
mergeFrom
in interfacecom.google.protobuf.MessageLite.Builder
- Overrides:
mergeFrom
in 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:
hasType
in interfaceMPSosConstraintOrBuilder
- Returns:
- Whether the type field is set.
-
getType
optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];
- Specified by:
getType
in 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:
getVarIndexList
in 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:
getVarIndexCount
in 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:
getVarIndex
in 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:
getWeightList
in 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:
getWeightCount
in 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:
getWeight
in 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.
-