Ignore:
Timestamp:
Dec 4, 2009, 4:44:16 PM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
4bd88af
Parents:
fabac4a
Message:

New class hierarchy

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1762 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/MulVarFunAprox/DesignC2.Monomial.Spheric.Grid.tol

    rfabac4a rb050cc43  
    99Text _.autodoc.member.DesignC2.Monomial.Spheric.Grid =
    1010"";
    11 Class @DesignC2.Monomial.Spheric.Grid : @DesignC2
     11Class @DesignC2.Monomial.Spheric.Grid :
     12  @DesignC2.Monomial,
     13  @DesignC2.Spheric
    1214//////////////////////////////////////////////////////////////////////////////
    1315{
    … …  
    1719 
    1820  Real force.reference.near.nodal = True;
    19   Real radius.margin  = 0.05;
    20   Real max.deg = 6;
    21   Real grid.size = ?;
     21  Real _.radius = ?;
     22  Real _.grid.size = ?;
    2223
    2324//////////////////////////////////////////////////////////////////////////////
    … …  
    2728  Set _.X.col.info = Copy(Empty);
    2829  Set _.range = Copy(Empty);
    29   Real _.radius = ?;
    3030  VMatrix _.grid = Rand(0,0,0,0);
    3131  Real _.G = ?;
    … …  
    3737
    3838  ////////////////////////////////////////////////////////////////////////////
    39   Static @DesignC2.Monomial.Spheric.Grid New(VMatrix X)
     39  Static @DesignC2.Monomial.Spheric.Grid New(VMatrix X, Real radius.margin)
    4040  ////////////////////////////////////////////////////////////////////////////
    4141  {
    … …  
    4444      VMatrix _.X = X;
    4545      Real    _.n = VColumns(X);
    46       Real    _.J = VRows(X)
     46      Real    _.J = VRows(X);
     47      Real _.radius.margin = radius.margin
    4748    ]]
    4849  };
    … …  
    6162      VMatrix Xi = SubCol(X,[[i]]);
    6263      VMatrix Yi.min = Rand(m,1,_.range[i][1],_.range[i][1]);
    63       VMatrix Ri = Round((Xi-Yi.min)/grid.size);
     64      VMatrix Ri = Round((Xi-Yi.min)/_.grid.size);
    6465      VMatrix minRi = Rand(m,1,0,0);
    6566      VMatrix maxRi = Rand(m,1,cRi-1,cRi-1);
    … …  
    99100    ]]});
    100101   
    101     Real If(Or(IsUnknown(grid.size),grid.size<=0),
     102    Real If(Or(IsUnknown(_.grid.size),_.grid.size<=0),
    102103    {
    103104      Real length.max = SetMax(Traspose(Extract(_.X.col.info,4))[1]);
    104105      Real density = _.J/SetProd(Traspose(Extract(_.X.col.info,4))[1]);
    105       grid.size := 0.5*(_.K0/density)^(1/_.n)
    106     });
    107    
    108     Real _.radius := (1+radius.margin)*grid.size/Sqrt(2);
     106      _.grid.size := 0.5*(_.K0/density)^(1/_.n)
     107    });
     108   
     109    Real _.radius := (1+_.radius.margin)*_.grid.size/Sqrt(2);
    109110   
    110111    WriteLn("TRACE "+_MID+"2");
    … …  
    112113    {
    113114      Set info = _.X.col.info[i];
    114       Real points = 1+Ceil(info::length/grid.size);
    115       Real exceed = (points-1)*grid.size-info::length;
     115      Real points = 1+Ceil(info::length/_.grid.size);
     116      Real exceed = (points-1)*_.grid.size-info::length;
    116117      Matrix rnk = Tra(DifEq(1/(1-B),Rand(points,1,1,1))-Rand(points,1,1,1));   
    117       Set MatSet((rnk*grid.size)+info::min-exceed/2)[1]
     118      Set MatSet((rnk*_.grid.size)+info::min-exceed/2)[1]
    118119    });
    119120    WriteLn("TRACE "+_MID+"3");
    … …  
    165166    VMatrix Y.closest.grid.index = closest.grid.index(_.Y);
    166167   
    167     VMatrix Y.neighbour.pos = Min(Y.max, _.Y + Rand(_.H,_.n,grid.size,grid.size));
    168     VMatrix Y.neighbour.neg = Max(Y.min, _.Y - Rand(_.H,_.n,grid.size,grid.size));
     168    VMatrix Y.neighbour.pos = Min(Y.max, _.Y + Rand(_.H,_.n,_.grid.size,_.grid.size));
     169    VMatrix Y.neighbour.neg = Max(Y.min, _.Y - Rand(_.H,_.n,_.grid.size,_.grid.size));
    169170   
    170171    VMatrix _.Y.h := DifEq(1/(1-B),Rand(_.H,1,1,1));
    … …  
    249250    VMatrix _.Z.h := SubRow(Z.h.a | Z.h.b,MatQuery::SelectMatch(Z.interior));
    250251   
    251     Real _.T := VRows(_.Z);
     252    Real _.Tz := VRows(_.Z);
    252253    Real _.Mz := Case(
    253254      prior.Z.order< 0, 0,
    254       prior.Z.order==0, _.T,
    255       prior.Z.order==1, _.T*(1+_.n),
    256       prior.Z.order==2, _.T*(1+_.n*3/2+(1/2)*_.n^2));
    257     _.T
    258   };
    259 
    260   //////////////////////////////////////////////////////////////////////////////
    261     Real build.base(Real void)
    262   //////////////////////////////////////////////////////////////////////////////
    263   {
    264     Text _MID = "[@DesignC2.Monomial.Spheric.Grid::build.base] ";
    265     Real max.K = Min(_.K0, Floor(_.M/(_.H*min.contrast.surface)));
    266    
    267     WriteLn("TRACE "+_MID+"1.1 K0="<<_.K0);
    268     WriteLn("TRACE "+_MID+"1.2 M="<<_.M);
    269     WriteLn("TRACE "+_MID+"1.3 H="<<_.H);
    270     WriteLn("TRACE "+_MID+"1.4 SC="<<min.contrast.surface);
    271     WriteLn("TRACE "+_MID+"1.5 max.K="<<max.K);
    272     Real deg =
    273     {
    274       Real deg = 0;
    275       Real K = 1;
    276       Set pair.deg.K = [[ [[Copy(deg),Copy(K),1]] ]];
    277       While(And(deg<=max.deg, K<=max.K),
    278       {
    279         Real deg := deg+1;
    280         Real k = Comb(_.n+deg-1,deg);
    281         Real K := K+k;
    282         WriteLn("TRACE "+_MID+"2."<<deg+" K="<<K);
    283         Set Append(pair.deg.K, [[ [[Copy(deg),Copy(K),Copy(k)]] ]])
    284       });
    285       If(pair.deg.K[deg+1][2]<=max.K,deg,deg-1)
    286     };
    287 
    288     WriteLn("TRACE "+_MID+"3");
    289     FunRn2R::@BaseC2 base.feasible = FunRn2R::@BaseC2.Monomial::New(_.n,deg);
    290     Real _.K := base.feasible::_.K;
    291     Set Append(_.base, [[base.feasible]]);
    292     Real _.base.sel := Card(_.base);
    293     _.K
     255      prior.Z.order==0, _.Tz,
     256      prior.Z.order==1, _.Tz*(1+_.n),
     257      prior.Z.order==2, _.Tz*(1+_.n*3/2+(1/2)*_.n^2));
     258    _.Tz
    294259  };
    295260
    … …  
    305270    Real _.K0 := base.max::_.K;
    306271    _build.model.design(void)
    307   };
    308 
    309   ///////////////////////////////////////////////////////////////////////////
    310   Set get.X.weight(Set X.dif)
    311   ///////////////////////////////////////////////////////////////////////////
    312   {
    313     Real m = VRows(X.dif[1]);
    314     Set X.tao = For(1,_.X.maxNeighbour,VMatrix(Real i)
    315     {
    316       VMatrix X.norm2 = RPow(X.dif[i],2)*Rand(_.n,1,1,1);
    317       RPow(X.norm2,0.5)/_.radius
    318     });
    319     Set X.tao2 = For(1,_.X.maxNeighbour,VMatrix(Real i)
    320     {
    321       RPow(X.tao[i],2)
    322     });
    323     Set X.match = For(1,_.X.maxNeighbour,VMatrix(Real i)
    324     {
    325       LE(X.tao[i],Rand(m,1,1,1))
    326     });
    327     Set X.lambda = For(1,_.X.maxNeighbour,VMatrix(Real i)
    328     {
    329       RPow(X.match[i] $* (Rand(m,1,1,1)-X.tao2[i]),4)
    330     });
    331     VMatrix X.lambda.sum = SetSum(X.lambda);
    332    
    333     Set X.weight = For(1,_.X.maxNeighbour,VMatrix(Real i)
    334     {
    335       X.lambda[i] $/ X.lambda.sum
    336     })
    337272  };
    338273
Note: See TracChangeset for help on using the changeset viewer.