1 /*
2 * Licensed to the Hipparchus project under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The Hipparchus project licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.hipparchus.optim.nonlinear.vector.constrained;
18
19
20 import org.hipparchus.linear.Array2DRowRealMatrix;
21 import org.hipparchus.linear.ArrayRealVector;
22 import org.hipparchus.linear.RealMatrix;
23 import org.hipparchus.linear.RealVector;
24 import org.hipparchus.optim.OptimizationData;
25
26 /** A set of linear inequality constraints expressed as ub>Ax>lb.
27 * @since 3.1
28 */
29 public class LinearBoundedConstraint extends BoundedConstraint implements OptimizationData {
30
31 /** The corresponding set of individual linear constraint functions. */
32 private final RealMatrix a;
33
34 /** Construct a set of linear inequality constraints from Ax < B
35 * @param a A matrix linear coefficient vectors
36 * @param lower lower bound
37 * @param upper upper bound
38 */
39 public LinearBoundedConstraint(final RealMatrix a, final RealVector lower, final RealVector upper) {
40 super(lower, upper);
41 this.a = a;
42 }
43
44 /** Construct a set of linear inequality constraints from Ax < B
45 * @param a A matrix linear coefficient vectors
46 * @param lower lower bound
47 * @param upper upper bound
48 */
49 public LinearBoundedConstraint(final double[][] a, final double[] lower, final double[] upper) {
50 this(new Array2DRowRealMatrix(a), new ArrayRealVector(lower), new ArrayRealVector(upper));
51 }
52
53 /** {@inheritDoc} */
54 @Override
55 public double[] value(final double[] x) {
56 return this.a.operate(x);
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public int dim() {
62 return a.getColumnDimension();
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 public RealVector value(final RealVector x) {
68 return a.operate(x);
69 }
70
71 /** {@inheritDoc} */
72 @Override
73 public RealMatrix jacobian(final RealVector x) {
74 return a.copy();
75 }
76
77 }