source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/loadsedumidata.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.1 KB
Line 
1function [F,h] = loadsedumidata(varargin)
2%LOADSEDUMIDATA Loads a problem definition in the SeDuMi format
3%
4%    [F,h] = loadsedumidata('filename')  Loads the problem min(h(x)), F(x)>0 from file 'filename'
5%    [F,h] = loadsedumidata              An "Open" - box will be opened
6
7% Author Johan Löfberg
8% $Id: loadsedumidata.m,v 1.2 2005/09/16 08:10:24 joloef Exp $
9
10filename = varargin{1};
11
12% Does the file exist
13if ~exist(filename)
14    filename = [filename '.mat'];
15    if ~exist(filename)
16        error(['No such file.']);
17    end
18end
19   
20load(filename)
21try
22    b = b(:);
23    c = c(:);
24    if ~exist('At')
25        At = A;
26    end
27    K = K;
28catch
29    error('The file should contain the data At, b, c and K');
30end
31
32nvars = length(b);
33x = sdpvar(nvars,1);
34
35if size(At,2)~=length(b)
36    At = At';
37end
38
39F = set([]);
40top = 1;
41
42if isvalidfield(K,'f')
43    X = c(top:top+K.f-1)-At(top:top+K.f-1,:)*x;
44    F = F + set(X(:) == 0);
45    top = top + K.f;
46end
47
48if isvalidfield(K,'l')
49    X = c(top:top+K.l-1)-At(top:top+K.l-1,:)*x;
50    F = F + set(X(:));
51    top = top + K.l;
52end
53
54if isvalidfield(K,'q')
55    for i = 1:length(K.q)
56        X = c(top:top+K.q(i)-1)-At(top:top+K.q(i)-1,:)*x;
57        F = F + set(cone(X(2:end),X(1)));
58        top = top + K.q(i);
59    end
60end
61
62if isvalidfield(K,'r')
63    for i = 1:length(K.r)
64        X = c(top:top+K.r(i)-1)-At(top:top+K.r(i)-1,:)*x;
65        F = F + set(rcone(X(3:end),X(2),X(1)));
66        top = top + K.r(i);
67    end
68end
69
70if isvalidfield(K,'s')
71    for i = 1:length(K.s)
72        [ix,iy,iv] = find([c(top:top+K.s(i)^2-1) At(top:top+K.s(i)^2-1,:)]);
73        off = (ix-1)/(K.s(i)+1);
74        if all(off == round(off))
75            X = c(top:top+K.s(i)^2-1)-At(top:top+K.s(i)^2-1,:)*x;
76            F = F + set(diag(reshape(X,K.s(i),K.s(i))) > 0);
77            top = top + K.s(i)^2;
78        else
79            X = c(top:top+K.s(i)^2-1)-At(top:top+K.s(i)^2-1,:)*x;
80            F = F + set(reshape(X,K.s(i),K.s(i)) > 0);
81            top = top + K.s(i)^2;
82        end
83    end
84end
85
86h = -b'*x;
87
88function ok = isvalidfield(K,fld)
89ok = 0;
90if isfield(K,fld)
91    s = getfield(K,fld);
92    if prod(size(s))>0
93        if s(1)>0
94            ok = 1;
95        end
96    end
97end
98
Note: See TracBrowser for help on using the repository browser.