【问题标题】:Augmenting Latin Hypercube Points in MATLAB在 MATLAB 中增加拉丁超立方点
【发布时间】:2015-03-19 11:24:24
【问题描述】:

我想知道创建 LHS 设计的命令是什么,然后如果模型不够好,然后用更多的点来增加它?例如,我将首先创建一个 50 点的 LHS 设计,然后逐步添加更多点(可能以 20 个为一组),直到模型足够准确。 例如:

Set1=lhsdesign(5,5); %5x5 matrix
%Use of set 1, then determine more points are needed 
Set2=%some command that adds 20 points to Set1 to make it a 25x5 matrix

20个新点再次运行lhsdesign的难度没有考虑到原来的点。也有使用原始点完成的工作,因此从头开始生成一组新点会浪费这项工作,因为新点不包含在新集合中。

【问题讨论】:

    标签: matlab


    【解决方案1】:

    我能够制作一个解决这个问题的函数。我不确定最终的矩阵是否是真正的拉丁超立方体,但如果需要,它会将所需数量的点添加到给定点并将它们移动到最近的可用开放“通道”(不存在点的子范围)。

    用法如下:

    x1=lhsdesign(200,17);
    xF=lhsaugment(x1,200);
    

    这将 200 个点添加到 x1 点集,导致 xF 为 400x17 矩阵。功能如下:

    function xF = lhsaugment(x1,nPoi)
    %function xF = lhsaugment(x1,nPoi)
    %Function to augment a given latin hypercube x1 by a number of points,
    %nPoi. Only the length is changed, i.e. points are added to the length.
    %The original points are left unctouched and appear first in the output
    %xF. Thus the size of xF is [size(x1,1)+nPoi size(x1,2)].
    x2=lhsdesign(nPoi,size(x1,2));
    nPoi=size(x2,1);
    oPoi=size(x1,1);
    tPoi=nPoi+oPoi;
    fInt=1/tPoi;
    for i=1:tPoi
        cBound(i,:)=[(i-1)*fInt i*fInt];
    end
    xF=zeros(tPoi,size(x1,2));
    bX1=zeros(size(x1));
    bX2=zeros(size(x2));
    bF=zeros(tPoi,size(x1,2));
    iF=zeros(1,size(x1,2));
    iMove=0;
    for i=1:oPoi
        for j=1:size(cBound,1)
            for l=1:size(x1,2)
                if (x1(i,l)>cBound(j,1))&&(x1(i,l)<=cBound(j,2))&&(bF(j,l)==0)
                    iF(1,l)=iF(1,l)+1;
                    xF(iF(1,l),l)=x1(i,l);
                    bX1(i,l)=1;
                    bF(j,l)=1;
                elseif (x1(i,l)>cBound(j,1))&&(x1(i,l)<=cBound(j,2))&&(bF(j,l)~=0)
                    iMin=size(cBound,1);
                    pMin=size(cBound,1);
                    for m=j:-1:1
                        if (bF(m,l)==0)
                            iMin=m;
                            pMin=j-m;
                            break
                        end
                    end
                    for m=j:size(cBound,1)
                        if (bF(m,l)==0)&&(m-j<pMin)
                            iMin=m;
                            pMin=j+m;
                            break
                        end
                    end
                    iF(1,l)=iF(1,l)+1;
                    xF(iF(1,l),l)=x1(i,l);
                    bX1(i,l)=1;
                    bF(iMin,l)=1;
                end
            end
        end
    end
    for i=1:nPoi
        for j=1:size(cBound,1)
            for l=1:size(x2,2)
                if (x2(i,l)>cBound(j,1))&&(x2(i,l)<=cBound(j,2))&&(bF(j,l)==0)
                    iF(1,l)=iF(1,l)+1;
                    xF(iF(1,l),l)=x2(i,l);
                    bX2(i,l)=1;
                    bF(j,l)=1;
                elseif (x2(i,l)>cBound(j,1))&&(x2(i,l)<=cBound(j,2))&&(bF(j,l)~=0)
                    iMin=size(cBound,1);
                    pMin=size(cBound,1);
                    for m=j:-1:1
                        if (bF(m,l)==0)
                            iMin=m;
                            pMin=j-m;
                            break
                        end
                    end
                    for m=j:size(cBound,1)
                        if (bF(m,l)==0)&&(m-j<pMin)
                            iMin=m;
                            pMin=j+m;
                            break
                        end
                    end
                    iF(1,l)=iF(1,l)+1;
                    xF(iF(1,l),l)=(x2(i,l)-(floor(x2(i,l)/fInt)*fInt))+((iMin-1)*fInt);
                    bX2(i,l)=1;
                    bF(iMin,l)=1;
                    if l==1
                    iMove=iMove+1;
                    end
                end
            end
        end    
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多