113 lines
3.4 KiB
C++
113 lines
3.4 KiB
C++
#ifndef SOLVER_H
|
|
#define SOLVER_H
|
|
|
|
#include <QVector>
|
|
#include <QObject>
|
|
#include <QThread>
|
|
#include <QFile>
|
|
#include <iostream>
|
|
#include <qmath.h>
|
|
#include <list>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
#include <cstdlib>
|
|
#include <ctime>
|
|
#include <boost/random/normal_distribution.hpp>
|
|
#include <boost/random/mersenne_twister.hpp>
|
|
#include <boost/random/variate_generator.hpp>
|
|
#include "Individ.h"
|
|
#include "history.h"
|
|
|
|
|
|
struct dataSet{
|
|
|
|
QVector<double> withFeedbackVect;
|
|
QVector<double> withoutFeedbackVect;
|
|
QVector<double> xRange;
|
|
|
|
QVector<double> meanE;
|
|
QVector<double> meanF;
|
|
QVector<double> meanC2;
|
|
QVector<double> individ;
|
|
QVector<double> individFeedback;
|
|
//int maxIters;
|
|
double maxWithFeedVal;
|
|
double maxWithoutFeedVal;
|
|
};
|
|
|
|
class Solver : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
Solver(QObject *parent = 0);
|
|
~Solver();
|
|
void solveModel(float c1, float c2, float c3, float c4, float c5, float sigC1, float sigC2, float sigC3, float sigC4, float sigC5,
|
|
float e, float sigE, float sigX0, float delX0, float sigX, float Xopt, int popSize, int maxSteps, int N, int flag, int iter, int modelCount);
|
|
double solveF(int x, int y, int a, double b);
|
|
double solveG(int x, int y, int c, double d);
|
|
void initialization(std::vector<Individ*>& population, int N_feedback);
|
|
void mutationSimple(std::vector<Individ*>& population);
|
|
void mutationComplex(std::vector<Individ*>& population);
|
|
void selection(std::vector<Individ*>& population, float renewRate);
|
|
void printStatistics(const std::vector<Individ*>& population, int i, int iters, int currentStep);
|
|
|
|
|
|
private:
|
|
QVector<double> predatorSolveVal;
|
|
QVector<double> preySolveVal;
|
|
|
|
QVector<double> withFeedbackVect;
|
|
QVector<double> withoutFeedbackVect;
|
|
QVector<double> firstXVect;
|
|
|
|
|
|
QVector<double> meanE;
|
|
QVector<double> meanF;
|
|
QVector<double> meanC2;
|
|
QVector<double> individ;
|
|
QVector<double> individFeedback;
|
|
|
|
|
|
QVector<double> withFeedbackVectAvg;
|
|
QVector<double> withoutFeedbackVectAvg;
|
|
QVector<double> meanEAvg;
|
|
QVector<double> meanFAvg;
|
|
QVector<double> meanC2Avg;
|
|
QVector<double> individAvg;
|
|
QVector<double> individFeedbackAvg;
|
|
|
|
std::vector<Individ*> population;
|
|
QVector <std::vector<Individ*> > popVect;
|
|
double maxWithFeedVal;
|
|
double maxWithoutFeedVal;
|
|
int withFeedback;
|
|
int withoutFeedback;
|
|
int N_forFeedback;
|
|
float meanC2Feedback;
|
|
float meanEFeedBack;
|
|
float meanENonFeedBack;
|
|
int newIters;
|
|
int addSteps;
|
|
int itersFlag;
|
|
int modCount;
|
|
dataSet vectors;
|
|
QVector <dataSet> singleModelHistory;
|
|
double lastXopt;
|
|
|
|
|
|
signals:
|
|
|
|
void sendFeedVectors(QVector<double> withFeed, QVector<double> withoutFeed, QVector<double> xValsVect ,double maxWithFeed, double maxWithoutFeed);
|
|
void sendMeanVectors(int iters, QVector<double> meanEV, QVector<double> meanFV, QVector<double> meanC2V, QVector<double> individV, QVector<double> individFeedbackV);
|
|
void sendHistory(QVector<dataSet> history, int iters);
|
|
void sendItersForProgressBar(int iters);
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
};
|
|
|
|
#endif // SOLVER_H
|