void fillTable( const std::vector<Path>& items )
  {
    unsigned int columnCount = table->width() / 150;
    table->setRowHeight( 150 );

    if( items.size() < columnCount )
      columnCount = items.size();

    for( unsigned int k=0; k < columnCount; k++ )
    {
      table->addColumn( "" );
      table->setColumnWidth( table->columnCount()-1, 150 );
    }

    for( unsigned int k=0; k < items.size(); k++ )
    {
      int rowNumber = k / columnCount;
      int columnNumber = k % columnCount;
      if( rowNumber >= table->rowCount() )
      {
        table->addRow( rowNumber );
      }

      Path picPath = items[ k ];
      if( available.contains( picPath.extension() ) )
      {
        picPath = picPath.changeExtension( "png" );
      }

      Picture pic = PictureLoader::instance().load( vfs::NFile::open( picPath ) );
      Image* image = new Image( table, Rect( 0, 0, 140, 140 ), pic, Image::best );
      table->addElementToCell( rowNumber, columnNumber, image );
      table->setCellData( rowNumber, columnNumber, "path", items[ k ].toString() );
    }    
  }
XHMM::xhmmInputManager::Table* XHMM::xhmmInputManager::readTable(string tableFile, bool header) {
#if defined(DEBUG)
	cerr << "Reading file " << tableFile << endl << endl;
#endif

	HMM_PP::istreamLineReader* tableStream = HMM_PP::utils::getIstreamLineReaderFromFile(tableFile);
	if (tableStream == NULL || tableStream->eof())
		throw new Exception("Unable to read from (possibly empty) file '" + tableFile + "'");

	Table* table = NULL;
	if (header) {
		Table::Row* columns = readRowFromStream(tableStream);
		table = new Table(columns);
	}
	else
		table = new Table();

	while (!tableStream->eof()) {
		Table::Row* row = readRowFromStream(tableStream);
		table->addRow(row);
	}

	delete tableStream;

	return table;
}
Exemple #3
0
void FillerBase::setTcal2(const String& tcaltime,
                          const Vector<Float>& tcal)
{
  uInt id = 0 ;
  Table tab = table_->tcal().table() ;
  Table result =
    //tab( nelements(tab.col("TCAL")) == uInt (tcal.size()) && 
    //     all(tab.col("TCAL")== tcal) &&
    //     tab.col("TIME") == tcaltime, 1 ) ;
    tab( nelements(tab.col("TCAL")) == uInt (tcal.size()) && 
         all(tab.col("TCAL")== tcal), 1 ) ;

  if ( result.nrow() > 0 ) {
    ROTableColumn tmpCol( result, "ID" ) ;
    tmpCol.getScalar( 0, id ) ;
  }
  else {
    uInt rno = tab.nrow();
    tab.addRow();
    TableColumn idCol( tab, "ID" ) ;
    TableColumn tctimeCol( tab, "TIME" ) ;
    ArrayColumn<Float> tcalCol( tab, "TCAL" ) ;
    // get last assigned _id and increment
    if ( rno > 0 ) {
      idCol.getScalar(rno-1, id);
      id++;
    }
    tctimeCol.putScalar(rno, tcaltime);
    tcalCol.put(rno, tcal);
    idCol.putScalar(rno, id);
  }

  RecordFieldPtr<uInt> mcalidCol(row_.record(), "TCAL_ID");
  *mcalidCol = id;
}
/*
 * rel table :
 * ROW[0] = TOT_T
 * ROW[1] = NREC_T
 * ROW[2] = REC_T
 * ROW[3] = COPY_T
 * ROW[4] = TUPLES
 * ROW[5] = REL NAME
 * ROW[6] = ID
 * ROW[7] = SRC
 * ROW[8] = PERFOR
 *
 */
