Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
com.google.ortools.linearsolver.MPSosConstraint Class Reference

Detailed Description

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

Definition at line 18 of file MPSosConstraint.java.

Inheritance diagram for com.google.ortools.linearsolver.MPSosConstraint:
com.google.ortools.linearsolver.MPSosConstraintOrBuilder

Classes

class  Builder
enum  Type

Public Member Functions

boolean hasType ()
com.google.ortools.linearsolver.MPSosConstraint.Type getType ()
java.util.List< java.lang.Integer > getVarIndexList ()
int getVarIndexCount ()
int getVarIndex (int index)
java.util.List< java.lang.Double > getWeightList ()
int getWeightCount ()
double getWeight (int index)
final boolean isInitialized ()
void writeTo (com.google.protobuf.CodedOutputStream output) throws java.io.IOException
int getSerializedSize ()
boolean equals (final java.lang.Object obj)
int hashCode ()
Builder newBuilderForType ()
Builder toBuilder ()
com.google.protobuf.Parser< MPSosConstraintgetParserForType ()
com.google.ortools.linearsolver.MPSosConstraint getDefaultInstanceForType ()

Static Public Member Functions

static final com.google.protobuf.Descriptors.Descriptor getDescriptor ()
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (byte[] data) throws com.google.protobuf.InvalidProtocolBufferException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (java.io.InputStream input) throws java.io.IOException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException
static com.google.ortools.linearsolver.MPSosConstraint parseDelimitedFrom (java.io.InputStream input) throws java.io.IOException
static com.google.ortools.linearsolver.MPSosConstraint parseDelimitedFrom (java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (com.google.protobuf.CodedInputStream input) throws java.io.IOException
static com.google.ortools.linearsolver.MPSosConstraint parseFrom (com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException
static Builder newBuilder ()
static Builder newBuilder (com.google.ortools.linearsolver.MPSosConstraint prototype)
static com.google.ortools.linearsolver.MPSosConstraint getDefaultInstance ()
static com.google.protobuf.Parser< MPSosConstraintparser ()

Static Public Attributes

static final int TYPE_FIELD_NUMBER = 1
static final int VAR_INDEX_FIELD_NUMBER = 2
static final int WEIGHT_FIELD_NUMBER = 3

Protected Member Functions

com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable ()
Builder newBuilderForType (com.google.protobuf.GeneratedMessage.BuilderParent parent)

Member Function Documentation

◆ equals()

boolean com.google.ortools.linearsolver.MPSosConstraint.equals ( final java.lang.Object obj)

Definition at line 368 of file MPSosConstraint.java.

◆ getDefaultInstance()

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.getDefaultInstance ( )
static

Definition at line 1071 of file MPSosConstraint.java.

◆ getDefaultInstanceForType()

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.getDefaultInstanceForType ( )

Definition at line 1107 of file MPSosConstraint.java.

◆ getDescriptor()

final com.google.protobuf.Descriptors.Descriptor com.google.ortools.linearsolver.MPSosConstraint.getDescriptor ( )
static

Definition at line 43 of file MPSosConstraint.java.

◆ getParserForType()

com.google.protobuf.Parser< MPSosConstraint > com.google.ortools.linearsolver.MPSosConstraint.getParserForType ( )

Definition at line 1102 of file MPSosConstraint.java.

◆ getSerializedSize()

int com.google.ortools.linearsolver.MPSosConstraint.getSerializedSize ( )

Definition at line 338 of file MPSosConstraint.java.

◆ getType()

com.google.ortools.linearsolver.MPSosConstraint.Type com.google.ortools.linearsolver.MPSosConstraint.getType ( )

optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];

Returns
The type.

Implements com.google.ortools.linearsolver.MPSosConstraintOrBuilder.

Definition at line 194 of file MPSosConstraint.java.

◆ getVarIndex()

int com.google.ortools.linearsolver.MPSosConstraint.getVarIndex ( int index)
Variable index (w.r.t. the "variable" field of MPModelProto) of the
variables in the SOS.

repeated int32 var_index = 2;

Parameters
indexThe index of the element to return.
Returns
The varIndex at the given index.

Implements com.google.ortools.linearsolver.MPSosConstraintOrBuilder.

Definition at line 239 of file MPSosConstraint.java.

◆ getVarIndexCount()

int com.google.ortools.linearsolver.MPSosConstraint.getVarIndexCount ( )
Variable index (w.r.t. the "variable" field of MPModelProto) of the
variables in the SOS.

repeated int32 var_index = 2;

Returns
The count of varIndex.

Implements com.google.ortools.linearsolver.MPSosConstraintOrBuilder.

Definition at line 226 of file MPSosConstraint.java.

◆ getVarIndexList()

java.util.List< java.lang.Integer > com.google.ortools.linearsolver.MPSosConstraint.getVarIndexList ( )
Variable index (w.r.t. the "variable" field of MPModelProto) of the
variables in the SOS.

repeated int32 var_index = 2;

Returns
A list containing the varIndex.

Implements com.google.ortools.linearsolver.MPSosConstraintOrBuilder.

Definition at line 214 of file MPSosConstraint.java.

◆ getWeight()

double com.google.ortools.linearsolver.MPSosConstraint.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;

Parameters
indexThe index of the element to return.
Returns
The weight at the given index.

Implements com.google.ortools.linearsolver.MPSosConstraintOrBuilder.

Definition at line 307 of file MPSosConstraint.java.

◆ getWeightCount()

int com.google.ortools.linearsolver.MPSosConstraint.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;

Returns
The count of weight.

Implements com.google.ortools.linearsolver.MPSosConstraintOrBuilder.

Definition at line 286 of file MPSosConstraint.java.

◆ getWeightList()

java.util.List< java.lang.Double > com.google.ortools.linearsolver.MPSosConstraint.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;

Returns
A list containing the weight.

Implements com.google.ortools.linearsolver.MPSosConstraintOrBuilder.

Definition at line 266 of file MPSosConstraint.java.

◆ hashCode()

int com.google.ortools.linearsolver.MPSosConstraint.hashCode ( )

Definition at line 390 of file MPSosConstraint.java.

◆ hasType()

boolean com.google.ortools.linearsolver.MPSosConstraint.hasType ( )

optional .operations_research.MPSosConstraint.Type type = 1 [default = SOS1_DEFAULT];

Returns
Whether the type field is set.

Implements com.google.ortools.linearsolver.MPSosConstraintOrBuilder.

Definition at line 187 of file MPSosConstraint.java.

◆ internalGetFieldAccessorTable()

com.google.protobuf.GeneratedMessage.FieldAccessorTable com.google.ortools.linearsolver.MPSosConstraint.internalGetFieldAccessorTable ( )
protected

Definition at line 49 of file MPSosConstraint.java.

◆ isInitialized()

final boolean com.google.ortools.linearsolver.MPSosConstraint.isInitialized ( )

Definition at line 313 of file MPSosConstraint.java.

◆ newBuilder() [1/2]

Builder com.google.ortools.linearsolver.MPSosConstraint.newBuilder ( )
static

Definition at line 487 of file MPSosConstraint.java.

◆ newBuilder() [2/2]

Builder com.google.ortools.linearsolver.MPSosConstraint.newBuilder ( com.google.ortools.linearsolver.MPSosConstraint prototype)
static

Definition at line 490 of file MPSosConstraint.java.

◆ newBuilderForType() [1/2]

Builder com.google.ortools.linearsolver.MPSosConstraint.newBuilderForType ( )

Definition at line 486 of file MPSosConstraint.java.

◆ newBuilderForType() [2/2]

Builder com.google.ortools.linearsolver.MPSosConstraint.newBuilderForType ( com.google.protobuf.GeneratedMessage.BuilderParent parent)
protected

Definition at line 500 of file MPSosConstraint.java.

◆ parseDelimitedFrom() [1/2]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseDelimitedFrom ( java.io.InputStream input) throws java.io.IOException
static

Definition at line 458 of file MPSosConstraint.java.

◆ parseDelimitedFrom() [2/2]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseDelimitedFrom ( java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry ) throws java.io.IOException
static

Definition at line 464 of file MPSosConstraint.java.

◆ parseFrom() [1/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( byte[] data) throws com.google.protobuf.InvalidProtocolBufferException
static

Definition at line 435 of file MPSosConstraint.java.

◆ parseFrom() [2/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry ) throws com.google.protobuf.InvalidProtocolBufferException
static

Definition at line 439 of file MPSosConstraint.java.

◆ parseFrom() [3/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException
static

Definition at line 424 of file MPSosConstraint.java.

◆ parseFrom() [4/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry ) throws com.google.protobuf.InvalidProtocolBufferException
static

Definition at line 429 of file MPSosConstraint.java.

◆ parseFrom() [5/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( com.google.protobuf.CodedInputStream input) throws java.io.IOException
static

Definition at line 471 of file MPSosConstraint.java.

◆ parseFrom() [6/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry ) throws java.io.IOException
static

Definition at line 477 of file MPSosConstraint.java.

◆ parseFrom() [7/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( java.io.InputStream input) throws java.io.IOException
static

Definition at line 445 of file MPSosConstraint.java.

◆ parseFrom() [8/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry ) throws java.io.IOException
static

Definition at line 450 of file MPSosConstraint.java.

◆ parseFrom() [9/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException
static

Definition at line 413 of file MPSosConstraint.java.

◆ parseFrom() [10/10]

com.google.ortools.linearsolver.MPSosConstraint com.google.ortools.linearsolver.MPSosConstraint.parseFrom ( java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry ) throws com.google.protobuf.InvalidProtocolBufferException
static

Definition at line 418 of file MPSosConstraint.java.

◆ parser()

com.google.protobuf.Parser< MPSosConstraint > com.google.ortools.linearsolver.MPSosConstraint.parser ( )
static

Definition at line 1097 of file MPSosConstraint.java.

◆ toBuilder()

Builder com.google.ortools.linearsolver.MPSosConstraint.toBuilder ( )

Definition at line 494 of file MPSosConstraint.java.

◆ writeTo()

void com.google.ortools.linearsolver.MPSosConstraint.writeTo ( com.google.protobuf.CodedOutputStream output) throws java.io.IOException

Definition at line 323 of file MPSosConstraint.java.

Member Data Documentation

◆ TYPE_FIELD_NUMBER

final int com.google.ortools.linearsolver.MPSosConstraint.TYPE_FIELD_NUMBER = 1
static

Definition at line 181 of file MPSosConstraint.java.

◆ VAR_INDEX_FIELD_NUMBER

final int com.google.ortools.linearsolver.MPSosConstraint.VAR_INDEX_FIELD_NUMBER = 2
static

Definition at line 199 of file MPSosConstraint.java.

◆ WEIGHT_FIELD_NUMBER

final int com.google.ortools.linearsolver.MPSosConstraint.WEIGHT_FIELD_NUMBER = 3
static

Definition at line 243 of file MPSosConstraint.java.


The documentation for this class was generated from the following file: