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.RealMatrix;
22 import org.hipparchus.linear.RealVector;
23
24 public class RosenbrookConstraint extends LinearInequalityConstraint {
25
26 public RosenbrookConstraint(RealMatrix m, RealVector b) {
27 super(m, b);
28 }
29
30 @Override
31 public RealVector value(RealVector x) {
32 RealVector a=new ArrayRealVector(5);
33 a.setEntry(0,-x.getEntry(0)*x.getEntry(0)-x.getEntry(1)*x.getEntry(1));
34 a.setEntry(1,x.getEntry(0));
35 a.setEntry(2,-x.getEntry(0));
36 a.setEntry(3,x.getEntry(1));
37 a.setEntry(4,-x.getEntry(1));
38
39 return a;
40 }
41
42 @Override
43 public RealMatrix jacobian(RealVector x) {
44 RealMatrix a= new Array2DRowRealMatrix(5,2);
45 a.setEntry(0, 0,-2*x.getEntry(0));
46 a.setEntry(0, 1,-2*x.getEntry(1));
47 a.setEntry(1, 0,1);
48 a.setEntry(2, 0,-1);
49 a.setEntry(3, 1,1);
50 a.setEntry(4, 1,-1);
51 return a;
52 }
53 //
54 // @Override
55 // public RealVector getLowerBound()
56 // { RealVector lb=new ArrayRealVector(9);
57 // lb.setEntry(0,25.0);
58 // lb.setEntry(1,1.0);
59 // lb.setEntry(2,1.0);
60 // lb.setEntry(3,1.0);
61 // lb.setEntry(4,1.0);
62 // lb.setEntry(5,-5.0);
63 // lb.setEntry(6,-5.0);
64 // lb.setEntry(7,-5.0);
65 // lb.setEntry(8,-5.0);
66 // return lb;
67 // }
68 //
69 // /**
70 // * Return Upper Bound .
71 // * @return Upper Bound Vector
72 // */
73 // @Override
74 // public RealVector getUpperBound()
75 // {
76 // return new ArrayRealVector(9,Double.POSITIVE_INFINITY);
77 // }
78 // @Override
79 public int dimY(){
80 return 5;
81 }
82 }