Table OutputProcessor::getRelTable() {
    std::unordered_map<std::string, std::shared_ptr<Relation>>& relation_map = programRun->getRelation_map();
    Table table;
    for (auto& rel : relation_map) {
        std::shared_ptr<Relation> r = rel.second;
        Row row(9);
        double total_time = r->getNonRecTime() + r->getRecTime() + r->getCopyTime();
        row[0] = std::shared_ptr<CellInterface>(new Cell<double>(total_time));
        row[1] = std::shared_ptr<CellInterface>(new Cell<double>(r->getNonRecTime()));
        row[2] = std::shared_ptr<CellInterface>(new Cell<double>(r->getRecTime()));
        row[3] = std::shared_ptr<CellInterface>(new Cell<double>(r->getCopyTime()));
        row[4] = std::shared_ptr<CellInterface>(new Cell<long>(r->getNum_tuplesRel()));
        row[5] = std::shared_ptr<CellInterface>(new Cell<std::string>(r->getName()));
        row[6] = std::shared_ptr<CellInterface>(new Cell<std::string>(r->getId()));
        row[7] = std::shared_ptr<CellInterface>(new Cell<std::string>(r->getLocator()));
        if (total_time != 0.0) {
            row[8] = std::shared_ptr<CellInterface>(new Cell<double>(r->getNum_tuplesRel() / total_time));
        } else {
            row[8] = std::shared_ptr<CellInterface>(new Cell<double>(r->getNum_tuplesRel() / 1.0));
        }

        table.addRow(std::make_shared<Row>(row));
    }
    return table;
}
int main(int argc, char const *argv[])
{
	DecisonMakingTree tree;
	Table table;
	vector<string> v1  {"qingnian", "1", "1", "1", "1"};
	vector<string> v2  {"qingnian", "1", "1", "2", "1"};
	vector<string> v3  {"qingnian", "2", "1", "2", "2"};
	vector<string> v4  {"qingnian", "2", "2", "1", "2"};
	vector<string> v5  {"qingnian", "1", "1", "1", "1"};
	vector<string> v6  {"zhongnian", "1", "1", "1", "1"};
	vector<string> v7  {"zhongnian", "1", "1", "2", "1"};
	vector<string> v8  {"zhongnian", "2", "2", "2", "2"};
	vector<string> v9  {"zhongnian", "1", "2", "3", "2"};
	vector<string> v10 {"zhongnian", "1", "2", "3", "2"};
	vector<string> v11 {"laonian", "1", "2", "3", "2"};
	vector<string> v12 {"laonian", "1", "2", "2", "2"};
	vector<string> v13 {"laonian", "2", "1", "2", "2"};
	vector<string> v14 {"laonian", "2", "1", "3", "2"};
	vector<string> v15 {"laonian", "1", "1", "1", "1"};

	table.addRow(Row(v1 ));
	table.addRow(Row(v2 ));
	table.addRow(Row(v3 ));
	table.addRow(Row(v4 ));
	table.addRow(Row(v5 ));
	table.addRow(Row(v6 ));
	table.addRow(Row(v7 ));
	table.addRow(Row(v8 ));
	table.addRow(Row(v9 ));
	table.addRow(Row(v10));
	table.addRow(Row(v11));
	table.addRow(Row(v12));
	table.addRow(Row(v13));
	table.addRow(Row(v14));
	table.addRow(Row(v15));

	cout << "----- tree with ID3 -------" << endl;
	tree.initTree(table, 4);
	tree.decisionMakingTreeID3();
	// tree.printTree();

	cout << "----- tree with C45 -------" << endl;
	tree.initTree(table, 4);
	tree.decisionMakingTreeC45();
	// tree.printTree();


	return 0;
}
Exemple #6
0
bool Problem::isSatisfiable() const {
	Table table;
	table.empty();
	table.addRow();
	table.addColumn(ProblemConstants::cResultColumnName);
	table.setField(table.getCurrentRow(), ProblemConstants::cResultColumnName, 0);
	
	for (unsigned int i = 0; i < _variables.size(); i++) {
		table.addColumn(_variables[i].toString());
		table.setField(table.getCurrentRow(), _variables[i].toString(), -1);
	}

	return simSat(table, 0);
}
Exemple #7
0
/*
 Add a row to the table given the column names and data for the rows
*/
void Database::addRowToTable(string tableName, vector<string> columnNames,
		vector<string> rowData) {

	if (columnNames.size() != rowData.size()) {
		throw DatabaseException(12);
	}

	Table *theTable = findTable(tableName);

	if (theTable == NULL) {
		throw DatabaseException(10, tableName + " does not exist.");
	}

	theTable->addRow(columnNames, rowData);
}
void InvokeCommand::fillTableArg(Table & tableArg, const mArray &tableArray) {
    for (mArray::const_iterator i = tableArray.begin(); i != tableArray.end(); ++i) {
        const mArray rowArray = i->get_array();
        if (i == tableArray.begin()) { // the first row are the columns
            for (mArray::const_iterator j = rowArray.begin(); j != rowArray.end(); ++j) {
                tableArg.addColumn(j->get_str());
            }
        } else {
            Table::row_type row;
            for (mArray::const_iterator j = rowArray.begin(); j != rowArray.end(); ++j) {
                row.push_back(j->get_str());
            }
            tableArg.addRow(row);
        }
    }
}
Exemple #9
0
void oDBRunnerEntry::addTableRow(Table &table) const {
  bool canEdit = !oe->isClient();

  oDBRunnerEntry &it = *(oDBRunnerEntry *)(this);
  table.addRow(index+1, &it);
  if (!db)
    throw meosException("Not initialized");

  RunnerDBEntry &r = db->rdb[index];
  int row = 0;
  table.set(row++, it, TID_INDEX, itos(index+1), false, cellEdit);

  table.set(row++, it, TID_ID, itos(r.extId), false, cellEdit);
  table.set(row++, it, TID_NAME, r.name, canEdit, cellEdit);

  const pClub pc = db->getClub(r.clubNo);
  if (pc)
    table.set(row++, it, TID_CLUB, pc->getName(), canEdit, cellSelection);
  else
    table.set(row++, it, TID_CLUB, "", canEdit, cellSelection);

  table.set(row++, it, TID_CARD, r.cardNo > 0 ? itos(r.cardNo) : "", canEdit, cellEdit);
  char nat[4] = {r.national[0],r.national[1],r.national[2], 0};

  table.set(row++, it, TID_NATIONAL, nat, canEdit, cellEdit);
  char sex[2] = {r.sex, 0};
  table.set(row++, it, TID_SEX, sex, canEdit, cellEdit);
  table.set(row++, it, TID_YEAR, itos(r.birthYear), canEdit, cellEdit);

  oClass *val = 0;
  bool found = false;

  if (r.extId < unsigned(-1))
    found = db->runnerInEvent.lookup(int(r.extId), val);

  if (canEdit)
    table.setTableProp(Table::CAN_DELETE|Table::CAN_INSERT|Table::CAN_PASTE);
  else
    table.setTableProp(0);

  if (!found)
    table.set(row++, it, TID_ENTER, "@+", false, cellAction);
  else
    table.set(row++, it, TID_ENTER, val ? val->getName() : "", false, cellEdit);
}
Exemple #10
0
void oClub::addTableRow(Table &table) const {
  table.addRow(getTableId(), pClass(this));

  bool dbClub = table.getInternalName() != TB_CLUBS;
  bool canEdit =  dbClub ? !oe->isClient() : true;

  pClub it = pClub(this);
  int row = 0;
  table.set(row++, *it, TID_ID, itos(getId()), false);
  table.set(row++, *it, TID_MODIFIED, getTimeStamp(), false);

  table.set(row++, *it, TID_CLUB, getName(), canEdit);
  row = oe->oClubData->fillTableCol(*this, table, canEdit);

  if (!dbClub) {
    table.set(row++, *it, TID_NUM, itos(tNumRunners), false);
    table.set(row++, *it, TID_FEE, oe->formatCurrency(tFee), false);
    table.set(row++, *it, TID_PAID, oe->formatCurrency(tPaid), false);
  }
}
Exemple #11
0
    std::ostream &
        Dashboard::print(std::ostream & os) {
            Table myTable;
            myTable.addColumn("timername","Timer Name",Table::JUSTIFIED_LEFT,Table::JUSTIFIED_LEFT);
            myTable.addColumn("elapsed","ms",'.',Table::JUSTIFIED_MIDDLE,4);
            myTable.addColumn("average","avrg.",'.',Table::JUSTIFIED_MIDDLE,4);
            myTable.addColumn("minimum","min.",'.',Table::JUSTIFIED_MIDDLE,4);
            myTable.addColumn("maximum","max.",'.',Table::JUSTIFIED_MIDDLE,4);
            myTable.addColumn("intervals","i",Table::JUSTIFIED_RIGHT);
            myTable.addColumn("persec","i/sec",Table::JUSTIFIED_MIDDLE);
            myTable.addColumn("cycles","cyc.",Table::JUSTIFIED_RIGHT);
            printTimers(myTable);
            myTable.print(os);

            if (!_myCounters.empty()) {
                Table myCounterTable;
                myCounterTable.addColumn("countername","Counter Name",Table::JUSTIFIED_LEFT);
                myCounterTable.addColumn("count","Count",'.');
                myCounterTable.addColumn("cycles","Cycles",Table::JUSTIFIED_MIDDLE);

                for (std::map<std::string,CounterPtr>::iterator it=_myCounters.begin();
                    it != _myCounters.end(); ++it)
                {
                    myCounterTable.addRow();
                    const asl::Counter & myCounter = _myCompleteCycleCounters[it->first];
                    unsigned long myCycleCount = _myGroupCounters[myCounter.getGroup()].getCount();
                    myCounterTable.setField("countername",it->first);
                    if (myCycleCount > 1) {
                        myCounterTable.setField("count",as_string(myCounter.getCount()));
                        // we do not want an averaged counter (vs)
                        //myCounterTable.setField("count",as_string(myCounter.getCount() / myCycleCount ));
                        myCounterTable.setField("cycles",as_string(myCycleCount));
                    } else {
                        myCounterTable.setField("count",as_string(myCounter.getCount()));
                        myCounterTable.setField("cycles","incomplete");
                    }
                }
                myCounterTable.print(os);
            }
            return os;
    }
