fix memory leaks on EMGLLF, test OK for EMGrank
[valse.git] / src / test / generate_test_data / generateRunSaveTest_constructionModelesLassoMLE.m
CommitLineData
7b272073 1function[] = generateRunSaveTest_constructionModelesLassoMLE(n, p, m, k, mini, maxi, gamma, glambda, varargin)
0f51ccae 2
7b272073
BA
3 %set defaults for optional inputs
4 optargs = {200 15 10 3 5 10 1.0 [0.0,0.01,0.02,0.03,0.05,0.1,0.2,0.3,0.5,0.7,0.85,0.99]};
5 %replace defaults by user parameters
6 optargs(1:length(varargin)) = varargin;
7 [n, p, m, k, mini, maxi, gamma, glambda] = optargs{:};
8 tau = 1e-6;
9 seuil = 1e-15;
10 mini = int64(mini);
11 maxi = int64(maxi);
12 L = length(glambda);
13
14 %Generate phiInit,piInit,...
15 [phiInit,rhoInit,piInit,gamInit] = basicInitParameters(n, p, m, k);
16
17 %Generate X and Y
18 [X, Y, ~] = generateIOdefault(n, p, m, k);
19
20 A2 = zeros(p,m+1,L,'int64');
21 for i=1:L
22 A2(:,1,i) = 1:p;
23 A2(1:5,2,i) = 1:5;
24 end
25 A1 = zeros(p,m+1,L,'int64');
26 for i=1:L
27 A1(:,1,i) = 1:p;
28 A1(1:5,2,i) = 1:5;
29 end
0f51ccae 30
7b272073
BA
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32
33 testFolder = 'data/';
34 mkdir(testFolder);
0f51ccae 35 delimiter = ' ';
7b272073
BA
36
37 %save inputs
38 dlmwrite(strcat(testFolder,'phiInit'), reshape(phiInit,1,[]), delimiter);
39 dlmwrite(strcat(testFolder,'rhoInit'), reshape(rhoInit,1,[]), delimiter);
40 dlmwrite(strcat(testFolder,'piInit'), piInit, delimiter);
41 dlmwrite(strcat(testFolder,'gamInit'), reshape(gamInit,1,[]), delimiter);
42 dlmwrite(strcat(testFolder,'mini'), mini, delimiter);
43 dlmwrite(strcat(testFolder,'maxi'), maxi, delimiter);
44 dlmwrite(strcat(testFolder,'gamma'), gamma, delimiter);
45 dlmwrite(strcat(testFolder,'glambda'), glambda, delimiter);
46 dlmwrite(strcat(testFolder,'X'), reshape(X,1,[]), delimiter);
47 dlmwrite(strcat(testFolder,'Y'), reshape(Y,1,[]), delimiter);
48 dlmwrite(strcat(testFolder,'seuil'), seuil, delimiter);
49 dlmwrite(strcat(testFolder,'tau'), tau, delimiter);
50 dlmwrite(strcat(testFolder,'A1'), reshape(A1,1,[]), delimiter);
51 dlmwrite(strcat(testFolder,'A2'), reshape(A2,1,[]), delimiter);
52 dlmwrite(strcat(testFolder,'dimensions'), [n,p,m,k,L], delimiter);
53
c3bc4705 54 [phi,rho,pi,llh] = constructionModelesLassoMLE(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,glambda,X,Y,seuil,tau,A1,A2);
7b272073
BA
55
56 %save output
57 dlmwrite(strcat(testFolder,'phi'), reshape(phi,1,[]), delimiter);
58 dlmwrite(strcat(testFolder,'rho'), reshape(rho,1,[]), delimiter);
59 dlmwrite(strcat(testFolder,'pi'), reshape(pi,1,[]), delimiter);
c3bc4705 60 dlmwrite(strcat(testFolder,'llh'), reshape(llh,1,[]), delimiter);
7b272073
BA
61
62end