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 HockSchittkowskiConstraintEquality78 extends EqualityConstraint {
26
27 public HockSchittkowskiConstraintEquality78() {
28 super(MatrixUtils.createRealVector(new double[] {
29 10, 0, -1
30 }));
31 }
32
33 @Override
34 public RealVector value(RealVector x) {
35 double x1 = x.getEntry(0);
36 double x2 = x.getEntry(1);
37 double x3 = x.getEntry(2);
38 double x4 = x.getEntry(3);
39 double x5 = x.getEntry(4);
40
41
42
43 RealVector a=new ArrayRealVector(3);
44 a.setEntry(0,(x1*x1)+(x2*x2)+(x3*x3)+(x4*x4)+x5*x5);
45 a.setEntry(1,x2*x3-5.0*x4*x5);
46 a.setEntry(2,x1*x1*x1+x2*x2*x2);
47
48
49
50 return a;
51 }
52
53 @Override
54 public RealMatrix jacobian(RealVector x) {
55 double x1 = x.getEntry(0);
56 double x2 = x.getEntry(1);
57 double x3 = x.getEntry(2);
58 double x4 = x.getEntry(3);
59 double x5 = x.getEntry(4);
60 RealMatrix a= new Array2DRowRealMatrix(3,5);
61
62 a.setEntry(0,0,2.0*x1);
63 a.setEntry(0,1,2.0*x2);
64 a.setEntry(0,2,2.0*x3);
65 a.setEntry(0,3,2.0*x4);
66 a.setEntry(0,4,2.0*x5);
67
68 a.setEntry(1,0,0.0);
69 a.setEntry(1,1,x3);
70 a.setEntry(1,2,x2);
71 a.setEntry(1,3,-5.0*x5);
72 a.setEntry(1,4,-5.0*x4);
73
74 a.setEntry(2,0,3.0*x1*x1);
75 a.setEntry(2,1,3.0*x2*x2);
76
77
78 return a;
79 }
80
81 @Override
82 public int dim(){
83 return 5;
84 }
85
86 }