|
|
|
@ -3213,12 +3213,26 @@ bool nmCalculationAutoFitPSO::startAutoFitting()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_isRunning = false;
|
|
|
|
m_isRunning = false;
|
|
|
|
|
|
|
|
bool finalFullSolverSucceeded = false;
|
|
|
|
|
|
|
|
|
|
|
|
// 应用最终参数
|
|
|
|
// 应用最终参数
|
|
|
|
if(!m_globalBestPosition.isEmpty()) {
|
|
|
|
if(!m_globalBestPosition.isEmpty()) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
emit logMessageGenerated(tr("Applying optimized parameters to model..."));
|
|
|
|
emit logMessageGenerated(tr("Applying optimized parameters to model..."));
|
|
|
|
applyParametersToDataManager(m_globalBestPosition);
|
|
|
|
applyParametersToDataManager(m_globalBestPosition);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 候选粒子只返回目标井曲线;最优参数确定后必须再生成并提交完整结果快照。
|
|
|
|
|
|
|
|
emit logMessageGenerated(
|
|
|
|
|
|
|
|
tr("Running final full-field calculation with optimized parameters..."));
|
|
|
|
|
|
|
|
finalFullSolverSucceeded = runFinalFullSolver();
|
|
|
|
|
|
|
|
if(finalFullSolverSucceeded) {
|
|
|
|
|
|
|
|
emit logMessageGenerated(
|
|
|
|
|
|
|
|
tr("Final full-field calculation completed successfully"));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
m_lastError = tr("Optimized parameters were found, but the final full-field calculation failed");
|
|
|
|
|
|
|
|
emit logMessageGenerated(
|
|
|
|
|
|
|
|
tr("ERROR: Final full-field calculation failed"));
|
|
|
|
|
|
|
|
}
|
|
|
|
saveOptimizationResult();
|
|
|
|
saveOptimizationResult();
|
|
|
|
|
|
|
|
|
|
|
|
// 输出最终优化结果
|
|
|
|
// 输出最终优化结果
|
|
|
|
@ -3237,7 +3251,13 @@ bool nmCalculationAutoFitPSO::startAutoFitting()
|
|
|
|
|
|
|
|
|
|
|
|
emit logMessageGenerated(finalParams);
|
|
|
|
emit logMessageGenerated(finalParams);
|
|
|
|
|
|
|
|
|
|
|
|
emit logMessageGenerated(tr("Parameters applied successfully to data manager"));
|
|
|
|
if(finalFullSolverSucceeded) {
|
|
|
|
|
|
|
|
emit logMessageGenerated(
|
|
|
|
|
|
|
|
tr("Parameters and full-field results applied successfully to data manager"));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
emit logMessageGenerated(
|
|
|
|
|
|
|
|
tr("Optimized parameters applied to data manager"));
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch(const std::exception& e) {
|
|
|
|
} catch(const std::exception& e) {
|
|
|
|
emit logMessageGenerated(tr("ERROR: Failed to apply final parameters: %1").arg(e.what()));
|
|
|
|
emit logMessageGenerated(tr("ERROR: Failed to apply final parameters: %1").arg(e.what()));
|
|
|
|
m_lastError = QString("Failed to apply final parameters: %1").arg(e.what());
|
|
|
|
m_lastError = QString("Failed to apply final parameters: %1").arg(e.what());
|
|
|
|
@ -3289,6 +3309,14 @@ bool nmCalculationAutoFitPSO::startAutoFitting()
|
|
|
|
emit logMessageGenerated(tr("=== PSO OPTIMIZATION - UNKNOWN END ==="));
|
|
|
|
emit logMessageGenerated(tr("=== PSO OPTIMIZATION - UNKNOWN END ==="));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 只有正式快照已经提交,界面收到的成功信号才代表本次拟合结果完整可用。
|
|
|
|
|
|
|
|
if(success && !finalFullSolverSucceeded) {
|
|
|
|
|
|
|
|
success = false;
|
|
|
|
|
|
|
|
message = m_lastError.isEmpty()
|
|
|
|
|
|
|
|
? tr("The final full-field calculation failed")
|
|
|
|
|
|
|
|
: m_lastError;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
emitRunSummary(success, finalReason);
|
|
|
|
emitRunSummary(success, finalReason);
|
|
|
|
|
|
|
|
|
|
|
|
// 先发送最终进度更新,确保进度条达到100%
|
|
|
|
// 先发送最终进度更新,确保进度条达到100%
|
|
|
|
@ -5199,6 +5227,51 @@ QVector<QVector<double>> nmCalculationAutoFitPSO::runSolverDll()
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool nmCalculationAutoFitPSO::runFinalFullSolver()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 不设置目标井名,任务按普通完整模式构建全部井、网格和压力场结果。
|
|
|
|
|
|
|
|
nmDataAnalyzeManager* pDataManager =
|
|
|
|
|
|
|
|
nmDataAnalyzeManager::getCurrentInstance();
|
|
|
|
|
|
|
|
if(pDataManager == nullptr || m_evaluationInProgress > 0) {
|
|
|
|
|
|
|
|
DEBUG_OUT("Cannot start final full-field solver");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
++m_evaluationInProgress;
|
|
|
|
|
|
|
|
nmCalculationDllPebiSolverTask dllTask(m_tempDirectory, pDataManager);
|
|
|
|
|
|
|
|
dllTask.start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int maxWait = 3600000;
|
|
|
|
|
|
|
|
const int checkInterval = 50;
|
|
|
|
|
|
|
|
QTime waitTimer;
|
|
|
|
|
|
|
|
waitTimer.start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(waitTimer.elapsed() < maxWait) {
|
|
|
|
|
|
|
|
if(dllTask.wait(checkInterval) || !dllTask.isRunning()) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 最终求解期间继续处理绘制事件,避免进度窗口看起来失去响应。
|
|
|
|
|
|
|
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,
|
|
|
|
|
|
|
|
checkInterval);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(dllTask.isRunning()) {
|
|
|
|
|
|
|
|
DEBUG_OUT("Final full-field solver timeout, terminating task");
|
|
|
|
|
|
|
|
dllTask.terminate();
|
|
|
|
|
|
|
|
dllTask.wait(2000);
|
|
|
|
|
|
|
|
--m_evaluationInProgress;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dllTask.wait();
|
|
|
|
|
|
|
|
// 后台只生成候选快照,必须回到 DataManager 所属线程一次性提交。
|
|
|
|
|
|
|
|
const bool succeeded =
|
|
|
|
|
|
|
|
dllTask.wasSuccessful() && dllTask.commitResult(pDataManager);
|
|
|
|
|
|
|
|
--m_evaluationInProgress;
|
|
|
|
|
|
|
|
return succeeded;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//QVector<QVector<double>> nmCalculationAutoFitPSO::runSolverExe()
|
|
|
|
//QVector<QVector<double>> nmCalculationAutoFitPSO::runSolverExe()
|
|
|
|
//{
|
|
|
|
//{
|
|
|
|
// DEBUG_OUT("SOLVER EXE START");
|
|
|
|
// DEBUG_OUT("SOLVER EXE START");
|
|
|
|
|