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.RealMatrix;
20  import org.hipparchus.linear.RealVector;
21  import org.hipparchus.optim.OptimizationData;
22  
23  /**
24   * Defines a nonlinear constrained optimization problem suitable for use
25   * with Sequential Quadratic Programming (SQP) solvers.
26   *
27   * <p>
28   * Implementations supply objective function information, constraint
29   * definitions, bounds, and problem dimensionality. SQP solvers use
30   * this interface to query the optimization model.
31   * </p>
32   *
33   * <p>
34   * Each component is optional: the problem may include only an objective
35   * (unconstrained case), or objective plus bounds, or full equality and
36   * inequality constraint sets. Boolean guard methods allow users and
37   * solvers to detect which problem structures are active.
38   * </p>
39   *
40   * <p>
41   * Implementations must be deterministic and thread-safe if used across
42   * multiple optimizer instances.
43   * </p>
44   *
45   * @since 1.0
46   *
47   */
48  public interface SQPProblem extends OptimizationData {
49  
50      /**
51       * Returns the number of decision variables of the problem.
52       *
53       * @return problem dimension
54       */
55      int getdim();
56  
57      /**
58       * Indicates whether explicit variable bounds are defined.
59       *
60       * @return true if box constraints are available
61       */
62      boolean hasBounds();
63  
64      /**
65       * Returns lower bounds for each decision variable, if available.
66       *
67       * @return array of lower bound values (length equals problem dimension)
68       */
69      double[] getBoundsLB();
70  
71      /**
72       * Returns upper bounds for each decision variable, if available.
73       *
74       * @return array of upper bound values (length equals problem dimension)
75       */
76      double[] getBoundsUB();
77  
78      /**
79       * Evaluates the objective function at the given point.
80       *
81       * @param rv point at which to evaluate the objective
82       * @return objective function value
83       */
84      double getObjectiveEvaluation(RealVector rv);
85  
86      /**
87       * Evaluates the gradient of the objective function at the given point.
88       *
89       * @param rv point at which to evaluate the gradient
90       * @return gradient vector
91       */
92      RealVector getObjectiveGradient(RealVector rv);
93  
94      /**
95       * Indicates whether equality constraints are present.
96       *
97       * @return true if the problem contains equality constraints
98       */
99      boolean hasEquality();
100 
101     /**
102      * Computes equality constraint values at the given point.
103      *
104      * @param rv evaluation point
105      * @return vector of equality constraint residuals
106      */
107     RealVector getEqConstraintEvaluation(RealVector rv);
108 
109     /**
110      * Computes the Jacobian of the equality constraints at the given point.
111      *
112      * @param rv evaluation point
113      * @return Jacobian matrix of equality constraints
114      */
115     RealMatrix getEqConstraintJacobian(RealVector rv);
116 
117     /**
118      * Returns the lower bound for equality constraints (typically zero).
119      *
120      * <p>
121      * Some interior-point/SQP formulations treat equalities as bounded
122      * two–sided constraints {@code h(x) = 0}.
123      * </p>
124      *
125      * @return vector of equality constraint lower bounds
126      */
127     RealVector getEqConstraintLB();
128 
129     /**
130      * Indicates whether inequality constraints are present.
131      *
132      * @return true if the problem contains inequality constraints
133      */
134     boolean hasInequality();
135 
136     /**
137      * Computes inequality constraint values at the given point.
138      *
139      * <p>
140      * Inequalities follow the canonical form {@code g(x) >= c}.
141      * </p>
142      *
143      * @param rv evaluation point
144      * @return vector of inequality constraint residuals
145      */
146     RealVector getIneqConstraintEvaluation(RealVector rv);
147 
148     /**
149      * Computes the Jacobian of inequality constraints at the given point.
150      *
151      * @param rv evaluation point
152      * @return Jacobian matrix of inequality constraints
153      */
154     RealMatrix getIneqConstraintJacobian(RealVector rv);
155 
156     /**
157      * Returns the lower bound for inequality constraints.
158      *
159      * @return vector of lower bound values for inequality constraints
160      */
161     RealVector getIneqConstraintLB();
162 }