Exemple #12
0
    void
        Dashboard::printTimers(Table & theTable, TimerPtr theParent, const std::string & theIndent) {

            for (unsigned i = 0; i < _mySortedTimers.size(); ++i) {
                std::string & myTimerName = _mySortedTimers[i].first;
                TimerPtr myTimerPtr       = _mySortedTimers[i].second;

                if (myTimerPtr->getParent() == theParent) {
                    theTable.addRow();
                    theTable.setField("timername", theIndent + myTimerName);
                    unsigned long myCycleCount = _myGroupCounters[myTimerPtr->getGroup()].getCount();
                    if (myCycleCount) {
                        const asl::Timer & myTimer = _myCompleteCycleTimers[myTimerName];
                        theTable.setField("elapsed",as_string((double)(myTimer.getElapsed().micros())/1000.0/myCycleCount));
                        const asl::Counter & myCounter = myTimer.getCounter();
                        if (myCounter.getCount()>1) {
                            theTable.setField("intervals",as_string((myCounter.getCount()+1.0)/myCycleCount));
                            theTable.setField("persec",as_string(myCounter.getCount()/myTimer.getElapsed().seconds()));
                            theTable.setField("average",as_string(myTimer.getElapsed().micros()/1000.0/myCounter.getCount()));
                            theTable.setField("minimum",as_string(myTimer.getMin().micros()/1000.0));
                            theTable.setField("maximum",as_string(myTimer.getMax().micros()/1000.0));
                            theTable.setField("cycles",as_string(myCycleCount));
                        }
                    } else {
                        const asl::Timer & myTimer = *myTimerPtr;
                        const asl::Counter & myCounter = myTimer.getCounter();
                        theTable.setField("elapsed",as_string((double)(myTimer.getElapsed().micros())/1000.0));
                        if (myCounter.getCount()>1) {
                            theTable.setField("intervals",as_string(myCounter.getCount()));
                            theTable.setField("persec",as_string(myCounter.getCount()/myTimer.getElapsed().seconds()));
                            theTable.setField("average",as_string(myTimer.getElapsed().micros()/1000.0));
                        }
                        theTable.setField("cycles","incomplete");
                    }
                    printTimers(theTable, myTimerPtr, theIndent+"  ");
                }
            }
    }
