Google OR-Tools
v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
LinearConstraint.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.modelbuilder;
15
17
public
class
LinearConstraint {
18
public
LinearConstraint
(
ModelBuilderHelper
helper) {
19
this.helper = helper;
20
this.index = helper.
addLinearConstraint
();
21
}
22
23
LinearConstraint
(
ModelBuilderHelper
helper,
int
index) {
24
this.helper = helper;
25
this.index = index;
26
}
27
29
public
int
getIndex
() {
30
return
index;
31
}
32
34
public
ModelBuilderHelper
getHelper
() {
35
return
helper;
36
}
37
39
public
double
getLowerBound
() {
40
return
helper.
getConstraintLowerBound
(index);
41
}
42
44
public
void
setLowerBound
(
double
lb) {
45
helper.
setConstraintLowerBound
(index, lb);
46
}
47
49
public
double
getUpperBound
() {
50
return
helper.
getConstraintUpperBound
(index);
51
}
52
54
public
void
setUpperBound
(
double
ub) {
55
helper.
setConstraintUpperBound
(index, ub);
56
}
57
59
public
String
getName
() {
60
return
helper.
getConstraintName
(index);
61
}
62
64
public
void
setName
(String name) {
65
helper.
setConstraintName
(index, name);
66
}
67
69
public
void
addTerm
(
Variable
v,
double
coeff) {
70
helper.
addConstraintTerm
(index, v.
getIndex
(), coeff);
71
}
72
74
public
void
setCoefficient
(
Variable
v,
double
coeff) {
75
helper.
setConstraintCoefficient
(index, v.
getIndex
(), coeff);
76
}
77
79
public
void
clearTerms
() {
80
helper.
clearConstraintTerms
(index);
81
}
82
84
public
LinearConstraint
withName
(String name) {
85
setName
(name);
86
return
this
;
87
}
88
89
private
final
ModelBuilderHelper
helper;
90
private
final
int
index;
91
}
com.google.ortools.modelbuilder.LinearConstraint
Definition
LinearConstraint.java:17
com.google.ortools.modelbuilder.LinearConstraint.getLowerBound
double getLowerBound()
Definition
LinearConstraint.java:39
com.google.ortools.modelbuilder.LinearConstraint.getIndex
int getIndex()
Definition
LinearConstraint.java:29
com.google.ortools.modelbuilder.LinearConstraint.withName
LinearConstraint withName(String name)
Definition
LinearConstraint.java:84
com.google.ortools.modelbuilder.LinearConstraint.setName
void setName(String name)
Definition
LinearConstraint.java:64
com.google.ortools.modelbuilder.LinearConstraint.addTerm
void addTerm(Variable v, double coeff)
Definition
LinearConstraint.java:69
com.google.ortools.modelbuilder.LinearConstraint.LinearConstraint
LinearConstraint(ModelBuilderHelper helper)
Definition
LinearConstraint.java:18
com.google.ortools.modelbuilder.LinearConstraint.setLowerBound
void setLowerBound(double lb)
Definition
LinearConstraint.java:44
com.google.ortools.modelbuilder.LinearConstraint.getName
String getName()
Definition
LinearConstraint.java:59
com.google.ortools.modelbuilder.LinearConstraint.setCoefficient
void setCoefficient(Variable v, double coeff)
Definition
LinearConstraint.java:74
com.google.ortools.modelbuilder.LinearConstraint.clearTerms
void clearTerms()
Definition
LinearConstraint.java:79
com.google.ortools.modelbuilder.LinearConstraint.getUpperBound
double getUpperBound()
Definition
LinearConstraint.java:49
com.google.ortools.modelbuilder.LinearConstraint.getHelper
ModelBuilderHelper getHelper()
Definition
LinearConstraint.java:34
com.google.ortools.modelbuilder.LinearConstraint.setUpperBound
void setUpperBound(double ub)
Definition
LinearConstraint.java:54
com.google.ortools.modelbuilder.ModelBuilderHelper
Definition
ModelBuilderHelper.java:11
com.google.ortools.modelbuilder.ModelBuilderHelper.getConstraintLowerBound
double getConstraintLowerBound(int ct_index)
Definition
ModelBuilderHelper.java:123
com.google.ortools.modelbuilder.ModelBuilderHelper.setConstraintLowerBound
void setConstraintLowerBound(int ct_index, double lb)
Definition
ModelBuilderHelper.java:163
com.google.ortools.modelbuilder.ModelBuilderHelper.setConstraintCoefficient
void setConstraintCoefficient(int ct_index, int var_index, double coeff)
Definition
ModelBuilderHelper.java:159
com.google.ortools.modelbuilder.ModelBuilderHelper.addLinearConstraint
int addLinearConstraint()
Definition
ModelBuilderHelper.java:131
com.google.ortools.modelbuilder.ModelBuilderHelper.getConstraintName
String getConstraintName(int ct_index)
Definition
ModelBuilderHelper.java:135
com.google.ortools.modelbuilder.ModelBuilderHelper.clearConstraintTerms
void clearConstraintTerms(int ct_index)
Definition
ModelBuilderHelper.java:151
com.google.ortools.modelbuilder.ModelBuilderHelper.setConstraintName
void setConstraintName(int ct_index, String name)
Definition
ModelBuilderHelper.java:167
com.google.ortools.modelbuilder.ModelBuilderHelper.addConstraintTerm
void addConstraintTerm(int ct_index, int var_index, double coeff)
Definition
ModelBuilderHelper.java:147
com.google.ortools.modelbuilder.ModelBuilderHelper.getConstraintUpperBound
double getConstraintUpperBound(int ct_index)
Definition
ModelBuilderHelper.java:127
com.google.ortools.modelbuilder.ModelBuilderHelper.setConstraintUpperBound
void setConstraintUpperBound(int ct_index, double ub)
Definition
ModelBuilderHelper.java:171
com.google.ortools.modelbuilder.Variable
Definition
Variable.java:17
com.google.ortools.modelbuilder.Variable.getIndex
int getIndex()
Definition
Variable.java:33
ortools
java
com
google
ortools
modelbuilder
LinearConstraint.java
Generated by
1.12.0