|
|
|
|
#ifndef NMWXAUTOMATICFITTINGSTART_H
|
|
|
|
|
#define NMWXAUTOMATICFITTINGSTART_H
|
|
|
|
|
|
|
|
|
|
#include "iDlgBase.h"
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QTableWidget>
|
|
|
|
|
#include <QTextEdit>
|
|
|
|
|
#include <QProgressBar>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QFont>
|
|
|
|
|
#include <QTextCursor>
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <QPointF>
|
|
|
|
|
#include <QRectF>
|
|
|
|
|
#include <QSplitter>
|
|
|
|
|
|
|
|
|
|
#include "nmCalculationAutoFitGA.h"
|
|
|
|
|
#include "nmCalculationAutoFitPSO.h"
|
|
|
|
|
|
|
|
|
|
// 前向声明
|
|
|
|
|
class nmCalculationAutoFitPSO;
|
|
|
|
|
class nmCalculationAutoFitGA;
|
|
|
|
|
class QPainter;
|
|
|
|
|
class QColor;
|
|
|
|
|
class QPaintEvent;
|
|
|
|
|
|
|
|
|
|
class nmAutomaticFittingCurveChart : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit nmAutomaticFittingCurveChart(QWidget* parent = 0);
|
|
|
|
|
|
|
|
|
|
void setTargetLogLogData(const QVector<QVector<double> >& data);
|
|
|
|
|
void setBestLogLogData(const QVector<QVector<double> >& data, int iteration, double fitness);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void paintEvent(QPaintEvent* event);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void rebuildRange();
|
|
|
|
|
void drawGrid(QPainter& painter);
|
|
|
|
|
void drawAxes(QPainter& painter);
|
|
|
|
|
void drawCurveLine(QPainter& painter, const QVector<QPointF>& points, const QColor& color);
|
|
|
|
|
void drawCrossMarkers(QPainter& painter, const QVector<QPointF>& points, const QColor& color);
|
|
|
|
|
void drawCircleMarkers(QPainter& painter, const QVector<QPointF>& points, const QColor& color);
|
|
|
|
|
QVector<QPointF> extractCurve(const QVector<QVector<double> >& data, int yIndex) const;
|
|
|
|
|
QPointF dataToScreen(const QPointF& point) const;
|
|
|
|
|
QString formatPowerTickLabel(int exponent) const;
|
|
|
|
|
|
|
|
|
|
QVector<QPointF> m_targetPressure;
|
|
|
|
|
QVector<QPointF> m_targetDerivative;
|
|
|
|
|
QVector<QPointF> m_bestPressure;
|
|
|
|
|
QVector<QPointF> m_bestDerivative;
|
|
|
|
|
QRectF m_chartRect;
|
|
|
|
|
QRectF m_logRange;
|
|
|
|
|
int m_bestIteration;
|
|
|
|
|
double m_bestFitness;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 算法类型枚举
|
|
|
|
|
enum FittingAlgorithmType {
|
|
|
|
|
FITTING_ALGORITHM_PSO = 0,
|
|
|
|
|
FITTING_ALGORITHM_GA = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class nmWxAutomaticfittingStart : public iDlgBase
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit nmWxAutomaticfittingStart(QWidget *parent = 0);
|
|
|
|
|
~nmWxAutomaticfittingStart();
|
|
|
|
|
|
|
|
|
|
// PSO算法接口
|
|
|
|
|
void setAutoFitter(nmCalculationAutoFitPSO* autoFitter);
|
|
|
|
|
|
|
|
|
|
// GA算法接口
|
|
|
|
|
void setAutoFitterGA(nmCalculationAutoFitGA* autoFitter);
|
|
|
|
|
|
|
|
|
|
// 通用设置接口
|
|
|
|
|
void setFittingParameters(int maxIterations, double targetError, const QString& wellName);
|
|
|
|
|
void setSelectedParameters(const QStringList& parameterNames);
|
|
|
|
|
void setTargetLogLogData(const QVector<QVector<double> >& targetData);
|
|
|
|
|
|
|
|
|
|
// 拟合
|
|
|
|
|
void markFittingStarted();
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void onFittingProgress(int iteration, double fitness);
|
|
|
|
|
void onFittingFinished(bool success, const QString& message);
|
|
|
|
|
void onStopButtonClicked();
|
|
|
|
|
void onLogMessageReceived(const QString& message);
|
|
|
|
|
void onBestCurveUpdated(QVector<QVector<double> > targetData,
|
|
|
|
|
QVector<QVector<double> > bestData,
|
|
|
|
|
int iteration,
|
|
|
|
|
double fitness);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void closeEvent(QCloseEvent *event);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void setupUI();
|
|
|
|
|
void setupParameterArea();
|
|
|
|
|
void setupTableArea();
|
|
|
|
|
void setupChartArea();
|
|
|
|
|
void setupLogArea();
|
|
|
|
|
void setupControlArea();
|
|
|
|
|
void updateParameterTable();
|
|
|
|
|
void addLogMessage(const QString& message);
|
|
|
|
|
QString formatScientific(double value);
|
|
|
|
|
|
|
|
|
|
// UI组件
|
|
|
|
|
QHBoxLayout* mainLayout;
|
|
|
|
|
QVBoxLayout* leftLayout;
|
|
|
|
|
QVBoxLayout* rightLayout;
|
|
|
|
|
QSplitter* rightSplitter;
|
|
|
|
|
|
|
|
|
|
// 参数显示区域
|
|
|
|
|
QGroupBox* parameterGroup;
|
|
|
|
|
QLabel* currentIterationLabel;
|
|
|
|
|
QLabel* maxIterationLabel;
|
|
|
|
|
QLabel* currentComfortLabel;
|
|
|
|
|
QLabel* bestComfortLabel;
|
|
|
|
|
QLabel* targetPrecisionLabel;
|
|
|
|
|
QLabel* targetWellLabel;
|
|
|
|
|
QLabel* algorithmTypeLabel;
|
|
|
|
|
|
|
|
|
|
QLabel* currentIterationValue;
|
|
|
|
|
QLabel* maxIterationValue;
|
|
|
|
|
QLabel* currentComfortValue;
|
|
|
|
|
QLabel* bestComfortValue;
|
|
|
|
|
QLabel* targetPrecisionValue;
|
|
|
|
|
QLabel* targetWellValue;
|
|
|
|
|
QLabel* algorithmTypeValue;
|
|
|
|
|
|
|
|
|
|
// 参数表格区域
|
|
|
|
|
QGroupBox* tableGroup;
|
|
|
|
|
QTableWidget* tableWidget;
|
|
|
|
|
|
|
|
|
|
// 日志区域
|
|
|
|
|
QGroupBox* chartGroup;
|
|
|
|
|
nmAutomaticFittingCurveChart* curveChart;
|
|
|
|
|
QGroupBox* logGroup;
|
|
|
|
|
QTextEdit* logTextEdit;
|
|
|
|
|
|
|
|
|
|
// 控制区域
|
|
|
|
|
QProgressBar* progressBar;
|
|
|
|
|
QPushButton* stopButton;
|
|
|
|
|
|
|
|
|
|
// 算法实例
|
|
|
|
|
nmCalculationAutoFitPSO* m_autoFitterPSO;
|
|
|
|
|
nmCalculationAutoFitGA* m_autoFitterGA;
|
|
|
|
|
FittingAlgorithmType m_algorithmType;
|
|
|
|
|
|
|
|
|
|
// 拟合参数
|
|
|
|
|
int m_maxIterations;
|
|
|
|
|
double m_targetError;
|
|
|
|
|
QString m_wellName;
|
|
|
|
|
QStringList m_selectedParameters;
|
|
|
|
|
bool m_isFinished;
|
|
|
|
|
double m_bestFitnessEver;
|
|
|
|
|
|
|
|
|
|
QDateTime m_startTime;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // NMWXAUTOMATICFITTINGSTART_H
|