void
PacketsScene::addPacket (qreal tx, qreal rx, uint32_t fromNodeId, uint32_t toNodeId, QString metaInfo, bool drawPacket)
{
  QString shortMeta = "";
  if (m_filter != AnimPacket::ALL)
    {
      bool result;
      shortMeta = AnimPacket::getMeta (metaInfo, m_filter, result, false);
      if (!result)
        return;
    }
  else
    {
      shortMeta = AnimPacket::getMeta (metaInfo, false);
    }

  QRegExp rex (m_filterRegex);
  if (rex.indexIn (metaInfo) == -1)
  {
    return;
  }

  qreal txY = 0;
  qreal rxY = 0;
  if (drawPacket && m_showGraph)
    {
      qreal fromNodeX = m_interNodeSpacing * m_lineIndex[fromNodeId];
      qreal toNodeX = m_interNodeSpacing * m_lineIndex[toNodeId];
      txY = timeToY (tx);
      rxY = timeToY (rx);

      GraphPacket * graphPacket = new GraphPacket (QPointF (fromNodeX, txY), QPointF (toNodeX, rxY));
      //addItem (graphPacket);
      m_packetPath.moveTo (graphPacket->line ().p1 ());
      m_packetPath.lineTo (graphPacket->line ().p2 ());
      qreal angle = 45;
      qreal mag = 9;
      QPointF endPoint (graphPacket->line ().p2 ());
      if (1)
        {
        if (graphPacket->line ().angle () > 270)
          {
            m_packetPath.moveTo (endPoint);
            angle += graphPacket->line ().angle ();
            //NS_LOG_DEBUG ("Angle:" << graphPacket->line ().angle () << " Final Angle:" << angle);
            m_packetPath.lineTo (endPoint.x () - mag * cos (angle * PI/180), endPoint.y () - mag * sin (angle * PI/180));
            m_packetPath.moveTo (endPoint);
            m_packetPath.lineTo (endPoint.x () - mag * cos (angle * PI/180), endPoint.y () + mag * sin (angle * PI/180));

          }
        else if (graphPacket->line ().angle () > 180)
          {
            m_packetPath.moveTo (endPoint);
            angle += 180 - graphPacket->line ().angle ();
            //NS_LOG_DEBUG ("Angle:" << graphPacket->line ().angle () << " Final Angle:" << angle);
            m_packetPath.lineTo (endPoint.x () + mag * cos (angle * PI/180), endPoint.y () - mag * sin (angle * PI/180));
            m_packetPath.moveTo (endPoint);
            m_packetPath.lineTo (endPoint.x () + mag * cos (angle * PI/180), endPoint.y () + mag * sin (angle * PI/180));
          }
        }

      m_packetPathItem->setPath (m_packetPath);

      m_packetLines.push_back (graphPacket);
      QGraphicsSimpleTextItem * info = new QGraphicsSimpleTextItem (shortMeta);
      addItem (info);
      m_packetInfoTexts.push_back (info);
      info->setFlag (QGraphicsItem::ItemIgnoresTransformations);
      info->setPos (QPointF (fromNodeX, txY));
      qreal textAngle = graphPacket->line().angle ();
      if(textAngle < 90)
        {
          textAngle = 360-textAngle;
        }
      else if (textAngle > 270)
        {
          textAngle = 360-textAngle;
        }
      else
        {
          textAngle = 180-textAngle;
          info->setPos (QPointF (toNodeX, rxY));

        }
      info->rotate (textAngle);
    }

  Table * table = PacketsMode::getInstance ()->getTable ();
  QStringList sl;
  sl << QString::number (fromNodeId)
     << QString::number (toNodeId)
     << QString::number (tx)
     << shortMeta;
  table->addRow (sl);

  if (m_showGrid && drawPacket && m_showGraph)
    {
      QGraphicsSimpleTextItem * txText = new QGraphicsSimpleTextItem (QString::number (tx));
      txText->setFlag (QGraphicsItem::ItemIgnoresTransformations);
      addItem (txText);
      txText->setPos (RULER_X, txY);
      QPen pen (QColor (200, 100, 155, 100));
      QGraphicsLineItem * horizontalTxLine = new QGraphicsLineItem (RULER_X, txY, m_interNodeSpacing * m_lineIndex.size (), txY);
      QGraphicsLineItem * horizontalRxLine = new QGraphicsLineItem (RULER_X, rxY, m_interNodeSpacing * m_lineIndex.size (), rxY);
      horizontalTxLine->setPen (pen);
      horizontalRxLine->setPen (pen);
      addItem (horizontalTxLine);
      addItem (horizontalRxLine);

      QGraphicsSimpleTextItem * rxText = new QGraphicsSimpleTextItem (QString::number (rx));
      addItem (rxText);
      rxText->setFlag (QGraphicsItem::ItemIgnoresTransformations);
      rxText->setPos (RULER_X, rxY);
      //graphPacket->setPos (QPointF (fromNodeX, txY));
      m_rulerTexts.push_back (txText);
      m_rulerTexts.push_back (rxText);
      m_horizontalRulerLines.push_back (horizontalTxLine);
      m_horizontalRulerLines.push_back (horizontalRxLine);
    }

}
Exemple #14
0
void FillerBase::setWeather2(Float temperature, 
                             Float pressure,
                             Float humidity,
                             Float windspeed, 
                             Float windaz)
{
  uInt nEntry = wEntry_.size() ;
  Int idx = -1 ;
  Vector<Float> entry( 5 ) ;
  entry[0] = temperature ;
  entry[1] = pressure ;
  entry[2] = humidity ;
  entry[3] = windspeed ;
  entry[4] = windaz ;
  for ( uInt i = 0 ; i < nEntry ; i++ ) {
    if ( allEQ( entry, wEntry_[i] ) ) {
      idx = i ;
      break ;
    }
  }
  uInt id ;
  if ( idx != -1 )
    id = wIdx_[idx] ;
  else {
    Table tab = table_->weather().table() ;
    Table subt = tab( tab.col("TEMPERATURE") == temperature     \
                      && tab.col("PRESSURE") == pressure        \
                      && tab.col("HUMIDITY") == humidity        \
                      && tab.col("WINDSPEED") == windspeed      \
                      && tab.col("WINDAZ") == windaz, 1 ) ;
    Int nrow = tab.nrow() ;
    Int nrowSel = subt.nrow() ;
    if ( nrowSel == 0 ) {
      tab.addRow( 1, True ) ;
      TableRow row( tab ) ;
      TableRecord &rec = row.record() ;
      RecordFieldPtr<casa::uInt> rfpi ;
      rfpi.attachToRecord( rec, "ID" ) ;
      *rfpi = (uInt)nrow ;
      RecordFieldPtr<casa::Float> rfp ;
      rfp.attachToRecord( rec, "TEMPERATURE" ) ;
      *rfp = temperature ;
      rfp.attachToRecord( rec, "PRESSURE" ) ;
      *rfp = pressure ;
      rfp.attachToRecord( rec, "HUMIDITY" ) ;
      *rfp = humidity ;
      rfp.attachToRecord( rec, "WINDSPEED" ) ;
      *rfp = windspeed ;
      rfp.attachToRecord( rec, "WINDAZ" ) ;
      *rfp = windaz ;
      row.put( nrow, rec ) ;
      id = (uInt)nrow ;
    }
    else {
      ROTableColumn tc( subt, "ID" ) ;
      id = tc.asuInt( 0 ) ;
    }
    wEntry_.push_back( entry ) ;
    wIdx_.push_back( id ) ;
  }
  RecordFieldPtr<uInt> mweatheridCol(row_.record(), "WEATHER_ID");
  *mweatheridCol = id;
}
/*
 * rul table :
 * ROW[0] = TOT_T
 * ROW[1] = NREC_T
 * ROW[2] = REC_T
 * ROW[3] = COPY_T
 * ROW[4] = TUPLES
 * ROW[5] = RUL NAME
 * ROW[6] = ID
 * ROW[7] = SRC
 * ROW[8] = PERFOR
 * ROW[9] = VER
 * ROW[10]= REL_NAME
 */
