Google OR-Tools
v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
AffineExpression.java
Go to the documentation of this file.
1
// Copyright 2010-2024 Google LLC
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13
14
package
com.google.ortools.sat;
15
17
public
final
class
AffineExpression
implements
LinearExpr
{
18
private
final
int
varIndex;
19
private
final
long
coefficient;
20
private
final
long
offset;
21
22
public
AffineExpression
(
int
varIndex,
long
coefficient,
long
offset) {
23
this.varIndex = varIndex;
24
this.coefficient = coefficient;
25
this.offset = offset;
26
}
27
28
// LinearArgument interface.
29
@Override
30
public
LinearExpr
build
() {
31
return
this
;
32
}
33
34
// LinearExpr interface.
35
@Override
36
public
int
numElements
() {
37
return
1;
38
}
39
40
@Override
41
public
int
getVariableIndex
(
int
index) {
42
if
(index != 0) {
43
throw
new
IllegalArgumentException(
"wrong index in LinearExpr.getIndex(): "
+ index);
44
}
45
return
varIndex;
46
}
47
48
@Override
49
public
long
getCoefficient
(
int
index) {
50
if
(index != 0) {
51
throw
new
IllegalArgumentException(
"wrong index in LinearExpr.getCoefficient(): "
+ index);
52
}
53
return
coefficient;
54
}
55
56
@Override
57
public
long
getOffset
() {
58
return
offset;
59
}
60
}
com.google.ortools.sat.AffineExpression
Definition
AffineExpression.java:17
com.google.ortools.sat.AffineExpression.getVariableIndex
int getVariableIndex(int index)
Definition
AffineExpression.java:41
com.google.ortools.sat.AffineExpression.getOffset
long getOffset()
Definition
AffineExpression.java:57
com.google.ortools.sat.AffineExpression.build
LinearExpr build()
LinearArgument interface.
Definition
AffineExpression.java:30
com.google.ortools.sat.AffineExpression.getCoefficient
long getCoefficient(int index)
Definition
AffineExpression.java:49
com.google.ortools.sat.AffineExpression.numElements
int numElements()
LinearExpr interface.
Definition
AffineExpression.java:36
com.google.ortools.sat.AffineExpression.AffineExpression
AffineExpression(int varIndex, long coefficient, long offset)
Definition
AffineExpression.java:22
com.google.ortools.sat.LinearExpr
Definition
LinearExpr.java:19
ortools
java
com
google
ortools
sat
AffineExpression.java
Generated by
1.12.0