Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef MODELSET_H
00028 #define MODELSET_H
00029
00030 #include <QGpCoreTools.h>
00031
00032 namespace DinverCore {
00033
00034 class Model;
00035 class RealSpace;
00036 class ReportReader;
00037
00038 class ModelSet : private QSet<Model>, private IncreaseStorage
00039 {
00040 TRANSLATIONS("ModelSet")
00041 public:
00042 ModelSet(int parameterCount, int targetCount, int defaultCapacity=16384);
00043 ~ModelSet();
00044
00045 bool importModelsFromAscii(RealSpace& parameterSpace, QString fileName);
00046 bool importModelsFromReport(RealSpace& parameterSpace, ReportReader& report, bool strict=true);
00047 bool importModels(RealSpace& parameterSpace, QString fileName, bool strict=true);
00048 int add(const RealSpace& parameterSpace, const double * misfit=0);
00049
00050 inline void setMisfit(int modelIndex, int targetIndex, double m);
00051
00052 void clear();
00053
00054 void reserve(int n) {IncreaseStorage::reserve(n);}
00055 int count() const {return _highestValidIndex+1;}
00056 int parameterCount() const {return _parameterCount;}
00057 int targetCount() const {return _targetCount;}
00058
00059 const int * model(int modelIndex) const {return _parameters+_parameterCount*modelIndex;}
00060 const int * firstModel() const {return _parameters;}
00061 const double * misfit(int modelIndex) const {return _misfits+_targetCount*modelIndex;}
00062
00063
00064 void lock() {_modelLock.lockForRead();}
00065 void unlock() {_modelLock.unlock();}
00066
00067 void print(int modelIndex) const;
00068 int bestModel() const;
00069 private:
00070 virtual void reallocate();
00071
00072 int _parameterCount;
00073 int _targetCount;
00074 int _highestValidIndex;
00075 int * _parameters;
00076 double * _misfits;
00077
00078
00079 QMutex _setLock;
00080 QReadWriteLock _modelLock;
00081 };
00082
00083 inline void ModelSet::setMisfit(int modelIndex, int targetIndex, double m)
00084 {
00085 _misfits[_targetCount*modelIndex+targetIndex]=m;
00086 if(modelIndex>_highestValidIndex) {
00087 _highestValidIndex=modelIndex;
00088 }
00089 }
00090
00091 }
00092
00093 #endif // MODELSET_H