Google OR-Tools
v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
EnforcedLinearConstraint.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
EnforcedLinearConstraint {
18
public
EnforcedLinearConstraint
(
ModelBuilderHelper
helper) {
19
this.helper = helper;
20
this.index = helper.
addEnforcedLinearConstraint
();
21
}
22
23
EnforcedLinearConstraint
(
ModelBuilderHelper
helper,
int
index) {
24
if
(!helper.
isEnforcedConstraint
(index)) {
25
throw
new
IllegalArgumentException(
26
"the given index does not refer to an enforced linear constraint"
);
27
}
28
this.helper = helper;
29
this.index = index;
30
}
31
33
public
int
getIndex
() {
34
return
index;
35
}
36
38
public
ModelBuilderHelper
getHelper
() {
39
return
helper;
40
}
41
43
public
double
getLowerBound
() {
44
return
helper.
getEnforcedConstraintLowerBound
(index);
45
}
46
48
public
void
setLowerBound
(
double
lb) {
49
helper.
setEnforcedConstraintLowerBound
(index, lb);
50
}
51
53
public
double
getUpperBound
() {
54
return
helper.
getEnforcedConstraintUpperBound
(index);
55
}
56
58
public
void
setUpperBound
(
double
ub) {
59
helper.
setEnforcedConstraintUpperBound
(index, ub);
60
}
61
63
public
String
getName
() {
64
return
helper.
getEnforcedConstraintName
(index);
65
}
66
67
// Sets the name of the constraint. */
68
public
void
setName
(String name) {
69
helper.
setEnforcedConstraintName
(index, name);
70
}
71
73
public
void
addTerm
(
Variable
v,
double
coeff) {
74
helper.
safeAddEnforcedConstraintTerm
(index, v.
getIndex
(), coeff);
75
}
76
78
public
void
setCoefficient
(
Variable
v,
double
coeff) {
79
helper.
setEnforcedConstraintCoefficient
(index, v.
getIndex
(), coeff);
80
}
81
83
public
void
clearTerms
() {
84
helper.
clearEnforcedConstraintTerms
(index);
85
}
86
88
public
Variable
getIndicatorVariable
() {
89
return
new
Variable
(helper, helper.
getEnforcedIndicatorVariableIndex
(index));
90
}
91
93
public
void
setIndicatorVariable
(
Variable
v) {
94
helper.
setEnforcedIndicatorVariableIndex
(index, v.
index
);
95
}
96
98
public
boolean
getIndicatorValue
() {
99
return
helper.
getEnforcedIndicatorValue
(index);
100
}
101
103
public
void
setIndicatorValue
(
boolean
b) {
104
helper.
setEnforcedIndicatorValue
(index, b);
105
}
106
108
public
EnforcedLinearConstraint
withName
(String name) {
109
setName
(name);
110
return
this
;
111
}
112
113
private
final
ModelBuilderHelper
helper;
114
private
final
int
index;
115
}
com.google.ortools.modelbuilder.EnforcedLinearConstraint
Definition
EnforcedLinearConstraint.java:17
com.google.ortools.modelbuilder.EnforcedLinearConstraint.getIndex
int getIndex()
Definition
EnforcedLinearConstraint.java:33
com.google.ortools.modelbuilder.EnforcedLinearConstraint.getLowerBound
double getLowerBound()
Definition
EnforcedLinearConstraint.java:43
com.google.ortools.modelbuilder.EnforcedLinearConstraint.getName
String getName()
Definition
EnforcedLinearConstraint.java:63
com.google.ortools.modelbuilder.EnforcedLinearConstraint.setUpperBound
void setUpperBound(double ub)
Definition
EnforcedLinearConstraint.java:58
com.google.ortools.modelbuilder.EnforcedLinearConstraint.getIndicatorValue
boolean getIndicatorValue()
Definition
EnforcedLinearConstraint.java:98
com.google.ortools.modelbuilder.EnforcedLinearConstraint.withName
EnforcedLinearConstraint withName(String name)
Definition
EnforcedLinearConstraint.java:108
com.google.ortools.modelbuilder.EnforcedLinearConstraint.getIndicatorVariable
Variable getIndicatorVariable()
Definition
EnforcedLinearConstraint.java:88
com.google.ortools.modelbuilder.EnforcedLinearConstraint.setIndicatorValue
void setIndicatorValue(boolean b)
Definition
EnforcedLinearConstraint.java:103
com.google.ortools.modelbuilder.EnforcedLinearConstraint.getUpperBound
double getUpperBound()
Definition
EnforcedLinearConstraint.java:53
com.google.ortools.modelbuilder.EnforcedLinearConstraint.addTerm
void addTerm(Variable v, double coeff)
Definition
EnforcedLinearConstraint.java:73
com.google.ortools.modelbuilder.EnforcedLinearConstraint.getHelper
ModelBuilderHelper getHelper()
Definition
EnforcedLinearConstraint.java:38
com.google.ortools.modelbuilder.EnforcedLinearConstraint.setLowerBound
void setLowerBound(double lb)
Definition
EnforcedLinearConstraint.java:48
com.google.ortools.modelbuilder.EnforcedLinearConstraint.setIndicatorVariable
void setIndicatorVariable(Variable v)
Definition
EnforcedLinearConstraint.java:93
com.google.ortools.modelbuilder.EnforcedLinearConstraint.setCoefficient
void setCoefficient(Variable v, double coeff)
Definition
EnforcedLinearConstraint.java:78
com.google.ortools.modelbuilder.EnforcedLinearConstraint.EnforcedLinearConstraint
EnforcedLinearConstraint(ModelBuilderHelper helper)
Definition
EnforcedLinearConstraint.java:18
com.google.ortools.modelbuilder.EnforcedLinearConstraint.setName
void setName(String name)
Sets the name of the constraint. */.
Definition
EnforcedLinearConstraint.java:68
com.google.ortools.modelbuilder.EnforcedLinearConstraint.clearTerms
void clearTerms()
Definition
EnforcedLinearConstraint.java:83
com.google.ortools.modelbuilder.ModelBuilderHelper
Definition
ModelBuilderHelper.java:11
com.google.ortools.modelbuilder.ModelBuilderHelper.clearEnforcedConstraintTerms
void clearEnforcedConstraintTerms(int ct_index)
Definition
ModelBuilderHelper.java:215
com.google.ortools.modelbuilder.ModelBuilderHelper.setEnforcedConstraintCoefficient
void setEnforcedConstraintCoefficient(int ct_index, int var_index, double coeff)
Definition
ModelBuilderHelper.java:223
com.google.ortools.modelbuilder.ModelBuilderHelper.addEnforcedLinearConstraint
int addEnforcedLinearConstraint()
Definition
ModelBuilderHelper.java:191
com.google.ortools.modelbuilder.ModelBuilderHelper.setEnforcedConstraintName
void setEnforcedConstraintName(int ct_index, String name)
Definition
ModelBuilderHelper.java:231
com.google.ortools.modelbuilder.ModelBuilderHelper.getEnforcedConstraintName
String getEnforcedConstraintName(int ct_index)
Definition
ModelBuilderHelper.java:199
com.google.ortools.modelbuilder.ModelBuilderHelper.getEnforcedConstraintUpperBound
double getEnforcedConstraintUpperBound(int ct_index)
Definition
ModelBuilderHelper.java:187
com.google.ortools.modelbuilder.ModelBuilderHelper.safeAddEnforcedConstraintTerm
void safeAddEnforcedConstraintTerm(int ct_index, int var_index, double coeff)
Definition
ModelBuilderHelper.java:219
com.google.ortools.modelbuilder.ModelBuilderHelper.setEnforcedConstraintUpperBound
void setEnforcedConstraintUpperBound(int ct_index, double ub)
Definition
ModelBuilderHelper.java:235
com.google.ortools.modelbuilder.ModelBuilderHelper.setEnforcedIndicatorVariableIndex
void setEnforcedIndicatorVariableIndex(int ct_index, int var_index)
Definition
ModelBuilderHelper.java:243
com.google.ortools.modelbuilder.ModelBuilderHelper.setEnforcedIndicatorValue
void setEnforcedIndicatorValue(int ct_index, boolean positive)
Definition
ModelBuilderHelper.java:239
com.google.ortools.modelbuilder.ModelBuilderHelper.getEnforcedIndicatorValue
boolean getEnforcedIndicatorValue(int ct_index)
Definition
ModelBuilderHelper.java:175
com.google.ortools.modelbuilder.ModelBuilderHelper.getEnforcedIndicatorVariableIndex
int getEnforcedIndicatorVariableIndex(int ct_index)
Definition
ModelBuilderHelper.java:195
com.google.ortools.modelbuilder.ModelBuilderHelper.isEnforcedConstraint
boolean isEnforcedConstraint(int ct_index)
Definition
ModelBuilderHelper.java:179
com.google.ortools.modelbuilder.ModelBuilderHelper.getEnforcedConstraintLowerBound
double getEnforcedConstraintLowerBound(int ct_index)
Definition
ModelBuilderHelper.java:183
com.google.ortools.modelbuilder.ModelBuilderHelper.setEnforcedConstraintLowerBound
void setEnforcedConstraintLowerBound(int ct_index, double lb)
Definition
ModelBuilderHelper.java:227
com.google.ortools.modelbuilder.Variable
Definition
Variable.java:17
com.google.ortools.modelbuilder.Variable.getIndex
int getIndex()
Definition
Variable.java:33
com.google.ortools.modelbuilder.Variable.index
final int index
Definition
Variable.java:106
ortools
java
com
google
ortools
modelbuilder
EnforcedLinearConstraint.java
Generated by
1.12.0