Replace waitbar by dyn_waitbar.

time-shift
Marco Ratto 2011-12-20 16:49:03 +01:00
parent 74e95eae61
commit 4b9b90f1bb
3 changed files with 28 additions and 91 deletions

View File

@ -90,13 +90,8 @@ CovJump = VarCov;
ModePar = xparam1; ModePar = xparam1;
%% [1] I tune the scale parameter. %% [1] I tune the scale parameter.
if exist('OCTAVE_VERSION') || options_.console_mode hh = dyn_waitbar(0,'Tuning of the scale parameter...');
diary off; set(hh,'Name','Tuning of the scale parameter.');
disp(' ');
else
hh = waitbar(0,'Tuning of the scale parameter...');
set(hh,'Name','Tuning of the scale parameter.')
end
j = 1; jj = 1; j = 1; jj = 1;
isux = 0; jsux = 0; test = 0; isux = 0; jsux = 0; test = 0;
ix2 = ModePar;% initial condition! ix2 = ModePar;% initial condition!
@ -126,16 +121,8 @@ while j<=MaxNumberOfTuningSimulations
jsux = jsux + 1; jsux = jsux + 1;
end% ... otherwise I don't move. end% ... otherwise I don't move.
prtfrc = j/MaxNumberOfTuningSimulations; prtfrc = j/MaxNumberOfTuningSimulations;
if exist('OCTAVE_VERSION') || options_.console_mode if mod(j, 10)==0
if mod(j, 10)==0 dyn_waitbar(prtfrc,hh,sprintf('Acceptance rates: %f [%f]',isux/j,jsux/jj));
if exist('OCTAVE_VERSION')
printf('Tuning of the scale parameter (%f%% done):: Acceptance rates: %f [%f]\r',prtfrc*100,isux/j,jsux/jj);
else
fprintf(' Tuning of the scale parameter (%f \b%% done):: Acceptance rates: %f [%f]\r',prtfrc*100,isux/j,jsux/jj);
end
end
else
waitbar(prtfrc,hh,sprintf('Acceptance rates: %f [%f]',isux/j,jsux/jj));
end end
if j/500 == round(j/500) if j/500 == round(j/500)
test1 = jsux/jj; test1 = jsux/jj;
@ -156,18 +143,11 @@ while j<=MaxNumberOfTuningSimulations
j = j+1; j = j+1;
jj = jj + 1; jj = jj + 1;
end end
if exist('OCTAVE_VERSION') || options_.console_mode
diary on; dyn_waitbar_close(hh);
else
close(hh);
end
%% [2] One block metropolis, I update the covariance matrix of the jumping distribution %% [2] One block metropolis, I update the covariance matrix of the jumping distribution
if exist('OCTAVE_VERSION') || options_.console_mode hh = dyn_waitbar(0,'Metropolis-Hastings...');
diary off; set(hh,'Name','Estimation of the posterior covariance...'),
else
hh = waitbar(0,'Metropolis-Hastings...');
set(hh,'Name','Estimation of the posterior covariance...')
end
j = 1; j = 1;
isux = 0; isux = 0;
ilogpo2 = - feval(ObjFun,ix2,varargin{:}); ilogpo2 = - feval(ObjFun,ix2,varargin{:});
@ -190,16 +170,8 @@ while j<= NumberOfIterations
jsux = jsux + 1; jsux = jsux + 1;
end% ... otherwise I don't move. end% ... otherwise I don't move.
prtfrc = j/NumberOfIterations; prtfrc = j/NumberOfIterations;
if exist('OCTAVE_VERSION') || options_.console_mode if mod(j, 10)==0
if mod(j, 10)==0 dyn_waitbar(prtfrc,hh,sprintf('Acceptance rate: %f',isux/j));
if exist('OCTAVE_VERSION')
printf('Estimation of the posterior covariance (%f%% done):: Acceptance rates: %f\r',prtfrc,isux/j);
else
fprintf(' Estimation of the posterior covariance (%f \b%% done):: Acceptance rates: %f \r',prtfrc*100,isux/j);
end
end
else
waitbar(prtfrc,hh,sprintf('Acceptance rate: %f',isux/j));
end end
% I update the covariance matrix and the mean: % I update the covariance matrix and the mean:
oldMeanPar = MeanPar; oldMeanPar = MeanPar;
@ -208,23 +180,15 @@ while j<= NumberOfIterations
(1/j)*(ix2*ix2' - CovJump - oldMeanPar*oldMeanPar'); (1/j)*(ix2*ix2' - CovJump - oldMeanPar*oldMeanPar');
j = j+1; j = j+1;
end end
if exist('OCTAVE_VERSION') || options_.console_mode dyn_waitbar_close(hh);
diary on;
else
close(hh);
end
PostVar = CovJump; PostVar = CovJump;
PostMean = MeanPar; PostMean = MeanPar;
%% [3 & 4] I tune the scale parameter (with the new covariance matrix) if %% [3 & 4] I tune the scale parameter (with the new covariance matrix) if
%% this is the last call to the routine, and I climb the hill (without %% this is the last call to the routine, and I climb the hill (without
%% updating the covariance matrix)... %% updating the covariance matrix)...
if strcmpi(info,'LastCall') if strcmpi(info,'LastCall')
if exist('OCTAVE_VERSION') || options_.console_mode hh = dyn_waitbar(0,'Tuning of the scale parameter...');
diary off; set(hh,'Name','Tuning of the scale parameter.'),
else
hh = waitbar(0,'Tuning of the scale parameter...');
set(hh,'Name','Tuning of the scale parameter.')
end
j = 1; jj = 1; j = 1; jj = 1;
isux = 0; jsux = 0; isux = 0; jsux = 0;
test = 0; test = 0;
@ -249,16 +213,8 @@ if strcmpi(info,'LastCall')
jsux = jsux + 1; jsux = jsux + 1;
end% ... otherwise I don't move. end% ... otherwise I don't move.
prtfrc = j/MaxNumberOfTuningSimulations; prtfrc = j/MaxNumberOfTuningSimulations;
if exist('OCTAVE_VERSION') || options_.console_mode if mod(j, 10)==0
if mod(j, 10)==0 dyn_waitbar(prtfrc,hh,sprintf('Acceptance rates: %f [%f]',isux/j,jsux/jj));
if exist('OCTAVE_VERSION')
printf('Tuning of the scale parameter (%f%% done):: Acceptance rates: %f [%f]\r',prtfrc*100,isux/j,jsux/jj);
else
fprintf(' Tuning of the scale parameter (%f \b%% done):: Acceptance rates: %f [%f] \r',prtfrc*100,isux/j,jsux/jj);
end
end
else
waitbar(prtfrc,hh,sprintf('Acceptance rates: %f [%f]',isux/j,jsux/jj));
end end
if j/1000 == round(j/1000) if j/1000 == round(j/1000)
test1 = jsux/jj; test1 = jsux/jj;
@ -275,23 +231,16 @@ if strcmpi(info,'LastCall')
j = j+1; j = j+1;
jj = jj + 1; jj = jj + 1;
end end
if exist('OCTAVE_VERSION') || options_.console_mode dyn_waitbar_close(hh);
diary on;
else
close(hh);
end
Scale = iScale; Scale = iScale;
%% %%
%% Now I climb the hill %% Now I climb the hill
%% %%
climb = 1; climb = 1;
if climb if climb
if exist('OCTAVE_VERSION') || options_.console_mode hh = dyn_waitbar(0,' ');
diary off; set(hh,'Name','Now I am climbing the hill...'),
else disp('Now I am climbing the hill...'),
hh = waitbar(0,' ');
set(hh,'Name','Now I am climbing the hill...')
end
j = 1; jj = 1; j = 1; jj = 1;
jsux = 0; jsux = 0;
test = 0; test = 0;
@ -308,16 +257,8 @@ if strcmpi(info,'LastCall')
jsux = jsux + 1; jsux = jsux + 1;
end% otherwise I don't move... end% otherwise I don't move...
prtfrc = j/MaxNumberOfClimbingSimulations; prtfrc = j/MaxNumberOfClimbingSimulations;
if exist('OCTAVE_VERSION') || options_.console_mode if mod(j, 10)==0
if mod(j, 10)==0 dyn_waitbar(prtfrc,hh,sprintf('%f Jumps / MaxStepSize %f',jsux,sqrt(max(diag(iScale*CovJump)))));
if exist('OCTAVE_VERSION')
printf('Now I am climbing the hill (%f%% done):: %f Jumps / MaxStepSize %f\r',prtfrc*100,jsux,sqrt(max(diag(iScale*CovJump))));
else
fprintf(' Now I am climbing the hill (%f \b%% done):: %f Jumps / MaxStepSize %f \r',prtfrc*100,jsux,sqrt(max(diag(iScale*CovJump))));
end
end
else
waitbar(prtfrc,hh,sprintf('%f Jumps / MaxStepSize %f',jsux,sqrt(max(diag(iScale*CovJump)))));
end end
if j/200 == round(j/200) if j/200 == round(j/200)
if jsux<=1 if jsux<=1
@ -338,11 +279,7 @@ if strcmpi(info,'LastCall')
j = j+1; j = j+1;
jj = jj + 1; jj = jj + 1;
end end
if exist('OCTAVE_VERSION') || options_.console_mode dyn_waitbar_close(hh);
diary on;
else
close(hh);
end
end%climb end%climb
else else
Scale = iScale; Scale = iScale;

