예제 #1
0
DifferentialEvolution::DifferentialEvolution(Pest &_pest_scenario,
	FileManager &_file_manager, ObjectiveFunc *_obj_func_ptr,
	const ParamTransformSeq &_par_transform, OutputFileWriter &_output_file_writer,
	PerformanceLog *_performance_log,  unsigned int seed)
	: file_manager(_file_manager), obj_func_ptr(_obj_func_ptr), par_transform(_par_transform),
	output_file_writer(_output_file_writer), performance_log(_performance_log),
	gen_1(_file_manager.build_filename("de1"))
{
	// initialize random number generator
	rand_engine.seed(seed);

	par_list = _pest_scenario.get_ctl_ordered_par_names();
	for (const auto &i : par_list)
	{
		const ParameterRec *p_info = _pest_scenario.get_ctl_parameter_info().get_parameter_rec_ptr(i);
		if (p_info->tranform_type == ParameterRec::TRAN_TYPE::LOG)
		{
			parameter_info[i] = ParameterInfoDE(p_info->lbnd, p_info->ubnd, true);
		}
		else if (p_info->tranform_type == ParameterRec::TRAN_TYPE::NONE)
		{
			parameter_info[i] = ParameterInfoDE(p_info->lbnd, p_info->ubnd, false);
		}
		else
		{
			// This is a fixed or tied parameter which will be handled by a transformations
		}

	}
}
예제 #2
0
map<string, string>  GsaAbstractBase::process_gsa_file(ifstream &fin, FileManager &file_manager)
{
	map<string, string> arg_map;
	string line;
	int lnum = 0;
	try {
		while(getline(fin, line))
		{
			++lnum;
			strip_ip(line);
			if (line[0] == '#')
			{
			}
			else
			{
				string line_upper = upper_cp(line);
				parce_line(line_upper, arg_map);
			}
		}
	}
	catch (PestConversionError &e) {
		std::stringstream out;
		out << "Error parsing \"" << file_manager.build_filename("gsa") << "\" on line number " << lnum << endl;
		out << e.what() << endl;
		e.add_front(out.str());
		e.raise();
	}
	return arg_map;
}