Changeset 75c47a9 in tol


Ignore:
Timestamp:
Jun 1, 2011, 9:51:48 AM (15 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
6c2b35a
Parents:
e4cfd8b
Message:

Fixes #1230 in version 2.0.2

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

Location:
tol/btol/bmodel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bmodel/aia.cpp

    re4cfd8b r75c47a9  
    8989:BObject(name), responseFunction_(rat), aia_(NIL), enabled_(BTRUE)
    9090{
    91 //Std(BText("\nCreating outlier ")+name+" = " +rat.Name());
     91#ifdef TRACE_LEVEL
     92  BText fun = BText("  BOutlier::BOutlier");
     93#endif
     94  TRACE_SHOW_TOP(fun,BText("\nCreating outlier ")+name+" = " +rat.Name());
    9295  if(name.HasName())
    9396  {
    … …  
    120123//--------------------------------------------------------------------
    121124{
     125#ifdef TRACE_LEVEL
     126  BText fun = BText("  BOutlier::CalcExpand");
     127#endif
    122128  expand_[n] = responseFunction_.Numerator().Coef(n);
    123 //Std(BText("\n   Expand[")+n+",0]="+expand_[n].Name());
     129  TRACE_SHOW_TOP(fun,BText("\n   Expand[")+n+",0]="+expand_[n].Name());
    124130  BInt i=n;
    125131  if(responseFunction_.Denominator().Degree()<n)
    … …  
    130136  {
    131137    expand_[n] -= expand_[n-i]*responseFunction_.Denominator().Coef(i);
    132   //Std(BText("\n  Expand[")+n+","+i+"]="+expand_[n].Name());
     138    TRACE_SHOW_TOP(fun,BText("\n  Expand[")+n+","+i+"]="+expand_[n].Name());
    133139  }
    134140  expand_[n] /= responseFunction_.Denominator()[0].Coef();
    … …  
    143149//--------------------------------------------------------------------
    144150{
     151#ifdef TRACE_LEVEL
     152  BText fun = BText("  BOutlier::Expand");
     153#endif
    145154  if((responseFunction_.Denominator().Degree()==0) &&
    146155     (responseFunction_.Denominator()[0].Coef()!=0))
    … …  
    155164    if(n>=size)
    156165    {
    157     //Std(BText("\nExpand : n = ")+n+", Size = "+ size +", MaxSize = "+expand_.MaxSize());
     166      TRACE_SHOW_TOP(fun,BText("\nExpand : n = ")+n+", Size = "+ size +", MaxSize = "+expand_.MaxSize());
    158167      if(n>=expand_.MaxSize()) { expand_.ReallocBuffer(2*(n+1)); }
    159168      if(n>=expand_.MaxSize()) { expand_.ReallocBuffer(2*(n+1)); }
    … …  
    207216//--------------------------------------------------------------------
    208217{
     218#ifdef TRACE_LEVEL
     219  BText fun = BText("  BOutlier::PutAia");
     220#endif
    209221  int i, j;
    210222  int length = aia->N_;
    … …  
    212224  rat_    = responseFunction_;
    213225  rat_*=aia_->rat_;
    214 //Std(BText("\n   Length      = ")+length);
     226  TRACE_SHOW_TOP(fun,BText("\n   Length      = ")+length);
    215227  BPol expand = rat_ % (length+1);
    216228  x_.ReallocBuffer(length);
    … …  
    237249  }
    238250  nearMaxAbs_.AllocBuffer(j);
    239 //Std(BText("\n   Ratio = ")+rat_.Name()+ " max (" + maxRelative_ +")="+max);
     251  TRACE_SHOW_TOP(fun,BText("\n   Ratio = ")+rat_.Name()+ " max (" + maxRelative_ +")="+max);
    240252}
    241253
    … …  
    355367//--------------------------------------------------------------------
    356368{
     369#ifdef TRACE_LEVEL
     370  BText fun = BText("  BOutlier::RecalcResiduous");
     371#endif
    357372  if(!aia_) { return(NIL); }
    358373  t-=maxRelative_;
    … …  
    360375  BDat sigma = 0;
    361376  BInt length = aia_->N_;
    362 //Std(BText("\nRecalcResiduous(")+Name()+","+t+","+w+")");
     377  TRACE_SHOW_TOP(fun,BText("\nRecalcResiduous(")+Name()+","+t+","+w+")");
    363378  for(; i<length; i++, j++)
    364379  {
    365380    aia_->res_->Data()[i]-=w*x_[j];
    366   //Std(BText("\n  x[")+j+"]="+x_[j].Name());
    367   //Std(BText("; Res[")+i+"]="+aia_->res_->Data()[i]);
     381    TRACE_SHOW_TOP(fun,BText("\n  x[")+j+"]="+x_[j].Name());
     382    TRACE_SHOW_TOP(fun,BText("; Res[")+i+"]="+aia_->res_->Data()[i]);
    368383  }
    369384  aia_->sigma_ = StandardDeviation(aia_->res_->Data()).Value();
    … …  
    423438//--------------------------------------------------------------------
    424439{
     440#ifdef TRACE_LEVEL
     441  BText fun = BText("  BAia::Initialize");
     442#endif
    425443  BInt o;
    426444  BDat f   = (*res_)[res_->FirstDate()]; //Forzes residuous calculation
    427445  N_  = res_->Data().Size();
    428 //Std(BText("\nResiduous dates ")+res_->FirstDate().Name()+", "+
    429 //          res_->LastDate ().Name()+", "+N_);
     446  TRACE_SHOW_TOP(fun,BText("\nResiduous dates ")+res_->FirstDate().Name()+", "+
     447             res_->LastDate ().Name()+", "+N_);
    430448  sigma_    = StandardDeviation(res_->Data()).Value();
    431449//Std("\nUsing outlier's types: ");
    … …  
    433451  {
    434452    userOutliers_[o]->PutAia(this);
    435   //Std(BText("\n  ")+userOutliers_[o]->Name());
     453    TRACE_SHOW_TOP(fun,BText("\n  ")+userOutliers_[o]->Name());
    436454  }
    437455}
    … …  
    453471  {
    454472    BReal absRes = Abs(res_->Data()[t]).Value();
    455   //Std(BText("\n   ")+absRes+ " <=> " + max);
     473    TRACE_SHOW_TOP(fun,BText("\n   ")+absRes+ " <=> " + max);
    456474    if(absRes>max)
    457475    {
  • tol/btol/bmodel/maia.cpp

    re4cfd8b r75c47a9  
    6363
    6464//--------------------------------------------------------------------
    65   bool BMultOutlier::IsDisjoint(const BMultOutlier& a)
    66 //--------------------------------------------------------------------
    67 {
     65  bool BMultOutlier::HasInput(BOutlier* outlier, int t) const
     66//--------------------------------------------------------------------
     67{
     68#ifdef TRACE_LEVEL
     69  BText fun = BText("  BMultOutlier::HasInput");
     70#endif
     71  int j;
     72  bool has = false;
     73  for(j=0; !has&&(j<input_.Size()); j++)
     74  {
     75    has = input_[j].t_ == t &&
     76          input_[j].outlier_ == outlier;
     77  }
     78  TRACE_SHOW_HIGH(fun, GetExpression()+"\n versus \n"+
     79   outlier->GetExpression(t,0)
     80   +"\n -> "+has+"\n");
     81  return(has);
     82};
     83
     84//--------------------------------------------------------------------
     85  bool BMultOutlier::IsDisjoint(const BMultOutlier& a) const
     86//--------------------------------------------------------------------
     87{
     88#ifdef TRACE_LEVEL
     89  BText fun = BText("  BMultOutlier::IsDisjoint");
     90#endif
    6891  int i, j;
    6992  bool ok = true;
    … …  
    79102    }
    80103  }
     104  TRACE_SHOW_HIGH(fun, GetExpression()+"\n versus \n"+a.GetExpression()+"\n -> "+ok+"\n");
    81105  return(ok);
    82106}
    … …  
    86110//--------------------------------------------------------------------
    87111{
    88   int s = input_.Size();
    89   input_.ReallocBuffer(s+1);
    90   input_[s].index_   = index;
    91   input_[s].outlier_ = outlier;
    92   input_[s].t_       = t;
    93   input_[s].w0_      = w;
    94   if(maxIndex_<index) { maxIndex_ = index; }
     112  if(!HasInput(outlier, t))
     113  {
     114    int s = input_.Size();
     115    input_.ReallocBuffer(s+1);
     116    input_[s].index_   = index;
     117    input_[s].outlier_ = outlier;
     118    input_[s].t_       = t;
     119    input_[s].w0_      = w;
     120    if(maxIndex_<index) { maxIndex_ = index; }
     121  }
    95122}
    96123
    … …  
    134161
    135162//--------------------------------------------------------------------
    136   BText BMultOutlier::GetExpression()
     163  BText BMultOutlier::GetExpression() const
    137164//--------------------------------------------------------------------
    138165{
    … …  
    164191{
    165192#ifdef TRACE_LEVEL
    166   BText fun = BText("  BOutlier::Estimate");
     193  BText fun = BText("  BMultOutlier::Estimate");
    167194#endif
    168195  TRACE_SHOW_HIGH(fun,"BEGIN");
    … …  
    370397{
    371398#ifdef TRACE_LEVEL
    372   BText fun = BText("  BOutlier::SetResiduals");
     399  BText fun = BText("  BMultAia::SetResiduals");
    373400#endif
    374401  assert(y.Size()==res_->Data().Size());
    … …  
    432459{
    433460#ifdef TRACE_LEVEL
    434   BText fun = BText("  BOutlier::RecalcResiduous");
     461  BText fun = BText("  BMultAia::RecalcResiduous");
    435462#endif
    436463  int s = mo.input_.Size();
    … …  
    454481{
    455482#ifdef TRACE_LEVEL
    456   BText fun = BText("  BAia::SearchMaxAbsRes");
     483  BText fun = BText("  BMultAia::SearchMaxAbsRes");
    457484#endif
    458485  if(optMaxOrder_>=N_) { return(false); }
    … …  
    497524{
    498525#ifdef TRACE_LEVEL
    499   BText fun = BText("  BAia::SearchRefObs");
     526  BText fun = BText("  BMultAia::SearchRefObs");
    500527#endif
    501528  int maxNearRefObs = 3;
    … …  
    516543          BMultOutlier& mor = mo[r];
    517544          int t = mr[i].t_-userOutliers_[j]->nearMaxAbs_[k];
    518           mor.Add(r,userOutliers_[j],t,0);
    519           r++;
     545          if(!mor.HasInput(userOutliers_[j],t))
     546          {
     547            mor.Add(r++,userOutliers_[j],t,0);
     548          }
    520549        }
    521550      }
    … …  
    532561{
    533562#ifdef TRACE_LEVEL
    534   BText fun = BText("  BAia::SearchNextMultOutlier");
     563  BText fun = BText("  BMultAia::SearchNextMultOutlier");
    535564#endif
    536565  BComparingInfo minimum;
    … …  
    717746{
    718747#ifdef TRACE_LEVEL
    719   BText fun = BText("  BAia::Input");
     748  BText fun = BText("  BMultAia::Input");
    720749#endif
    721750  if(!input_)
  • tol/btol/bmodel/tol_bmaia.h

    re4cfd8b r75c47a9  
    8888    return(*this);
    8989  }
    90   bool IsDisjoint(const BMultOutlier& a);
    91   BText GetExpression();
     90  bool HasInput(BOutlier* outlier, int t) const;
     91  bool IsDisjoint(const BMultOutlier& a) const;
     92  BText GetExpression() const;
    9293  void Add(int index, BOutlier* outlier, int t, BDat w);
    9394  void Add(const BMultOutlier& mo);
Note: See TracChangeset for help on using the changeset viewer.