1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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 HockSchittkowskiConstraintEquality71 extends EqualityConstraint {
26
27 public HockSchittkowskiConstraintEquality71() {
28 super(MatrixUtils.createRealVector(new double[] { 40.0 }));
29 }
30
31 @Override
32 public RealVector value(RealVector x) {
33 double x1 = x.getEntry(0);
34 double x2 = x.getEntry(1);
35 double x3 = x.getEntry(2);
36 double x4 = x.getEntry(3);
37
38 RealVector a=new ArrayRealVector(1);
39 a.setEntry(0,x1*x1+x2*x2+x3*x3+x4*x4);
40
41
42 return a;
43 }
44
45 @Override
46 public RealMatrix jacobian(RealVector x) {
47 double x1 = x.getEntry(0);
48 double x2 = x.getEntry(1);
49 double x3 = x.getEntry(2);
50 double x4 = x.getEntry(3);
51 RealMatrix a= new Array2DRowRealMatrix(1,4);
52
53 a.setEntry(0,0,2.0*x1);
54 a.setEntry(0,1,2.0*x2);
55 a.setEntry(0,2,2.0*x3);
56 a.setEntry(0,3,2.0*x4);
57
58 return a;
59 }
60
61 @Override
62 public int dim() {
63 return 4;
64 }
65 }