Table OutputProcessor::getRulTable() {
    std::unordered_map<std::string, std::shared_ptr<Relation>>& relation_map = programRun->getRelation_map();
    std::unordered_map<std::string, std::shared_ptr<Row>> rule_map;

    double tot_rec_tup = programRun->getTotNumRecTuples();
    double tot_copy_time = programRun->getTotCopyTime();

    for (auto& rel : relation_map) {
        for (auto& _rul : rel.second->getRuleMap()) {
            Row row(11);
            std::shared_ptr<Rule> rul = _rul.second;
            row[1] = std::shared_ptr<CellInterface>(new Cell<double>(rul->getRuntime()));
            row[2] = std::shared_ptr<CellInterface>(new Cell<double>(0.0));
            row[3] = std::shared_ptr<CellInterface>(new Cell<double>(0.0));
            row[4] = std::shared_ptr<CellInterface>(new Cell<long>(rul->getNum_tuples()));
            row[5] = std::shared_ptr<CellInterface>(new Cell<std::string>(rul->getName()));
            row[6] = std::shared_ptr<CellInterface>(new Cell<std::string>(rul->getId()));
            row[7] = std::shared_ptr<CellInterface>(new Cell<std::string>(rel.second->getName()));
            row[8] = std::shared_ptr<CellInterface>(new Cell<long>(0));
            row[10] = std::shared_ptr<CellInterface>(new Cell<std::string>(rul->getLocator()));

            rule_map.emplace(rul->getName(), std::make_shared<Row>(row));
        }
        for (auto& iter : rel.second->getIterations()) {
            for (auto& _rul : iter->getRul_rec()) {
                std::shared_ptr<Rule> rul = _rul.second;
                if (rule_map.find(rul->getName()) != rule_map.end()) {
                    std::shared_ptr<Row> _row = rule_map[rul->getName()];
                    Row row = *_row;
                    row[2] = std::shared_ptr<CellInterface>(
                            new Cell<double>(row[2]->getDoubVal() + rul->getRuntime()));
                    row[4] = std::shared_ptr<CellInterface>(
                            new Cell<long>(row[4]->getLongVal() + rul->getNum_tuples()));
                    row[0] = std::shared_ptr<CellInterface>(new Cell<double>(rul->getRuntime()));
                    rule_map[rul->getName()] = std::make_shared<Row>(row);
                } else {
                    Row row(11);
                    row[1] = std::shared_ptr<CellInterface>(new Cell<double>(0.0));
                    row[2] = std::shared_ptr<CellInterface>(new Cell<double>(rul->getRuntime()));
                    row[3] = std::shared_ptr<CellInterface>(new Cell<double>(0.0));
                    row[4] = std::shared_ptr<CellInterface>(new Cell<long>(rul->getNum_tuples()));
                    row[5] = std::shared_ptr<CellInterface>(new Cell<std::string>(rul->getName()));
                    row[6] = std::shared_ptr<CellInterface>(new Cell<std::string>(rul->getId()));
                    row[7] = std::shared_ptr<CellInterface>(new Cell<std::string>(rel.second->getName()));
                    row[8] = std::shared_ptr<CellInterface>(new Cell<long>(rul->getVersion()));
                    row[0] = std::shared_ptr<CellInterface>(new Cell<double>(rul->getRuntime()));
                    rule_map[rul->getName()] = std::make_shared<Row>(row);
                }
            }
        }
        for (auto& _row : rule_map) {
            std::shared_ptr<Row> row = _row.second;
            Row t = *row;
            if (t[6]->getStringVal().at(0) == 'C') {
                double rec_tup = (double)(t[4]->getLongVal());
                t[3] = std::shared_ptr<CellInterface>(
                        new Cell<double>(rec_tup * tot_copy_time / tot_rec_tup));
            }
            double val = t[1]->getDoubVal() + t[2]->getDoubVal() + t[3]->getDoubVal();

            t[0] = std::shared_ptr<CellInterface>(new Cell<double>(val));

            if (t[0]->getDoubVal() != 0.0) {
                t[9] = std::shared_ptr<CellInterface>(
                        new Cell<double>(t[4]->getLongVal() / t[0]->getDoubVal()));
            } else {
                t[9] = std::shared_ptr<CellInterface>(new Cell<double>(t[4]->getLongVal() / 1.0));
            }
            _row.second = std::make_shared<Row>(t);
        }
    }

    Table table;
    for (auto& _row : rule_map) {
        table.addRow(_row.second);
    }
    return table;
}
/*
 * ver table :
 * ROW[0] = TOT_T
 * ROW[1] = NREC_T
 * ROW[2] = REC_T
 * ROW[3] = COPY_T
 * ROW[4] = TUPLES
 * ROW[5] = RUL NAME
 * ROW[6] = ID
 * ROW[7] = SRC
 * ROW[8] = PERFOR
 * ROW[9] = VER
 * ROW[10]= REL_NAME
 */