View File

@ -3,7 +3,7 @@ global options_ M_
[nr1, nc1, nsam] = size(mm); [nr1, nc1, nsam] = size(mm);
disp('Computing theoretical moments ...') disp('Computing theoretical moments ...')
h = waitbar(0,'Theoretical moments ...'); h = dyn_waitbar(0,'Theoretical moments ...');
for j=1:nsam, for j=1:nsam,
dr.ghx = mm(:, [1:(nc1-M_.exo_nbr)],j); dr.ghx = mm(:, [1:(nc1-M_.exo_nbr)],j);
@ -18,8 +18,8 @@ global options_ M_
dum=[dum, autocorr{i}]; dum=[dum, autocorr{i}];
end end
ac(:,:,j)=dum; ac(:,:,j)=dum;
waitbar(j/nsam,h) dyn_waitbar(j/nsam,h)
end end
close(h) dyn_waitbar_close(h)
disp(' ') disp(' ')
disp('... done !') disp('... done !')

View File

@ -25,7 +25,7 @@ nrun=size(B,3);
iff=zeros(nvar,nshock,nrun); iff=zeros(nvar,nshock,nrun);
tadj=iff; tadj=iff;
disp('Computing speed of adjustement ...') disp('Computing speed of adjustement ...')
h = waitbar(0,'Speed of adjustement...'); h = dyn_waitbar(0,'Speed of adjustement...');
for i=1:nrun, for i=1:nrun,
irf=zeros(nvar,nshock); irf=zeros(nvar,nshock);
@ -45,8 +45,8 @@ for i=1:nrun,
tt=(irf>0.5).*t; tt=(irf>0.5).*t;
tadj(:,:,i)=((tt-tadj(:,:,i))==tt).*tt+tadj(:,:,i); tadj(:,:,i)=((tt-tadj(:,:,i))==tt).*tt+tadj(:,:,i);
end end
waitbar(i/nrun,h) dyn_waitbar(i/nrun,h)
end end
disp(' ') disp(' ')
disp('.. done !') disp('.. done !')
close(h) dyn_waitbar_close(h)