00001
00002
00004
00005 #include "GnuPlotterParameterScatterPlot.h"
00006
00008
00010
00011 GnuPlotterParameterScatterPlot::GnuPlotterParameterScatterPlot()
00012 {
00013
00014 }
00015
00016 GnuPlotterParameterScatterPlot::~GnuPlotterParameterScatterPlot()
00017 {
00018
00019 }
00020
00021 void GnuPlotterParameterScatterPlot::Update(Subject *theChangedSubject)
00022 {
00023 int m,j,k,i;
00024
00025 CStochasticSensitivityAnalysis *analysis = (CStochasticSensitivityAnalysis *)theChangedSubject;
00026 int nParams = analysis->GetEnsemble()->at(0)->GetParameterSize();
00027
00028
00029
00030
00031
00032 double *eigenPar = new double[nParams];
00033 double *minEigen = new double[nParams];
00034 for(m = 0; m < nParams; m++)
00035 {
00036 minEigen[m] = 0.0;
00037 eigenPar[m] = 0.0;
00038 }
00039
00040
00041 char titlestring[100];
00042 char commandstring[1000];
00043 sprintf(titlestring,"set title \"%s\"\n",title);
00044 SendPlotCommand(titlestring);
00045 SendPlotCommand("set grid\n");
00046
00047 SendPlotCommand("set xlabel \"i\"\n");
00048 SendPlotCommand("set ylabel \"Displacement of Eigenparameter from Minimum\"\n");
00049
00050
00051 freopen(buffername,"w",buffer);
00052
00053
00054
00055 for(m = 0; m < nParams; m++)
00056 {
00057 minEigen[m] = 0.0;
00058 }
00059
00060 for(j = 0; j < nParams; j++)
00061 {
00062 double parameter = log(analysis->GetEnsemble()->at(0)->GetParameter(j));
00063 for(k = 0; k < nParams; k++)
00064 {
00065 minEigen[k] += parameter*(analysis->GetEigenvectorMatrix()[j][k]);
00066 }
00067 }
00068 for(j = 0; j < nParams; j++)
00069 {
00070 fprintf(buffer,"%i\t\t%e\n",j,0);
00071 }
00072
00073
00074 for(i = 1; i < analysis->GetEnsemble()->size(); i++)
00075 {
00076
00077 for(m = 0; m < nParams; m++)
00078 {
00079 eigenPar[m] = 0.0;
00080 }
00081
00082 for(j = 0; j < nParams; j++)
00083 {
00084 double parameter = log(analysis->GetEnsemble()->at(i)->GetParameter(j));
00085 for(k = 0; k < nParams; k++)
00086 {
00087 eigenPar[k] += parameter*(analysis->GetEigenvectorMatrix()[j][k]);
00088 }
00089 }
00090
00091 for(j = 0; j < nParams; j++)
00092 {
00093 fprintf(buffer,"%i\t\t%e\n",j,eigenPar[j]-minEigen[j]);
00094 }
00095 }
00096 fprintf(buffer,"\n\n");
00097 fflush(buffer);
00098
00099
00100
00101
00102 double randVal = analysis->GetRWValue();
00103 fprintf(buffer,"%i\t\t%e\t\t%e\n",nParams+1,0.0,sqrt(randVal));
00104 fprintf(buffer,"\n\n");
00105 fflush(buffer);
00106
00107
00108 sprintf(commandstring,"plot \"%s\" index 0 t \"parameters\" w points, \"%s\" index 1 t \"RW estimate\" w errorbars\n",buffername,buffername);
00109
00110
00111
00112
00113 #ifdef _WIN32
00114 int iterator = 0;
00115 while(commandstring[iterator] != '\0')
00116 {
00117 if(commandstring[iterator] == '\\') {commandstring[iterator] = '/';}
00118 iterator++;
00119 }
00120 #endif
00121
00122 SendPlotCommand(commandstring);
00123
00124 delete [] eigenPar;
00125 delete [] minEigen;
00126
00127 return;
00128 }