Exemplo n.º 1
0
void raw2()
{
    typedef double Scalar;
    
    Experiment<Scalar> *x = new LorenzExperiment();
//    RungeKutta4 *rk4 = dynamic_cast<RungeKutta4*>(x->integrator);
//    rk4->setRealParamValue("stepSize", .001);
    x->setIntegrator("rk4");
    std::cout << x->integrator->getName() << std::endl;
    
    
    std::cout << "New Vector\n";
    DTS::Vector<Scalar> v(4), v2(4);
    v[0] = 1;
    v[1] = 1;
    v[2] = 1;
    v[3] = 0;

    for (int i =0; i < 100000000; i++) {        
//    for (int i =0; i < 10; i++) {        
        x->integrator->step( v, v2 );
        v2 += v;
        v = v2;
    }
    std::cout << v2 << std::endl;
    x->model->printRealParams();
    
    delete x;

}
Exemplo n.º 2
0
void MainWindowImpl::openModel(QTreeWidgetItem *item) {	
  Experiment *experiment = new Experiment("/home/ahlatimer/vset");
  std::vector<Model> models = experiment->getModels();
  
  std::string model_type = "";
  std::string iteration = "";
  std::string step = "";
  
  if(item->text(0) == "Coverage") {
    model_type = "icov";
  } else if(item->text(0) == "Time") {
    model_type = "time";
  } else if(item->text(0) == "Vel Perturbation") {
    model_type = "dusum";
  } else if(item->text(0) == "Smoother 1") {
    model_type = "velaa";
  } else if(item->text(9) == "Smoother 2") {
    model_type = "dvaa";
  }
  
  for(int i = 0; i < models.size(); i++) {
    iteration = intToString(models[i].getIteration());
    step = intToString(models[i].getStep());
    if(models[i].getName() == model_type && item->text(1) == QString::fromStdString(iteration) && item->text(2) == QString::fromStdString(step)) {
      models[i].render();
      return;
    }
  }
}
Exemplo n.º 3
0
	// function that reads in data from file into data maps
	static bool readFromFile(DataManager<T>& data, 
						     const std::string& dataPath) {
		// declare vector for saving file names
		std::vector<std::string> fileList;
        try {
			// get file list
			getFileList(fileList, dataPath);
			// count number of files
			size_t noOfFiles{fileList.size()};
			// loop through all files
			for (size_t i{}; i < noOfFiles; ++i) {
				// declare experiment object
				Experiment<T> userExperiment;
				// pass file name to experiment read from file function
				userExperiment.readFromFile(fileList[i]);
				// insert data into maps
				data.insertExperiment(userExperiment);
			}  
        }
        catch (const std::invalid_argument& e) {
            ErrorMsg::print(e.what());
            return false;
        }
        return true;
	}	
Exemplo n.º 4
0
	// function that reads in data from screen into data maps
	static bool readFromScreen(DataManager<T>& data) {
		bool finished{false};
		while (!finished) {
			// declare experiment object
			Experiment<T> experiment;
			try {
				// call read from screen function
				experiment.readFromScreen();
			}
	        catch (const std::invalid_argument& e) {
	            ErrorMsg::print(e.what());
	            return false;
	        }
			// insert data into maps
			data.insertExperiment(experiment);
			ScreenMsg::print("Type <y> to add another experiment ");
			ScreenMsg::print("or any other letter to finish >> ");
	        std::string reply{getInput<std::string>()};
	        // convert to uppercase letters in case user used upper case
    		std::transform(reply.begin(), reply.end(), reply.begin(), ::toupper);
    		// check reply
	        if (reply == "Y") {
	            continue;
	        } else {
	            finished = true;
	            break;           
	        }
		}
		return true;
	}	
Exemplo n.º 5
0
//SELECTION
void Viewer::postSelection(const QPoint& point){
    int experimentState=0;
    // Compute orig and dir, used to draw a representation of the intersecting line
    //camera()->convertClickToLine(point, orig, dir);
        
    
    //Click and returns the state of the experiment:
    //- 0: The Experiment doesn't have started
    //- 1: The Experiment has started, shows the current block
    //- 2: Finished Experiment, doesn't show anything
    experimentState=exper.click(point);
    
    if(experimentState==2){
        thanks();
    }
    
    
    addMessage("click x: ",point.x(),2);
    addMessage("click y: ",point.y(),3);
    
    clicks++;
    addMessage("Clicks: ",clicks,4);
    
    addMessage("Experiment state: ",experimentState,5);
    
    addMessage("Block: ",exper.getCurrentBlock(),6);
    addMessage("Trial: ",exper.getCurrentTrial(),7);
    
}
Exemplo n.º 6
0
double run_experiment(const Experiment & experiment, Generator gen, int n)
{
  generic_counter<std::vector<int> > v(experiment.classes());
  experiment.run(gen, v, n);
  return chi_square_value(v.begin(), v.end(),
                          std::bind1st(std::mem_fun_ref(&Experiment::probability), 
                                       experiment));
}
int main(int argc, char *argv[]){
  if(argc!=2){
    cerr<<"Argument 1 required"<<endl;
    return -1;
  }

  if(SRAND_ON){
    srand(time(NULL));
  }

  vector<string> server_list = SERVER_LIST; //{"10.129.26.246:8091", "10.129.28.141:8091", "10.129.26.81:8091"};

  vector<string> key = DataSetGenerator::getRandomStrings(DATASET_SIZE,KEY_SIZE);
  vector<string> value = DataSetGenerator::getRandomStrings(DATASET_SIZE,VALUE_SIZE);

  int thread_count = THREAD_COUNT;
  int run_time = RUN_TIME;
  vector<string> conn = CONN;
  Experiment e = Experiment(key, value, conn, thread_count, run_time,DIST==ZIPF); //vector<string> &k, vector<string> &v, string con, int tc, int rt, int dist

  string sep="/";
  string DATE=currentDateTime("%Y-%m-%d");
  string iter_num = string(argv[1]);
  string folder=string(DS)+sep+DATE+sep+"TC"+to_string(thread_count)+sep+iter_num+sep;
  cout<<folder<<endl;
  system((string("mkdir -p ")+folder).c_str());
  SystemMonitor sm(server_list,folder);

  // e.setReadProb(0.5);
  // e.runExperiment(folder + "RP_"+to_string(e.getReadProb()));
  //
  // e.setReadProb(1);
  // e.runExperiment(folder + "RP_"+to_string(e.getReadProb()));

  sm.startMonitoring();
  e.setReadProb(READPROB);
  e.runExperiment(folder + "RP_"+to_string(e.getReadProb()));
  sm.stopMonitoring();

  // sm.startMonitoring();
  // e.setReadProb(0.95);
  // e.runExperiment(folder + "RP_"+to_string(e.getReadProb()));
  // sm.stopMonitoring();

  // long num_cpus = std::thread::hardware_concurrency();
  // string detailes = "CPU count, CPU util, NW rx(KBps), NW tx(KBps), NW util, Mem Size, Mem util, Disk util, Page Faults";

  return 0;
}
Exemplo n.º 8
0
int main()
{
	printf("Running EagleTree\n");
	set_small_SSD_config();
	string name  = "/demo_output/";
	Experiment::create_base_folder(name.c_str());
	Experiment* e = new Experiment();
	Workload_Definition* workload = new Example_Workload();
	e->set_workload(workload);
	e->set_io_limit(1000000);
	e->run("test");
	e->draw_graphs();
	delete workload;
	return 0;
}
Exemplo n.º 9
0
void ExperimentController::calculateEstimatedDuration()
{
    Experiment experiment = this->experiment();
    double duration = (boost::posix_time::microsec_clock::local_time() - experiment.startedAt()).total_milliseconds() - (experiment.pausedDuration() * 1000);
    double previousTargetTemp = HeatBlockInstance::getInstance()->temperature();

    do
    {
        Stage *stage = experiment.protocol()->currentStage();
        std::time_t holdTime = stage->currentStep()->holdTime();

        double temperature = stage->currentStep()->temperature();

        if (stage->autoDelta() && stage->currentCycle() > stage->autoDeltaStartCycle())
        {
            holdTime += stage->currentStep()->deltaDuration() * (stage->currentCycle() - stage->autoDeltaStartCycle());

            if (holdTime < 0)
                holdTime = 0;

            temperature += stage->currentStep()->deltaTemperature() * (stage->currentCycle() - stage->autoDeltaStartCycle());

            if (temperature < HeatBlockInstance::getInstance()->minTargetTemperature())
                temperature = HeatBlockInstance::getInstance()->minTargetTemperature();
            else if (temperature > HeatBlockInstance::getInstance()->maxTargetTemperature())
                temperature = HeatBlockInstance::getInstance()->maxTargetTemperature();
        }

        double rate = stage->currentRamp()->rate();
        rate = rate > 0 && rate <= kDurationCalcHeatBlockRampSpeed ? rate : kDurationCalcHeatBlockRampSpeed;

        if (previousTargetTemp < temperature)
            duration += (((temperature - previousTargetTemp) / rate) + holdTime) * 1000;
        else
            duration += (((previousTargetTemp - temperature) / rate) + holdTime) * 1000;

        previousTargetTemp = temperature;
    }
    while (experiment.protocol()->advanceNextStep());

    {
        Poco::RWLock::ScopedWriteLock lock(*_machineMutex);
        _experiment.setEstimatedDuration(std::round(duration / 1000));
    }
}
Exemplo n.º 10
0
bool ExperimentModel::insertRow(int row, Experiment& e, const QModelIndex & parent)
{
	beginInsertRows(parent, row, row);
	if(row > qExpMap.size() || row < 0)
		return false;
	qExpMap[e.getName()] = &e;
	endInsertRows();

	return  true;
}
void ScenarioConverter::PrintNthExperiment( int n )
{
  char old_start, old_goal;
  int start_x, start_y, goal_x, goal_y;
  Experiment exp = this->scen->GetNthExperiment( n );
  start_x = exp.GetStartX();
  start_y = exp.GetStartY();
  goal_x = exp.GetGoalX();
  goal_y = exp.GetGoalY();
  old_start = this->map[start_y][start_x];
  old_goal = this->map[goal_y][goal_x];
  this->map[start_y][start_x] = '@';
  this->map[goal_y][goal_x] = '*';

  this->PrintMap();

  this->map[start_y][start_x] = old_start;
  this->map[goal_y][goal_x] = old_goal;
}
Exemplo n.º 12
0
 /// @brief Evaluation of the metric in CPU cycles
 template<typename Experiment> inline
 double operator() ( Experiment const& e
                   , std::string const& name
                   , details::times_set const&
                   , details::cycles_set const& c
                   ) const
 {
   double m = Stat::evaluate(c) / e.size();
   details::measures_map[details::identify_result(name,e,*this)] = m;
   return m;
 }
ScenarioConverter::ScenarioConverter( ScenarioLoader *scen )
{
  this->scen = scen;
  ifstream in;
  char scrap[256], type[256];
  int rows, columns, i, j;

  Experiment exp = scen->GetNthExperiment( 0 );
  
  /*cout << "map " << exp.GetMapName() << "\n";*/

  in.open( exp.GetMapName(), ifstream::in );
  in >> scrap; 
  in >> type;
  in >> scrap;
  in >> rows;
  in >> scrap;
  in >> columns;
  in >> scrap;

  /*cout << "type " << type << "\n";
  cout << "rows " << rows << "\n";
  cout << "columns " << columns << "\n";*/

  this->rows = rows;
  this->columns = columns;
  this->map = (char**)malloc( sizeof(char*) * rows );

  for( i = 0; i < rows; i++ )
    this->map[i] = (char*)malloc( sizeof(char) * columns );

  in.get(); /*newline*/
  for( i = 0; i < rows; i++ )
  {
    for( j = 0; j < columns; j++ )
      this->map[i][j] = in.get();
    in.get(); /*newline*/
  }
}
Exemplo n.º 14
0
int main()
{
	printf("Running EagleTree\n");
	set_small_SSD_config();
//	set_big_SSD_config();

	//gogo greedy
	// GARBAGE_COLLECTION_POLICY = 0;
	// string name  = "/greedy_demo_output/";

	// gogo LRU
	GARBAGE_COLLECTION_POLICY = 1;
	string name  = "/lru_demo_output/";

	//gogo dj
//		GARBAGE_COLLECTION_POLICY = 2;
//	string name  = "/demo_output_500/";


	FTL_DESIGN = 1;	// using DFTL
	SCHEDULING_SCHEME = 7;
	PRINT_LEVEL = 0;
	MAX_SSD_QUEUE_SIZE = 16;
	ftl_cache::CACHED_ENTRIES_THRESHOLD = pow(2,15);		// SRAM fitting 256 kb, or 2^25 entries,
	DFTL::ENTRIES_PER_TRANSLATION_PAGE = 128;

	Experiment::create_base_folder(name.c_str());
	Experiment* e = new Experiment();
	Workload_Definition* workload = new Example_Workload();
	e->set_workload(workload);
	printf("NUMBER_OF_ADDRESSABLE_PAGES: %d  %d\n", NUMBER_OF_ADDRESSABLE_PAGES(), (int)(NUMBER_OF_ADDRESSABLE_PAGES() * OVER_PROVISIONING_FACTOR));
	e->set_io_limit(3000000);
//	e->set_io_limit(30000000);
//	e->set_io_limit(pow(2,0));
	e->run("test");
	e->draw_graphs();
	delete workload;
	return 0;
}
    void MainFrame::analyzeIndividual( wxCommandEvent& event )
    {
        int generation = generationSpinner->GetValue();
        int individual = individualSpinner->GetValue();

        string title;

        title +=
            populationFileName +
            string("_") +
            string("Generation: ") +
            toString(generation) +
            string(" Individual: ") +
            toString(individual);

        mutex *populationMutex = experimentRun.getPopulationMutex();
        {
            mutex::scoped_lock scoped_lock(*populationMutex);

            Experiment *experiment = experimentRun.getExperiment()->clone();

            shared_ptr<NEAT::GeneticIndividual> indiv(
                new NEAT::GeneticIndividual(
                    *(experimentRun.getIndividual(generation-1,individual-1).get())
                )
            );

            experiment->processIndividualPostHoc(indiv);

            if (indiv->getUserData().length())
            {
                cout_ << "PRINTING USER DATA RESULTS:\n";
                cout_ << indiv->getUserData() << endl;
            }

            delete experiment;

        }
    }
Exemplo n.º 16
0
void Viewer::draw(){
    startScreenCoordinatesSystem();
    exper.paint(width(),height());
    stopScreenCoordinatesSystem();
    cursor=falcon.getPos();
    if(falcon.getClick(0)||falcon.getClick(1)||falcon.getClick(2)||falcon.getClick(3)){
        const QPoint point((int)cursor.getX(),(int)cursor.getY());
        postSelection(point);
    }
    drawCursor();
    addMessage("Width: ",width(),0);
    addMessage("Height: ",height(),1);
    displayMessages();
}
int main() {
	cout << "Computational Exercise 4.2a)\n\nDouble Slit\n" << endl;

	DoubleSlit *slit = new DoubleSlit(62,272);
	cout << "Slit has width = " <<  slit->Width() << " nm and Distance = " << slit->Distance() <<  " nm" << endl;

	Electron *elec = new Electron(300);
	cout << "The Electron has a lambda of " << elec->Lambda() << endl;

	// Idee: Electron erzeugen
	// Winkel zuordnen nach Wahrscheinlichkeitsverteilung

	// Seeding
	srand(time(NULL));



	Experiment *expe = new Experiment(*elec,*slit);
	cout << "\nDie Minima der Intensität liegen bei: " << expe->Minima() << endl;
	expe->printEx(10000);


	cout << "\n *** Starte Experiment mit normalverteilter Spannung ***" << endl;
	// SecondExperiment(DoubleSlit slit, unsigned int numberOfElec,unsigned int numberOfBins, double U,double deltaU,
	SecondExperiment *expe2 = new SecondExperiment(*slit,10000,200,300.,10.);
	expe2->printExp();
	expe2->printNormv();


	cout << "\n +++ Finished! +++" << endl;

	delete expe;
	delete elec;
	delete slit;
	return 0;
}
Exemplo n.º 18
0
// experiments with 0, 10, ..., 100 differential heuristics
void RunExperiments1(ScenarioLoader *sl)
{
	std::vector<graphState> aPath;

	Map *m = new Map(sl->GetNthExperiment(0).GetMapName());
	m->Scale(sl->GetNthExperiment(0).GetXScale(), 
			 sl->GetNthExperiment(0).GetYScale());
	Graph *g = GraphSearchConstants::GetGraph(m);
	
	GraphDistanceHeuristic diffHeuristic(g);
	diffHeuristic.SetPlacement(kAvoidPlacement);
	
	GraphEnvironment gEnv(g, &diffHeuristic);
	gEnv.SetDirected(true);
	
	TemplateAStar<graphState, graphMove, GraphEnvironment> taNew;

	
	for (int z = 0; z <= 10; z++)
	{
		for (int x = 0; x < sl->GetNumExperiments(); x++)
		{
			Experiment e = sl->GetNthExperiment(x);

			graphState start, goal;
			start = m->GetNodeNum(e.GetStartX(), e.GetStartY());
			goal = m->GetNodeNum(e.GetGoalX(), e.GetGoalY());

			Timer t;
			t.StartTimer();
			taNew.GetPath(&gEnv, start, goal, aPath);
			t.EndTimer();

			printf("%d\t%d\t%lld\t%f\n", e.GetBucket(), diffHeuristic.GetNumHeuristics(), taNew.GetNodesExpanded(), t.GetElapsedTime());
		}
		for (int x = 0; x < 10; x++)
			diffHeuristic.AddHeuristic();
	}
	exit(0);
}
Exemplo n.º 19
0
int main()
{
	printf("Running EagleTree\n");
	set_small_SSD_config();
	string name  = "/demo_output/";
	Experiment::create_base_folder(name.c_str());
	Workload_Definition* init = new Init_Workload();
	string calibration_file = "calib.txt";
	SCHEDULING_SCHEME = 1; // use the noop IO scheduler during calibration because it's fastest in terms of real execution time
	Experiment::calibrate_and_save(init, calibration_file);
	delete init;
	Experiment* e = new Experiment();
	e->set_calibration_file(calibration_file);
	Workload_Definition* workload = new Asynch_Random_Workload();
	e->set_workload(workload);
	e->set_io_limit(1000000);
	SCHEDULING_SCHEME = 0; // use a fifo IO scheduler during the actual experiment
	e->run("test");
	e->draw_graphs();
	delete workload;
	return 0;
}
Exemplo n.º 20
0
ExperimentController::StartingResult ExperimentController::start(int experimentId)
{
    if (OpticsInstance::getInstance()->lidOpen())
        return LidIsOpen;

    Experiment experiment = _dbControl->getExperiment(experimentId);

    if (experiment.empty() || !experiment.protocol())
        return ExperimentNotFound;
    else if (experiment.startedAt() != boost::posix_time::not_a_date_time)
        return ExperimentUsed;

    experiment.setStartedAt(boost::posix_time::microsec_clock::local_time());

    if (machineState() != IdleMachineState)
        return MachineRunning;

    stopLogging();

    {
        Poco::RWLock::ScopedWriteLock lock(*_machineMutex);

        _settings.temperatureLogsState = false;
        _settings.debugTemperatureLogsState = false;

        LidInstance::getInstance()->setTargetTemperature(experiment.protocol()->lidTemperature());

        _dbControl->startExperiment(experiment);

        _machineState = LidHeatingMachineState;
        _experiment = std::move(experiment);

        LidInstance::getInstance()->setEnableMode(true);
    }

    startLogging();

    return Started;
}
Exemplo n.º 21
0
int main(int argc, char* argv[])
{
	printf("Running sequential!!\n");
	char* results_file = "";
	if (argc == 1) {
		printf("Setting big SSD config\n");
		set_big_SSD();
	}
	else if (argc == 3) {
		char* config_file_name = argv[1];
		printf("Setting config from file:  %s\n", config_file_name);
		results_file = argv[2];
		printf("results_file:  %s\n", results_file);
		load_config(config_file_name);
	}

	string name = "/exp_sequential/";
	string exp_folder = get_current_dir_name() + name;
	Experiment::create_base_folder(exp_folder.c_str());

	//set_big_SSD();
	//OVER_PROVISIONING_FACTOR = 0.70;

	Workload_Definition* workload = new File_System_With_Noise();

	OS_SCHEDULER = 1;
	vector<vector<Experiment_Result> > exps;


	Experiment* e = new Experiment();
	e->set_io_limit(200000);
	//e->set_generate_trace_file(true);
	if (argc == 1) {
		BLOCK_MANAGER_ID = 0;
		string no_locality_calibration_file = "no_locality_calibration_file.txt";
		Experiment::calibrate_and_save(workload, no_locality_calibration_file, 4 * NUMBER_OF_ADDRESSABLE_PAGES());
		e->set_calibration_file(no_locality_calibration_file);
		e->run("no_locality");

		BLOCK_MANAGER_ID = 2;
		ENABLE_TAGGING = true;
		string locality_calibration_file = "locality_calibration_file.txt";
		Experiment::calibrate_and_save(workload, locality_calibration_file);
		e->set_calibration_file(locality_calibration_file);
		e->run("locality");
	}
	else if (argc == 3 && BLOCK_MANAGER_ID == 0) {
		printf("running no locality\n");
		string no_locality_calibration_file = "no_locality_calibration_file.txt";
		e->set_calibration_file(no_locality_calibration_file);
		e->set_alternate_location_for_results_file(results_file);
		e->run("no_locality");
	}
	else if (argc == 3 && BLOCK_MANAGER_ID == 2) {
		printf("running locality\n");
		string locality_calibration_file = "locality_calibration_file.txt";
		e->set_calibration_file(locality_calibration_file);
		e->set_alternate_location_for_results_file(results_file);
		e->run("locality");
	}
	e->draw_graphs();


	delete workload;
	delete e;
	//BLOCK_MANAGER_ID = 3;
	//ENABLE_TAGGING = true;
	//Experiment_Runner::calibrate_and_save(workload, true);
	//vector<Experiment_Result> er = Experiment::simple_experiment(workload, "sequential", IO_limit, OVER_PROVISIONING_FACTOR, space_min, space_max, space_inc);
	//exps.push_back(er);

	//exp.push_back( Experiment_Runner::overprovisioning_experiment(detection_LUN, 	space_min, space_max, space_inc, exp_folder + "seq_detect_lun/",	"Seq Detect: LUN", IO_limit) );
	//exp.push_back( Experiment_Runner::simple_experiment(experiment, Init_Workload, space_min, space_max, space_inc, exp_folder + "oracle/",			"Oracle", IO_limit) );
	//exp.push_back( Experiment_Runner::overprovisioning_experiment(shortest_queues,	space_min, space_max, space_inc, exp_folder + "shortest_queues/",	"Shortest Queues", IO_limit) );

	/*Experiment_Runner::draw_graphs(exps, exp_folder);
	vector<int> num_write_thread_values_to_show;
	for (double i = space_min; i <= space_max; i += space_inc)
		num_write_thread_values_to_show.push_back(i); // Show all used spaces values in multi-graphs

	Experiment_Runner::draw_experiment_spesific_graphs(exps, exp_folder, num_write_thread_values_to_show);
	chdir(".."); // Leaving*/
	return 0;
}
Exemplo n.º 22
0
// Compare:
// * 1 random lookup of 10 with BPMX
// * 1 random lookup of 10 without BPMX
// * octile
// * max of 10 heuristics
// * 1 lookup in compressed heuristic
void RunExperiments4(ScenarioLoader *sl)
{
	std::vector<graphState> aPath;
	
	Map *m = new Map(sl->GetNthExperiment(0).GetMapName());
	m->Scale(sl->GetNthExperiment(0).GetXScale(), 
			 sl->GetNthExperiment(0).GetYScale());
	Graph *g = GraphSearchConstants::GetGraph(m);
	
	GraphMapInconsistentHeuristic diffHeuristic(m, g);
	diffHeuristic.SetPlacement(kAvoidPlacement);
	diffHeuristic.SetMode(kRandom);
	
	GraphEnvironment gEnv(g, &diffHeuristic);
	gEnv.SetDirected(true);
	
	TemplateAStar<graphState, graphMove, GraphEnvironment> taNew;

	Timer t;
	
	for (int x = 0; x < 10; x++)
		diffHeuristic.AddHeuristic();
	//diffHeuristic.SetNumUsedHeuristics(diffHeuristic.GetNumHeuristics()/10);

	for (int x = 0; x < sl->GetNumExperiments(); x++)
	{
		Experiment e = sl->GetNthExperiment(x);
		
		graphState start, goal;
		start = m->GetNodeNum(e.GetStartX(), e.GetStartY());
		goal = m->GetNodeNum(e.GetGoalX(), e.GetGoalY());
	
		
		printf("%d\t", e.GetBucket());
		
		// N memory -- 1 heuristic
		diffHeuristic.SetNumUsedHeuristics(1);
		diffHeuristic.SetMode(kMax);
		taNew.SetUseBPMX(0);

		t.StartTimer();
		taNew.GetPath(&gEnv, start, goal, aPath);
		t.EndTimer();		
		printf("%df\t%lld\t%f\t%f\t", diffHeuristic.GetNumHeuristics(),
			   taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
		
		// N memory -- 10 compressed heuristics no BPMX
		diffHeuristic.SetNumUsedHeuristics(10);
		diffHeuristic.SetMode(kCompressed);
		taNew.SetUseBPMX(0);

		t.StartTimer();
		taNew.GetPath(&gEnv, start, goal, aPath);
		t.EndTimer();		
		printf("%dc\t%lld\t%f\t%f\t", diffHeuristic.GetNumHeuristics(),
			   taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
		
		// N memory -- 10 compressed heuristics BPMX 1
		diffHeuristic.SetNumUsedHeuristics(10);
		diffHeuristic.SetMode(kCompressed);
		taNew.SetUseBPMX(1);

		t.StartTimer();
		taNew.GetPath(&gEnv, start, goal, aPath);
		t.EndTimer();		
		printf("%dcb1\t%lld\t%f\t%f\t", diffHeuristic.GetNumHeuristics(),
			   taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
		
		// N memory -- 10 compressed heuristics BPMX(°)
		diffHeuristic.SetNumUsedHeuristics(10);
		diffHeuristic.SetMode(kCompressed);
		taNew.SetUseBPMX(1000);
				
		t.StartTimer();
		taNew.GetPath(&gEnv, start, goal, aPath);
		t.EndTimer();		
		printf("%dcbi\t%lld\t%f\t%f\n", diffHeuristic.GetNumHeuristics(),
			   taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
		
	}
	exit(0);
}
Exemplo n.º 23
0
int main(int argc, char* argv[]) {

  if (argc < 2) {
    std::cout << "Insufficient arguments" << std::endl;
    std::cout << "Usage : simulate <params file>" << std::endl;
    exit(1);
  }

  // arguments
  std::string paramfile = std::string(argv[1]);


  Experiment* e;


  // read parameters from file and create experiment object
  e = new Experiment(paramfile);
  std::cout << "Simulation parameters" << std::endl;
  std::cout << "From file : " << paramfile << std::endl;
  std::cout << *e << std::endl;

  // setup tree to write out
  TFile f("outfile.root", "RECREATE");
  TTree *tree = new TTree("T", "Experiments from the Stopped Particle MC");
  tree->Branch("Experiment", "Experiment", &e);

  // fills file
  std::ofstream fillsfile;
  fillsfile.open("fills.txt");

  // setup simulation
  Simulator sim;

  // set parameters
  sim.setParameters(e);

  // set observed events
  sim.setupObservedEvents();

  // set up luminosity data
  sim.setupLumi(false, true, true, e->lumiFile);

  // set up lifetime mask
  sim.setupLifetimeMask();

  //  sim.getLhcFills().print(std::cout);


  // simulate everything at once
  unsigned firstFill = e->fills.at(0);
  unsigned lastFill  = e->fills.at(e->fills.size()-1);

  // expected background
  sim.calculateExpectedBG(firstFill, lastFill);
  
  // get observed events
  sim.calculateObservedEvents(firstFill, lastFill);
  
  // run MC
  sim.simulateSignal(firstFill, lastFill);
  
  // calculate limit
  sim.calculateLimit();

  std::cout << std::endl;

  // write results summary
  std::ofstream summaryfile;
  summaryfile.open("summary.txt", std::ios::app);
  e->summary(summaryfile);
  summaryfile.close();

  std::cout << *e << std::endl;

  tree->Fill();
  f.cd();
  tree->Write();

  fillsfile.close();

  return 0;
}
Exemplo n.º 24
0
int main(int argc, char** argv){
  
  //flags set by command line options
  int verbose_flag = 0;
  int graphviz_flag = 0;
  int gnuplot_flag = 0;
  int outputall_flag = 0;
  int csvCell_flag = 0;
  int csvData_flag = 0;
  int usage_flag = 0;
  int gillespie_flag = 0;
  int rungeKutta_flag = 0;

  // used by command line parser
  int c;


  //trace related trace messages
  t.addTraceType("trce",0);
  
  //program arguments
  t.addTraceType("args",0);

  //error messages
  t.addTraceType("error",1);
 
  //object creation / construction
  t.addTraceType("init",1);

  //memory location of created objects
  t.addTraceType("mloc",1);

  //object deletion / destruction
  t.addTraceType("free",1);

  //calculated effect of interactions
  t.addTraceType("efct",0);

  //generational messages
  t.addTraceType("gens",0);

  // runge kutta (data / general messages)
  t.addTraceType("rk-4",0);
  
  // runge kutta (rk vals)
  t.addTraceType("rk-val",0);
 
  
  // runge kutta (calculation of next points) 
  t.addTraceType("rk-new",0);

  // hill / goodwin term calculation (transcription::getEffect)
  t.addTraceType("hill",0);

  // molecule scoring
  t.addTraceType("score",0);
  
  // mutation
  t.addTraceType("mutate",1);

  // polymorphic comparisons (not used?)
  t.addTraceType("typeid",0);

  t.addTraceType("stoch",1);

  int numCells = 2;
  int numGenerations = 10;

  int scoringInterval = 1;

  int maxBasic = 1;
  int maxPTM = 1;
  int maxComp = 1;
  int maxPromoter = 1;

  float minKineticRate = 0;
  float maxKineticRate = 1;

  float initialConcentration = 0;

  float rkTimeLimit = 20;
  float rkTimeStep = .05;


  // this loop parses the command line options. it was mostly adapted from online examples
  while(1){

  //define the command line options and their usage
    static struct option long_options[] =
     {
      {"help", no_argument, &usage_flag, 1},
      {"usage", no_argument, &usage_flag, 1},
      {"graphviz", no_argument, &graphviz_flag, 1},
      {"gnuplot",   no_argument, &gnuplot_flag, 1},
      {"outputall", no_argument, &outputall_flag, 1},
      {"csvCell", no_argument, &csvCell_flag, 1}, 
      {"csvData", no_argument, &csvData_flag, 1},
	  {"deterministic", no_argument, &rungeKutta_flag, 1},
	  {"stochastic", no_argument, &gillespie_flag, 1},

      {"cells",  required_argument, 0, 'c'},
      {"gens",  required_argument, 0, 'g'},
      {"minrate", required_argument, 0, 'a'},
      {"maxrate", required_argument, 0, 'b'},
      {"maxbasic", required_argument, 0, 'd'},
      {"maxptm", required_argument, 0, 'e'},
      {"maxcomp", required_argument, 0, 'f'},
      {"maxprom", required_argument, 0, 'h'},
      {"initconc", required_argument, 0, 'i'},
      {"rklim", required_argument, 0, 'j'},
      {"rkstep", required_argument, 0, 'k'},
      {"interval", required_argument, 0, 'l'},
      {"hill", required_argument, 0, 'm'},

      {0,0,0,0}
     };

 int option_index = 0;

 // which argument is currently seen?
 c = getopt_long (argc, argv, "a:b:c:d:e:f:g:h:i:j:k:l:", long_options, &option_index);

 if (c == -1)
 	break;

// what effect does that argument have
 switch(c)
 {
	case 0:
		if(long_options[option_index].flag != 0)
			break;
		printf("option %s", long_options[option_index].name);
		if (optarg)
			printf(" with arg %s", optarg);
		printf("\n");
		break;
	case 'a':
		minKineticRate = atof(optarg);
		break;
	case 'b':
		maxKineticRate = atof(optarg);
		break;
	case 'c':
		numCells = atoi(optarg);
		break;
	case 'd':
		maxBasic = atoi(optarg);
		break;
	case 'e':
		maxPTM = atoi(optarg);
		break;
	case 'f':
		maxComp = atoi(optarg);
		break;
	case 'g':
		numGenerations = atoi(optarg);
		break;
	case 'h':
		maxPromoter = atoi(optarg);
		break;
	case 'i':
		initialConcentration = atof(optarg);
		break;
	case 'j':
		rkTimeLimit = atof(optarg);
		break;
	case 'k':
		rkTimeStep = atof(optarg);
		break;
	case 'l':
		scoringInterval = atoi(optarg);
		break;
	case 'm':
		hillParam = atoi(optarg);
		break;
	case '?':
		break;
	default:
		abort();
}	
}

if (usage_flag){
      printf("EvoDevo Help\n");
      printf("---------------------------\n");
      printf("Flags:\n");
      printf("  --help            This help message\n");
      printf("  --usage           This help message\n");
      printf("  --graphviz        Output graphviz png files displaying the cell configuration\n");
      printf("  --gnuplot         Output gnuplot png files displaying molecule concentrations over time\n");
      printf("  --outputall       Output data about each cell every generation\n");
      printf("  --csvCell         Output csv data containing cell configuration\n");
      printf("  --csvData         Output csv data containing molecule concentrations\n");
	  printf("  --deterministic   Use deterministic Runge-Kutta solver for solving curves\n");
	  printf("  --stochastic      Use stochastic gillespie algorithm for solving curves\n");
      printf("\n");
      printf("Parameters:\n");
      printf("  --cells <int>        Number of Cells to simulate\n");
      printf("  --gens  <int>        Number of Generations to run for\n");
      printf("  --minrate <float>    Minimum value for random kinetic rates\n");
      printf("  --maxrate <float>    Maximum value for random kinetic rates\n");
      printf("  --maxbasic <int>     Maximum number of Basic Proteins\n");
      printf("  --maxptm <int>       Maximum number of Post Translationally Modified proteins\n");
      printf("  --maxcomp <int>      Maximum number of Protein-Protein Complexes\n");
      printf("  --maxprom <int>      Maximum number of Protein-Promoter Interactions\n");
      printf("  --initconc <float>   Initial concentration of molecules\n");
      printf("  --rklim <float>      Upper limit on time (x-axis) for differential equation solving\n");
      printf("  --rkstep <float>     Step size between points for differential equation solving\n");
      printf("  --interval <int>     Number of generations between equation solving and scoring\n");
      printf("  --hill <int>         Value of Hill Coefficient for DNA Transcription\n");

return 0;
}

// create our experiment with the options from the command line
Experiment e = Experiment(numCells, numGenerations, maxBasic, maxPTM, maxComp, maxPromoter, minKineticRate, maxKineticRate, rkTimeLimit, rkTimeStep, initialConcentration, rungeKutta_flag, gillespie_flag);

//set options related to output
e.setOutputOptions(graphviz_flag, gnuplot_flag, outputall_flag, csvCell_flag, csvData_flag, scoringInterval);

//start the experiment
e.start();


return 0;

}
Exemplo n.º 25
0
/*!
    \todo Clarify that spatio_temporal_average specifies milliseconds from 
    simulation start, not from simulation time window that is reported in 
    the file. also produce an error message if interval not in file. Should 
    actually probably go in the Stream_Playback_Control then.
*/
void spatiotemporal_average (URI            blue_config_filename, 
							 Filename		volume_compartment_mapping_filename,
							 Filename		output_filename_prefix,
							 Millisecond	begin_time,
							 Millisecond	end_time,
							 Millisecond	average_time_window,
                             bool           portable = false)
{
	Count frames_per_second(10);

    // experiment
    Experiment  experiment;
    experiment.open(blue_config_filename);
	Cell_Target circuit_target = experiment.cell_target("Column");

    std::cout << "Microcircuit: loading target Column" << std::endl;
    Count j = 0;

    for (Cell_Target::const_iterator i = circuit_target.begin();
        i != circuit_target.end(); ++i)
    {
        Neuron_Ptr new_neuron(new Neuron(experiment.microcircuit(), *i , j));
	    experiment.microcircuit().neurons().insert(new_neuron);
        ++j;
    }
	
	Volume_Temporal_Average<Millivolt, Micron, Millisecond>	
		temporal_average(Count (average_time_window * frames_per_second));

    Filter_Data<Microcircuit> microcircuit(experiment.microcircuit_ptr());
    
    // pipeline setup
    Pipeline    pipeline;
        
    std::cout << "Loading compartment report..." << std::endl;
    Reports_Specification::const_iterator result = 
        experiment.reports().find("allCompartments");
    if (result == experiment.reports().end())
    {
        std::cerr << "No \"allCompartments\" report found" << std::endl;
        exit(1);
    }
    Compartment_Report_Stream_Reader<Millivolt> binary_report_reader(* result, 2);
    binary_report_reader.cell_target(circuit_target);
    Compartment_Report_Printer<Millivolt>   printer;
    Compartment_Voltages_to_Microcircuit    report_link;
    Compartment_Voltage_Voxel_Average voltage_volume_average(volume_compartment_mapping_filename, false);
    Volume_Voltage_to_Byte voltage_to_byte;

	binary_report_reader.time_window(begin_time, end_time);
	binary_report_reader.speed(1.0);
	voltage_to_byte.dynamic_range(-65.0, -20.0);

	std::cout << "Pipeline 1: Setup spatio-temporal average." << std::endl;
	pipeline = binary_report_reader
		  + printer
		  + report_link
		  + microcircuit
		  + voltage_volume_average
		  + temporal_average;

	std::cout << "Pipeline 1: Started processing spatio-temporal average." 
		<< std::endl;
	pipeline.start();
	pipeline.wait_until_finished();
	pipeline.stop();
	std::cout << "Pipeline 1: Temporal average finished." << std::endl;


    std::cout << "Pipeline 2: Setup NRRD volume file writer." << std::endl;

    Pipeline    pipeline2;
    Filter_Reader<Volume<Millivolt, Micron, Millisecond> >   volume_buffer_reader;
    volume_buffer_reader.input_ptr(temporal_average.output_ptr());
	Volume_NRRD_File_Stream_Writer nrrd_file_writer(output_filename_prefix);

    pipeline2 = volume_buffer_reader 
                + voltage_to_byte 
                + nrrd_file_writer;

    std::cout << "Pipeline 2: Started writing volumes to disk." << std::endl;
	pipeline2.start();
	pipeline2.wait_until_finished();
	std::cout << "Pipeline 2: Written volumes to disk." << std::endl;
	
}
Exemplo n.º 26
0
int main(int argc, const char* argv[])
{
	/*
	 *  Build 48 Index with Links
	 */


	// Load Circuit
    Experiment experiment;
    experiment.open(blue_config_filename);
    Microcircuit & microcircuit = experiment.microcircuit();
    const Targets & targets = experiment.targets();
    const Cell_Target target = targets.cell_target("Column");
    microcircuit.load(target, NEURONS | MORPHOLOGIES);

    //Make Neuron Rtrees
    ISpatialIndex *neuronTrees[MORPHOLOGIES_COUNT];
    string *morphologyLabels[MORPHOLOGIES_COUNT];

    int cm=0;
    Morphologies & myMorphologies = microcircuit.morphologies();
    Morphologies::iterator myMorphologiesEnd = myMorphologies.end();
      for (Morphologies::iterator i = myMorphologies.begin(); i != myMorphologiesEnd; ++i)
      {
    	  morphologyLabels[cm] = i->label();
    	  neuronTrees[cm] = RTree::createNewRTree (createNewMemoryStorageManager(), 0.7, 127, 127, 3,RTree::RV_RSTAR,indexIdentifier);
    	  cm++;
      }

    Neurons & myNeurons = microcircuit.neurons();
    Neurons::iterator myNeuronsEnd = myNeurons.end();
    for (Neurons::iterator i = myNeurons.begin(); i != myNeuronsEnd; ++i)
    {
    	cm=0;
    	for (cm=0;cm<MORPHOLOGIES_COUNT;cm++)
    		if (strcmp(i->morphology().label(),morphologyLabels[cm])==0) break;

    	Transform_3D<Micron> trafo = i->global_transform();
    	Sections mySections = i->morphology().all_sections();
    	Sections::iterator mySectionsEnd = mySections.end();
    	for (Sections::iterator s = mySections.begin(); s != mySectionsEnd; ++s)
    	    {
    		 Segments segments = s->segments();
    		 Segments::const_iterator segments_end = segments.end();
    		 for (Segments::const_iterator j = segments.begin(); j != segments_end ; ++j)
    		     {
     			 vect plow, phigh;
     			 get_segment_mbr (*j, trafo, &plow, &phigh);
     			 SpatialIndex::Region mbr = SpatialIndex::Region(plow.data(),phigh.data(),3);

     			 std::stringstream strStream;
     			 strStream << i->gid() <<"-"<< s->id()<< "-" << j->id();
     			 neuronTrees[cm]->insertData (strStream.str().length(), (byte*)(strStream.str().c_str()), mbr, segmentid);
    		     }
    	    }
    }

    // Make Morphology Rtrees
    Morphologies & myMorphologies = microcircuit.morphologies();
    Morphologies::iterator myMorphologiesEnd = myMorphologies.end();
      for (Morphologies::iterator i = myMorphologies.begin(); i != myMorphologiesEnd; ++i)
      {
      	cout << "Indexing Morphology: " << i->label();
      	string baseName = i->label();
        IStorageManager* diskfile = StorageManager::createNewDiskStorageManager(baseName, 4096);
        ISpatialIndex *tree = RTree::createNewRTree (*diskfile, 0.7, 127, 127, 3,RTree::RV_RSTAR,indexIdentifier);
        indexIdentifier++; segmentid=0;

      	Sections mySections = i->all_sections();
      	Sections::iterator mySectionsEnd = mySections.end();
      	for (Sections::iterator s = mySections.begin(); s != mySectionsEnd; ++s)
      	{
            Segments segments = s->segments();
      		Segments::const_iterator segments_end = segments.end();
      		for (Segments::const_iterator j = segments.begin(); j != segments_end ; ++j)
      		{

      			Box<bbp::Micron> Mbr = AABBCylinder::calculateAABBForCylinder(j->begin().center(),
      								  j->begin().radius(),j->end().center(),j->begin().radius());

      			vect plow, phigh;

      			plow[0] = Mbr.center().x() - Mbr.dimensions().x() / 2;
      			phigh[0] = Mbr.center().x() + Mbr.dimensions().x() / 2;
      			plow[1] = Mbr.center().y() - Mbr.dimensions().y() / 2;
      			phigh[1] = Mbr.center().y() + Mbr.dimensions().y() / 2;
      			plow[2] = Mbr.center().z() - Mbr.dimensions().z() / 2;
      			phigh[2] = Mbr.center().z() + Mbr.dimensions().z() / 2;

				SpatialIndex::Region mbr = SpatialIndex::Region(plow.data(),phigh.data(),3);

      			std::stringstream strStream;
      			strStream << s->id()<< "-" << j->id();

      			tree->insertData (strStream.str().length(), (byte*)(strStream.str().c_str()), mbr, segmentid);
      			segmentid++;
      		}
      	}
      	cout << ".. Total Segments: " << segmentid << "\n";
        tree->~ISpatialIndex();
        diskfile->~IStorageManager();
      }


    // PRELOAD the Trees amd Neuron Morphology Mapping


    ISpatialIndex *neurons[NEURONS_COUNT];
    global_transformer *transforms[NEURONS_COUNT];

    int cm=0;
    int cn=0;
    string baseName = "";
    Morphologies & myMorphologies = microcircuit.morphologies();
    Neurons & myNeurons = microcircuit.neurons();

    cout << "PreLoading Mappings \n";
    Morphologies::iterator myMorphologiesEnd = myMorphologies.end();
      for (Morphologies::iterator m = myMorphologies.begin(); m != myMorphologiesEnd; ++m)
      {
    	  baseName = m->label();
    	  m->
          IStorageManager* diskfile = StorageManager::loadDiskStorageManager(baseName);
          trees[cm] = RTree::loadRTree(*diskfile, 1);

          std::cout << "Checking R-tree structure... ";
          if (!trees[cm]->isIndexValid()) std::cerr << "R-tree internal checks failed!\n"; else std::cout << "OK\n";
          IStatistics * tree_stats;
          trees[cm]->getStatistics (&tree_stats);
          cout << *tree_stats;

          Neurons::iterator myNeuronsEnd = myNeurons.end();
          for (Neurons::iterator n = myNeurons.begin(); n != myNeuronsEnd; ++n)
              {
        	  if (strcmp(n->morphology().label().c_str(),m->label().c_str())==0)
        		  {
        		  transforms[cn] = n->global_transform().inverse();
        		  neurons[cn] = trees[cm];
        		  }
        	  cn++;
        	  if (cn>=NEURONS_COUNT) break;
              }
          cn=0;cm++;
      }




	/*
	 *  Query the Index
	 */








}
Exemplo n.º 27
0
int main(int argc, char **argv)
{
        
        int airavata_port, airavata_timeout;
        string airavata_server;
				char* cfgfile;
				cfgfile = "./airavata-client-properties.ini";
        readConfigFile(cfgfile, airavata_server, airavata_port, airavata_timeout);				
				airavata_server.erase(0,1);
				airavata_server.erase(airavata_server.length()-1,1);			
			  boost::shared_ptr<TSocket> socket(new TSocket(airavata_server, airavata_port));
				socket->setSendTimeout(airavata_timeout);
  			boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));	
  			boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
				AiravataClient airavataclient(protocol);
				transport->open();
				
				if(argc !=4){
					cout << "Usage: ./createExperiment <username> <experiment_name> <project_ID>";
					return 0;
				}
				/* ComputationalResourceScheduling data for Trestles*/
        ComputationalResourceScheduling cmRST;
        cmRST.__set_resourceHostId("trestles.sdsc.edu");
        cmRST.__set_computationalProjectAccount("sds128");
        cmRST.__set_totalCPUCount(1);
        cmRST.__set_nodeCount(1);
        cmRST.__set_numberOfThreads(0);
        cmRST.__set_queueName("normal");
        cmRST.__set_wallTimeLimit(15);
        cmRST.__set_jobStartTime(0);
        cmRST.__set_totalPhysicalMemory(0);


				UserConfigurationData userConfigurationData;
        userConfigurationData.__set_airavataAutoSchedule(0);
        userConfigurationData.__set_overrideManualScheduledParams(0);
        userConfigurationData.__set_computationalResourceScheduling(cmRST);
       
				
				/*Application ID for Trestles */
        char* appId = "SimpleEcho2";        

				 /* Experiment input and output data. */
        DataObjectType input;
        input.__set_key("echo_input");
        input.__set_value("echo_output=Hello World");
        input.__set_type(DataType::STRING);
				std::vector<DataObjectType> exInputs;
				exInputs.push_back(input);				
        DataObjectType output;
        output.__set_key("echo_output");
        output.__set_value("");
        output.__set_type(DataType::STRING);
				std::vector<DataObjectType> exOutputs;
				exOutputs.push_back(output);
        
        
				char* user = argv[1];
        char* exp_name = argv[2];
        char* proj = argv[3];

        Experiment experiment;
        experiment.__set_projectID(proj);
        experiment.__set_userName(user);
        experiment.__set_name(exp_name);
        experiment.__set_applicationId(appId);
        experiment.__set_userConfigurationData(userConfigurationData);
        experiment.__set_experimentInputs(exInputs);
        experiment.__set_experimentOutputs(exOutputs);
								
				string _return = "";
        airavataclient.createExperiment(_return, experiment);

        if (_return!="")
        {
            
            cout << "Experiment " << _return <<" created! \n    ";
        }
        else
        {
            cout << "Failed to create experiment. \n";
        }
				transport->close();
}
Exemplo n.º 28
0
int main(int argc, const char* argv[])
{
    const URI blue_config_filename(argv[1]);
    try {
    	// LOADING CURCUIT
        Experiment experiment;
        experiment.open(blue_config_filename);
        Microcircuit & microcircuit = experiment.microcircuit();
        const Targets & targets = experiment.targets();
        const Cell_Target target = targets.cell_target("Column");
        microcircuit.load(target, NEURONS | MORPHOLOGIES);

        // PRELOAD the Trees amd Neuron Morphology Mapping
        ISpatialIndex *trees[MORPHOLOGIES_COUNT];
        ISpatialIndex *neurons[NEURONS_COUNT];
        global_transformer *transforms[NEURONS_COUNT];

        int cm=0;
        int cn=0;
        string baseName = "";
        Morphologies & myMorphologies = microcircuit.morphologies();
        Neurons & myNeurons = microcircuit.neurons();

        cout << "PreLoading Mappings \n";
        Morphologies::iterator myMorphologiesEnd = myMorphologies.end();
          for (Morphologies::iterator m = myMorphologies.begin(); m != myMorphologiesEnd; ++m)
          {
        	  baseName = m->label();
              IStorageManager* diskfile = StorageManager::loadDiskStorageManager(baseName);
              trees[cm] = RTree::loadRTree(*diskfile, 1);

              std::cout << "Checking R-tree structure... ";
              if (!trees[cm]->isIndexValid()) std::cerr << "R-tree internal checks failed!\n"; else std::cout << "OK\n";
              IStatistics * tree_stats;
              trees[cm]->getStatistics (&tree_stats);
              cout << *tree_stats;

              Neurons::iterator myNeuronsEnd = myNeurons.end();
              for (Neurons::iterator n = myNeurons.begin(); n != myNeuronsEnd; ++n)
                  {
            	  if (strcmp(n->morphology().label().c_str(),m->label().c_str())==0)
            		  {
            		  transforms[cn] = n->global_transform().inverse();
            		  neurons[cn] = trees[cm];
            		  }
            	  cn++;
            	  if (cn>=NEURONS_COUNT) break;
                  }
              cn=0;cm++;
          }
          /*
          // SINGLE QUERY
          cout << "Start Querying \n";
          range_query_visitor visitor;
		  SpatialIndex::Region query;

		  micron_vector plow,phigh;
		  plow[0] = 0; plow[1] = 0; plow[2] = 0;
		  phigh[0]=90; phigh[1]=90; phigh[2]=90;

          for (int i=0;i<NEURONS_COUNT;i++)
          {
    		  get_transformed_cube_mbr(plow,phigh,*transforms[i],&query);
    		  neurons[i]->intersectsWithQuery(query,visitor);
    		  visitor.inc_neuron();
          }
          visitor.print_stats();
*/

          // PERFORMANCE EVALUATION RANDOM RANGE QUERIES
          {
          cout << "Start Range Query Analysis \n";
          range_query_visitor visitor;
  		  double plow[3],phigh[3];
  		  plow[0]  = 98.2538; plow[1]  = 1005.14; plow[2]  = 92.9046;
  		  phigh[0] = 452.301; phigh[1] = 1385.56; phigh[2] = 456.743;
  	 	  //plow[0]  = -1698.38; plow[1] = -1065.03; plow[2] = -1724.75;
  	 	 // phigh[0] = 2248.56;  phigh[1]= 1894.28;  phigh[2]= 2276.71;
          SpatialIndex::Region query_region = SpatialIndex::Region(plow,phigh,3);
  		  boost::mt11213b generator (42u);
  		  const double x[3] = {0.0, 0.0, 0.0};
  		  SpatialIndex::Point rnd_point1 (x, query_region.m_dimension);
  		  SpatialIndex::Point rnd_point2 (x, query_region.m_dimension);
  		  SpatialIndex::Region query;

  		  for (int j=0;j<QUERIES_FOR_ANALYSIS;j++)
  		  {
  		     for (size_t i = 0; i < query_region.m_dimension; i++)
  	 	     {
  	 	          boost::uniform_real<> uni_dist (query_region.m_pLow[i],query_region.m_pHigh[i]);
  	 	          boost::variate_generator<boost::mt11213b &,boost::uniform_real<> > uni(generator, uni_dist);
  	 	          rnd_point1.m_pCoords[i] = uni();

  	 	          boost::uniform_real<> uni_dist1 (rnd_point1.m_pCoords[i],query_region.m_pHigh[i]);
  	 	          boost::variate_generator<boost::mt11213b &,boost::uniform_real<> > uni1(generator, uni_dist1);
  	 	          rnd_point2.m_pCoords[i] = uni1();
  	 	     }
  			  visitor.new_query();
  			  visitor.reset_neuron();
  			  for (int i=0;i<NEURONS_COUNT;i++)
  			  {
  				  Vector_3D<Micron> low  = Vector_3D<Micron>((Micron)rnd_point1.m_pCoords[0],(Micron)rnd_point1.m_pCoords[1],(Micron)rnd_point1.m_pCoords[2]);
  				  Vector_3D<Micron> high = Vector_3D<Micron>((Micron)rnd_point2.m_pCoords[0],(Micron)rnd_point2.m_pCoords[1],(Micron)rnd_point2.m_pCoords[2]);
  				  get_transformed_cube_mbr(low,high,*transforms[i],&query);
  				  neurons[i]->intersectsWithQuery(query,visitor);
  			  }
  			  if (j%100==0) cout << "Queries Done: " << j << "\n";
  		  }
  		  visitor.print_stats();
          }
/*
          {
          // PERFORMANCE EVALUATION RANDOM POINT QUERIES
          cout << "Start Point Query Analysis \n";
          range_query_visitor visitor;
		  double plow[3],phigh[3];
		  //plow[0]  = 98.2538; plow[1]  = 1005.14; plow[2]  = 92.9046;
		 // phigh[0] = 452.301; phigh[1] = 1385.56; phigh[2] = 456.743;
  	 	  plow[0]  = -1698.38; plow[1] = -1065.03; plow[2] = -1724.75;
  	 	  phigh[0] = 2248.56;  phigh[1]= 1894.28;  phigh[2]= 2276.71;
          SpatialIndex::Region query_region = SpatialIndex::Region(plow,phigh,3);
		  boost::mt11213b generator (42u);

		  for (int j=0;j<QUERIES_FOR_ANALYSIS;j++)
		  {
			  const double x[3] = {0.0, 0.0, 0.0};
			  SpatialIndex::Point rnd_point (x, query_region.m_dimension);
			  SpatialIndex::Point tmp_point (x, query_region.m_dimension);

			  for (size_t i = 0; i < query_region.m_dimension; i++)
		      {
		          boost::uniform_real<> uni_dist (query_region.m_pLow[i],query_region.m_pHigh[i]);
		          boost::variate_generator<boost::mt11213b &,boost::uniform_real<> > uni(generator, uni_dist);
		          rnd_point.m_pCoords[i] = uni();
		      }
			  visitor.new_query();
			  visitor.reset_neuron();
			  //visitor.reset_stats();
			  for (int i=0;i<NEURONS_COUNT;i++)
			  {
				 // cout << "Point Query: (" <<  rnd_point.m_pCoords[0] << "," <<  rnd_point.m_pCoords[1] << "," << rnd_point.m_pCoords[2] << ") Transformed to: (";
				  Vector_3D<Micron> v = Vector_3D<Micron>((Micron)rnd_point.m_pCoords[0],(Micron)rnd_point.m_pCoords[1],(Micron)rnd_point.m_pCoords[2]);
				  v = *transforms[i]*v;
				  tmp_point.m_pCoords[0] = (double)v.x();
				  tmp_point.m_pCoords[1] = (double)v.y();
				  tmp_point.m_pCoords[2] = (double)v.z();
				 // cout <<  tmp_point.m_pCoords[0] << "," <<  tmp_point.m_pCoords[1] << "," << tmp_point.m_pCoords[2] << ")\n";
				  neurons[i]->pointLocationQuery(tmp_point,visitor);
			  }

		  }
		  visitor.print_stats();
          }
*/
          // PERFORMANCE EVALUATION RANDOM RANGE QUERIES





    }
    catch (Tools::Exception& e)
    {
      cout << e.what() << endl;
      exit(0);
    }
   // delete tree_stats;
    return 0;
}
Exemplo n.º 29
0
void Viewer::init(){
    int type,device;
    long document;
    bool okType=false, okDevice=false, okDocument=false;
    /*Size of window
     * The size of window has an initial value for unsupported screens and fullScreen
     * for the rest.
     * **/
    resize(STARTWIDTH,STARTHEIGHT);
    setFullScreen(true);
    //Select type of experiment. '1' for 2D, '2' for 3D
    qglviewer::AxisPlaneConstraint* constraint;
    constraint = new LocalConstraint();
    if(type=='1'){
        constraint->setRotationConstraintType(AxisPlaneConstraint::FORBIDDEN);
    }else{
        constraint->setRotationConstraintType(AxisPlaneConstraint::FREE);
    }
    //Constraint the zoom
    constraint->setTranslationConstraintType(AxisPlaneConstraint::FORBIDDEN);
    camera()->frame()->setConstraint(constraint);
    showEntireScene();
    
    
    //Inicialization vars
    countMessages=0;
    
    
    
    addMessage("Inicializando Viewer ",0,9);
    
    //Ask for user data
    while(!okType){
        type=QInputDialog::getInt (this,
            tr("Type of experiment"),
            tr("Select the type of experiment:"
                "\n   1. Pointing experiment"
                "\n   2. 3D drag and drop"),
            1,1,2,1,&okType);
    }
    while(!okDevice){
        device=QInputDialog::getInt (this,
            tr("Device to test"),
            tr("Select the device for the experiment:"
                "\n   1. Mouse"
                "\n   2. Wiimote"
                "\n   3. Kinect"
                "\n   4. Falcon"),
            4,1,4,1,&okDevice);
    }
    while(!okDocument){
        document=QInputDialog::getInt (this,
            tr("Document of the participant"),
            tr("Type the document of the participant"),
            0,0,2147483647,1,&okDocument);
    }
    if(type==1){
        //Experiment inicialization    
        exper.init(width(),height(),device,document,BLOCKS_PER_EXPERIMENT,TRIALS_PER_ID);
        // Click on the right button to make a selection
        setMouseBinding(Qt::LeftButton,SELECT);
        
        
        falcon.init(width(),height());
        falcon.addOptions(FalconMouse::DEVICE_OPTIONS | FalconMouse::COMM_OPTIONS | FalconMouse::FIRMWARE_OPTIONS);
        
        
        startAnimation();
    }else{
        QMessageBox::information(this,
                "Under construction",
                "The 3D experiment is under construction");
        init();
    }
}
Exemplo n.º 30
0
// Compare:
// * 10 N memory
// * 1...10 regular lookups
// * 1...9 random lookups with and without BPMX
// Only compare on longest problems
void RunExperiments5(ScenarioLoader *sl)
{
	std::vector<graphState> aPath;
	
	Map *m = new Map(sl->GetNthExperiment(0).GetMapName());
	m->Scale(sl->GetNthExperiment(0).GetXScale(), 
			 sl->GetNthExperiment(0).GetYScale());
	Graph *g = GraphSearchConstants::GetGraph(m);
	
	GraphMapInconsistentHeuristic diffHeuristic(m, g);
	diffHeuristic.SetPlacement(kAvoidPlacement);
	diffHeuristic.SetMode(kRandom);
	
	GraphEnvironment gEnv(g, &diffHeuristic);
	gEnv.SetDirected(true);
	
	TemplateAStar<graphState, graphMove, GraphEnvironment> taNew;
	
	Timer t;
	
	for (int x = 0; x < 10; x++)
		diffHeuristic.AddHeuristic();
	//diffHeuristic.SetNumUsedHeuristics(diffHeuristic.GetNumHeuristics()/10);
	
	for (int x = 0; x < sl->GetNumExperiments(); x++)
	{
		Experiment e = sl->GetNthExperiment(x);
		
		if (e.GetBucket() != 127)
			continue;
		
		graphState start, goal;
		start = m->GetNodeNum(e.GetStartX(), e.GetStartY());
		goal = m->GetNodeNum(e.GetGoalX(), e.GetGoalY());
		
		
		printf("%d\t", e.GetBucket());
		
		
		for (int y = 1; y <= 10; y++)
		{
			// N memory -- 1 heuristic
			diffHeuristic.SetNumUsedHeuristics(y);
			diffHeuristic.SetMode(kMax);
			taNew.SetUseBPMX(0);
			
			t.StartTimer();
			taNew.GetPath(&gEnv, start, goal, aPath);
			t.EndTimer();		
			printf("%dmx\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
				   taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
		}
		
		for (int y = 1; y <= 9; y++)
		{
			for (int z = 0; z <= 1; z++)
			{
				// N memory -- 1 heuristic
				diffHeuristic.SetNumUsedHeuristics(y);
				diffHeuristic.SetMode(kRandom);
				taNew.SetUseBPMX(z);
				
				t.StartTimer();
				taNew.GetPath(&gEnv, start, goal, aPath);
				t.EndTimer();	
				if (z==0)
					printf("%drnd\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
						   taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
				else
					printf("%drdb\t%lld\t%f\t%f\t", diffHeuristic.GetNumUsedHeuristics(),
						   taNew.GetNodesExpanded(), t.GetElapsedTime(), gEnv.GetPathLength(aPath));
			}
		}
		printf("\n");
		
	}
	exit(0);
}