Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
LinearExpr.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 interface LinearExpr extends LinearArgument {
20
22 int getVariableIndex(int index);
23
25 double getCoefficient(int index);
26
28 double getOffset();
29
32 return new LinearExprBuilder();
33 }
34
36 static LinearExpr constant(double value) {
37 return newBuilder().add(value).build();
38 }
39
41 static LinearExpr term(LinearArgument expr, double coeff) {
42 return newBuilder().addTerm(expr, coeff).build();
43 }
44
46 static LinearExpr affine(LinearArgument expr, double coeff, double offset) {
47 return newBuilder().addTerm(expr, coeff).add(offset).build();
48 }
49
51 static LinearExpr sum(LinearArgument[] exprs) {
52 return newBuilder().addSum(exprs).build();
53 }
54
56 static LinearExpr weightedSum(LinearArgument[] exprs, double[] coeffs) {
57 return newBuilder().addWeightedSum(exprs, coeffs).build();
58 }
59}
LinearExprBuilder addWeightedSum(LinearArgument[] exprs, double[] coeffs)
LinearExprBuilder addTerm(LinearArgument expr, double coeff)
LinearExprBuilder addSum(LinearArgument[] exprs)
LinearExprBuilder add(LinearArgument expr)
static LinearExpr weightedSum(LinearArgument[] exprs, double[] coeffs)
static LinearExpr constant(double value)
static LinearExpr term(LinearArgument expr, double coeff)
static LinearExpr sum(LinearArgument[] exprs)
static LinearExpr affine(LinearArgument expr, double coeff, double offset)
static LinearExprBuilder newBuilder()