% function: fwlsmm.m
% purpose: FWLSMM finds a constrained minimum of a function of several variables.
% FWLSMM attempts to solve problems of the form:
% min beta*(W_ls*F(X)) + (1 - beta)*(max(W_mm*F(X)))
% X
%
% subject to: A*X <= B, Aeq*X = Beq (linear constraints)
% C(X) <= 0, Ceq(X) = 0 (nonlinear constraints)
% LB <= X <= UB (bounds)
%
% inputs: All inputs follows closely to FMINCON function, except for the
% following 3 input parameters.
% beta - weight to select between weighted least square or weighted min-max
% optimisation. Must be between 0 - 1, inclusively. 0 for pure
% weighted min-max, 1 for pure weighted least square optimisation.
% wls - weight for least squares optimisation. Must have same size as
% the matrix returned by the cost function, F(X). Default value is
% ones(R, C)/(R*C), where R and C are number of rows and columns of
% the matrix returned by the cost function, F(X).
% wmm - weight for min-max optimisation. Must have same size as the
% matrix returned by the cost function, F(X). Default value is
% ones(R, C)/(R*C), where R and C are number of rows and columns of
% the matrix returned by the cost function, F(X).
%
% outputs: All outputs follow closely to the one from FMINCON
%
% comment: As with the fmincon.m, this function also suffers from local
% minima solution. Can try to compare the solution with the one obtained
% from SOCP(sedumi). SOCP gives global minima
%
% author: LCC Corps
% date: Sept 12, 2008
function [x, fval, exitflag, output, lambda, grad, hessian] = ...
fwlsmm(fun, x0, beta, wls, wmm, A, b, Aeq, beq, lb, ub, nonlcon, options)
% set parameters not imported to default value
if (nargin < 13),
options = [];
if (nargin < 12),
nonlcon = [];
if (nargin < 11),
ub = [];
if (nargin < 10),
lb = [];
if (nargin < 9),
beq = [];
if (nargin < 8),
Aeq = [];
if (nargin < 7),
b = [];
if (nargin < 6),
A = [];
if (nargin < 5),
wmm = [];
if (nargin < 4),
wls = [];
if (nargin < 3)
beta = [];
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
if (isempty(nonlcon)),
nonlcon = @defnlcon;
end;
[rc, cc] = size(fun(x0));
if (isempty(wls)),
wls = ones(rc, cc)/(rc*cc);
end;
if (isempty(wmm)),
wmm = ones(rc, cc);
end;
% cost function having both weighted least squares and weighted min-max
cost = @(x) beta*sum(wls.*fun(x)) + (1-beta)*max(wmm.*fun(x));
% solving the weighted least squares and weighted min-max problem using
% fmincon
[x, fval, exitflag, output, lambda, grad, hessian] = ...
fmincon(cost, x0, A, b, Aeq, beq, lb, ub, nonlcon, options);
% default non-linear contraints, in case the user did not pass in any
function [c, ceq] = defnlcon(x)
c = 0;
ceq = 0;
评论11
最新资源