Table OutputProcessor::getVersions(std::string strRel, std::string strRul) {
    std::unordered_map<std::string, std::shared_ptr<Relation>>& relation_map = programRun->getRelation_map();
    std::unordered_map<std::string, std::shared_ptr<Row>> rule_map;

    double tot_rec_tup = programRun->getTotNumRecTuples();
    double tot_copy_time = programRun->getTotCopyTime();

    for (auto& _rel : relation_map) {
        std::shared_ptr<Relation> rel = _rel.second;
        if (rel->getId().compare(strRel) == 0) {
            for (auto& iter : rel->getIterations()) {
                for (auto& _rul : iter->getRul_rec()) {
                    std::shared_ptr<Rule> rul = _rul.second;
                    if (rul->getId().compare(strRul) == 0) {
                        std::string strTemp =
                                rul->getName() + rul->getLocator() + std::to_string(rul->getVersion());

                        if (rule_map.find(strTemp) != rule_map.end()) {
                            std::shared_ptr<Row> _row = rule_map[strTemp];
                            Row row = *_row;
                            row[2] = std::shared_ptr<CellInterface>(
                                    new Cell<double>(row[2]->getDoubVal() + rul->getRuntime()));
                            row[4] = std::shared_ptr<CellInterface>(
                                    new Cell<long>(row[4]->getLongVal() + rul->getNum_tuples()));
                            row[0] = std::shared_ptr<CellInterface>(new Cell<double>(rul->getRuntime()));
                            rule_map[strTemp] = std::make_shared<Row>(row);
                        } else {
                            Row row(10);
                            row[1] = std::shared_ptr<CellInterface>(new Cell<double>(0.0));
                            row[2] = std::shared_ptr<CellInterface>(new Cell<double>(rul->getRuntime()));
                            row[4] = std::shared_ptr<CellInterface>(new Cell<long>(rul->getNum_tuples()));
                            row[5] = std::shared_ptr<CellInterface>(new Cell<std::string>(rul->getName()));
                            row[6] = std::shared_ptr<CellInterface>(new Cell<std::string>(rul->getId()));
                            row[7] = std::shared_ptr<CellInterface>(new Cell<std::string>(rel->getName()));
                            row[8] = std::shared_ptr<CellInterface>(new Cell<long>(rul->getVersion()));
                            row[9] = std::shared_ptr<CellInterface>(new Cell<std::string>(rul->getLocator()));
                            row[0] = std::shared_ptr<CellInterface>(new Cell<double>(rul->getRuntime()));
                            rule_map[strTemp] = std::make_shared<Row>(row);
                        }
                    }
                }
            }
            for (auto row : rule_map) {
                Row t = *row.second;
                double d = tot_rec_tup;
                long d2 = t[4]->getLongVal();
                t[3] = std::shared_ptr<CellInterface>(new Cell<double>(d2 * tot_copy_time / d));
                t[0] = std::shared_ptr<CellInterface>(
                        new Cell<double>(t[1]->getDoubVal() + t[2]->getDoubVal() + t[3]->getDoubVal()));
                rule_map[row.first] = std::make_shared<Row>(t);
            }
            break;
        }
    }

    Table table;
    for (auto& _row : rule_map) {
        table.addRow(_row.second);
    }
    return table;
}