CGreyModel::CGreyModel(CDataSet& his_data) { m_his_data.assign(his_data.begin(), his_data.end()); m_forecast_data.assign(his_data.begin(), his_data.end()); m_data_size = m_his_data.size(); cout<<"输入数据大小:m_data_size="<<m_data_size<<endl; // print_his_data(); m_init_population_num = 5; //初始种群数目 m_max_population_num = 300; //最大种群数目 m_min_seed = 0; //最小种子数 m_max_seed = 5; //最大种子数 m_max_iteration_num = 100; //最大迭代次数 m_dimension = 2; //求解维数 m_nonlinear_parameter = 2; //非线性调制参数 m_init_stand_dev = 50.00; //初始标准差 m_final_stand_dev = 0.01; //最终标准差 m_a_min = -0.3; //a随机范围下限 m_a_max = 2; //a随机范围上限 m_u_min = 0.00; //u随机范围下限 m_u_max = 200.5; //u随机范围上限 m_curr_population_num = 0; get_model(); forecast_data(); }
//---------------------------------------- int32_t CBratProcessExportAscii::WriteData() { int32_t result = BRATHL_SUCCESS; //CTrace *p = CTrace::GetInstance(); //p->Tracer(1, "Writing data ..."); CObArray::iterator itDataSet; CRecordSet* recordSet = NULL; CDataSet* dataSet = m_product->GetDataSet(); for (itDataSet = dataSet->begin(); itDataSet != dataSet->end() ; itDataSet++) { recordSet = dataSet->GetRecordSet(itDataSet); ///bool firstRecord = (record == dataSet->front()); CExpressionValue exprValueSelect; if (m_alwaysTrue == false) { recordSet->ExecuteExpression(m_select, m_recordName, exprValueSelect, m_product); } if (m_writeHeader) { for (uint32_t indexExpr = 0 ; indexExpr < m_fields.size() ; indexExpr++) { CExpressionValue exprValueData; recordSet->ExecuteExpression(m_fields[indexExpr], m_recordName, exprValueData, m_product); string colName = (m_names[indexExpr].empty() ? m_fields[indexExpr].AsString() : m_names[indexExpr]); string unitStr; unitStr.append(" ("); unitStr.append(m_units[indexExpr].AsString(false, true)); unitStr.append(") "); if (m_units[indexExpr].IsDate() && !m_dateAsPeriod ) { unitStr = ""; } if (m_units[indexExpr].IsDate() && !m_units[indexExpr].HasDateRef() ) { unitStr = ""; } *m_outputFile << colName << unitStr << " " << exprValueData.GetDimensionsAsString() << "\t"; } *m_outputFile << endl; m_writeHeader = false; } if (m_alwaysTrue == false) { if (exprValueSelect.IsTrue() != 1) { //Data doesn't match SELECT options, //------------- continue; //------------- } } for (uint32_t indexExpr = 0 ; indexExpr < m_fields.size() ; indexExpr++) { CExpressionValue exprValueData; recordSet->ExecuteExpression(m_fields[indexExpr], m_recordName, exprValueData, m_product); *m_outputFile << exprValueData.AsString(m_units[indexExpr], m_formats[indexExpr], m_dateAsPeriod) << "\t"; } *m_outputFile << endl; } //p->Tracer(1,"End writing data ..."); return result; }