📄 newcompileinterfacedata.m
字号:
function [interfacedata,recoverdata,solver,diagnostic,F] = compileinterfacedata(F,G,P,h,options,CACHED_SOLVERS,findallsolvers)
diagnostic = [];
interfacedata = [];
recoverdata = [];
solver = [];
% ******************************************
% EXTRACT LOW-RANK DESCRIPTION
% ******************************************
lowrankdetails = getlrdata(F);
if ~isempty(lowrankdetails)
F = F(~is(F,'lowrank'));
end
% ******************************************
% PERTURB STRICT INEQULAITIES?
% ******************************************
if isa(options.shift,'sdpvar') | (options.shift~=0)
F = shift(F,options.shift);
end
% ******************************************
% ADD RADIUS CONSTRAINT?
% ******************************************
if isa(options.radius,'sdpvar') | ~isinf(options.radius)
x = recover(unique(union(depends(h),depends(F))));
if length(x)>1
F = F + set(cone(x,options.radius));
else
F = F + set(-options.radius < x < options.radius);
end
end
% ******************************************
% Take care of the compound objects
% by convexifying stuff like t = max(x,y)
% ******************************************
if ~isempty(yalmip('extvariables'))
[F,failure] = convexitypropagation(F,h,1);
if failure
interfacedata = [];
recoverdata = [];
solver = '';
diagnostic.solvertime = 0;
diagnostic.problem = 14;
diagnostic.info = yalmiperror(14,'YALMIP');
return
end
end
% *********************************************
% CONVERT LOGIC CONSTRAINTS (future project...)
% *********************************************
% [F,changed] = convertlogics(F);
% if changed
% options.saveduals = 0; % We cannot calculate duals since we changed the problem
% end
% % *******************************************
% % UNCERTAIN VARIABLES (future project...)
% % *******************************************
% [F,changed] = robustify(F);
% if changed
% options.saveduals = 0; % We cannot calculate duals since we changed the problem
% end
% *********************************************
% CONVERT CONVEX QUADRATIC CONSTRAINTS
% *********************************************
if (options.convertconvexquad) & ~(strcmp(options.solver,'bmibnb')) &~options.relax
[F,socp_changed] = convertquadratics(F);
if socp_changed % changed holds the number of QC -> SOCC conversions
options.saveduals = 0; % We cannot calculate duals since we changed the problem
end
else
socp_changed = 0;
end
% ******************************************
% LOOK FOR AVAILABLE SOLVERS
% ******************************************
if (options.cachesolvers==0) | isempty(CACHED_SOLVERS)
solvers = getavailablesolvers(findallsolvers);
CACHED_SOLVERS = solvers;
else
solvers = CACHED_SOLVERS;
end
% ******************************************
% NO SOLVER AVAILABLE
% ******************************************
if isempty(solvers)
diagnostic.solvertime = 0;
if isempty(options.solver)
diagnostic.info = yalmiperror(-2,'YALMIP');
diagnostic.problem = -2;
else
diagnostic.info = yalmiperror(-3,'YALMIP');
diagnostic.problem = -3;
end
if (options.warning) & isempty(findstr(diagnostic.info,'No problems detected'))
disp(['Warning: ' diagnostic.info]);
end
return
end
% CHEAT FOR QC
if socp_changed>0 & length(find(is(F,'socc')))==socp_changed
socp_are_really_qc = 1;
else
socp_are_really_qc = 0;
end
% ******************************************
% TRY TO SELECT SUITABLE SOLVER
% ******************************************
disp('Using new problem categorization')
[ProblemClass,integer_variables,binary_variables,parametric_variables,quad_info] = newcatsdp(F,G,h,options.relax);
%[ProblemString,integer_variables,binary_variables,parametric_variables,quad_info] = catsdp(F,G,h,options.relax);
% Relax ?
if options.relax
error
ProblemString = strrep(ProblemString,'DI','');
ProblemString = strrep(ProblemString,'DB','');
ProblemString = strrep(ProblemString,'DP','');
ProblemString = strrep(ProblemString,'OQ','');
end
%[solver,problem] = selectsolver(options,ProblemString,solvers,socp_are_really_qc);
[solver,problem] = newselectsolver(options,ProblemClass,solvers,socp_are_really_qc);
if isempty(solver)
diagnostic.solvertime = 0;
if problem == -4
diagnostic.info = yalmiperror(problem,upper(options.solver));
else
diagnostic.info = yalmiperror(problem,'YALMIP');
end
diagnostic.problem = problem;
if (options.warning)
disp(['Warning: ' diagnostic.info]);
end
return
end
if length(solver.version)>0
solver.tag = [solver.tag '-' solver.version];
end
% *****************************************
% DID WE SELECT THE INTERNAL BNB SOLVER
% IN THAT CASE, SELECT LOCAL SOLVER
% (UNLESS ALREADY SPECIFIED IN OPTIONS.BNB)
% *****************************************
localsolver.qc = 0;
if strcmp(solver.tag,'bnb')
temp_options = options;
temp_options.solver = options.bnb.solver;
localsolver = selectsolver(temp_options,strrep(strrep(ProblemString,'DI',''),'DB',''),solvers,socp_are_really_qc);
if isempty(localsolver) | strcmp(localsolver.tag,'bnb')
diagnostic.solvertime = 0;
diagnostic.info = yalmiperror(-2,'YALMIP');
diagnostic.problem = -2;
return
end
solver.subcall = localsolver.call;
end
% *****************************************
% DID WE SELECT THE INTERNAL BMIBNB SOLVER
% IN THAT CASE, SELECT UPPER/LOWER SOLVERs
% (UNLESS ALREADY SPECIFIED IN OPTIONS)
% *****************************************
if strcmp(solver.tag,'bmibnb')
temp_options = options;
temp_options.solver = options.bmibnb.lowersolver;
% if ~isempty(binary_variables)
binary_variables2 = binary_variables;
ProblemString = strrep(ProblemString,'DB','');
binary_variables = [];
% end
if isempty(findstr(ProblemString,'CS'))
localsolver = selectsolver(temp_options,strrep(ProblemString,'CB','CE'),solvers);
else
localsolver = selectsolver(temp_options,strrep(ProblemString,'CB','CS'),solvers);
end
if isempty(localsolver) | strcmp(localsolver.tag,'bmibnb')
diagnostic.solvertime = 0;
diagnostic.info = yalmiperror(-2,'YALMIP');
diagnostic.problem = -2;
return
end
solver.lowercall = localsolver.call;
temp_options = options;
temp_options.solver = options.bmibnb.uppersolver;
localsolver = selectsolver(temp_options,ProblemString,solvers);
if isempty(localsolver) | strcmp(localsolver.tag,'bmibnb')
diagnostic.solvertime = 0;
diagnostic.info = yalmiperror(-2,'YALMIP');
diagnostic.problem = -2;
return
end
solver.uppercall = localsolver.call;
temp_options = options;
temp_options.solver = options.bmibnb.lpsolver;
localsolver = selectsolver(temp_options,strrep(strrep(strrep(ProblemString,'CB','CE'),'CS','CE'),'OQ',''),solvers);
if isempty(localsolver) | strcmp(localsolver.tag,'bmibnb')
diagnostic.solvertime = 0;
diagnostic.info = yalmiperror(-2,'YALMIP');
diagnostic.problem = -2;
return
end
solver.lpcall = localsolver.call;
binary_variables = binary_variables2;
end
% *****************************************
% DID WE SELECT THE INTERNAL MP SOLVER
% IN THAT CASE, SELECT LOCAL SOLVER
% (UNLESS ALREADY SPECIFIED IN OPTIONS.BNB)
% *****************************************
localsolver.qc = 0;
if strcmp(solver.tag,'mpcvx')
temp_options = options;
temp_options.solver = options.mpcvx.solver;
temp = strrep(strrep(ProblemString,'DI',''),'DB','');
temp = strrep(ProblemString,'MP','');
localsolver = selectsolver(temp_options,temp,solvers,socp_are_really_qc);
if isempty(localsolver) | strcmp(localsolver.tag,'mpcvx')
diagnostic.solvertime = 0;
diagnostic.info = yalmiperror(-2,'YALMIP');
diagnostic.problem = -2;
return
end
solver.subcall = localsolver.call;
end
showprogress(['Solver chosen : ' solver.tag],options.showprogress);
% % ******************************************
% % CONVERT TO STANDARD PROBlEMS
% % ******************************************
% if ~isempty(P) & solver.maxdet==0
% t = sdpvar(1,1);
% F = F + detset(t,P);
% if isempty(h)
% h = -t;
% else
% h = h-t;
% end
% end
if ~isempty(binary_variables) & (solver.constraint.binary==0)
x_bin = recover(binary_variables);
F = F + lmi(x_bin<1)+lmi(x_bin>0);
integer_variables = union(binary_variables,integer_variables);
binary_variables = [];
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -