/**
* @file RTBGrid.h
* @brief random regression tree
* @author Sven Sickert
* @date 07/15/2013

*/
#ifndef RTBGRIDINCLUDE
#define RTBGRIDINCLUDE

#include <vector>

#include "core/vector/VectorT.h"
#include "core/vector/VVector.h"

#include "core/basics/Config.h"
#include "RegressionTreeBuilder.h"


namespace OBJREC {

/** random regression tree */
class RTBGrid : public RegressionTreeBuilder
{
  
  protected:
    int max_depth;
    int min_examples;
    
    /** save indices in leaves */
    bool save_indices;

    RegressionNode *buildRecursive ( const NICE::VVector & x,
          const std::vector< std::vector< double > > & limits,
          std::vector<int> & selection,
          int depth);

    bool balancingLeftRight ( const std::vector< std::pair< double, int > > values,
          double threshold,
          int & count_left,
          int & count_right );

  public:
    
    /** simple constructor */
    RTBGrid( const NICE::Config *conf, std::string section = "RTBGrid" );
    
    /** simple destructor */
    virtual ~RTBGrid();
    
    RegressionNode *build ( const NICE::VVector & x,
          const NICE::Vector & y );
    
};
  
  
}

#endif