Exemplo n.º 1
0
//============================================================================
MortalityRates::MortalityRates(BasicValues const& basic_values)
    :Length_(basic_values.GetLength())
{
    reserve_vectors();
    fetch_parameters(basic_values);
    initialize();
}
Exemplo n.º 2
0
	// ----------------------------------------------------------------------
	void
		AutoCastProcessor::
	   boot( void )
		throw()
	{
		neighborhood_.set_owner(owner());
		fetch_parameters();
		double now = owner().world().scheduler().current_time();

		double lb2 = owner().world().simulation_controller().environment().optional_double_param("_lb2__boot",0.9);
		double ub1 = owner().world().simulation_controller().environment().optional_double_param("_ub1__boot",1.1);
		update_timer_ = owner_w().world_w().scheduler_w().new_event(*this,now+fabs(max_startup_time_) * uniform_random(lb2,ub1),NULL);
		max_iterations_ = owner().world().simulation_controller().environment().required_int_param("max_iterations");
		logging_ = owner().world().simulation_controller().environment().optional_bool_param("autocast_logging", logging_);
		use_stale_hashes_ = owner().world().simulation_controller().environment().optional_bool_param("autocast_stale_hashes", use_stale_hashes_);

		std::string activity_file = owner().world().simulation_controller().environment().optional_string_param("activity_file", "");
		if (activity_file != "")
		{
			std::ifstream * inputfile = new ifstream(activity_file.c_str());
			if (inputfile->is_open())
			{
				std::ostringstream oss;
				oss << "$g(" << owner().id() << ")";
				string id(oss.str());
				std::cerr << "\nSearching for " << id << " in " << activity_file << " ";
				char buffer[250];
				std::string line;
				while (! inputfile->eof())
				{
					inputfile->getline(buffer,250);
					line = string(buffer);
					if (line.find(id) != std::string::npos)
					{
						//std::cerr << line << " " << "\n";
						line.assign(line,line.find("$ns_ at ")+8,std::string::npos);
						//std::cerr << line << "\n";
						line.assign(line,0,line.find("."));
						//std::cerr << line << "\n";
						int time = shawn::conv_string_to_int(line);
						active_times_.push_back(time);

						std::cerr << " " << time << " ";
					}
				}
				inputfile->close();

				// If an activity file is given, we let the processors sleep until the first given time
				this->set_state(Processor::Sleeping);
				active_times_it_ = active_times_.begin();
			}
		}
	}