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
14package com.google.ortools.modelbuilder;
15
17public class LinearConstraint {
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
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}
void setConstraintCoefficient(int ct_index, int var_index, double coeff)
void addConstraintTerm(int ct_index, int var_index, double coeff)