|
|
|
|
@ -80,10 +80,6 @@ static const double kSurrogateConstPvtCtFixed = 1.0e-2; // T1/T3 训练数据
|
|
|
|
|
static const double kSurrogateFixedParamRelTol = 1.0e-4; // 固定参数仅允许 0.01% 相对偏差。
|
|
|
|
|
static const double kSurrogateCfMin = 1.0e-5; // T2/T4 训练数据中的 Cf 下界。
|
|
|
|
|
static const double kSurrogateCfMax = 1.0e-2; // T2/T4 训练数据中的 Cf 上界。
|
|
|
|
|
static const char kSurrogateProcessedPath[] = "C:/Users/Asus/Desktop/test/data/processed/dataset_T1_T4_fixed_time_40000.pkl";
|
|
|
|
|
static const char kSurrogateModelPath[] = "C:/Users/Asus/Desktop/test/models/T1_T4_fixed_time_40000_autofit_v1/forward_surrogate_best.pt";
|
|
|
|
|
static const char kT5SurrogateProcessedPath[] = "C:/Users/Asus/Desktop/test/data/processed/dataset_T5_fixedcf_random_18448.pkl";
|
|
|
|
|
static const char kT5SurrogateModelPath[] = "C:/Users/Asus/Desktop/test/models/T5_fixedcf_random_18448_delta_v1/forward_surrogate_best.pt";
|
|
|
|
|
static const double kSurrogateTrainingInitialPressure = 34.47;
|
|
|
|
|
static const int kSurrogateMinProdSections = 3; // 代理训练流量制度:生产段数量下界。
|
|
|
|
|
static const int kSurrogateMaxProdSections = 5; // 代理训练流量制度:生产段数量上界。
|
|
|
|
|
@ -129,24 +125,6 @@ static NM_SOLVER_MODEL_TYPE currentSolverModelType()
|
|
|
|
|
return dataManager ? dataManager->getSolverModelType() : SMT_Oil_ConstPvt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString surrogateProcessedPath(NM_SOLVER_MODEL_TYPE solverModelType)
|
|
|
|
|
{
|
|
|
|
|
if(solverModelType == SMT_Gas_VariablePvt) {
|
|
|
|
|
return QDir::cleanPath(QString::fromLatin1(kT5SurrogateProcessedPath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QDir::cleanPath(QString::fromLatin1(kSurrogateProcessedPath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString surrogateModelPath(NM_SOLVER_MODEL_TYPE solverModelType)
|
|
|
|
|
{
|
|
|
|
|
if(solverModelType == SMT_Gas_VariablePvt) {
|
|
|
|
|
return QDir::cleanPath(QString::fromLatin1(kT5SurrogateModelPath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QDir::cleanPath(QString::fromLatin1(kSurrogateModelPath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct SurrogateParameterDomain
|
|
|
|
|
{
|
|
|
|
|
double kMin;
|
|
|
|
|
@ -1352,10 +1330,10 @@ QString nmCalculationAutoFitPSO::getSurrogateTag() const
|
|
|
|
|
// 当前 C++ 绑定的代理模型实验标识,对应 ML 侧训练输出目录/checkpoint 命名。
|
|
|
|
|
// 如果以后换模型,需要同步更新这里和 ML 脚本可识别的 tag。
|
|
|
|
|
if(currentSolverModelType() == SMT_Gas_VariablePvt) {
|
|
|
|
|
return "T5_fixedcf_random_18448_delta_v1";
|
|
|
|
|
return "T5_family_random_18448_local_delta";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "T1_T4_fixed_time_40000_autofit_v1";
|
|
|
|
|
return "T1_T4_family_random_40k_merged_autofit";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString nmCalculationAutoFitPSO::getSurrogateStage() const
|
|
|
|
|
@ -1504,7 +1482,7 @@ bool nmCalculationAutoFitPSO::ensureSurrogateScoringServer(QString* failureReaso
|
|
|
|
|
{
|
|
|
|
|
// 确保常驻代理评分 server 已启动且与当前 run 配置匹配。
|
|
|
|
|
//
|
|
|
|
|
// serverKey 由 Python 路径、脚本路径、跟踪元数据、模型数据路径、模型标识和阶段组成。
|
|
|
|
|
// serverKey 由 Python 路径、脚本路径、跟踪元数据、模型标识和阶段组成。
|
|
|
|
|
// 只要其中任何一个变化,就停止旧进程并启动新进程,避免拿旧模型或旧目标曲线评分。
|
|
|
|
|
if(m_traceMetaFilePath.isEmpty() || !QFileInfo(m_traceMetaFilePath).exists()) {
|
|
|
|
|
QString reason = "trace meta file is missing";
|
|
|
|
|
@ -1532,15 +1510,10 @@ bool nmCalculationAutoFitPSO::ensureSurrogateScoringServer(QString* failureReaso
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString pythonPath = getPythonExecutablePath();
|
|
|
|
|
NM_SOLVER_MODEL_TYPE solverModelType = currentSolverModelType();
|
|
|
|
|
QString processedPath = surrogateProcessedPath(solverModelType);
|
|
|
|
|
QString modelPath = surrogateModelPath(solverModelType);
|
|
|
|
|
QString serverKey = QString("%1|%2|%3|%4|%5|%6|%7")
|
|
|
|
|
QString serverKey = QString("%1|%2|%3|%4|%5")
|
|
|
|
|
.arg(pythonPath)
|
|
|
|
|
.arg(scriptPath)
|
|
|
|
|
.arg(m_traceMetaFilePath)
|
|
|
|
|
.arg(processedPath)
|
|
|
|
|
.arg(modelPath)
|
|
|
|
|
.arg(getSurrogateTag())
|
|
|
|
|
.arg(getSurrogateStage());
|
|
|
|
|
|
|
|
|
|
@ -1556,8 +1529,6 @@ bool nmCalculationAutoFitPSO::ensureSurrogateScoringServer(QString* failureReaso
|
|
|
|
|
args << "-u"
|
|
|
|
|
<< scriptPath
|
|
|
|
|
<< "--trace-meta" << m_traceMetaFilePath
|
|
|
|
|
<< "--processed" << processedPath
|
|
|
|
|
<< "--model" << modelPath
|
|
|
|
|
<< "--tag" << getSurrogateTag()
|
|
|
|
|
<< "--stage" << getSurrogateStage();
|
|
|
|
|
|
|
|
|
|
@ -1837,16 +1808,11 @@ bool nmCalculationAutoFitPSO::runSurrogateScoringScriptOnce(const QString& candi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString pythonPath = getPythonExecutablePath();
|
|
|
|
|
NM_SOLVER_MODEL_TYPE solverModelType = currentSolverModelType();
|
|
|
|
|
QString processedPath = surrogateProcessedPath(solverModelType);
|
|
|
|
|
QString modelPath = surrogateModelPath(solverModelType);
|
|
|
|
|
QStringList args;
|
|
|
|
|
args << scriptPath
|
|
|
|
|
<< "--candidates" << candidatePath
|
|
|
|
|
<< "--trace-meta" << m_traceMetaFilePath
|
|
|
|
|
<< "--output" << scorePath
|
|
|
|
|
<< "--processed" << processedPath
|
|
|
|
|
<< "--model" << modelPath
|
|
|
|
|
<< "--tag" << getSurrogateTag()
|
|
|
|
|
<< "--stage" << getSurrogateStage();
|
|
|
|
|
|
|
|
|
|
|