Example #1
0
//@@@ basic definitions
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Arena *w = new Arena;

    //vector<string> vec;
    w->vec.push_back("1");
    w->vec.push_back("2");
    w->vec.push_back("3");
    w->vec.push_back("4");
/*
    w->vec.push_back("5");
    w->vec.push_back("6");
    w->vec.push_back("7");
    w->vec.push_back("8");
    w->vec.push_back("9");
    w->vec.push_back("10");
    w->vec.push_back("11"); w->vec.push_back("12");w->vec.push_back("13");w->vec.push_back("14");w->vec.push_back("15");
    w->vec.push_back("16");w->vec.push_back("17");w->vec.push_back("18");w->vec.push_back("19");w->vec.push_back("20");
    w->vec.push_back("21");w->vec.push_back("22");w->vec.push_back("23");w->vec.push_back("24");w->vec.push_back("25");
    w->vec.push_back("26");w->vec.push_back("27");w->vec.push_back("28");w->vec.push_back("29");w->vec.push_back("30");
    w->vec.push_back("31");w->vec.push_back("32");w->vec.push_back("33");w->vec.push_back("34");w->vec.push_back("35");
    w->vec.push_back("36");w->vec.push_back("37");w->vec.push_back("38");w->vec.push_back("39");w->vec.push_back("40");
    w->vec.push_back("41");
    

//  ################################################################//


    
    /**********************Creating indexes ******************************/
	
	ifstream iput;
    int updateCounter=100; //to update index files
//	int n=10;	// display list size
	string str1="qvlc";
	
	int flag=0,flag1=0;
	FILE* fp;
	fp=fopen("counter.txt","r");
	if(fp==NULL)
	{
		flag=1;
	}
	else
		fclose(fp);

	if(flag==1)
	{
		int k=1;
		fp=fopen("counter.txt","w");
		fprintf(fp,"%i",k);
		fclose(fp);
	}
	else
	{
		
		iput.open("counter.txt");
		int count;
		iput>>count;
		iput.close();
		
		if(count>=updateCounter)
		{
		//	callFileList();
			flag1=1;
			count=-1;
		}
		count++;
		
		fp=fopen("counter.txt","w+");
		fprintf(fp,"%i",count);
		fclose(fp);
	}
	
	if(flag1==1 || flag==1)
	{
		fileList f1;
		f1.runner();
	}


	
    

/********************Reading files in Prefix -trie********************************/	
		Btree b1;
		b1.takeInput(str1);
		tries t2;
		callPrefixTrie(t2);

/*************************history trie*****************************************/		

		tries t1;
		callHistoryTrie(t1);
				
/**************************************************************/
		string str;
		cout<<"enter the string :"<<endl;
		//cin>>str;
		 
        //vector<fax*> inputVector;
        //inputVector=process(str,t2,t1,n);
		
/*		for(int i=0;i<star.size();i++)
		{
			cout<<star[i]->nam<<endl;
		}
*/		 
/*		fax* fax1=new fax("rhythmbox-client","##");
		show(fax1,t2,t1);
		onClose(t1);
*/
    
//##########################################################################3


    w->startArena(t1,t2, 15);

    QScrollArea scrollarea;
    scrollarea.setWidget(w);
    scrollarea.setWidgetResizable(true);
    scrollarea.viewport()->setBackgroundRole(QPalette::Dark);
    scrollarea.viewport()->setAutoFillBackground(true);
    scrollarea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    scrollarea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    scrollarea.setWindowTitle(QObject::tr("arena"));
    scrollarea.show();




    //w->show();


    return a.exec();
}
Example #2
0
		ValidationResultDialog::ValidationResultDialog(ValidationItem* item)
		{
			//return if there's no parent
			if (item == NULL)
			{
				return;
			}

			QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok,Qt::Horizontal, this);
			QPushButton* print_button = new QPushButton("Save to File", buttons);

			QVBoxLayout* mainLayout = new QVBoxLayout();
			QGroupBox* resultGroup = new QGroupBox(tr("Validation Results"),this);
			QGridLayout* layout = new QGridLayout();
			QVBoxLayout* resultGroupLayout = new QVBoxLayout();

			int type = item->getValidationType();

			if (type < 4 || type==5)
			{
				String train_fit ="R^2";
				String pred_qual="Q^2";
				String n = item->modelItem()->getRegistryEntry()->getStatName(item->getValidationStatistic());
				
				if(n!="") 
				{
					train_fit = n+"<br>on training data";
					pred_qual = "predictive<br>"+n;			
				}
				
				QLabel* rlabel = new QLabel(train_fit.c_str(),this);
				layout->addWidget(rlabel, 0,1);
				QString tmp;
				QLabel* qlabel=NULL;
				
				if(type<3)
				{
					qlabel = new QLabel(tmp.setNum(item->k())+ " fold "+pred_qual.c_str(),this);
				}
				else if(type==3) // boostrap
				{
					qlabel = new QLabel(QString(pred_qual.c_str())+" of "+tmp.setNum(item->numOfSamples())+ "\nbootstrap samples",this);
				}
				else if(type==5)
				{
					qlabel = new QLabel(tmp.setNum(item->getNoExternalFolds())+ " fold nested "+pred_qual.c_str(),this);
				}
				
				layout->addWidget(qlabel, 0,2);

				QLabel* rvaluelabel = new QLabel(QString(((String)(item->getR2())).c_str()),this);
				layout->addWidget(rvaluelabel,1,1);
				QLabel* qvaluelabel = new QLabel(QString(((String)(item->getQ2())).c_str()),this);
				layout->addWidget(qvaluelabel,1,2);

				resultGroup->setLayout(layout);
			}	
			else if (type == 4)
			{
				QString value;
				float num;

				QStringList labels;
				labels << "# Tests" << "R^2" << "Q^2";

				QTableWidget* table = new QTableWidget(item->resultOfRandTest()->rows(), 3, this);
				table->verticalHeader()->hide();
				table->setHorizontalHeaderLabels (labels);
				table->setAlternatingRowColors(true);
				table->setDragDropMode(QAbstractItemView::NoDragDrop);
				table->setEditTriggers(QAbstractItemView::NoEditTriggers);
				table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
				table->horizontalHeader()->setResizeMode(2,QHeaderView::Stretch); 
			
				for (int i = 0; i < item->resultOfRandTest()->rows();i++)
				{
					value.setNum(i);
					QTableWidgetItem* num_of_Test = new QTableWidgetItem(value);
					table->setItem(i, 0, num_of_Test);

					num = (*(item->resultOfRandTest()))(i,item->resultOfRandTest()->cols()-2);
					value.setNum(num);
					QTableWidgetItem* r = new QTableWidgetItem(value);
					table->setItem(i, 1, r);

					num = (*(item->resultOfRandTest()))(i,item->resultOfRandTest()->cols()-1);
					value.setNum(num);
					QTableWidgetItem* q = new QTableWidgetItem(value);
					table->setItem(i, 2, q);
				}

				QScrollArea* scrollArea = new QScrollArea(this);
				scrollArea->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
				scrollArea->setVerticalScrollBarPolicy ( Qt::ScrollBarAsNeeded );
				scrollArea->setFrameShape(QFrame::NoFrame);
				scrollArea->setWidget(table);
				scrollArea->setWidgetResizable(true);
			
				resultGroupLayout->addWidget(scrollArea);
				resultGroup->setLayout(resultGroupLayout);
			}
			mainLayout->addWidget(resultGroup);
			mainLayout->addWidget(buttons);
			mainLayout->addStretch(1);
			setLayout(mainLayout);	
			setWindowTitle("Validation Results for " + item->name());

			connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
			connect(print_button, SIGNAL(clicked()), this, SLOT(saveToFile()));
		}
Example #3
0
void QtUnit::mousePressEvent(QMouseEvent *event)
{
    if (event->button() != Qt::LeftButton)
        return;
    printf("[0x%08x] a=[%d,%d] p=[%d,%d] l=[%d,%d]\n",
        node, node->WasActive(), node->IsActive(),
        node->WasPredicted(), node->IsPredicted(),
        node->WasLearning(), node->IsLearning()
    );
    if (!this->IsClickable())
        return;

    QVBoxLayout *objGroupLayout = new QVBoxLayout();
    QScrollArea *objScroll = new QScrollArea(objDetail);
    objScroll->setStyleSheet("background-color: rgb(25, 25, 25);");
    objScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    objScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

    QWidget *scrollChild = new QWidget();
    QGridLayout *objGrid = new QGridLayout(scrollChild);
    objGrid->setSizeConstraint(QLayout::SetMinAndMaxSize);

    QLayout *currentLayout = NULL;
    QLayoutItem *child = NULL;
    if (objDetail) {
        if ((currentLayout = objDetail->layout())) {
            while ((child = currentLayout->takeAt(0)) != 0)
                delete child->widget();
            delete currentLayout;
        }
        
    }

    objGroupLayout->addWidget(objScroll);

    QLabel *columnPosLab = new QLabel("position: ");
    int colx = ((Column *)node)->GetX();
    int coly = ((Column *)node)->GetY();
    char posbuf[32];
    snprintf(posbuf, sizeof(posbuf), "(%d,%d)", colx, coly);
    QLabel *columnPosVal = new QLabel(posbuf);
    objGrid->addWidget(columnPosLab, 0, 0);
    objGrid->addWidget(columnPosVal, 0, 1);
    QLabel *overlapLab = new QLabel("overlap: ");
    QLabel *overlapVal = new QLabel(QString::number(((Column *)node)->GetOverlap()));
    objGrid->addWidget(overlapLab, 1, 0);
    objGrid->addWidget(overlapVal, 1, 1);

    QLabel *synapsesLab = new QLabel("synaptic details");
    objGrid->addWidget(synapsesLab, 2, 0, 1, 3);
    QLabel *idx = new QLabel("Idx");
    QLabel *coord = new QLabel("Coord");
    QLabel *firing = new QLabel("Firing");
    QLabel *perm = new QLabel("Perm");
    objGrid->addWidget(idx, 3, 0);
    objGrid->addWidget(coord, 3, 1);
    objGrid->addWidget(firing, 3, 2);
    objGrid->addWidget(perm, 3, 3);

    Column *col = (Column *)node;
    DendriteSegment *segment = col->GetProximalDendriteSegment();
    std::vector<Synapse *> syns  = segment->GetSynapses();

    for (int i=0; i<col->GetRecFieldSz(); i++) {
        char synCoordStr[32];
        memset(synCoordStr, 0, sizeof(synCoordStr));
        int x = syns[i]->GetX(), y = syns[i]->GetY();
        snprintf(synCoordStr, sizeof(synCoordStr), "(%d, %d)", x, y);
        float p = syns[i]->GetPerm();

        QLabel *synIdx = new QLabel(QString("%1: ").arg(i));
        QLabel *synCoordLab = new QLabel(synCoordStr);
        QLabel *synFiring = new QLabel(QString("%1").arg(syns[i]->IsFiring()? 1 : 0));
        QLabel *synPerm = new QLabel(QString("%1: ").arg(p));
        objGrid->addWidget(synIdx, 4+i, 0, 1, 1);
        objGrid->addWidget(synCoordLab, 4+i, 1, 1, 1);
        objGrid->addWidget(synFiring, 4+i, 2, 1, 1);
        objGrid->addWidget(synPerm, 4+i, 3, 1, 1);
    }

    // Note: must add the layout of widget before calling setWidget() or won't
    // be visible.
    objScroll->setWidget(scrollChild);
    objDetail->setLayout(objGroupLayout);
}