Beispiel #1
0
int instCycle(){
    fetchCycle();
    memoryAcessControl(getReg(IR));
    getOperands(getReg(MAR));    
    execute(getReg(IR));
    branchControl(getReg(IR));
    saveResults(getReg(MAR),getReg(MBR),getReg(MSK));
    return getReg(IR);
} 
Beispiel #2
0
// ============================================================================================
bool TestLauncher::saveResults()
{
	String tmpString( stimuliDirectory ) ;
	Time	now =  Time::getCurrentTime();
	
	tmpString += now.formatted(L"%Y-%m-%d_%H%M%S_") + subjectID + ".txt";

	return saveResults(tmpString);
}
// ######################################################################
void SimulationViewerSurpCont::save1(const ModelComponentSaveInfo& sinfo)
{
  // get the OFS to save to, assuming sinfo is of type
  // SimModuleSaveInfo (will throw a fatal exception otherwise):
  nub::ref<FrameOstream> ofs =
    dynamic_cast<const SimModuleSaveInfo&>(sinfo).ofs;

  saveResults(ofs);
}
Beispiel #4
0
Kfind::Kfind( QWidget *parent, const char *name, const char *searchPath )
    : QWidget( parent, name )
  {
    // init IO buffer
    iBuffer = 0;

    //create tabdialog
    tabDialog = new KfindTabDialog(this,"dialog",searchPath);

    //prepare window for find results
    win = new KfindWindow(this,"window");
    win->hide();  //and hide it firstly    
    winsize=1;

    connect(win ,SIGNAL(resultSelected(bool)),
	    this,SIGNAL(resultSelected(bool)));
    connect(win ,SIGNAL(statusChanged(const char *)),
	    this,SIGNAL(statusChanged(const char *)));
    connect(this,SIGNAL(deleteFile()),
	    win,SLOT(deleteFiles()));
    connect(this,SIGNAL(properties()),
	    win,SLOT(fileProperties()));
    connect(this,SIGNAL(openFolder()),
	    win,SLOT(openFolder()));
    connect(this,SIGNAL(saveResults()),
	    win,SLOT(saveResults()));
    connect(this,SIGNAL(addToArchive()),
	    win,SLOT(addToArchive()));
    connect(this,SIGNAL(open()),
	    win,SLOT(openBinding()));
    connect(parentWidget(),SIGNAL(selectAll()),
	    win,SLOT(selectAll()));
    connect(parentWidget(),SIGNAL(unselectAll()),
	    win,SLOT(unselectAll()));
    connect(parentWidget(),SIGNAL(invertSelection()),
	    win,SLOT(invertSelection()));
    connect(&findProcess,SIGNAL(processExited(KProcess *)),
	    this,SLOT(processResults()));
    connect(&findProcess,SIGNAL(receivedStdout(KProcess *, char *, int)), 
	    this, SLOT(handleStdout(KProcess *, char *, int))) ;
    
    resize(sizeHint());
    //emit haveResults(false); // we're not connectd to anything yet!?
  };
void jaspResults::complete()
{
	completeChildren();

	if(getStatus() == "running")
		setStatus("complete");

	send();
	saveResults();
}
Beispiel #6
0
void ConfigChecker::run()
{
	m_tester = new Tester(this, "configtester");

	connect(m_tester, SIGNAL(started()), this, SLOT(started()));
	connect(m_tester, SIGNAL(percentageDone(int)), this, SLOT(setPercentageDone(int)));
	connect(m_tester, SIGNAL(finished(bool)), this, SLOT(finished(bool)));
	connect(this, SIGNAL(user1Clicked()), this, SLOT(saveResults()));

	m_tester->runTests();
}
Beispiel #7
0
// Init components
void UserForm::init()
{
	connect(m_ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
	logicCore = new LogicCore(this);
	connect(m_ui->actionPreprocessing,SIGNAL(triggered()), logicCore,
			SLOT(preprocess()));
	connect(m_ui->actionSegmentation,SIGNAL(triggered()), logicCore,
			SLOT(segmentate()));
	connect(m_ui->actionRecognition,SIGNAL(triggered()), logicCore,
			SLOT(classify()));
	connect(m_ui->tbSaveResultsAs,SIGNAL(clicked()), logicCore,
			SLOT(saveResults()));
}
Beispiel #8
0
/**
* Tries all distributions ITERATIONS times
*/
void testDists(char* uniid)
{
	const unsigned int MEASURES = 5;
	const unsigned int DISTRIBUTIONS = 6;
	const unsigned int STARTSIZE = 2<<19;

	// Allocate memory for the sequences to be sorted
	unsigned int maxsize = STARTSIZE<<(MEASURES-1);
	element* data = new element[maxsize];
	element* data2 = new element[maxsize];

	double timerValue;
	unsigned int run = 0;

	// Go through all distributions
	for(int d=0;d<DISTRIBUTIONS;d++)
	{
		unsigned int testsize = STARTSIZE;

		// Go through all sizes
		for(int i=0;i<MEASURES;i++,testsize<<=1)
		{
			// Do it several times
			for(int q=0;q<ITERATIONS;q++)
			{
				// Create sequence according to distribution
				dist(data,testsize,d);
				// Store copy of sequence
				memcpy(data2,data,testsize*sizeof(element));

				int threads  =0;
				int maxblocks=0;
				int sbsize   =0;

				// Sort it
				if(gpuqsort(data,testsize,&timerValue,maxblocks,threads,sbsize,0)!=0)
				{
					printf("Error! (%s)\n",getGPUSortErrorStr());
					exit(1);
				}

				// Validate the result
				if(!validate(data2,data,testsize))
					exit(1); 

				saveResults(testsize,getDistString(d),(float)timerValue,threads,maxblocks,sbsize,uniid,0,1);
				printf("%d/%d!\n",run++,MEASURES*DISTRIBUTIONS*ITERATIONS);
			}
		}
	}
}
/* This function saves the results of a single solve() functionality
   (for the given frequency) into the output dataset. */
void acsolver::saveAllResults (nr_double_t freq) {
  vector * f;
  // add current frequency to the dependency of the output dataset
  if ((f = data->findDependency ("acfrequency")) == NULL) {
    f = new vector ("acfrequency");
    data->addDependency (f);
  }
  if (runs == 1) f->add (freq);
  saveResults ("v", "i", 0, f);

  // additionally save noise results if requested
  if (noise) {
    saveNoiseResults (f);
  }
}
Beispiel #10
0
Kfind::Kfind(QWidget *parent, const char *name) : QWidget(parent, name)
{
    kdDebug() << "Kfind::Kfind " << this << endl;
    QBoxLayout *mTopLayout = new QBoxLayout(this, QBoxLayout::LeftToRight, KDialog::marginHint(), KDialog::spacingHint());

    // create tabwidget
    tabWidget = new KfindTabWidget(this);
    mTopLayout->addWidget(tabWidget);

    /*
     * This is ugly.  Might be a KSeparator bug, but it makes a small black
     * pixel for me which is visually distracting (GS).
    // create separator
    KSeparator * mActionSep = new KSeparator( this );
    mActionSep->setFocusPolicy( QWidget::ClickFocus );
    mActionSep->setOrientation( QFrame::VLine );
    mTopLayout->addWidget(mActionSep);
    */

    // create button box
    QVBox *mButtonBox = new QVBox(this);
    QVBoxLayout *lay = (QVBoxLayout *)mButtonBox->layout();
    lay->addStretch(1);
    mTopLayout->addWidget(mButtonBox);

    mSearch = new KPushButton(KGuiItem(i18n("&Find"), "find"), mButtonBox);
    mButtonBox->setSpacing((tabWidget->sizeHint().height() - 4 * mSearch->sizeHint().height()) / 4);
    connect(mSearch, SIGNAL(clicked()), this, SLOT(startSearch()));
    mStop = new KPushButton(KGuiItem(i18n("Stop"), "stop"), mButtonBox);
    connect(mStop, SIGNAL(clicked()), this, SLOT(stopSearch()));
    mSave = new KPushButton(KStdGuiItem::saveAs(), mButtonBox);
    connect(mSave, SIGNAL(clicked()), this, SLOT(saveResults()));

    KPushButton *mClose = new KPushButton(KStdGuiItem::close(), mButtonBox);
    connect(mClose, SIGNAL(clicked()), this, SIGNAL(destroyMe()));

    // react to search requests from widget
    connect(tabWidget, SIGNAL(startSearch()), this, SLOT(startSearch()));

    mSearch->setEnabled(true); // Enable "Search"
    mStop->setEnabled(false);  // Disable "Stop"
    mSave->setEnabled(false);  // Disable "Save..."

    dirlister = new KDirLister();
}
Beispiel #11
0
int main()
{
	addLog("===========================================================");
	addLog("NWChecker started");
	string curdir=getCurrentDir();
	loadResults();
	if (parseConfig())
		return 1;
	checkAll();
	SetCurrentDirectory(curdir.c_str());
	generateHTML();
	saveResults();
	if(silentMode) {
		int i;
		cin>>i;
	}
	return 0;
}
Beispiel #12
0
/**
 * Follow the directions in the tracebackMove array to work back from the traceback's
 * starting point (remember: we are tracing back from the ends of the winning sequences)
 * to reconstruct the winning alignment.  The code computes the sequences from back to
 * front, inserting a "gap" character in each as needed to keep all the matched entries
 * aligned.  When the sequence starting points are finally arrived at, we reverse the
 * buffered aligned sequences. 
 */
void doTheTraceback(char shortSequence[], int shortLength, char longSequence[], int longLength, Output *output) {
   char nextMove;
   int i = winningShortSequenceEnd; /* i now marks the end of the winning subsequence of the shorter sequence */
   int j = winningLongSequenceEnd;  /* j marks the end of the winning subsequence of the longer sequence */
   int bufferSizeNeeded = 1+computeMaxAlignedLength(shortSequence, shortLength, longLength);
   char *shortAlignedBuffer = malloc(bufferSizeNeeded*sizeof(char)); /* buffer to hold winner with gaps */
   char *longAlignedBuffer  = malloc(bufferSizeNeeded*sizeof(char)); /*         "                       */
   char *shortAligned = shortAlignedBuffer + (bufferSizeNeeded-1);
   char *longAligned  = longAlignedBuffer  + (bufferSizeNeeded-1);
   char *shortEnd     = shortAligned;
   const char GAP = '-';
   *shortAligned-- = *longAligned-- = '\0';
   do { /*  until we are at the tracebackMove matrix boundary marked by the STOP sentinels */
      nextMove = tracebackMove(i, j, longLength);
      switch (nextMove) {
      case UP:       /* UP means we got here by HOLDING J THE SAME and adding one to I */
         *shortAligned-- = shortSequence[--i];
         *longAligned--  = GAP;
         break;
      case DIAGONAL: /* DIAGONAL means we got here by matching two elements */
         *shortAligned-- = shortSequence[--i];
         *longAligned--  = longSequence[--j];
         break;
      case LEFT:     /* LEFT means we got here by holding I the same and adding one to J */
    	 *shortAligned-- = GAP;
         *longAligned--  = longSequence[--j];
         break;
      case STOP:    /* If we move back further the score goes non-positive */
         output->shortSliceStart = i+1;
         output->shortSliceEnd   = winningShortSequenceEnd;
         output->longSliceStart  = j+1;
         output->longSliceEnd    = winningLongSequenceEnd;
         output->commonLength	 = shortEnd - shortAligned;
         saveResults(output, ++shortAligned, ++longAligned);
         free(tracebackMoves);
         free(shortAlignedBuffer);
         free(longAlignedBuffer);
        return;
      case BAD: exit(21);
      }
    } while(1);
}
Beispiel #13
0
/**
* Tries different combinations of parameters and measures each phase
*/
void testPhases(char* uniid)
{
	unsigned int testsize = 2<<22;
	element* data = new element[testsize];
	element* data2 = new element[testsize];
	double timerValue;

	unsigned int run=0;

	// Uses same distribution for all
	int d = 0;
	dist(data2,testsize,d);

	// Test different sizes
	for(testsize = 2<<18;testsize<=(2<<22)+500;testsize *= 2)  // 5
	{
		// Measure each phase
		for(int phase=0;phase<3;phase++)  // 3
			// Vary the number of threads
			for(int threads=32;threads<=256;threads*=2) // 4
				// Vary the number of blocks
				for(int maxblocks=32;maxblocks<=1024;maxblocks*=2)  // 6
					// Vary when to switch to bitonic
					for(int sbsize=64;sbsize<=2048;sbsize*=2) // 6
						// Do it several times
						for(int q=0;q<ITERATIONS;q++)
						{
							// Store a copy sequence for reuse
							memcpy(data,data2,testsize*4);

							// Sort it
							if(gpuqsort(data,testsize,&timerValue,maxblocks,threads,sbsize,phase)!=0)
							{
								printf("Error! (%s)\n",getGPUSortErrorStr());
								exit(1);
							}

							saveResults(testsize,getDistString(d),(float)timerValue,threads,maxblocks,sbsize,uniid,phase,0);
							printf("%d/%d!\n",run++,2160*ITERATIONS);
						}
	}
}
Beispiel #14
0
STDMETHODIMP CKhParser::Terminate( long* hRes )
{
    saveResults();
    if (pIXMLHTTPRequest != NULL)
        pIXMLHTTPRequest.Release();
    repl.clear();
    if (locinfo != 0) {
        _free_locale(locinfo);
        locinfo = 0;
    }
    homonyms.clear();
    currHom = -1;
    cache.clear();
    sentences.clear();
    empty.clear();
    safeArraySize = 0;
    request = L"/suddenly/?parse=";

    return S_OK;
}
Beispiel #15
0
/**
* Tries all model distributions ITERATIONS times
*/
void testModels(char* uniid)
{
	char* names[] = {"norm-dragon.dat","norm-happy.dat","norm-lucy.dat","norm-manuscript.dat","norm-rgbdragon.dat","norm-statuette.dat"};
	unsigned int run = 0;
	element* data2 = new element[16027872];

	// Try the 6 different models
	for(int i=0;i<6;i++)
	{
		// several times
		for(int q=0;q<ITERATIONS;q++)
		{
			double timerValue;
			int testsize;

			// Read sequence from file
			unsigned int* data = readModel(testsize,names[i]);
			// Store copy for later validation
			memcpy(data2,data,testsize*sizeof(element));

			int threads   =0;
			int maxblocks =0;
			int sbsize    =0;

			// Sort it
			if(gpuqsort(data,testsize,&timerValue,maxblocks,threads,sbsize,0)!=0)
			{
				printf("Error! (%s)\n",getGPUSortErrorStr());
				exit(1);
			}

			// Validate the result
			if(!validate(data2,data,testsize))
				exit(1); 
			saveResults(testsize,names[i],(float)timerValue,threads,maxblocks,sbsize,uniid,0,2);
			printf("%d/%d!\n",run++,6*ITERATIONS);
			free(data);
		}
	}
}
Beispiel #16
0
int main(int argc, char **argv)
{
    int **graph; /// graph in a whole
    int **wccs;
    int ret = -EINVAL; /// returned value
    int fd = 0;
    timeval begin, end;
    //    fd = open("sample_data6.txt", O_RDONLY);

    if (argv[1] &&
            (strcmp(argv[1], "-h") || strcmp(argv[1], "--help")))
        goto exit_help;

    ret = read_graph(fd, &graph);
    close(fd);
    if (ret < 0)
        goto exit_help;

    gettimeofday(&begin, NULL);

    wccs = generate_wccs(graph, ret);
    if (!wccs) {
        ret = -EINVAL;
        goto out;
    }

    gettimeofday(&end, NULL);
    saveResults(begin, end, get_number_vertices(graph), get_number_edges(graph));

    //    print_graph(wccs);

    free_graph(wccs);
out:
    free_graph(graph);
    return ret;
exit_help:
    print_help();
    return ret;
}
Beispiel #17
0
void MainWgt::slotGameOver(bool isWinner)
{
  placeSemkoTimer->stop();
  QApplication::processEvents();

  if (isSound()){
    moMainTheme->stop();
    moGameOver->play();
  }

  QString name = QInputDialog::getText(this,tr("Game over!"), tr("Enter your name"));
  if (name.isEmpty()){
    on_pbBackFromGame_clicked();
    return;
  }

  results.insert(ui->lcdSluzgano->intValue(), name);

  saveResults();
  updateResultsList();
  on_pbResults_clicked();
}
/* The function computes the final noise results and puts them into
   the output dataset. */
void acsolver::saveNoiseResults (vector * f) {
  int N = countNodes ();
  int M = countVoltageSources ();
  for (int r = 0; r < N + M; r++) {
    // renormalise the results
    x->set (r, fabs (xn->get (r) * sqrt (kB * T0)));
  }

  // apply probe data
  circuit * root = subnet->getRoot ();
  for (circuit * c = root; c != NULL; c = (circuit *) c->getNext ()) {
    if (!c->isProbe ()) continue;
    int np, nn;
    nr_double_t vp, vn;
    np = getNodeNr (c->getNode (NODE_1)->getName ());
    vp = np > 0 ? xn->get (np - 1) : 0.0;
    nn = getNodeNr (c->getNode (NODE_2)->getName ());
    vn = nn > 0 ? xn->get (nn - 1) : 0.0;
    c->setOperatingPoint ("Vr", fabs ((vp - vn) * sqrt (kB * T0)));
    c->setOperatingPoint ("Vi", 0.0);
  }

  saveResults ("vn", "in", 0, f);
}
Beispiel #19
0
int main(){
	// Load Movie data
	loadMovieData("../../netflix/um/qual.dta");
	//loadMovieData("../stats/probe.dta");
	printf("test %d\n", movie_data[20]);
	// printf("test %f %f %f %f\n", userOffset[5], userOffset[num_users - 1], movieOffset[5], movieOffset[num_movies - 1]);
	
	// Set up offsets
	userOffset = calloc(num_users, sizeof(float));
	movieOffset = calloc(num_movies, sizeof(float));
	if (userOffset == NULL || movieOffset == NULL) {
		printf("Malloc failed\n");
		return -1;
	}


	// Set up feature arrays for user and movies
	userFeatures = calloc(num_users, sizeof(float *));
	movieFeatures = calloc(num_movies, sizeof(float *));
	implicitFeatures = calloc(num_movies, sizeof(float *));
	userImplicitData = calloc(num_users*2, sizeof(float));
	if (userFeatures == NULL || movieFeatures == NULL || userImplicitData == NULL) {
		printf("Malloc failed\n");
		return -1;
	}


	// Load offsets
	loadData("features/f220_e050/user_offset.dta", userOffset);
	loadData("features/f220_e050/movie_offset.dta", movieOffset);

	
	// Load user implicit data
	loadUserImplicit("../stats/user_implicit_2.dta", userImplicitData);
	// Load 
	initializeImplicitMovies("../../implicit/user_implicit_movies.dta");

	// Load featuress
	loadFeatures("features/f220_e050/user_features.dta", num_users, userFeatures);
	loadFeatures("features/f220_e050/movie_features.dta", num_movies, movieFeatures);
	loadFeatures("features/f220_e050/implicit_features.dta", num_movies, implicitFeatures);
	printf("Test %f %f\n", userFeatures[1][num_features - 1], userFeatures[num_users-1][num_features-1]);

	predictions = calloc(num_lines, sizeof(float));
	if (predictions == NULL) {
		return -1;
	}

	printf("--------------Predicting --------------\n");
	int user, movie, line_number;
	int count = 0;
	float n = userImplicitData[1*2 + 1]; // get n for first user
	float feature_c;
	int temp = 0;
	for (int j = 0; j < num_lines; j++) {
		line_number = j * 2;
		user = movie_data[line_number];
		movie = movie_data[line_number + 1];
		if (temp != user) {
			n = userImplicitData[user*2 + 1];
			getImplicitC(user, n);
			temp = user;
		}
		feature_c = 0;
		for (int i = 0; i < num_features; i++) {
			feature_c += (userFeatures[user][i] + implicitC[i])* movieFeatures[movie][i];
		}
		predictions[count] = clipScore(GLOBAL_AVG + userOffset[user] + movieOffset[movie] + feature_c);
		count++;
	}
	

	printf("-----------Saving results-----------\n");
	saveResults("results/um_test_f220_e050.dta");
	
	free(userOffset);
	free(movieOffset);
	free(movie_data);
	return 0;
}
Beispiel #20
0
	bool funcCallPrologue(Thread* t, Function* func, AbsStack returnSlot, word expectedResults, AbsStack paramSlot,
		uword numParams, bool isTailcall)
	{
		if(numParams > func->maxParams)
			croc_eh_throwStd(*t, "ParamError",
				"Function %s expected at most %" CROC_SIZE_T_FORMAT " parameters but was given %" CROC_SIZE_T_FORMAT,
				func->name->toCString(), func->maxParams - 1, numParams - 1);

		if(!func->isNative)
		{
			// Script function
			auto funcdef = func->scriptFunc;
			auto ar = isTailcall ? t->currentAR : pushAR(t);

			if(isTailcall)
			{
				assert(ar && ar->func && !ar->func->isNative);
				assert(paramSlot == returnSlot + 1);

				closeUpvals(t, ar->base);
				ar->numTailcalls++;
				memmove(&t->stack[ar->returnSlot], &t->stack[returnSlot], sizeof(Value) * (numParams + 1));
				returnSlot = ar->returnSlot;
				paramSlot = returnSlot + 1;
			}

			if(funcdef->isVararg && numParams > func->numParams)
			{
				// In this case, we move the formal parameters after the varargs and null out where the formal
				// params used to be.
				ar->base = paramSlot + numParams;
				ar->vargBase = paramSlot + func->numParams;
				checkStack(t, ar->base + funcdef->stackSize - 1);
				auto oldParams = t->stack.slice(paramSlot, paramSlot + func->numParams);
				t->stack.slicea(ar->base, ar->base + func->numParams, oldParams);
				oldParams.fill(Value::nullValue);

				// For nulling out the stack.
				numParams = func->numParams;
			}
			else
			{
				// In this case, everything is where it needs to be already.
				ar->base = paramSlot;
				ar->vargBase = paramSlot;
				checkStack(t, ar->base + funcdef->stackSize - 1);
				// If we have too few params, the extra param slots will be nulled out.
			}

			// Null out the stack frame after the parameters.
			t->stack.slice(ar->base + numParams, ar->base + funcdef->stackSize).fill(Value::nullValue);

			// Fill in the rest of the activation record.
			ar->returnSlot = returnSlot;
			ar->func = func;
			ar->pc = funcdef->code.ptr;
			ar->firstResult = 0;
			ar->numResults = 0;
			ar->savedTop = ar->base + funcdef->stackSize;
			ar->unwindCounter = 0;
			ar->unwindReturn = nullptr;

			if(!isTailcall)
			{
				ar->expectedResults = expectedResults;
				ar->numTailcalls = 0;
			}

			// Set the stack indices.
			t->stackBase = ar->base;
			t->stackIndex = ar->savedTop;

			// Call any hook.
			if(t->hooks & CrocThreadHook_Call)
				callHook(t, isTailcall ? CrocThreadHook_TailCall : CrocThreadHook_Call);

			return true;
		}
		else
		{
			// Native function
			t->stackIndex = paramSlot + numParams;
			checkStack(t, t->stackIndex);

			auto ar = pushAR(t);

			ar->base = paramSlot;
			ar->vargBase = paramSlot;
			ar->returnSlot = returnSlot;
			ar->func = func;
			ar->expectedResults = expectedResults;
			ar->firstResult = 0;
			ar->numResults = 0;
			ar->savedTop = t->stackIndex;
			ar->numTailcalls = 0;
			ar->unwindCounter = 0;
			ar->unwindReturn = nullptr;

			t->stackBase = ar->base;

			if(t->hooks & CrocThreadHook_Call)
				callHook(t, CrocThreadHook_Call);

			t->vm->curThread = t;
			t->nativeCallDepth++;
			auto savedState = t->state;
			t->state = CrocThreadState_Running;
			word actualResults = func->nativeFunc(*t);
			t->state = savedState;
			t->nativeCallDepth--;

			assert(actualResults >= 0); // for now, will change in the future

			if(cast(uword)actualResults > (t->stackIndex - (t->stackBase + 1)))
				croc_eh_throwStd(*t, "ApiError", "Native function '%s' returned an invalid number of results",
					func->name->toCString());

			saveResults(t, t, t->stackIndex - actualResults, actualResults);
			callEpilogue(t);
			return false;
		}
	}
Beispiel #21
0
void FileBatch::accept()
{
    bool ok;
    int times = _times->text().toInt(&ok);
    MainWindow * main = qobject_cast<MainWindow*>(parent());
    if (!ok)
        times = 1;

    bool improve = _applyImprovement->isChecked();

    int tights = 3;
    if (!_changeTight->isChecked()) {
        tights = 1;
    }
    for(int i = 0; i < _filesList->count(); ++i) {
        QString filename = _filesList->item(i)->text();
        qDebug() << "processing: " << filename;
        double adj = 1.0;
        emit openFile(filename);


        for (int j = 0; j < tights; ++j) {
            if (_changeTight->isChecked()) {
                adj += 0.1;
                main->instance()->setTight(adj);
            }
            if (_emitReport->isChecked()) {
                InstanceInfo info(main->instance());
                QFile f("info.txt");
                if (!f.open(QIODevice::Append)) {
                    qDebug() << "Cannot open file info.txt to write.";
                } else {
                    QTextStream out(&f);
                    info.calculate();
                    out << info.report() << "\n";
                }
            }
            QString str = _times->text().replace(QRegExp("clusters"), QString::number(main->instance()->numCenters()));
            str = str.replace(QRegExp("points"), QString::number(main->instance()->numPoints()));
            QScriptEngine eng;
            QScriptValue value = eng.evaluate(str).toInt32();
            if (!eng.hasUncaughtException())
                times = value.toNumber();

            if (_farthest->isChecked()) {
                emit process(CCP::Farthest, improve, false);
            }
            if (_density->isChecked()) {
                emit process(CCP::Density, improve, false);
            }
            if (_hmeans->isChecked()) {
                for (int i = 0; i < times; ++i)
                    emit process(CCP::HMeans, improve, false);
            }
            if (_jmeans->isChecked()) {
                for (int i = 0; i < times; ++i)
                    emit process(CCP::JMeans, improve, false);
            }
            if (_densityRandom->isChecked()) {
                for (int i = 0; i < times; ++i) {
                    emit process(CCP::RandonDensity, improve, false);
                    main->improveSolution(CCP::WaveShift);
//            while (SolutionRunner::New()->isRunning())
//              usleep(100);
                }
            }
            if (_hmeansDensity->isChecked()) {
                for (int i = 0; i < times; ++i)
                    emit process(CCP::DensityHMeans, improve, false);
            }
            if (_jmeansDensity->isChecked()) {
                for (int i = 0; i < times; ++i)
                    emit process(CCP::DensityJMeans, improve, false);
            }
        }
        emit saveResults(filename.append(".out"));
    }
    QDialog::accept();
}
Beispiel #22
0
int main(int argc, const char *argv[])
{
  Json::Value options;
  char usage[] = "Usage: main [jobNum] config1 [config2 ...]";
  
  if (argc <= 1) {
    std::cerr << "Too few arguments" << std::endl;
    std::cerr << usage << std::endl;
    return 1;
  } else if ((std::string(argv[1]) == "-h") || (std::string(argv[1]) == "--help")) {
    std::cout << usage << std::endl;
    return 0;
  }
  
  unsigned int configStart = 1;
  int jobNum = -1;
  // try to interpret the first arg as a job number
  bool isJobNum = true;
  for (int i = 0; argv[1][i] != '\0'; i++) {
    if (!isdigit(argv[1][i])) {
      isJobNum = false;
      break;
    }
  }
  if (isJobNum) {
    jobNum = atoi(argv[1]);
    configStart++;
  }
  

  for (int i = configStart; i < argc; i++) {
    if (! readJson(argv[i],options)) {
      return 1;
    }
  }

  int numTrials = options.get("trials",1).asUInt();
  int startTrial = 0;
  int origNumTrials = numTrials;
  unsigned int numTrialsPerJob = options.get("trialsPerJob",1).asUInt();
  unsigned int maxNumStepsPerEpisode = options.get("maxNumStepsPerEpisode",10000).asUInt();
  
  if (jobNum < 0) {
    jobNum = 0;
  } else {
    startTrial = jobNum * numTrialsPerJob;
    numTrials = min((int)numTrialsPerJob,numTrials-startTrial);
  }
  if (numTrials <= 0) {
    std::cerr << "ERROR: insufficient number of trials: " << numTrials << std::endl;
    std::cerr << "Calculated from: jobNum: " << jobNum << " numTrialsPerJob: " << numTrialsPerJob << " numTrials: " << origNumTrials << std::endl;
    std::cerr << "Start trial should be: " << startTrial << std::endl;
    return 1;
  }
  replaceOptsDir(options);
  if (jobNum == 0)
    saveConfig(options);

  replaceOptsJob(options,boost::lexical_cast<std::string>(jobNum)); 

  unsigned int numEpisodes = options.get("numEpisodesPerTrial",1).asUInt();
  bool displayDescriptionQ = options["verbosity"].get("description",true).asBool();
  bool displaySummaryQ = options["verbosity"].get("summary",true).asBool();
  bool displayObsQ = options["verbosity"].get("observation",true).asBool();
  bool displayStepsPerEpisodeQ = options["verbosity"].get("stepsPerEpisode",true).asBool();
  bool displayStepsPerTrialQ = options["verbosity"].get("stepsPerTrial",true).asBool();
  std::string saveFilename = options["save"].get("results","").asString();
  bool saveResultsQ = (saveFilename != "");
  bool randomizeSeedQ = options.get("randomizeSeed",false).asBool();
  // running for fixed lengths
  unsigned int numStepsPerEpisode = options.get("numStepsPerEpisode",0).asUInt();
  bool runForFixedLength = (numStepsPerEpisode != 0);

  // get the output DT information
  unsigned int outputDTSteps = options["verbosity"].get("dtsteps",0).asUInt();
  std::string outputDTFilename = options["verbosity"].get("dtfile","").asString();
  bool outputDTCSVQ = (outputDTFilename != "");
  boost::shared_ptr<OutputDT> outputDT;
  boost::shared_ptr<std::vector<Action::Type> > actions;

  Observation obs;
  double startTime = getTime();

  std::vector<std::vector<unsigned int> > numSteps(numTrials,std::vector<unsigned int>(numEpisodes,0));
  std::vector<std::vector<unsigned int> > numCaptures(numTrials,std::vector<unsigned int>(numEpisodes,0));
  std::vector<std::vector<unsigned int> > *results = &numSteps;
  if (runForFixedLength)
    results = &numCaptures;

  std::cout << "Running for " << numTrials << " trials" << std::endl;
  
  unsigned int trialNum;
  unsigned int randomSeed;
  for (int trial = 0; trial < numTrials; trial++) {
    trialNum = trial + startTrial;
    if (randomizeSeedQ)
      randomSeed = getTime() * 1000000 + 1000 * getpid() + trialNum; // hopefully random enough
    else
      randomSeed = trialNum;
    //std::cout << "RANDOM SEED: " << randomSeed << std::endl;

    Json::Value trialOptions(options);
    replaceOptsTrial(trialOptions,trialNum);

    boost::shared_ptr<World> world = createWorldAgents(randomSeed,trialNum,trialOptions);
    boost::shared_ptr<const WorldModel> model = world->getModel();
    std::cout << "Ad hoc agent ind: " << model->getAdhocInd() << std::endl;

    // INITIALIZATION
    if (trial == 0) {
      if (displayDescriptionQ)
        std::cout << world->generateDescription() << std::endl;
      if (outputDTCSVQ) {
        // set up the actions
        actions = boost::shared_ptr<std::vector<Action::Type> >(new std::vector<Action::Type>(model->getNumAgents()));
        // create models for the DT csv output if required
        std::vector<std::string> modelNames;
        //modelNames.push_back("GR");
        //modelNames.push_back("TA");
        //modelNames.push_back("GP");
        //modelNames.push_back("PD");
        outputDT = boost::shared_ptr<OutputDT>(new OutputDT(outputDTFilename,model->getDims(),model->getNumAgents()-1,modelNames,true,false,outputDTSteps));
      }
    }

    if (outputDTCSVQ) {
      if (outputDT->hasCollectedSufficientData()) {
        std::cout << "WARNING: collected sufficient data, stopping with " << trial << " trials" << std::endl;
        numSteps.resize(trial);
        break;
      }
    }
    
    
    if (displayStepsPerTrialQ)
      std::cout << "trial " << std::setw(2) << trialNum << ": " << std::flush;
    
    for (unsigned int episode = 0; episode < numEpisodes; episode++) {
      world->randomizePositions();
      world->restartAgents();
      if (outputDTCSVQ) {
        // for the first step, add the observation, since it keeps a history of 1
        world->generateObservation(obs);
        outputDT->saveStep(trial,numSteps[trial][episode],obs,*actions);
      }
      while (!model->isPreyCaptured()) {
        numSteps[trial][episode]++;
        // check end conditions
        if (runForFixedLength) {
          if (numSteps[trial][episode] > numStepsPerEpisode)
            break;
        } else {
          if (numSteps[trial][episode] > maxNumStepsPerEpisode) {
            std::cerr << "TRIAL " << trial << " EPISODE " << episode << " TOO LONG" << std::endl;
            break;
          }
        }

        if (displayObsQ) {
          world->generateObservation(obs);
          std::cout << obs << std::endl;
        }
        world->step(actions);
        if (outputDTCSVQ){
          world->generateObservation(obs);  // should follow world->step so that we can extract the observed actions of the previous step
          outputDT->saveStep(trial,numSteps[trial][episode],obs,*actions);
        }

        // if we want to run for a fixed length and the prey is captured, find a new position for the prey
        if (runForFixedLength && model->isPreyCaptured()) {
          //std::cout << "Prey is captured, generating new position" << std::endl;
          world->randomizePreyPosition();
          numCaptures[trial][episode]++;
        }
      } // while the episode lasts

      if (displayObsQ) {
        world->generateObservation(obs);
        std::cout << obs << std::endl;
      }
      if (displayStepsPerEpisodeQ)
        std::cout << std::setw(3) << (*results)[trial][episode] << " " << std::flush;
    }
    if (displayStepsPerTrialQ)
      displayStepsPerTrial(displayStepsPerEpisodeQ,(*results)[trial]);

  } // end for trial
  double endTime = getTime();
  // optionally display the summary
  if (displaySummaryQ)
    displaySummary(endTime-startTime,*results);
  // optionally save the results
  if (saveResultsQ)
    saveResults(saveFilename,startTrial,*results);
  // optionally finialize the saving of data for the DT
  if (outputDTCSVQ)
    outputDT->finalizeSave(randomSeed);

  return 0;
}
Beispiel #23
0
/* This is the DC netlist solver.  It prepares the circuit list and
   solves it then. */
int dcsolver::solve (void) {
  // fetch simulation properties
  saveOPs |= !strcmp (getPropertyString ("saveOPs"), "yes") ? SAVE_OPS : 0;
  saveOPs |= !strcmp (getPropertyString ("saveAll"), "yes") ? SAVE_ALL : 0;
  char * solver = getPropertyString ("Solver");

  // initialize node voltages, first guess for non-linear circuits and
  // generate extra circuits if necessary
  init ();
  setCalculation ((calculate_func_t) &calc);

  // start the iterative solver
  solve_pre ();

  // choose a solver
  if (!strcmp (solver, "CroutLU"))
    eqnAlgo = ALGO_LU_DECOMPOSITION_CROUT;
  else if (!strcmp (solver, "DoolittleLU"))
    eqnAlgo = ALGO_LU_DECOMPOSITION_DOOLITTLE;
  else if (!strcmp (solver, "HouseholderQR"))
    eqnAlgo = ALGO_QR_DECOMPOSITION;
  else if (!strcmp (solver, "HouseholderLQ"))
    eqnAlgo = ALGO_QR_DECOMPOSITION_LS;
  else if (!strcmp (solver, "GolubSVD"))
    eqnAlgo = ALGO_SV_DECOMPOSITION;

  // local variables for the fallback thingies
  int retry = -1, error, fallback = 0, preferred;
  int helpers[] = {
    CONV_SourceStepping,
    CONV_GMinStepping,
    CONV_SteepestDescent,
    CONV_LineSearch,
    CONV_Attenuation,
    -1 };

  // is a certain convergence helper requested?
  char * helper = getPropertyString ("convHelper");
  convHelper = CONV_None;
  if (!strcmp (helper, "LineSearch")) {
    convHelper = CONV_LineSearch;
  } else if (!strcmp (helper, "SteepestDescent")) {
    convHelper = CONV_SteepestDescent;
  } else if (!strcmp (helper, "Attenuation")) {
    convHelper = CONV_Attenuation;
  } else if (!strcmp (helper, "gMinStepping")) {
    convHelper = CONV_GMinStepping;
  } else if (!strcmp (helper, "SourceStepping")) {
    convHelper = CONV_SourceStepping;
  }
  preferred = convHelper;

  if (!subnet->isNonLinear ()) {
    // Start the linear solver.
    convHelper = CONV_None;
    error = solve_linear ();
  }
  else do {
    // Run the DC solver once.
    try_running () {
      applyNodeset ();
      error = solve_nonlinear ();
#if DEBUG
      if (!error) {
	logprint (LOG_STATUS,
		  "NOTIFY: %s: convergence reached after %d iterations\n",
		  getName (), iterations);
      }
#endif /* DEBUG */
      if (!error) retry = -1;
    }
    // Appropriate exception handling.
    catch_exception () {
    case EXCEPTION_NO_CONVERGENCE:
      pop_exception ();
      if (preferred == helpers[fallback] && preferred) fallback++;
      convHelper = helpers[fallback++];
      if (convHelper != -1) {
	logprint (LOG_ERROR, "WARNING: %s: %s analysis failed, using fallback "
		  "#%d (%s)\n", getName (), getDescription (), fallback,
		  getHelperDescription ());
	retry++;
	restart ();
      }
      else {
	retry = -1;
      }
      break;
    default:
      // Otherwise return.
      estack.print ();
      error++;
      break;
    }
  } while (retry != -1);

  // save results and cleanup the solver
  saveOperatingPoints ();
  saveResults ("V", "I", saveOPs);

  solve_post ();
  return 0;
}
Beispiel #24
0
int main(){
	// Load Movie data
	loadMovieData("../../netflix/um/all_ut.dta");
	//loadMovieData("../stats/probe.dta");
	printf("test %d\n", movie_data[20]);
	// printf("test %f %f %f %f\n", userOffset[5], userOffset[num_users - 1], movieOffset[5], movieOffset[num_movies - 1]);
	
	// Set up offsets
	userOffset = calloc(num_users, sizeof(float));
	movieOffset = calloc(num_movies, sizeof(float));
	
	if (userOffset == NULL || movieOffset == NULL) {
		printf("Malloc failed\n");
		return -1;
	}


	// Set up feature arrays for user and movies
	userFeatures = calloc(num_users, sizeof(float *));
	movieFeatures = calloc(num_movies, sizeof(float *));
	implicitFeatures = calloc(num_movies, sizeof(float *));
	userImplicitData = calloc(num_users*2, sizeof(float));
	itemBinBias = calloc(num_movies, sizeof(float *));
	userAlphas = calloc(num_users, sizeof(float));
	if (userFeatures == NULL || movieFeatures == NULL || userImplicitData == NULL) {
		printf("Malloc failed\n");
		return -1;
	}


	// Load offsets
	loadData("features/f050_e030/user_offset.dta", userOffset);
	loadData("features/f050_e030/movie_offset.dta", movieOffset);
	loadData("features/f050_e030/user_alphas.dta", userAlphas);
	// Load item bin bias
	loadFileAvg("../stats/user_date_avg.dta");
	loadUserDev("../stats/user_date_dev.dta", "features/f050_e030/user_time_bias.dta");
	
	
	// Load user implicit data
	loadUserImplicit("../stats/user_implicit_2.dta", userImplicitData);
	// Load 
	initializeImplicitMovies("../../implicit/user_implicit_movies.dta");

	// Load featuress
	loadFeatures("features/f050_e030/user_features.dta", num_users, num_features, userFeatures);
	loadFeatures("features/f050_e030/movie_features.dta", num_movies, num_features, movieFeatures);
	loadFeatures("features/f050_e030/implicit_features.dta", num_movies, num_features, implicitFeatures);
	loadFeatures("features/f050_e030/item_bin_bias.dta", num_movies, num_time_bins, itemBinBias);
	printf("Test %f %f\n", userFeatures[1][num_features - 1], userFeatures[num_users-1][num_features-1]);

	predictions = calloc(num_lines*3, sizeof(float));
	if (predictions == NULL) {
		return -1;
	}

	printf("--------------Predicting --------------\n");
	int user, movie, line_number, item_bin, date, rating;
	int count = 0;
	int user_date_count = -1;
	float n = userImplicitData[1*2 + 1]; // get n for first user
	float feature_c, alpha, dev, user_time_b;
	int temp = 0;
	int date_temp = 0;
	for (unsigned int j = 0; j < total_size; j++) {
			line_number = j * 4;
			user = movie_data[line_number];
			movie = movie_data[line_number  + 1];
			date = movie_data[line_number   + 2];
			rating = movie_data[line_number + 3];
			if (temp != user) {
				// update implict feature for previous user
				n = userImplicitData[user*2 + 1];
				getImplicitC(user, n);
				temp = user;
				date_temp = 0;
				user_date_count = -1;
			} 
			// Update different date count
			if (date != date_temp) {
				//printf("date %d ", date);
				user_date_count ++;
				date_temp = date;
			}
			// if not in test set continue
			if (rating != 0) {
				continue;
			}

			// Get contribution from each feature
			feature_c = 0;
			for (unsigned int i = 0; i < num_features; i++) {
				feature_c += (userFeatures[user][i] + implicitC[i])* movieFeatures[movie][i];
			}
			//printf("user %d movie %d date %d user_date_count %d rating %d total dates %d\n",
			//	user, movie, date, user_date_count, rating, (int) timeAvg[user]);
			// Get user time bias and alpha
			alpha = userAlphas[user];
			dev = userDev[user][(user_date_count)*2];
			user_time_b = userDev[user][(user_date_count)*2 +1];
			// Get item bin number and bias
			item_bin = (int) floor(date / 75.0);
			predictions[count] = user;
			predictions[count + 1] = movie;
			predictions[count + 2] = (GLOBAL_AVG + userOffset[user] + movieOffset[movie] 
				+ itemBinBias[movie][item_bin] + alpha*dev + user_time_b + feature_c);
			count += 3;
		}
	

	printf("-----------Saving results-----------\n");
	saveResults("results/ut_test_f050_e030.dta");

	free(userOffset);
	free(movieOffset);
	free(movie_data);
	return 0;
}
Beispiel #25
0
void KfindTop::menuInit()
  {
    KStdAccel stdAccel;

    _fileMenu   = new QPopupMenu;
    _editMenu   = new QPopupMenu;
    _optionMenu = new QPopupMenu;
    _helpMenu   = new QPopupMenu;        

    fileStart = _fileMenu->insertItem(i18n("&Start search"), _kfind,
			      SLOT(startSearch()), stdAccel.find());
    fileStop = _fileMenu->insertItem(i18n("S&top search"), _kfind,
			      SLOT(stopSearch()), Key_Escape);    
    _fileMenu->setItemEnabled(fileStop, FALSE);
    _fileMenu->insertSeparator();

    openWithM  = _fileMenu->insertItem(i18n("&Open"),
				       this,SIGNAL(open()), stdAccel.open());
    toArchM    = _fileMenu->insertItem(i18n("&Add to archive"),
				       this,SIGNAL(addToArchive()));
    _fileMenu             ->insertSeparator();
    deleteM    = _fileMenu->insertItem(i18n("&Delete"),
				       this,SIGNAL(deleteFile()));
    propsM     = _fileMenu->insertItem(i18n("&Properties"),
				       this,SIGNAL(properties()));
    _fileMenu             ->insertSeparator();
    openFldrM  = _fileMenu->insertItem(i18n("Open Containing &Folder"),
				       this,SIGNAL(openFolder()));
    _fileMenu             ->insertSeparator();
    saveSearchM= _fileMenu->insertItem(i18n("&Save Search"),
				       this,SIGNAL(saveResults()),stdAccel.save());
    _fileMenu             ->insertSeparator();
    quitM      = _fileMenu->insertItem(i18n("&Quit"),qApp,
				       SLOT(quit()),stdAccel.quit());

    for(int i=openWithM;i>quitM;i--)
       _fileMenu->setItemEnabled(i,FALSE);  
   
    int undo =       _editMenu->insertItem(i18n("&Undo"),
					   this, SIGNAL(undo()), stdAccel.undo() );
    _editMenu                 ->insertSeparator();
    int cut  =       _editMenu->insertItem(i18n("&Cut"),
					   this, SIGNAL(cut()), stdAccel.cut() );
    editCopy =       _editMenu->insertItem(i18n("&Copy"),
					   this, SLOT(copySelection()), stdAccel.copy() );
    _editMenu->insertSeparator();
    editSelectAll = _editMenu->insertItem(i18n("&Select All"),
					   this,SIGNAL(selectAll()) );
    editUnselectAll = _editMenu->insertItem(i18n("Unse&lect All"),
					   this,SIGNAL(unselectAll()) );
    editInvertSelection = _editMenu->insertItem(i18n("&Invert Selection"),
					   this,SIGNAL(invertSelection()) );

    _editMenu->setItemEnabled( undo      , FALSE );
    _editMenu->setItemEnabled( cut       , FALSE );
    _editMenu->setItemEnabled( editCopy  , FALSE );
    _editMenu->setItemEnabled( editSelectAll, FALSE );
    _editMenu->setItemEnabled( editUnselectAll, FALSE );
    _editMenu->setItemEnabled( editInvertSelection, FALSE ); 

    CHECK_PTR( _optionMenu ); 

    _optionMenu->insertItem(i18n("&Preferences ..."),
			    this,SLOT(prefs()));
    //_optionMenu->insertItem("Configure key bindings",this,SIGNAL(keys()));

    QString tmp;
    tmp.sprintf(i18n("KFind %s\nFrontend to find utility\nMiroslav Flídr <*****@*****.**>\n\nSpecial thanks to Stephan Kulow\n<*****@*****.**>"),
                KFIND_VERSION);
    _helpMenu=kapp->getHelpMenu( true, tmp );    

    _mainMenu = new KMenuBar(this, "_mainMenu");
    _mainMenu->insertItem( i18n("&File"), _fileMenu);
    _mainMenu->insertItem( i18n("&Edit"), _editMenu);
    _mainMenu->insertItem( i18n("&Options"), _optionMenu);
    _mainMenu->insertSeparator();
    _mainMenu->insertItem( i18n("&Help"), _helpMenu );
  };
Beispiel #26
0
void KfindTop::toolBarInit()
  {
    KIconLoader *loader = kapp->getIconLoader();
    QPixmap icon;

    icon = loader->loadIcon("search.xpm");
    _toolBar->insertButton( icon, 0, SIGNAL(clicked()),
			    _kfind, SLOT(startSearch()),
			    TRUE, i18n("Start Search"));

    icon = loader->loadIcon("reload.xpm");
    _toolBar->insertButton( icon, 1, SIGNAL(clicked()),
			    _kfind, SLOT(newSearch()),
			    TRUE, i18n("New Search"));

    icon = loader->loadIcon("stop.xpm");
    _toolBar->insertButton( icon, 2, SIGNAL(clicked()),
			    _kfind, SLOT(stopSearch()),
			    FALSE, i18n("Stop Search"));

    _toolBar->insertSeparator();


    icon = loader->loadIcon("openfile.xpm");
    _toolBar->insertButton( icon, 3,SIGNAL(clicked()),
			    _kfind,SIGNAL(open()),
			    FALSE, i18n("Open"));

    icon = loader->loadIcon("archive.xpm");
    _toolBar->insertButton( icon, 4,SIGNAL(clicked()),
			    _kfind,SIGNAL(addToArchive()),
			    FALSE, i18n("Add to archive"));

    icon = loader->loadIcon("delete.xpm");
    _toolBar->insertButton( icon, 5,SIGNAL(clicked()),
			    _kfind,SIGNAL(deleteFile()),
			    FALSE, i18n("Delete"));

    icon = loader->loadIcon("info.xpm");
    _toolBar->insertButton( icon, 6,SIGNAL(clicked()),
			    _kfind,SIGNAL(properties()),
			    FALSE, i18n("Properties"));

    icon = loader->loadIcon("fileopen.xpm");
    _toolBar->insertButton( icon, 7,SIGNAL(clicked()),
			    _kfind,SIGNAL(openFolder()),
			    FALSE, i18n("Open Containing Folder"));

    icon = loader->loadIcon("save.xpm");
    _toolBar->insertButton( icon, 8,SIGNAL(clicked()),
			    _kfind,SIGNAL(saveResults()),
			    FALSE, i18n("Save Search Results"));

    _toolBar->insertSeparator();
    icon = loader->loadIcon("contents.xpm");
    _toolBar->insertButton( icon, 9, SIGNAL( clicked() ),
			  kapp, SLOT( appHelpActivated() ),
			  TRUE, i18n("Help"));

    icon = loader->loadIcon("exit.xpm");
    _toolBar->insertButton( icon, 10, SIGNAL( clicked() ),
                          KApplication::getKApplication(), SLOT( quit() ),  
			  TRUE, i18n("Quit"));
  };
Beispiel #27
0
KfindTop::KfindTop(const char *searchPath) : KTopLevelWidget()
  {
//     setCaption(QString("KFind ")+KFIND_VERSION);

    _toolBar = new KToolBar( this, "_toolBar" );
    _toolBar->setBarPos( KToolBar::Top );      
    _toolBar->show();
    enableToolBar( KToolBar::Show, addToolBar( _toolBar ) );

    _kfind = new Kfind(this,"dialog",searchPath);   
    setView( _kfind, FALSE );
    _kfind->show();

    menuInit();
    toolBarInit();

    setMenu(_mainMenu);
    _mainMenu->show();

    //_mainMenu->enableMoving(false);

    _statusBar = new KStatusBar( this, "_statusBar");
    _statusBar->insertItem("0 file(s) found", 0);
    _statusBar->enable(KStatusBar::Hide);
    setStatusBar( _statusBar );

    connect(_kfind,SIGNAL(haveResults(bool)),
            this,SLOT(enableSaveResults(bool)));
    connect(_kfind,SIGNAL(resultSelected(bool)),
	    this,SLOT(enableMenuItems(bool)));
    connect(this,SIGNAL(deleteFile()),
 	    _kfind,SIGNAL(deleteFile()));
    connect(this,SIGNAL(properties()),
 	    _kfind,SIGNAL(properties()));
    connect(this,SIGNAL(openFolder()),
 	    _kfind,SIGNAL(openFolder()));
    connect(this,SIGNAL(saveResults()),
 	    _kfind,SIGNAL(saveResults()));
    connect(this,SIGNAL(addToArchive()),
 	    _kfind,SIGNAL(addToArchive()));
    connect(this,SIGNAL(open()),
 	    _kfind,SIGNAL(open()));
    connect(_kfind ,SIGNAL(statusChanged(const char *)),
	    this,SLOT(statusChanged(const char *)));
    connect(_kfind ,SIGNAL(enableSearchButton(bool)),
	    this,SLOT(enableSearchButton(bool)));
    connect(_kfind ,SIGNAL(enableStatusBar(bool)),
            this,SLOT(enableStatusBar(bool)));

// No, No, No!!! This is pointless!   (sven)
//    connect(_mainMenu ,SIGNAL(moved(menuPosition)),
//    	    this,SLOT(resizeOnFloating()));
//    connect(_toolBar ,SIGNAL(moved(BarPosition)),
//    	    this,SLOT(resizeOnFloating()));

    //_width=(440>_toolBar->width())?440:_toolBar->width();
    _width=520;
    //_height=(_kfind->sizeHint()).height(); // Unused as far as I can tell

// Fixed and Y-fixed guys:  Please, please, please stop setting fixed size
// on KTW! Fix it on your main view!
//                                     sven

    this->enableStatusBar(false); // _kfile emited before connected (sven)

   }; // and what's this semi-colon for? Grrrr!!!! (sven, too)