⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sequence.m

📁 炼钢浇注的时序规划算法
💻 M
字号:

%%

function [output,insert_disp_output,insert_disp]  =  sequence(n,m,a,b)

%%%%
all_result   =   nchoosek(1:n+1,m);     %all the possible solutions
[col,row]    =   size(all_result);      % the size of all_result

Cat_col_A      =   (n+1)*ones(col,1);    
Cat_col_B      =   ones(col,1);


dis_A        =   cat(2,all_result,Cat_col_A);
dis_B        =   cat(2,Cat_col_B,all_result);
difference_matrix      =      abs(dis_A  - dis_B);   %the numbers of white balls between every two black balls


% test the solutions in dismantle_matrix whether statify the constrians of
% a and b ;

logic_res    =    difference_matrix>=a  &   difference_matrix <= b;
sum_res      =    (sum(logic_res'))';

index  = 1;
for k  = 1: col
    if difference_matrix(k,1) == 0  &  sum_res(k)==m
        result(index,:)  =  difference_matrix(k,:);
        insert_disp(index,:)      =  all_result(k,:);
        index = index + 1;
    end
    
    if difference_matrix(k,m+1) == 0  &  sum_res(k)==m
        result(index,:)  =  difference_matrix(k,:);
        insert_disp(index,:)      =  all_result(k,:);
        index = index + 1;
    end
    
    if sum_res(k)>m;
        result(index,:) = difference_matrix(k,:);
        insert_disp(index,:)      =  all_result(k,:);
        index = index + 1;
    end
end
        
[col_result,row_result]   =   size(result);


%%output

output        =         ones(col_result,m+n);


for     m_col  =  1:  col_result
    for    n_row = 1:  row_result-1
        
        if result(m_col,n_row)  ==  0
                output(m_col,n_row)  =   0;
        else
                output(     m_col,   sum(    result(m_col,1:n_row))  +  n_row     ) = 0;
        end
    end
end
     
for  i  =  1: col_result
    ind  = 1;
    for   j  =  1: m+n
       
        if  output(i,j)  ~=  0
            output(i,j)  = ind;
            ind  = ind+1;
        end
    end
end
        
[row_insert,col_insert] =  size(insert_disp);
insert_disp_output      =  ones(row_insert,n+1);
for   i  =  1:row_insert
    for  j  = 1:col_insert
        insert_disp_output(i,insert_disp(i,j) ) =0;
    end
end



   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -