Google OR-Tools
v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
ConstantExpression.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
ConstantExpression
implements
LinearExpr {
18
private
final
long
offset;
19
20
public
ConstantExpression
(
long
offset) {
21
this.offset = offset;
22
}
23
24
// LinearArgument interface.
25
@Override
26
public
LinearExpr
build
() {
27
return
this
;
28
}
29
30
// LinearExpr interface.
31
@Override
32
public
int
numElements
() {
33
return
0;
34
}
35
36
@Override
37
public
int
getVariableIndex
(
int
index) {
38
throw
new
IllegalArgumentException(
"wrong index in LinearExpr.getVariable(): "
+ index);
39
}
40
41
@Override
42
public
long
getCoefficient
(
int
index) {
43
throw
new
IllegalArgumentException(
"wrong index in LinearExpr.getCoefficient(): "
+ index);
44
}
45
46
@Override
47
public
long
getOffset
() {
48
return
offset;
49
}
50
51
@Override
52
public
String
toString
() {
53
return
String.format(
"%d"
, offset);
54
}
55
}
com.google.ortools.sat.ConstantExpression.getCoefficient
long getCoefficient(int index)
Definition
ConstantExpression.java:42
com.google.ortools.sat.ConstantExpression.getOffset
long getOffset()
Definition
ConstantExpression.java:47
com.google.ortools.sat.ConstantExpression.getVariableIndex
int getVariableIndex(int index)
Definition
ConstantExpression.java:37
com.google.ortools.sat.ConstantExpression.build
LinearExpr build()
LinearArgument interface.
Definition
ConstantExpression.java:26
com.google.ortools.sat.ConstantExpression.ConstantExpression
ConstantExpression(long offset)
Definition
ConstantExpression.java:20
com.google.ortools.sat.ConstantExpression.toString
String toString()
Definition
ConstantExpression.java:52
com.google.ortools.sat.ConstantExpression.numElements
int numElements()
LinearExpr interface.
Definition
ConstantExpression.java:32
com.google.ortools.sat.LinearExpr
Definition
LinearExpr.java:19
ortools
java
com
google
ortools
sat
ConstantExpression.java
Generated by
1.12.0