|
|
|
|
@ -887,7 +887,7 @@ void nmCalculationAutoFitPSO::closeTraceFile()
|
|
|
|
|
void nmCalculationAutoFitPSO::writeTraceHeader()
|
|
|
|
|
{
|
|
|
|
|
// trace CSV 字段说明:
|
|
|
|
|
// - 当前粒子参数只记录代理模型关心的 k/skin/wellboreC/phi/h/Cf;
|
|
|
|
|
// - 当前粒子参数只记录代理模型关心的 k/skin/wellboreC/phi/h/Ct/Cf;
|
|
|
|
|
// - solver_objective 是真实求解器误差;
|
|
|
|
|
// - surrogate_objective 是 Python 代理评分;
|
|
|
|
|
// - screening_decision 说明该粒子为什么跑/不跑真实求解器;
|
|
|
|
|
@ -906,6 +906,7 @@ void nmCalculationAutoFitPSO::writeTraceHeader()
|
|
|
|
|
<< "wellboreC"
|
|
|
|
|
<< "phi"
|
|
|
|
|
<< "h"
|
|
|
|
|
<< "Ct"
|
|
|
|
|
<< "Cf"
|
|
|
|
|
<< "solver_objective"
|
|
|
|
|
<< "solver_success"
|
|
|
|
|
@ -918,6 +919,7 @@ void nmCalculationAutoFitPSO::writeTraceHeader()
|
|
|
|
|
<< "pbest_wellboreC"
|
|
|
|
|
<< "pbest_phi"
|
|
|
|
|
<< "pbest_h"
|
|
|
|
|
<< "pbest_Ct"
|
|
|
|
|
<< "pbest_Cf"
|
|
|
|
|
<< "gbest_objective"
|
|
|
|
|
<< "gbest_k"
|
|
|
|
|
@ -925,6 +927,7 @@ void nmCalculationAutoFitPSO::writeTraceHeader()
|
|
|
|
|
<< "gbest_wellboreC"
|
|
|
|
|
<< "gbest_phi"
|
|
|
|
|
<< "gbest_h"
|
|
|
|
|
<< "gbest_Ct"
|
|
|
|
|
<< "gbest_Cf"
|
|
|
|
|
<< "enabled_param_indices";
|
|
|
|
|
|
|
|
|
|
@ -1101,6 +1104,7 @@ void nmCalculationAutoFitPSO::writeTraceRow(int generation,
|
|
|
|
|
<< traceParamAt(currentParams, 2)
|
|
|
|
|
<< traceParamAt(currentParams, 3)
|
|
|
|
|
<< traceParamAt(currentParams, 5)
|
|
|
|
|
<< traceParamAt(currentParams, 6)
|
|
|
|
|
<< traceParamAt(currentParams, 7)
|
|
|
|
|
<< traceNumber(solverObjective)
|
|
|
|
|
<< QString::number(solverSuccess ? 1 : 0)
|
|
|
|
|
@ -1113,6 +1117,7 @@ void nmCalculationAutoFitPSO::writeTraceRow(int generation,
|
|
|
|
|
<< traceParamAt(pbestParams, 2)
|
|
|
|
|
<< traceParamAt(pbestParams, 3)
|
|
|
|
|
<< traceParamAt(pbestParams, 5)
|
|
|
|
|
<< traceParamAt(pbestParams, 6)
|
|
|
|
|
<< traceParamAt(pbestParams, 7)
|
|
|
|
|
<< traceNumber(m_globalBestFitness)
|
|
|
|
|
<< traceParamAt(gbestParams, 0)
|
|
|
|
|
@ -1120,6 +1125,7 @@ void nmCalculationAutoFitPSO::writeTraceRow(int generation,
|
|
|
|
|
<< traceParamAt(gbestParams, 2)
|
|
|
|
|
<< traceParamAt(gbestParams, 3)
|
|
|
|
|
<< traceParamAt(gbestParams, 5)
|
|
|
|
|
<< traceParamAt(gbestParams, 6)
|
|
|
|
|
<< traceParamAt(gbestParams, 7)
|
|
|
|
|
<< csvEscape(enabledIndices.join(";"));
|
|
|
|
|
|
|
|
|
|
@ -1272,7 +1278,7 @@ bool nmCalculationAutoFitPSO::writeSurrogateCandidateCsv(const QString& candidat
|
|
|
|
|
//
|
|
|
|
|
// 文件位置通常是 ML/nmWTAI-ML/data/temp/pso_screen_candidates_<run_id>_gen<N>.csv。
|
|
|
|
|
// 字段顺序必须与 ML 脚本 score_pso_candidates*.py 保持一致:
|
|
|
|
|
// particle_id,k,skin,wellboreC,phi,h,Cf
|
|
|
|
|
// particle_id,k,skin,wellboreC,phi,h,Ct,Cf
|
|
|
|
|
//
|
|
|
|
|
// 这里写的是“完整参数体系”中的关键字段,不是粒子内部紧凑向量。
|
|
|
|
|
// 例如用户没有勾选 Cf 时,Cf 会从当前 DataManager 取值写入 CSV。
|
|
|
|
|
@ -1285,7 +1291,7 @@ bool nmCalculationAutoFitPSO::writeSurrogateCandidateCsv(const QString& candidat
|
|
|
|
|
|
|
|
|
|
QTextStream out(&file);
|
|
|
|
|
// 代理模型只需要这些输入字段;其它参数当前不在训练输入集中。
|
|
|
|
|
out << "particle_id,k,skin,wellboreC,phi,h,Cf\n";
|
|
|
|
|
out << "particle_id,k,skin,wellboreC,phi,h,Ct,Cf\n";
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < m_swarm.size(); ++i) {
|
|
|
|
|
QVector<double> params = buildTraceParameterVector(m_swarm[i].position);
|
|
|
|
|
@ -1296,6 +1302,7 @@ bool nmCalculationAutoFitPSO::writeSurrogateCandidateCsv(const QString& candidat
|
|
|
|
|
<< traceParamAt(params, 2)
|
|
|
|
|
<< traceParamAt(params, 3)
|
|
|
|
|
<< traceParamAt(params, 5)
|
|
|
|
|
<< traceParamAt(params, 6)
|
|
|
|
|
<< traceParamAt(params, 7);
|
|
|
|
|
out << cols.join(",") << "\n";
|
|
|
|
|
}
|
|
|
|
|
@ -1893,10 +1900,10 @@ bool nmCalculationAutoFitPSO::isSurrogateRunContextSupported(QString* reason) co
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 参数 gate:代理输入目前只覆盖 k/skin/wellboreC/phi/h。
|
|
|
|
|
// 参数 gate:代理输入目前只覆盖 k/skin/wellboreC/phi/h/Ct。
|
|
|
|
|
// 用户勾选其它参数时,代理无法可靠反映这些参数变化,直接禁用代理筛选。
|
|
|
|
|
QVector<int> allowedParamIndices;
|
|
|
|
|
allowedParamIndices << 0 << 1 << 2 << 3 << 5;
|
|
|
|
|
allowedParamIndices << 0 << 1 << 2 << 3 << 5 << 6;
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < m_enabledParamIndices.size(); ++i) {
|
|
|
|
|
if(!allowedParamIndices.contains(m_enabledParamIndices[i])) {
|
|
|
|
|
|