function MarkovPrognozOptimizeCmd(infile,matfile,outmatfile,logfile,lenprognoz,mindt,maxdt,outfile);
% консольная функция подбора параметров программы
global hierarchy_params;
global in_series;
global in_series_urez;
global type_prirash;
type_prirash=0;
%%%0 - absolutnie, 1 - otnositelnie
global type_raspr; % Тип распределения
type_raspr=5;
global graphs;
graphs=[];
global graphs_raspr;
graphs_raspr=[];
global logs_skleyka;
logs_skleyka=1;
in_series_urez=dlmread(infile);
%in_series_urez=in_series_urez(1:12000);
in_series=in_series_urez;
n=length(in_series_urez);

nbeg=1;
nend=n;
s=5;
k=1;
rmin=1;
rmax=99999;
nprognoz=lenprognoz;
type_hier=1; %0 - cложная, 1-простая
tbeg=nbeg;
tend=nend;
global limitdt;
limitdt=maxdt;

global limitdt_min;
limitdt_min=mindt;



if (isempty(matfile))
    generate_hier([nbeg,nend,s,k,rmin,rmax,nprognoz,type_hier,tend,tbeg]);
    %hierarchy_params=generate_hier();
else
    load(matfile);
end
global hlogfile;
if (isempty(logfile))
    hlogfile=1;
else
    hlogfile=fopen(logfile,'w');
end
in_series_urez=dlmread(infile);
%in_series_urez=in_series_urez(1:12000);
in_series=in_series_urez;
[yprogn,masdtparam]=MarkovPrognozOptimize(in_series_urez,hierarchy_params);
hierarchy_params=masdtparam;
save(outmatfile);
fclose(hlogfile);
dlmwrite(outfile,yprogn,'\n'); 