| Optimization Toolbox™ | ![]() |
Find minimum of semi-infinitely constrained multivariable nonlinear function
Finds the minimum of a problem specified by

x, b, beq, lb, and ub are vectors, A and Aeq are matrices, c(x), ceq(x), and Ki(x,wi) are functions that return vectors, and f(x) is a function that returns a scalar. f(x), c(x), and ceq(x) can be nonlinear functions. The vectors (or matrices) Ki(x,wi) ≤ 0 are continuous functions of both x and an additional set of variables w1,w2,...,wn. The variables w1,w2,...,wn are vectors of, at most, length two.
x = fseminf(fun,x0,ntheta,seminfcon)
x = fseminf(fun,x0,ntheta,seminfcon,A,b)
x = fseminf(fun,x0,ntheta,seminfcon,A,b,Aeq,beq)
x = fseminf(fun,x0,ntheta,seminfcon,A,b,Aeq,beq,lb,ub)
x = fseminf(fun,x0,ntheta,seminfcon,A,b,Aeq,beq,lb,ub,options)
x = fseminf(problem)
[x,fval] = fseminf(...)
[x,fval,exitflag] = fseminf(...)
[x,fval,exitflag,output] = fseminf(...)
[x,fval,exitflag,output,lambda] = fseminf(...)
fseminf finds a minimum of a semi-infinitely constrained scalar function of several variables, starting at an initial estimate. The aim is to minimize f(x) so the constraints hold for all possible values of wi∈ℜ1 (or wi∈ℜ2). Because it is impossible to calculate all possible values of Ki(x,wi), a region must be chosen for wi over which to calculate an appropriately sampled set of values.
x = fseminf(fun,x0,ntheta,seminfcon) starts at x0 and finds a minimum of the function fun constrained by ntheta semi-infinite constraints defined in seminfcon.
x = fseminf(fun,x0,ntheta,seminfcon,A,b) also tries to satisfy the linear inequalities A*x ≤ b.
x = fseminf(fun,x0,ntheta,seminfcon,A,b,Aeq,beq) minimizes subject to the linear equalities Aeq*x = beq as well. Set A = [] and b = [] if no inequalities exist.
x = fseminf(fun,x0,ntheta,seminfcon,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on the design variables in x, so that the solution is always in the range lb ≤ x ≤ ub.
x = fseminf(fun,x0,ntheta,seminfcon,A,b,Aeq,beq,lb,ub,options) minimizes with the optimization options specified in the structure options. Use optimset to set these options.
x = fseminf(problem) finds the minimum for problem, where problem is a structure described in Input Arguments.
Create the structure problem by exporting a problem from Optimization Tool, as described in Exporting to the MATLAB® Workspace.
[x,fval] = fseminf(...) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fseminf(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fseminf(...) returns a structure output that contains information about the optimization.
[x,fval,exitflag,output,lambda] = fseminf(...) returns a structure lambda whose fields contain the Lagrange multipliers at the solution x.
Passing Extra Parameters explains how to parameterize the objective function fun, if necessary.
Note If the specified input bounds for a problem are inconsistent, the output x is x0 and the output fval is []. |
Function Arguments contains general descriptions of arguments passed into fseminf. This section provides function-specific details for fun, ntheta, options, seminfcon, and problem:
The function to be minimized. fun is a function that accepts a vector x and returns a scalar f, the objective function evaluated at x. The function fun can be specified as a function handle for an M-file function x = fseminf(@myfun,x0,ntheta,seminfcon) where myfun is a MATLAB® function such as function f = myfun(x) f = ... % Compute function value at x fun can also be a function handle for an anonymous function. fun = @(x)sin(x''*x); If the gradient of fun can also be computed and the GradObj option is 'on', as set by options = optimset('GradObj','on')
then the function fun must return, in the second output argument, the gradient value g, a vector, at x. | |||
| ntheta | The number of semi-infinite constraints. | ||
| options | Options provides the function-specific details for the options values. | ||
seminfcon | The function that computes the vector of nonlinear inequality constraints, c, a vector of nonlinear equality constraints, ceq, and ntheta semi-infinite constraints (vectors or matrices) K1, K2,..., Kntheta evaluated over an interval S at the point x. The function seminfcon can be specified as a function handle. x = fseminf(@myfun,x0,ntheta,@myinfcon) where myinfcon is a MATLAB function such as function [c,ceq,K1,K2,...,Kntheta,S] = myinfcon(x,S) % Initial sampling interval if isnan(S(1,1)), S = ...% S has ntheta rows and 2 columns end w1 = ...% Compute sample set w2 = ...% Compute sample set ... wntheta = ... % Compute sample set K1 = ... % 1st semi-infinite constraint at x and w K2 = ... % 2nd semi-infinite constraint at x and w ... Kntheta = ...% Last semi-infinite constraint at x and w c = ... % Compute nonlinear inequalities at x ceq = ... % Compute the nonlinear equalities at x S is a recommended sampling interval, which might or might not be used. Return [] for c and ceq if no such constraints exist. | ||
The vectors or matrices K1, K2, ..., Kntheta contain the semi-infinite constraints evaluated for a sampled set of values for the independent variables w1, w2, ... wntheta, respectively. The two-column matrix, S, contains a recommended sampling interval for values of w1, w2, ..., wntheta, which are used to evaluate K1, K2, ..., Kntheta. The ith row of S contains the recommended sampling interval for evaluating Ki. When Ki is a vector, use only S(i,1) (the second column can be all zeros). When Ki is a matrix, S(i,2) is used for the sampling of the rows in Ki, S(i,1) is used for the sampling interval of the columns of Ki (see Two-Dimensional Example). On the first iteration S is NaN, so that some initial sampling interval must be determined by seminfcon.
Passing Extra Parameters explains how to parameterize seminfcon, if necessary. | |||
| problem | objective | Objective function | |
x0 | Initial point for x | ||
| ntheta | Number of semi-infinite constraints | ||
| seminfcon | Semi-infinite constraint function | ||
Aineq | Matrix for linear inequality constraints | ||
bineq | Vector for linear inequality constraints | ||
Aeq | Matrix for linear equality constraints | ||
beq | Vector for linear equality constraints | ||
| lb | Vector of lower bounds | ||
| ub | Vector of upper bounds | ||
solver | 'fseminf' | ||
options | Options structure created with optimset | ||
Function Arguments contains general descriptions of arguments returned by fseminf. This section provides function-specific details for exitflag, lambda, and output:
exitflag | Integer identifying the reason the algorithm terminated. The following lists the values of exitflag and the corresponding reasons the algorithm terminated. | |
1 | Function converged to a solution x. | |
4 | Magnitude of the search direction was less than the specified tolerance and constraint violation was less than options.TolCon. | |
5 | Magnitude of directional derivative was less than the specified tolerance and constraint violation was less than options.TolCon. | |
0 | Number of iterations exceeded options.MaxIter or number of function evaluations exceeded options.FunEvals. | |
-1 | Algorithm was terminated by the output function. | |
-2 | No feasible point was found. | |
lambda | Structure containing the Lagrange multipliers at the solution x (separated by constraint type). The fields of the structure are | |
| lower | Lower bounds lb | |
| upper | Upper bounds ub | |
| ineqlin | Linear inequalities | |
| eqlin | Linear equalities | |
| ineqnonlin | Nonlinear inequalities | |
| eqnonlin | Nonlinear equalities | |
output | Structure containing information about the optimization. The fields of the structure are | |
| iterations | Number of iterations taken | |
| funcCount | Number of function evaluations | |
| lssteplength | Size of line search step relative to search direction | |
| stepsize | Final displacement in x | |
| algorithm | Optimization algorithm used | |
| constrviolation | Maximum of nonlinear constraint functions | |
| firstorderopt | Measure of first-order optimality | |
| message | Exit message | |
Optimization options used by fseminf. You can use optimset to set or change the values of these fields in the options structure options. See Optimization Options for detailed information.
DerivativeCheck | Compare user-supplied derivatives (gradients) to finite-differencing derivatives. |
Diagnostics | Display diagnostic information about the function to be minimized or solved. |
DiffMaxChange | Maximum change in variables for finite-difference gradients. |
DiffMinChange | Minimum change in variables for finite-difference gradients. |
Display | Level of display. 'off' displays no output; 'iter' displays output at each iteration; 'notify' displays output only if the function does not converge;'final' (default) displays just the final output. |
| FunValCheck | Check whether objective function and constraints values are valid. 'on' displays an error when the objective function or constraints return a value that is complex, Inf, or NaN. 'off' (the default) displays no error. |
GradObj | Gradient for the objective function defined by the user. See the preceding description of fun to see how to define the gradient in fun. |
MaxFunEvals | Maximum number of function evaluations allowed. |
MaxIter | Maximum number of iterations allowed. |
| OutputFcn | Specify one or more user-defined functions that an optimization function calls at each iteration. See Output Function. |
PlotFcns | Plots various measures of progress while the algorithm executes, select from predefined plots or write your own. Specifying @optimplotx plots the current point; @optimplotfunccount plots the function count; @optimplotfval plots the function value; @optimplotconstrviolation plots the maximum constraint violation; @optimplotstepsize plots the step size. |
| RelLineSrchBnd | Relative bound (a real nonnegative scalar value) on the line search step length such that the total displacement in x satisfies |Δx(i)| ≤ relLineSrchBnd· max(|x(i)|,|typicalx(i)|). This option provides control over the magnitude of the displacements in x for cases in which the solver takes steps that are considered too large. |
| RelLineSrchBndDuration | Number of iterations for which the bound specified in RelLineSrchBnd should be active (default is 1). |
TolCon | Termination tolerance on the constraint violation. |
TolConSQP | Termination tolerance on inner iteration SQP constraint violation. |
TolFun | Termination tolerance on the function value. |
TolX | Termination tolerance on x. |
The optimization routine fseminf might vary the recommended sampling interval, S, set in seminfcon, during the computation because values other than the recommended interval might be more appropriate for efficiency or robustness. Also, the finite region wi, over which Ki(x,wi) is calculated, is allowed to vary during the optimization, provided that it does not result in significant changes in the number of local minima in Ki(x,wi).
Find values of x that minimize
f(x) = (x1 – 0.5)2 + (x2– 0.5)2 + (x3– 0.5)2
where

for all values of w1 and w2 over the ranges
1 ≤ w1≤ 100,
1 ≤ w2≤ 100.
Note that the semi-infinite constraints are one-dimensional, that is, vectors. Because the constraints must be in the form Ki(x,wi) ≤ 0, you need to compute the constraints as

First, write an M-file that computes the objective function.
function f = myfun(x,s) % Objective function f = sum((x-0.5).^2);
Second, write an M-file, mycon.m, that computes the nonlinear equality and inequality constraints and the semi-infinite constraints.
function [c,ceq,K1,K2,s] = mycon(X,s)
% Initial sampling interval
if isnan(s(1,1)),
s = [0.2 0; 0.2 0];
end
% Sample set
w1 = 1:s(1,1):100;
w2 = 1:s(2,1):100;
% Semi-infinite constraints
K1 = sin(w1*X(1)).*cos(w1*X(2)) - 1/1000*(w1-50).^2 -...
sin(w1*X(3))-X(3)-1;
K2 = sin(w2*X(2)).*cos(w2*X(1)) - 1/1000*(w2-50).^2 -...
sin(w2*X(3))-X(3)-1;
% No finite nonlinear constraints
c = []; ceq=[];
% Plot a graph of semi-infinite constraints
plot(w1,K1,'-',w2,K2,':')
title('Semi-infinite constraints')
drawnow
Then, invoke an optimization routine.
x0 = [0.5; 0.2; 0.3]; % Starting guess [x,fval] = fseminf(@myfun,x0,2,@mycon)
After eight iterations, the solution is
x =
0.6673
0.3013
0.4023
The function value and the maximum values of the semi-infinite constraints at the solution x are
fval =
0.0770
[c,ceq,K1,K2] = mycon(x,NaN); % Initial sampling interval
max(K1)
ans =
-0.0017
max(K2)
ans =
-0.0845
A plot of the semi-infinite constraints is produced.

This plot shows how peaks in both constraints are on the constraint boundary.
The plot command inside 'mycon.m' slows down the computation. Remove this line to improve the speed.
Find values of x that minimize
f(x) = (x1 – 0.2)2 + (x2– 0.2)2 + (x3– 0.2)2,
where

for all values of w1 and w2 over the ranges
1 ≤ w1≤ 100,
1 ≤ w2≤ 100,
starting at the point x = [0.25,0.25,0.25].
Note that the semi-infinite constraint is two-dimensional, that is, a matrix.
First, write an M-file that computes the objective function.
function f = myfun(x,s) % Objective function f = sum((x-0.2).^2);
Second, write an M-file for the constraints, called mycon.m. Include code to draw the surface plot of the semi-infinite constraint each time mycon is called. This enables you to see how the constraint changes as X is being minimized.
function [c,ceq,K1,s] = mycon(X,s)
% Initial sampling interval
if isnan(s(1,1)),
s = [2 2];
end
% Sampling set
w1x = 1:s(1,1):100;
w1y = 1:s(1,2):100;
[wx,wy] = meshgrid(w1x,w1y);
% Semi-infinite constraint
K1 = sin(wx*X(1)).*cos(wx*X(2))-1/1000*(wx-50).^2 -...
sin(wx*X(3))-X(3)+sin(wy*X(2)).*cos(wx*X(1))-...
1/1000*(wy-50).^2-sin(wy*X(3))-X(3)-1.5;
% No finite nonlinear constraints
c = []; ceq=[];
% Mesh plot
m = surf(wx,wy,K1,'edgecolor','none','facecolor','interp');
camlight headlight
title('Semi-infinite constraint')
drawnow
Next, invoke an optimization routine.
x0 = [0.25, 0.25, 0.25]; % Starting guess [x,fval] = fseminf(@myfun,x0,1,@mycon)
After nine iterations, the solution is
x =
0.2926 0.1874 0.2202
and the function value at the solution is
fval =
0.0091
The goal was to minimize the objective f(x) such that the semi-infinite constraint satisfied K1(x,w) ≤ 1.5. Evaluating mycon at the solution x and looking at the maximum element of the matrix K1 shows the constraint is easily satisfied.
[c,ceq,K1] = mycon(x,[0.5,0.5]); % Sampling interval 0.5
max(max(K1))
ans =
-0.0027
This call to mycon produces the following surf plot, which shows the semi-infinite constraint at x.

fseminf uses cubic and quadratic interpolation techniques to estimate peak values in the semi-infinite constraints. The peak values are used to form a set of constraints that are supplied to an SQP method as in the function fmincon. When the number of constraints changes, Lagrange multipliers are reallocated to the new set of constraints.
The recommended sampling interval calculation uses the difference between the interpolated peak values and peak values appearing in the data set to estimate whether the function needs to take more or fewer points. The function also evaluates the effectiveness of the interpolation by extrapolating the curve and comparing it to other points in the curve. The recommended sampling interval is decreased when the peak values are close to constraint boundaries, i.e., zero.
See also SQP Implementation for more details on the algorithm used and the types of procedures displayed under the Procedures heading when the Display option is set to 'iter' with optimset.
The function to be minimized, the constraints, and semi-infinite constraints, must be continuous functions of x and w. fseminf might only give local solutions.
When the problem is not feasible, fseminf attempts to minimize the maximum constraint value.
@ (function_handle), fmincon, optimset, optimtool
![]() | fminunc | fsolve | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |