当前位置: 首页>>代码示例>>C++>>正文


C++ Params::add方法代码示例

本文整理汇总了C++中Params::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Params::add方法的具体用法?C++ Params::add怎么用?C++ Params::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Params的用法示例。


在下文中一共展示了Params::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

BOOL EvolutionaryOptimization::Solver::Run()
{
	using namespace vrc;
	using namespace Nena::Scripting;

	Data.solver = this;

	loadScript("evolution_solver", _scriptFile);
	luaL_openlibs(_p_state);

	Params args;
	Params rets;

	std::string outputFilename;

	callScriptFunction("__aligning_call", &args, &rets);

	// read static data

	GetVar("evolution_data.vars_count", Data.iNumVars);
	GetVar("evolution_data.nonlinear_eq_count", Data.iNumNLE);
	GetVar("evolution_data.nonlinear_ineq_count", Data.iNumNLIE);
	GetVar("evolution_data.linear_ineq_count", Data.iNumLC);
	GetVar("evolution_data.vars_domains_count", Data.iNumDC);
	callScriptFunction("__aligning_call", &args, &rets);
	GetVar("evolution_data.reference_population_size", Data.iRefPopSize);
	GetVar("evolution_data.search_population_size", Data.iSearchPopSize);
	GetVar("evolution_data.operators_count", Data.iNumOperators);
	GetVar("evolution_data.evaluations_count", Data.lTotEvals);
	GetVar("evolution_data.reference_population_period", Data.iRefPeriod);
	callScriptFunction("__aligning_call", &args, &rets);
	GetVar("evolution_data.reference_population_offspring_count", Data.iRefOffspring);
	GetVar("evolution_data.reference_point_selection_method", Data.iSelRefPoint);
	GetVar("evolution_data.search_point_repair_method", Data.iRepairMethod);
	GetVar("evolution_data.search_point_replacement_ratio", Data.fReplRatio);
	callScriptFunction("__aligning_call", &args, &rets);
	GetVar("evolution_data.reference_point_initialization_method", Data.iRefInitType);
	GetVar("evolution_data.search_point_initialization_method", Data.iSearchInitType);
	GetVar("evolution_data.objective_function_type", Data.iObjFnType);
	Data.iNumTestCase = 0xffffffff;
	GetVar("evolution_data.precision_factor", Data.fEpsilon);
	GetVar("evolution_data.random_number_generator_seed1", Data.iSeed1);
	GetVar("evolution_data.random_number_generator_seed2", Data.iSeed2);
	//GetVar("evolution_data.frequency_control_mode", Data.iFreqMode);
	Data.iFreqMode = GENOCOP_FIXED;
	GetVar("evolution_data.output_file", outputFilename);
	callScriptFunction("__aligning_call", &args, &rets);

	fRefPop = init_matrix(Data.iRefPopSize + 1, Data.iNumVars + 1);
	fRefProbDist = init_vector(Data.iRefPopSize + 1);
	fSearchPop = init_matrix(Data.iSearchPopSize + 1, Data.iNumVars + 1);
	fSearchProbDist = init_vector(Data.iSearchPopSize + 1);

	fDC = init_matrix(Data.iNumDC + 1, 4);
	fLC = init_matrix(Data.iNumLC + 1, Data.iNumVars + 2);
	fOpProbDist = init_vector(Data.iNumOperators + 1);
	fNormProbDist = init_vector(Data.iNumOperators + 1);

	start_randgen(Data.iSeed1, Data.iSeed2);
	assign_probab(fRefProbDist, Data.iRefPopSize, GENOCOP_RQFACTOR);
	assign_probab(fSearchProbDist, Data.iSearchPopSize, GENOCOP_SQFACTOR);

	// read dynamic data

	args.add(0);
	rets.add(0.0);
	rets.add(0.0);

	for (int idx = 1; idx <= Data.iNumVars; idx++)
	{
		args.setValue<int>(0u, idx);

		//if (Lua::GetVarToStack(_p_state, "evolution_data.objective_function_variable_domain_get"))
		{
			//callScriptFunction("", &args, &rets);
			callScriptFunction("evol_obj_func_var_domains", &args, &rets);

			fDC[idx][2] = idx;
			fDC[idx][1] = rets.getValue<double>(0);
			fDC[idx][3] = rets.getValue<double>(1);

			//printf_s("domain for is %d: [%f; %f]\n", (int)fDC[idx][2], fDC[idx][1], fDC[idx][3]);
			//callScriptFunction("__aligning_call", &args, &rets);
		}
	}

	Params lcrets;
	for (int j = 1; j <= Data.iNumVars + 1; j++)
		lcrets.add(0.0);

	for (int idx = 1; idx <= Data.iNumLC; idx++)
	{
		args.setValue<int>(0u, idx);
		//if (Lua::GetVarToStack(_p_state, "evolution_data.objective_function_lineqgez_get_coeffs"))
		{
			callScriptFunction("evol_obj_func_lineq", &args, &lcrets);
			//callScriptFunction("", &args, &lcrets);
			for (int j = 1; j <= Data.iNumVars + 1; j++)
				fLC[idx][j] = lcrets.getValue<double>(j);
			//callScriptFunction("__aligning_call", &args, &rets);
//.........这里部分代码省略.........
开发者ID:VladSerhiienko,项目名称:Nena.v.1,代码行数:101,代码来源:EvolutionLuaAssist.cpp


注:本文中的Params::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。