clear all;%General settings:
dirctry=' ';dirctry='S:\Dropbox\ZEF\Storage\storage_cooperation\calculation';cd(dirctry);

%Run specs-file for the specific calculation:
% v25_specs_speedtest;
v25_specs_test;
% v25_specs_defaultvalues;

%Run script:
load('specs1');
%Solving only:
for i=1:num
     disp(['Solving scenario ' num2str(i) ' out of ' num2str(num) ', i.e. ' num2str(round(i/num*1*100)) '%'])%Sho which number is running
    if i>1; load(['specs' num2str(i)]); end;%Always load the appropriate dataset
    [interp(i,:),model(i,:),s(i).x,x(i).x,z(i).x]=v25_solve(filename,0,varnum,usesolver,loop,method,sim1,sim2,sim_start,shock_nodes,approx_order,state_min,state_max,t_convergence,Mu,sigma1,par);
end;
save results/results_all_last;save(['results/' saveasfilename]);%Save results

%Simulation is done in its own routine: v25_run_simulation.m
%v25_run_simulation;
%[SSIM,XSIM,ESIM,STAT]=v25_run_simulation('results_all_last');

%save results/results_all_last_sim;

%Plot results in one graph:
% figure;hold on;
% for i=1:num
%     for i2=1:size(STAT,2);%Calculate the y-axis variables and intervals: %%STAT-var:    Mean      Std. Dev. Skewness  Kurtosis  Min       Max       %LB       %UB
%         y(i,i2)=STAT(i,i2).moments(varrow(1,i),1);sd(i,i2)=STAT(i,i2).moments(varrow(1,i),2);y_lsd(i,i2)=y(i,i2)-sd(i,i2);y_hsd(i,i2)=y(i,i2)+sd(i,i2);y_min(i,i2)=STAT(i,i2).moments(varrow(1,i),5);y_max(i,i2)=STAT(i,i2).moments(varrow(1,i),6);
%     end;
%     %:Plot different lines depending on plot specification in spec-file:
%     if linesfor(1)==1;plot(yaxisp,y(i,:),[line(1).type colorset(1,i)]);end;
%     if linesfor(2)==1;plot(yaxisp,y_lsd(i,:),[line(2).type colorset(1,i)]);end;
%     if linesfor(3)==1;plot(yaxisp,y_hsd(i,:),[line(2).type colorset(1,i)]);end;
%     if linesfor(4)==1;plot(yaxisp,y_min(i,:),[line(3).type colorset(1,i)]);end;
%     if linesfor(5)==1;plot(yaxisp,y_max(i,:),[line(3).type colorset(1,i)]);end;
% end;
% hold off;xlabel(x_label);ylabel(y_label);

%Boxplots for different settings:
% pop(i,:,1)=y(i,:);pop(i,:,2)=y_lsd(i,:);pop(i,:,3)=y_hsd(i,:);
% pop(i,:,4)=y_min(i,:);pop(i,:,5)=y_max(i,:);
% clear pop;
% pop(1,:)=y(i,:);pop(2,:)=y_lsd(i,:);pop(3,:)=y_hsd(i,:);
% pop(4,:)=y_min(i,:);pop(5,:)=y_max(i,:);
% % h=boxplot(pop(1,:,:))
% figure;boxplot_jb(pop(1,:,:));
% set(h(5,1), 'YData', [pop(2,i) pop(3,i) pop(3,i) pop(2,i) pop(2,i)]);% blue box  
% 
% upWhisker = get(h(1,1), 'YData');  
% set(h(1,1), 'YData', [q90 upWhisker(2)])  
% 
% dwWhisker = get(h(2,1), 'YData');  
% set(h(2,1), 'YData', [ dwWhisker(1) q10])  


% todo:
% - build separate models
% - speed test
% - plot results OK!!! (Boxplots for later)
% - include fixed shocks OK!!!
% - include model change (filename) OK!!!
