Minimizes a smooth multivariate function f(x), subject to bounds on the design variables, using sequential quadratic programming (SQP). The second form allows for specifying the gradient of the objective. |
||
Syntax |
x, f, dh, oh = FMinBnd(objFunc, lb, ub, init, maxIter, sqp_eps, deriv, gmax, userdata) x, f, dh, oh = FMinBnd(objFunc, gradFunc, lb, ub, init, maxIter, sqp_eps, gmax, userdata) |
|
Arguments |
Name |
Description |
objFunc |
Name of the user defined objective function. It must return a real number or one element vector. See Comments. |
|
gradFunc |
The name of the user defined objective gradient function. It must return a vector that has a length equal to the number of state variables. If the vector has one element, then a real number may be returned instead. |
|
lb |
The vector of lower bounds of the design variables. The length is the number of variables. |
|
ub |
The vector of upper bounds of the design variables. |
|
init (optional) |
The vector of initial estimates for the design variables. The length is the number of variables. If it is empty or omitted, the midpoints of the bounding intervals are used. See Comments section. |
|
maxIter (optional) |
A one element vector containing the maximum number of iterations allowed. If it is empty or omitted, it defaults to 25. |
|
sqp_eps (optional) |
A one element vector containing a tolerance value in the SQP algorithm. If it is empty or omitted, it defaults to 0.0001. |
|
deriv (optional) |
A one element vector containing an integer to indicate the numerical derivative type to use. It equals 1 for backward differences and 2 for central differences. If it is empty or omitted, it defaults to 2. |
|
gmax (optional) |
A one element vector containing a constraint violation margin. If it is empty or omitted, it defaults to 0.5. |
|
userdata (optional) |
Data matrix that is passed to the user defined function at each iteration. This can be used to supply data that are defined outside the function. It can be omitted or empty. |
|
Output |
Name |
Description |
x |
The location of the function minimum. It may be a local minimum. See Comments section. |
|
f |
The minimum value of the function. |
|
dh |
A matrix containing the design variable history. Each column of the matrix contains the iteration step values for a design variable. |
|
oh |
A row vector containing the objective function history at each iteration step. |
|
Example 1 |
Find the minimum of a paraboloid, subject to x is in [7,9] and y is in [5,7]. f(x,y) = 2(x-3)^2 - 5(x-3)(y-2) + 4(y-2)^2 + 6. |
|
Syntax |
||
// define the objective function function ObjFunc(x, d) { return 2*(x(1)-d(1))^2 - 5*(x(1)-d(1))*(x(2)-d(2)) + 4*(x(2)-d(2))^2 + 6 }
// find the minimum lowerBound = [7, 5] upperBound = [9, 7] userData = [3, 2]
x,f = FMinBnd("ObjFunc", lowerBound, upperBound, [], [50], [1.0e-5], [], [0.6], userData) |
||
Resultx = 7 5 f = 14 |
||
Example 2 |
Extend the previous example to use the analytical gradient vector. |
|
Syntax // define the gradient function function GradFunc(x) { out = [0, 0] out(1) = 4*(x(1)-3) - 5*(x(2)-2) out(2) = -5*(x(1)-3) + 8*(x(2)-2) return out }
// find the minimum x, f = FMinBnd("ObjFunc", "GradFunc", lowerBound, upperBound, [], [50], [1.0e-5], [0.6], userData) |
||
Resultx = 7 5 f = 14 |
||
Comments |
FMinBnd is designed to work with objective functions that have continuous gradients. Otherwise, the chances of success may be greater using GA. The user defined objective function gets called by the solver until it is no longer decreasing based on the given tolerance. It requires a vector of the same size as init for the variable values, and this must be the first argument. Optionally, it can take a data matrix as the second argument. The user defined gradient vector function has the same arguments as the objective function. If the function that computes the gradient is omitted, the vector will be computed internally with numerical derivatives. The output vector x will have the same orientation as the input vector init. If the vector of initial estimates is omitted, the output vector will have the same orientation as the vector of lower bounds. However, the vector for the design variables that is passed to the user functions will be a column vector. |
|
See Also: |