?? subseteq.m
字號:
function isfeasible = subseteq(CONfeas,CONsup)% Compute whether one linear constraint defines a subset of another set% of linear constraints%% Syntax:% "C = subseteq(a,b)"%% Description:% "subseteq(a,b)" returns a boolean that is 1 if "a" is a subset of% "b", and a 0 otherwise.%% Note:% At most one equality constraint is allowed in "a", and if "b" has an% equality constraint, it must be the same as the one present in "a".%% See Also:% linearcon,isfeasible,and, intersectglobal GLOBAL_APPROX_PARAMglobal GLOBAL_OPTIM_PARepsilon = GLOBAL_APPROX_PARAM.poly_epsilon;hyperplane_tol = GLOBAL_APPROX_PARAM.poly_hyperplane_tol;if isempty(CONfeas) isfeasible=1; returnendif isempty(CONsup) isfeasible=0; returnendif (length(CONfeas.dE) > 1) | (length(CONsup.dE) > 1) fprintf('\007intersect: Invalid constraints given, more than 1 equality found\n') returnendif (length(CONfeas.dE) == 0) & (length(CONsup.dE) == 1) %fprintf('\007intersect: Invalid constraints given, additional equality constraints\n') returnend% If an equality constraint is found in both sets of constraints,% check if they're the same constraint, if not return an empty% cell arrayif (length(CONfeas.dE) == 1) & (length(CONsup.dE) == 1) MATRIX = [CONfeas.CE CONfeas.dE CONsup.CE CONsup.dE]; if rank(MATRIX,hyperplane_tol) > 1% fprintf('intersect: Patches w/ different eq constraints found\n') return else CONsup.CE = []; CONsup.dE = []; endend % Start with the feasible constraintsCE = CONfeas.CE; dE = CONfeas.dE;CI = CONfeas.CI; dI = CONfeas.dI;% Find out if each new inequality constraint is feasibleCIsup = CONsup.CI; dIsup = CONsup.dI;for k = 1:size(CIsup,1) cIk = CIsup(k,:); dIk = dIsup(k); xmax = linprog(-cIk',CI,dI,CE,dE,[],[],[],GLOBAL_OPTIM_PAR); fmax = cIk*xmax; isfeasible = (fmax < dIk+epsilon); if ~ isfeasible break; endendreturn
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -