优化代理筛选和模型路由

- T1到T4使用融合模型,T5使用气井专用模型
- 常规每代真实求解比例下限由55%调整为45%
- 使用guide pbest改善被筛选粒子的移动方向
- 增加模型预热、初始解复用和求解等待优化
- 修正代理模式下的粒子停滞率统计
feature/Model-20260625
lvjunjie 2 days ago
parent be498f8ffc
commit 57b3d8f66c

@ -24,16 +24,20 @@ class QProcess;
// 不是完整的 11 个储层/井筒参数。完整参数向量会在写 trace 或调用代理模型时 // 不是完整的 11 个储层/井筒参数。完整参数向量会在写 trace 或调用代理模型时
// 通过 buildTraceParameterVector() 重新组装。 // 通过 buildTraceParameterVector() 重新组装。
// //
// surrogate* 和 screeningDecision 是 PSO 加速筛选的辅助字段。代理模型只决定 // surrogate* 和 screeningDecision 是 PSO 加速筛选的辅助字段。真实 pbest / gbest
// “这一代哪些粒子需要继续跑真实求解器”,不会直接更新 pbest / gbest // 始终只由求解器更新T1-T5 可另外维护不参与最终结果的 guideBestPosition 来修正速度方向
struct AutoFitParticle { struct AutoFitParticle {
QVector<QVector<double> > currentLogLogData; QVector<QVector<double> > currentLogLogData;
QVector<QVector<double> > bestLogLogData; QVector<QVector<double> > bestLogLogData;
QVector<double> position; // 当前位置(参数值) QVector<double> position; // 当前位置(参数值)
QVector<double> velocity; // 速度 QVector<double> velocity; // 速度
QVector<double> bestPosition; // 个体最优位置 QVector<double> bestPosition; // 真实求解器确认的个体最优位置
QVector<double> guideBestPosition; // 仅用于速度更新的引导位置;不会参与真实 gbest/最终结果
double fitness; // 当前适应度 double fitness; // 当前适应度
double bestFitness; // 个体最优适应度 double bestFitness; // 真实求解器确认的个体最优适应度
double guideBestObjective; // guideBestPosition 对应的真实或代理目标值
bool guideBestFromSurrogate; // true 表示当前引导位置尚未经过真实求解器验证
double pbestRelativeImprovementThisIteration; // 本代真实评价相对旧 pbest 的改善幅度
bool evaluatedThisIteration; bool evaluatedThisIteration;
bool lastEvaluationSuccess; bool lastEvaluationSuccess;
@ -46,6 +50,9 @@ struct AutoFitParticle {
AutoFitParticle() AutoFitParticle()
: fitness(1e10) : fitness(1e10)
, bestFitness(1e10) , bestFitness(1e10)
, guideBestObjective(1e10)
, guideBestFromSurrogate(false)
, pbestRelativeImprovementThisIteration(0.0)
, evaluatedThisIteration(false) , evaluatedThisIteration(false)
, lastEvaluationSuccess(false) , lastEvaluationSuccess(false)
, lastEvaluationElapsedMs(-1) , lastEvaluationElapsedMs(-1)
@ -241,13 +248,14 @@ private:
int getSurrogateWarmupIterations() const; int getSurrogateWarmupIterations() const;
int getSurrogateFullSolverInterval() const; int getSurrogateFullSolverInterval() const;
QVector<bool> buildSurrogateEvaluationMask(); QVector<bool> buildSurrogateEvaluationMask();
bool writeSurrogateCandidateCsv(const QString& candidatePath) const; bool writeSurrogateCandidateCsv(const QString& candidatePath, bool includeGuideCandidates) const;
bool runSurrogateScoringProcess(const QString& candidatePath, const QString& scorePath, QString* failureReason = nullptr); bool runSurrogateScoringProcess(const QString& candidatePath, const QString& scorePath, QString* failureReason = nullptr);
bool runSurrogateScoringScriptOnce(const QString& candidatePath, const QString& scorePath, QString* failureReason = nullptr); bool runSurrogateScoringScriptOnce(const QString& candidatePath, const QString& scorePath, QString* failureReason = nullptr);
bool ensureSurrogateScoringServer(QString* failureReason = nullptr); bool ensureSurrogateScoringServer(QString* failureReason = nullptr, bool waitForReady = true);
bool requestSurrogateScoresFromServer(const QString& candidatePath, const QString& scorePath, QString* failureReason = nullptr); bool requestSurrogateScoresFromServer(const QString& candidatePath, const QString& scorePath, QString* failureReason = nullptr);
void stopSurrogateScoringServer(); void stopSurrogateScoringServer();
QVector<double> readSurrogateScores(const QString& scorePath) const; void resetGuideBestToVerified();
QVector<double> readSurrogateScores(const QString& scorePath, int expectedCount) const;
bool forceSolverByFallbackGate(const QVector<double>& selectedParameters) const; bool forceSolverByFallbackGate(const QVector<double>& selectedParameters) const;
bool isStrongDecliningProductionSchedule(double* endStartRatio = nullptr) const; bool isStrongDecliningProductionSchedule(double* endStartRatio = nullptr) const;
bool isSurrogateRunContextSupported(QString* reason) const; bool isSurrogateRunContextSupported(QString* reason) const;
@ -369,6 +377,7 @@ private:
int m_surrogateMinFloorParticleCount; // 因最低真实求解比例被补选中的粒子累计数。 int m_surrogateMinFloorParticleCount; // 因最低真实求解比例被补选中的粒子累计数。
QProcess* m_surrogateScoringProcess; // 常驻 Python 代理评分 server 进程。 QProcess* m_surrogateScoringProcess; // 常驻 Python 代理评分 server 进程。
QString m_surrogateScoringServerKey; // 标识当前 server 对应的 python/script/meta/tag/stage。 QString m_surrogateScoringServerKey; // 标识当前 server 对应的 python/script/meta/tag/stage。
bool m_surrogateScoringServerReady; // Python 已加载模型并输出 ready=true。
private: private:
// 模拟拟合相关成员 // 模拟拟合相关成员

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save