Documentation 
Find minimum of semiinfinitely constrained multivariable nonlinear function
Finds the minimum of a problem specified by
$$\underset{x}{\mathrm{min}}f(x)\text{suchthat}\{\begin{array}{c}A\cdot x\le b,\\ Aeq\cdot x=beq,\\ lb\le x\le ub,\\ c(x)\le 0,\\ ceq(x)=0,\\ {K}_{i}(x,{w}_{i})\le 0,\text{}1\le i\le n.\end{array}$$
b and beq are vectors, A and Aeq are matrices, c(x), ceq(x), and K_{i}(x,w_{i}) 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) K_{i}(x,w_{i}) ≤ 0 are continuous functions of both x and an additional set of variables w_{1},w_{2},...,w_{n}. The variables w_{1},w_{2},...,w_{n} are vectors of, at most, length two.
x, lb, and ub can be passed as vectors or matrices; see Matrix Arguments.
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 semiinfinitely 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 w_{i}∈ℜ^{1} (or w_{i}∈ℜ^{2}). Because it is impossible to calculate all possible values of K_{i}(x,w_{i}), a region must be chosen for w_{i} over which to calculate an appropriately sampled set of values.
Note: Passing Extra Parameters explains how to pass extra parameters to the objective function and nonlinear constraint functions, if necessary. 
x = fseminf(fun,x0,ntheta,seminfcon) starts at x0 and finds a minimum of the function fun constrained by ntheta semiinfinite 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.
Note: See Iterations Can Violate Constraints. 
x = fseminf(fun,x0,ntheta,seminfcon,A,b,Aeq,beq,lb,ub,options) minimizes with the optimization options specified in options. Use optimoptions to set these options.
x = fseminf(problem) finds the minimum for problem, where problem is a structure described in Input Arguments.
Create the problem structure by exporting a problem from Optimization app, as described in Exporting Your Work.
[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.
Function Arguments contains general descriptions of arguments passed into fseminf. This section provides functionspecific 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 a file 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 = optimoptions('fseminf','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 semiinfinite constraints.  
options  Options provides the functionspecific 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 semiinfinite 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 semiinfinite constraint at x and w K2 = ... % 2nd semiinfinite constraint at x and w ... Kntheta = ...% Last semiinfinite 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 semiinfinite constraints evaluated for a sampled set of values for the independent variables w1, w2, ..., wntheta, respectively. The twocolumn 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 TwoDimensional SemiInfinite Constraint). 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. Example of Creating Sampling Points contains an example of both one and twodimensional sampling points.  
problem  objective  Objective function  
x0  Initial point for x  
ntheta  Number of semiinfinite constraints  
seminfcon  Semiinfinite 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 created with optimoptions 
Function Arguments contains general descriptions of arguments returned by fseminf. This section provides functionspecific 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.MaxFunEvals.  
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 constraint functions  
firstorderopt  Measure of firstorder optimality  
message  Exit message 
Optimization options used by fseminf. Use optimoptions to set or change options. See Optimization Options Reference for detailed information.
DerivativeCheck  Compare usersupplied derivatives (gradients of objective or constraints) to finitedifferencing derivatives. The choices are 'on' or the default 'off'. 
Diagnostics  Display diagnostic information about the function to be minimized or solved. The choices are 'on' or the default 'off'. 
DiffMaxChange  Maximum change in variables for finitedifference gradients (a positive scalar). The default is Inf. 
DiffMinChange  Minimum change in variables for finitedifference gradients (a positive scalar). The default is 0. 
Display  Level of display:

FinDiffRelStep  Scalar or vector step size factor. When you set FinDiffRelStep to a vector v, forward finite differences delta are delta = v.*sign(x).*max(abs(x),TypicalX); and central finite differences are delta = v.*max(abs(x),TypicalX); Scalar FinDiffRelStep expands to a vector. The default is sqrt(eps) for forward finite differences, and eps^(1/3) for central finite differences. 
FinDiffType  Finite differences, used to estimate gradients, are either 'forward' (the default), or 'central' (centered). 'central' takes twice as many function evaluations, but should be more accurate. The algorithm is careful to obey bounds when estimating both types of finite differences. So, for example, it could take a backward, rather than a forward, difference to avoid evaluating at a point outside bounds. 
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. The default 'off' 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. Set to 'on' to have fseminf use a userdefined gradient of the objective function. The default 'off' causes fseminf to estimate gradients using finite differences. 
MaxFunEvals  Maximum number of function evaluations allowed, a positive integer. The default is 100*numberOfVariables. 
MaxIter  Maximum number of iterations allowed, a positive integer. The default is 400. 
MaxSQPIter  Maximum number of SQP iterations allowed, a positive integer. The default is 10*max(numberOfVariables, numberOfInequalities + numberOfBounds). 
OutputFcn  Specify one or more userdefined functions that an optimization function calls at each iteration, either as a function handle or as a cell array of function handles. The default is none ([]). See Output Function. 
PlotFcns  Plots various measures of progress while the algorithm executes, select from predefined plots or write your own. Pass a function handle or a cell array of function handles. The default is none ([]):
For information on writing a custom plot function, see Plot Functions. 
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 fseminf considers too large. The default is no bounds ([]). 
RelLineSrchBndDuration  Number of iterations for which the bound specified in RelLineSrchBnd should be active (default is 1) 
TolCon  Termination tolerance on the constraint violation, a positive scalar. The default is 1e6. 
TolConSQP  Termination tolerance on inner iteration SQP constraint violation, a positive scalar. The default is 1e6. 
TolFun  Termination tolerance on the function value, a positive scalar. The default is 1e4. 
TolX  Termination tolerance on x, a positive scalar. The default value is 1e4. 
TypicalX  Typical x values. The number of elements in TypicalX is equal to the number of elements in x0, the starting point. The default value is ones(numberofvariables,1). fseminf uses TypicalX for scaling finite differences for gradient estimation. 
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 w_{i}, over which K_{i}(x,w_{i}) 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 K_{i}(x,w_{i}).
This example minimizes the function
(x – 1)^{2},
subject to the constraints
0 ≤ x ≤ 2
g(x, t)
= (x – 1/2) – (t –
1/2)^{2} ≤ 0 for all 0 ≤ t ≤
1.
The unconstrained objective function is minimized at x = 1. However, the constraint,
g(x, t) ≤ 0 for all 0 ≤ t ≤ 1,
implies x ≤ 1/2. You can see this by noticing that (t – 1/2)^{2} ≥ 0, so
max_{t} g(x, t) = (x– 1/2).
Therefore
max_{t} g(x, t) ≤ 0 when x ≤ 1/2.
To solve this problem using fseminf:
Write the objective function as an anonymous function:
objfun = @(x)(x1)^2;
Write the semiinfinite constraint function, which includes the nonlinear constraints ([ ] in this case), initial sampling interval for t (0 to 1 in steps of 0.01 in this case), and the semiinfinite constraint function g(x, t):
function [c, ceq, K1, s] = seminfcon(x,s) % No finite nonlinear inequality and equality constraints c = []; ceq = []; % Sample set if isnan(s) % Initial sampling interval s = [0.01 0]; end t = 0:s(1):1; % Evaluate the semiinfinite constraint K1 = (x  0.5)  (t  0.5).^2;
Call fseminf with initial point 0.2, and view the result:
x = fseminf(objfun,0.2,1,@seminfcon) Local minimum found that satisfies the constraints. Optimization completed because the objective function is nondecreasing in feasible directions, to within the default value of the function tolerance, and constraints are satisfied to within the default value of the constraint tolerance. Active inequalities (to within options.TolCon = 1e006): lower upper ineqlin ineqnonlin 1 x = 0.5000
The function to be minimized, the constraints, and semiinfinite 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.