fix generateRunSave_EMGLLF, simplify arrays readings
[valse.git] / src / test / generate_test_data / generateRunSaveTest_constructionModelesLassoRank.m
CommitLineData
0f51ccae
BA
1function[] = generateRunSaveTest_constructionModelesLassoRank(n, p, m, k, L, mini, maxi, gamma, rangmin, rangmax, varargin)
2
3 %set defaults for optional inputs
4 optargs = {200 15 10 3 12 5 10 1.0 3 6};
5 %replace defaults by user parameters
6 optargs(1:length(varargin)) = varargin;
7 [n, p, m, k, L, mini, maxi, gamma, rangmin, rangmax] = optargs{:};
8 mini = int64(mini);
9 maxi = int64(maxi);
10 rangmin = int64(rangmin);
11 rangmax = int64(rangmax);
12 tau = 1e-6;
13
14 Pi = zeros(k,L);
15 for l=1:L
16 Pi(:,l) = (1.0/k)*ones(1,k);
17 end
18 Rho = zeros(m,m,k,L);
19 for l=1:L
20 for r=1:k
21 Rho(:,:,r,l) = eye(m);
22 end
23 end
24
25 %Generate X and Y
26 [X, Y, ~] = generateIOdefault(n, p, m, k);
27
28 A1 = zeros(p,L,'int64');
29 for i=1:L
30 A1(:,i) = 1:p;
31 end
32
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34
35 testFolder = 'data/';
36 mkdir(testFolder);
37 delimiter = ' ';
38
39 %save inputs
40 dlmwrite(strcat(testFolder,'Rho'), reshape(Rho,1,[]), delimiter);
41 dlmwrite(strcat(testFolder,'Pi'), reshape(Pi,1,[]), delimiter);
42 dlmwrite(strcat(testFolder,'mini'), mini, delimiter);
43 dlmwrite(strcat(testFolder,'maxi'), maxi, delimiter);
44 dlmwrite(strcat(testFolder,'X'), reshape(X,1,[]), delimiter);
45 dlmwrite(strcat(testFolder,'Y'), reshape(Y,1,[]), delimiter);
46 dlmwrite(strcat(testFolder,'tau'), tau, delimiter);
47 dlmwrite(strcat(testFolder,'A1'), reshape(A1,1,[]), delimiter);
48 dlmwrite(strcat(testFolder,'rangmin'), rangmin, delimiter);
49 dlmwrite(strcat(testFolder,'rangmax'), rangmax, delimiter);
50 dlmwrite(strcat(testFolder,'dimensions'), [n,p,m,k,L], delimiter);
51
52 [phi,lvraisemblance] = constructionModelesLassoRank(Pi,Rho,mini,maxi,X,Y,tau,A1,rangmin,rangmax);
53
54 %save output
55 Size = (rangmax-rangmin+1)^k;
56 dlmwrite(strcat(testFolder,'phi'), reshape(phi,1,[]), delimiter);
57 dlmwrite(strcat(testFolder,'lvraisemblance'), reshape(lvraisemblance,1,[]), delimiter);
58
59end