# Dattorro Convex Optimization of Eternity II

(Difference between revisions)
 Revision as of 14:08, 30 January 2009 (edit) (Undo revision 862 by Dattorro (Talk))← Previous diff Revision as of 20:22, 19 March 2009 (edit) (undo)Next diff → Line 1: Line 1: - +
+                                                             %%% Theorem of the Alternative.
+                                                             clear all
+                                                             clc
+                                                             [m n] = size(E);
+                                                             found=[];
+                                                             cvx_quiet('true')
+                                                             for i=1:n
+                                                             inconclusive = true;
+                                                             cvx_begin
+                                                             variable a(n+1,1);
+                                                             a(1:n) >= 0;
+                                                             -E(:,i) == [E t]*a;
+                                                             cvx_end
+                                                             if strcmp(cvx_status,'Solved') || strcmp(cvx_status,'Solved/Inaccurate')
+                                                             problem_solved = 1;
+                                                             inconclusive = false;
+                                                             else
+                                                             cvx_begin
+                                                             variable z(m,1);
+                                                             t'*z == 0;
+                                                             E(:,i)'*z == 1;
+                                                             E'*z >= 0;
+                                                             cvx_end
+                                                             if strcmp(cvx_status,'Solved') || strcmp(cvx_status,'Solved/Inaccurate')
+                                                             problem_solved = 2;
+                                                             inconclusive = false;
+                                                             end
+                                                             end
+                                                             fprintf('%6d/%6d',i,n);
+                                                             if inconclusive, fprintf('   numeric   failure\n'), else fprintf('   problem %d solved\n',problem_solved), end
+                                                             end
+

## Revision as of 20:22, 19 March 2009

```%%% Theorem of the Alternative.
clear all
clc
[m n] = size(E);
found=[];
cvx_quiet('true')
for i=1:n
inconclusive = true;
cvx_begin
variable a(n+1,1);
a(1:n) >= 0;
-E(:,i) == [E t]*a;
cvx_end
if strcmp(cvx_status,'Solved') || strcmp(cvx_status,'Solved/Inaccurate')
problem_solved = 1;
inconclusive = false;
else
cvx_begin
variable z(m,1);
t'*z == 0;
E(:,i)'*z == 1;
E'*z >= 0;
cvx_end
if strcmp(cvx_status,'Solved') || strcmp(cvx_status,'Solved/Inaccurate')
problem_solved = 2;
inconclusive = false;
end
end
fprintf('%6d/%6d',i,n);
if inconclusive, fprintf('   numeric   failure\n'), else fprintf('   problem %d solved\n',problem_solved), end
end
```