View Javadoc
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  import org.hipparchus.linear.Array2DRowRealMatrix;
20  import org.hipparchus.linear.ArrayRealVector;
21  import org.hipparchus.linear.MatrixUtils;
22  import org.hipparchus.linear.RealMatrix;
23  import org.hipparchus.linear.RealVector;
24  
25  public class HockSchittkowskiConstraintInequality72 extends InequalityConstraint {
26  
27      private static final double A11 = 4;
28      private static final double A12 = 2.25;
29      private static final double A13 = 1.0;
30      private static final double A14 = 0.25;
31      private static final double A21 = 0.16;
32      private static final double A22 = 0.36;
33      private static final double A23 = 0.64;
34      private static final double A24 = 0.64;
35      private static final double B1  = 0.0401;
36      private static final double B2  = 0.010085;
37  
38      public HockSchittkowskiConstraintInequality72() {
39          super(MatrixUtils.createRealVector(new double[] { -B1, -B2 }));
40      }
41  
42      @Override
43      public RealVector value(RealVector x) {
44          double x1 = x.getEntry(0);
45          double x2 = x.getEntry(1);
46          double x3 = x.getEntry(2);
47          double x4 = x.getEntry(3);
48  
49          // a[1][1]/x[1] + a[1][2]/x[2] + a[1][3]/x[3] + a[1][4]/x[4] <= b[1]
50          //a[2][1]/x[1] + a[2][2]/x[2] + a[2][3]/x[3] + a[2][4]/x[4] <= b[2]
51          RealVector a=new ArrayRealVector(2);
52          a.setEntry(0,-A11/x1-A12/x2-A13/x3-A14/x4);
53          a.setEntry(1,-A21/x1-A22/x2-A23/x3-A24/x4);
54  
55  
56          return a;
57      }
58  
59      @Override
60      public RealMatrix jacobian(RealVector x) {
61          double x1 = x.getEntry(0);
62          double x2 = x.getEntry(1);
63          double x3 = x.getEntry(2);
64          double x4 = x.getEntry(3);
65  
66          RealMatrix a= new Array2DRowRealMatrix(2,4);
67  
68          a.setEntry(0,0,A11/(x1*x1));
69          a.setEntry(0,1,A12/(x2*x2));
70          a.setEntry(0,2,A13/(x3*x3));
71          a.setEntry(0,3,A14/(x4*x4));
72  
73          a.setEntry(1,0,A21/(x1*x1));
74          a.setEntry(1,1,A22/(x2*x2));
75          a.setEntry(1,2,A23/(x3*x3));
76          a.setEntry(1,3,A24/(x4*x4));
77  
78  
79          return a;
80      }
81  
82      @Override
83      public int dim() {
84          return 4;
85      }
86  
87  }