Index: /trunk/packages/optimizer/src/fitfunc/ff_helper_modules_for_curves.c
===================================================================
--- /trunk/packages/optimizer/src/fitfunc/ff_helper_modules_for_curves.c	(revision 1061)
+++ /trunk/packages/optimizer/src/fitfunc/ff_helper_modules_for_curves.c	(revision 1062)
@@ -11,4 +11,5 @@
 #include<stdlib.h>
 #include<time.h>
+//#include <tcl.h>
 
 #define EPSILON 0.005
@@ -20,4 +21,5 @@
 #define INVALID_SLOPE 99999.9999
 #define TOLERANCE 1e-5
+#define BLOCK_SIZE 160
 
 typedef struct Curve{
@@ -39,5 +41,6 @@
 	double *yvals;
 	double *xvals;
-	int no_of_actual_max_or_mins;	
+	int no_of_actual_max_or_mins;
+	int size_allotted;	//While using the structure, be sure you initialize this to the amount of memory malloc'ed, else there is no way to keep track of memory allocated dynamically
 }MaxOrMinList;
 
@@ -63,5 +66,5 @@
 			}
 			break;
-		case 3://Y = EXP(-x)*SINC(X);
+		case 3://Y = EXP(-x)*SIN(10X);
 //			init = -5;
 			for(index=0;index<NO_OF_POINTS;index++){
@@ -190,7 +193,12 @@
 					if(slope_at_prev_point>0 && slope_at_point<=0){
 						++no_of_actual_max;
-						if(no_of_actual_max>1){
-							buffer->xvals = realloc(buffer->xvals,(sizeof(double))*(no_of_actual_max));
-							buffer->yvals = realloc(buffer->yvals,(sizeof(double))*(no_of_actual_max));
+						if(no_of_actual_max>((buffer->size_allotted)/sizeof(double))){
+							buffer->size_allotted*=2;
+							buffer->xvals = realloc(buffer->xvals,buffer->size_allotted);
+							buffer->yvals = realloc(buffer->yvals,buffer->size_allotted);
+							if(buffer->xvals==NULL || buffer->yvals==NULL){
+								printf("\nError: Reallocation for buffer failed while populating local maxima list");
+								return NULL;
+							}
 						}
 						buffer->yvals[no_of_actual_max-1]=Y_Axis_Values[i];
@@ -223,7 +231,12 @@
 					if(slope_at_prev_point<0 && slope_at_point>=0){
 						++no_of_actual_min;
-						if(no_of_actual_min>1){
-							buffer->xvals = realloc(buffer->xvals,(sizeof(double))*(no_of_actual_min));
-							buffer->yvals = realloc(buffer->yvals,(sizeof(double))*(no_of_actual_min));
+						if(no_of_actual_min>((buffer->size_allotted)/sizeof(double))){
+							buffer->size_allotted*=2;
+							buffer->xvals = realloc(buffer->xvals,buffer->size_allotted);
+							buffer->yvals = realloc(buffer->yvals,buffer->size_allotted);
+							if(buffer->xvals==NULL || buffer->yvals==NULL){
+								printf("\nError: Reallocation for buffer failed while populating local maxima list");
+								return NULL;
+							}
 						}
 						buffer->yvals[no_of_actual_min-1]=Y_Axis_Values[i];
@@ -247,6 +260,8 @@
 	double temp_glob_max;
 	if(buffer!=NULL){
-		local_max_list_buffer.xvals = malloc(sizeof(double));
-		local_max_list_buffer.yvals = malloc(sizeof(double));
+		//size_allotted must be specified, or you sow what you reap...
+		local_max_list_buffer.xvals = malloc(BLOCK_SIZE);
+		local_max_list_buffer.yvals = malloc(BLOCK_SIZE);
+		local_max_list_buffer.size_allotted = BLOCK_SIZE;
 		if(local_max_list_buffer.xvals!=NULL && local_max_list_buffer.yvals!=NULL){
 			local_max_list = get_local_max_list(&local_max_list_buffer);
@@ -258,31 +273,33 @@
 						buffer->no_of_actual_max_or_mins = 1;
 						no_of_actual_global_max=1;
-					if(local_max_list->no_of_actual_max_or_mins == 1){
-						return buffer;
-					}
-					for(i=1;i<local_max_list->no_of_actual_max_or_mins;i++){
-						if(fabs(temp_glob_max-local_max_list->yvals[i])<TOLERANCE){
-							++no_of_actual_global_max;
-						}else{
-							if(temp_glob_max < local_max_list->yvals[i]){
-								no_of_actual_global_max =1;
-								temp_glob_max = local_max_list->yvals[i];
+						if(local_max_list->no_of_actual_max_or_mins == 1){
+							return buffer;
+						}
+						for(i=1;i<local_max_list->no_of_actual_max_or_mins;i++){
+							if(fabs(temp_glob_max-local_max_list->yvals[i])<TOLERANCE){
+								++no_of_actual_global_max;
 							}else{
-								continue;
-							}
-						}
-						if(no_of_actual_global_max>1){
-							//Reallocate space if necessary...
-							buffer->yvals = realloc(buffer->yvals,no_of_actual_global_max*sizeof(double));
-							buffer->xvals = realloc(buffer->xvals,no_of_actual_global_max*sizeof(double));
-							if(buffer->xvals == NULL || buffer->yvals == NULL){
-								printf("\nError: Could not Reallocate space for the Global Maxima List.\n");
-								return NULL;
-							}
-						}
-						buffer->yvals[no_of_actual_global_max-1] = temp_glob_max;
-						buffer->xvals[no_of_actual_global_max-1] = local_max_list->xvals[i];
-						buffer->no_of_actual_max_or_mins = no_of_actual_global_max;
-					}
+								if(temp_glob_max < local_max_list->yvals[i]){
+									no_of_actual_global_max =1;
+									temp_glob_max = local_max_list->yvals[i];
+								}else{
+									continue;
+								}
+							}
+							if(no_of_actual_global_max>((buffer->size_allotted)/sizeof(double))){
+								printf("Buffer Size allotted for Global Max list = %d", buffer->size_allotted);
+								//Reallocate space if necessary...
+								buffer->size_allotted*=2;
+								buffer->yvals = realloc(buffer->yvals,buffer->size_allotted);
+								buffer->xvals = realloc(buffer->xvals,buffer->size_allotted);
+								if(buffer->xvals == NULL || buffer->yvals == NULL){
+									printf("\nError: Could not Reallocate space for the Global Maxima List.\n");
+									return NULL;
+								}
+							}
+							buffer->yvals[no_of_actual_global_max-1] = temp_glob_max;
+							buffer->xvals[no_of_actual_global_max-1] = local_max_list->xvals[i];
+							buffer->no_of_actual_max_or_mins = no_of_actual_global_max;
+						}
 				}else{
 					printf("\nThere are no Local Maxima, consequently a Global Maxima List cannot be generated\n");
@@ -313,6 +330,8 @@
 	double temp_glob_min;
 	if(buffer!=NULL){
-		local_min_list_buffer.xvals = malloc(sizeof(double));
-		local_min_list_buffer.yvals = malloc(sizeof(double));
+		//size_allotted must be specified, or you sow what you reap...
+		local_min_list_buffer.xvals = malloc(BLOCK_SIZE);
+		local_min_list_buffer.yvals = malloc(BLOCK_SIZE);
+		local_min_list_buffer.size_allotted = BLOCK_SIZE;
 		if(local_min_list_buffer.xvals!=NULL && local_min_list_buffer.yvals!=NULL){
 			local_min_list = get_local_min_list(&local_min_list_buffer);
@@ -324,31 +343,33 @@
 						buffer->no_of_actual_max_or_mins = 1;
 						no_of_actual_global_min=1;
-					if(local_min_list->no_of_actual_max_or_mins == 1){
-						return buffer;
-					}
-					for(i=1;i<local_min_list->no_of_actual_max_or_mins;i++){
-						if(fabs(temp_glob_min-local_min_list->yvals[i])<TOLERANCE){
-							++no_of_actual_global_min;
-						}else{
-							if(temp_glob_min > local_min_list->yvals[i]){
-								no_of_actual_global_min =1;
-								temp_glob_min = local_min_list->yvals[i];
+						if(local_min_list->no_of_actual_max_or_mins == 1){
+							return buffer;
+						}
+						for(i=1;i<local_min_list->no_of_actual_max_or_mins;i++){
+							if(fabs(temp_glob_min-local_min_list->yvals[i])<TOLERANCE){
+								++no_of_actual_global_min;
 							}else{
-								continue;
-							}
-						}
-						if(no_of_actual_global_min>1){
-							//Reallocate space if necessary...
-							buffer->yvals = realloc(buffer->yvals,no_of_actual_global_min*sizeof(double));
-							buffer->xvals = realloc(buffer->xvals,no_of_actual_global_min*sizeof(double));
-							if(buffer->xvals == NULL || buffer->yvals == NULL){
-								printf("\nError: Could not Reallocate space for the Global Minima List.\n");
-								return NULL;
-							}
-						}
-						buffer->yvals[no_of_actual_global_min-1] = temp_glob_min;
-						buffer->xvals[no_of_actual_global_min-1] = local_min_list->xvals[i];
-						buffer->no_of_actual_max_or_mins = no_of_actual_global_min;
-					}
+								if(temp_glob_min > local_min_list->yvals[i]){
+									no_of_actual_global_min =1;
+									temp_glob_min = local_min_list->yvals[i];
+								}else{
+									continue;
+								}
+							}
+							if(no_of_actual_global_min>((buffer->size_allotted)/sizeof(double))){
+								//Reallocate space if necessary...
+								printf("Buffer Size allotted for Global Max list = %d", buffer->size_allotted);
+								buffer->size_allotted*=2;
+								buffer->yvals = realloc(buffer->yvals,buffer->size_allotted);
+								buffer->xvals = realloc(buffer->xvals,buffer->size_allotted);
+								if(buffer->xvals == NULL || buffer->yvals == NULL){
+									printf("\nError: Could not Reallocate space for the Global Minima List.\n");
+									return NULL;
+								}
+							}
+							buffer->yvals[no_of_actual_global_min-1] = temp_glob_min;
+							buffer->xvals[no_of_actual_global_min-1] = local_min_list->xvals[i];
+							buffer->no_of_actual_max_or_mins = no_of_actual_global_min;
+						}
 				}else{
 					printf("\nThere are no Local Minima, consequently a Global Minima List cannot be generated\n");
@@ -399,7 +420,12 @@
 					if(slope_at_prev_point>0 && slope_at_point<=0){
 						++no_of_actual_max;
-						if(no_of_actual_max>1){
-							buffer->xvals = realloc(buffer->xvals,(sizeof(double))*(no_of_actual_max));
-							buffer->yvals = realloc(buffer->yvals,(sizeof(double))*(no_of_actual_max));
+						if(no_of_actual_max>((buffer->size_allotted)/sizeof(double))){
+							buffer->size_allotted*=2;
+							buffer->xvals = realloc(buffer->xvals,buffer->size_allotted);
+							buffer->yvals = realloc(buffer->yvals,buffer->size_allotted);
+							if(buffer->xvals == NULL || buffer->yvals == NULL){
+									printf("\nError: Could not Reallocate space for the Global Minima List.\n");
+									return NULL;
+							}
 						}
 						buffer->yvals[no_of_actual_max-1]=Y_Axis_Values[i];
@@ -446,7 +472,12 @@
 					if(slope_at_prev_point<0 && slope_at_point>=0){
 						++no_of_actual_min;
-						if(no_of_actual_min>1){
-							buffer->xvals = realloc(buffer->xvals,(sizeof(double))*(no_of_actual_min));
-							buffer->yvals = realloc(buffer->yvals,(sizeof(double))*(no_of_actual_min));
+						if(no_of_actual_min>((buffer->size_allotted)/sizeof(double))){
+							buffer->size_allotted*=2;
+							buffer->xvals = realloc(buffer->xvals,buffer->size_allotted);
+							buffer->yvals = realloc(buffer->yvals,buffer->size_allotted);
+							if(buffer->xvals == NULL || buffer->yvals == NULL){
+									printf("\nError: Could not Reallocate space for the Global Minima List.\n");
+									return NULL;
+							}
 						}
 						buffer->yvals[no_of_actual_min-1]=Y_Axis_Values[i];
@@ -474,6 +505,7 @@
 	int i; 
 	double xval1,xval2;
-	list.xvals = malloc(sizeof(double));
-	list.yvals = malloc(sizeof(double));
+	list.xvals = malloc(BLOCK_SIZE);
+	list.yvals = malloc(BLOCK_SIZE);
+	list.size_allotted =BLOCK_SIZE;
 	if(list.xvals!=NULL && list.yvals!=NULL){
 		buffer = get_local_max_list(&list);
Index: /trunk/packages/optimizer/src/fitfunc/ff_modules_for_discrete_params.c
===================================================================
--- /trunk/packages/optimizer/src/fitfunc/ff_modules_for_discrete_params.c	(revision 1061)
+++ /trunk/packages/optimizer/src/fitfunc/ff_modules_for_discrete_params.c	(revision 1062)
@@ -7,14 +7,6 @@
 #include<stdlib.h>
 #include<time.h>
-
-//I think this structure needs to be included with PGAPACK code. A list of current gene values can be maintained and 
-//before each evaluation the gene values can be updated.
-typedef struct Gene{
-	int geneID;
-	double weight;
-	double value;
-	double rangemin;
-	double rangemax;
-}Gene;
+#include "pgapack.h"
+#include "rp_optimizer.h"
 
 
@@ -23,10 +15,10 @@
 * is not yet complete.
 */
-double get_gene(int geneID){
+double get_gene(char* name){
 	return 0;
 }
 
 /*
- * Return the actual values of all the genes in the current string
+ * Return the actual values of all the genes in the currently evaluated chromosome
  */
 double* get_all_genes(){
@@ -35,30 +27,18 @@
 
 /*
- * Return the gene value raised to a power
+ * The way to go about doing this is to fetch  
  */
-double gene_value_raised_to_power(int geneID){
+double weighted_sum_of_variances(double* array_of_current_values, double* array_of_desired_values){
 	return 0;
 }
 
-/*
- * Return the absolute value of a gene.
- */
- 
-double gene_abs_value(int geneID){
- 	return 0;
-}
- 
-double weighted_sum_of_genes(){
-	return 0;
-}
 
-/*
- * I need to verify this yet. 
- */
-double weighted_sum_of_nth_power_distances(){
-	return 0;
+double abs_nth_power_distance(double actual_value, double desired_value,double power){
+	return pow(fabs(actual_value-desired_value),power);
 }
 
 int main(){
+	double actual=5,desired=30,power=0.2;
+	printf("Actual - %lf, Desired - %lf, (Actual-Desired)^ %lf is %lf\n", actual,desired,power,abs_nth_power_distance(actual,desired,power));
 	return 0;
 }
Index: /trunk/packages/optimizer/src/plugin_pgapack.c
===================================================================
--- /trunk/packages/optimizer/src/plugin_pgapack.c	(revision 1061)
+++ /trunk/packages/optimizer/src/plugin_pgapack.c	(revision 1062)
@@ -24,4 +24,5 @@
 } PgapackData;
 
+
 RpCustomTclOptionParse RpOption_ParseOper;
 RpCustomTclOptionGet RpOption_GetOper;
@@ -35,4 +36,11 @@
     "pga_poprepl", RpOption_ParsePopRepl, RpOption_GetPopRepl, NULL
 };
+
+typedef struct PgapackRuntimeDataTable{
+	double **data;				/*Actual data per sample, like values of the genes, fitness of a sample, etc*/
+	int num_of_rows;			/*Number of rows alloced..should be constant for a run*/
+	int no_of_samples_evaled;	/*Number of samples evaluated so far*/
+	int no_of_columns;					/*Number of columns allocated to the data table so far*/
+}PgapackRuntimeDataTable;
 
 RpTclOption PgapackOptions[] = {
@@ -58,6 +66,9 @@
 static RpOptimEnv* PgapGetEnvForContext _ANSI_ARGS_((PGAContext *ctx));
 static void PgapUnlinkContext2Env _ANSI_ARGS_((PGAContext *ctx));
-
-
+void PGARuntimeDataTableInit _ANSI_ARGS_((RpOptimEnv *envPtr));
+void PGARuntimeDataTableDeInit();
+void GetSampleInformation _ANSI_ARGS_((char *buffer, int sampleNumber));
+void PGARuntimeDataTableSetSampleValue _ANSI_ARGS_((RpOptimParam *chrom, double fitness));
+static PgapackRuntimeDataTable table;
 /*
  * ----------------------------------------------------------------------
@@ -144,5 +155,4 @@
     PGARun(ctx, PgapEvaluate);
     PGADestroy(ctx);
-
     PgapUnlinkContext2Env(ctx);
 
@@ -168,4 +178,5 @@
     int p;            /* sample #p being run */
     int pop;          /* identifier for this population */
+    
 {
     double fit = 0.0;
@@ -173,10 +184,8 @@
     RpOptimParam *paramPtr;
     RpOptimStatus status;
-
     envPtr = PgapGetEnvForContext(ctx);
     paramPtr = (RpOptimParam*)PGAGetIndividual(ctx, p, pop)->chrom;
-
     status = (*envPtr->evalProc)(envPtr, paramPtr, envPtr->numParams, &fit);
-
+	
     if (pgapack_abort) {
         fprintf(stderr, "==WARNING: run aborted!");
@@ -188,5 +197,7 @@
         PgapPrintString(ctx, stderr, p, pop);
     }
-
+	
+	/*populate the table with this sample*/
+	PGARuntimeDataTableSetSampleValue(paramPtr,fit);
     return fit;
 }
@@ -518,4 +529,6 @@
 }
 
+
+
 /*
  * ----------------------------------------------------------------------
@@ -707,2 +720,127 @@
     }
 }
+/*---------------------------------------------------------------------------------
+ * PGARuntimeDTInit(): It initializes the runtime data table.
+ * The table is organized slightly counter-intuitively
+ * Instead of a
+ *  param1|param2|param3  |param4...
+ * 	val11 |val12 |val13   |val14...
+ * 	val12 |val22 |val23   |val24....
+ * orientation, it is organized as
+ * 	param1|val11|val12
+ * 	param2|val21|val22
+ * 	param3|val31|val32
+ * 	param4|val41|val42
+ * Reallocating for additional columns is easier than reallocating additional rows and then
+ * reallocating for columns 
+ * --------------------------------------------------------------------------------
+ */
+
+void PGARuntimeDataTableInit(envPtr)
+RpOptimEnv *envPtr;
+{    
+	int i;
+	if(envPtr != NULL){
+		table.num_of_rows = (envPtr->numParams)+1;
+		table.data = malloc((table.num_of_rows)*sizeof(double*));
+		if(table.data == NULL){
+			panic("\nAllocation for Runtime Data Table failed\n");
+		}
+		for(i=0;i<table.num_of_rows;i++){
+			table.data[i] = malloc(PGAPACK_RUNTIME_TABLE_DEFAULT_SIZE*sizeof(double));
+			if(table.data[i] == NULL){
+				panic("\nAllocation for Runtime Data Table failed\n");
+			}			
+		}
+		table.no_of_samples_evaled = 0;
+		table.no_of_columns = PGAPACK_RUNTIME_TABLE_DEFAULT_SIZE;
+		
+	}else{
+		panic("\nError: NULL Environment variable OR Table pointer passed to Data Table Init\n");
+	}
+}
+
+void PGARuntimeDataTableDeInit()
+{	
+	int i;
+	if((&table) == NULL){
+		panic("Error: Table not present, therefore cannot free memory..");
+	}
+	for(i=0;i<table.num_of_rows;i++){
+		free(table.data[i]);
+	}
+	free(table.data);
+}
+
+void PGARuntimeDataTableSetSampleValue(chrom,fitness)
+RpOptimParam *chrom;
+double fitness;
+{
+	int i;
+	printf("\nSetting sample value.......................\n");
+	if(chrom!=NULL && (&table)!=NULL){
+		(table.no_of_samples_evaled)+=1;
+		if((table.no_of_samples_evaled) > table.no_of_columns){
+			/* then Reallocate space for more columns)*/
+			(table.no_of_columns)+=(table.no_of_columns);
+				//TODO GTG: Delete printing stuff
+			for(i=0;i<(table.num_of_rows);i++){
+				table.data[i] = realloc(table.data[i],table.no_of_columns);
+				if(table.data[i]==NULL){
+					panic("\nError: Could not Reallocate more space for the table");
+				}				
+			}
+		}else{
+			if(chrom->type == RP_OPTIMPARAM_NUMBER){
+				for(i=0;i<(table.num_of_rows);i++){
+					if(i==0){
+						table.data[i][(table.no_of_samples_evaled)-1] = fitness;
+						printf("\nSample Number %d:- Fitness: %lf\t",table.no_of_samples_evaled,fitness);
+					}else{
+						table.data[i][(table.no_of_samples_evaled)-1] = chrom[i-1].value.dval;
+						printf("Param %d %lf\t",i,table.data[i][(table.no_of_samples_evaled)-1]);
+					}
+                }
+			}else{
+				panic("\n Chromosome value is RP_OPTIMPARAM_STRING\n");
+				//GTG TODO: find out what happens in this case. Will we be better off handling Tcl_objects?
+			}	
+		}
+	}else{
+		panic("\nError:Either Chromosome, or table passed to PGARuntimeDataTableSetSampleValue() is NULL\n"); 
+	}
+	
+}
+
+void GetSampleInformation(buffer,sampleNumber)
+	char *buffer;
+	int sampleNumber;
+{
+	int i;
+	char tempBuff[50];
+	printf("\nFetching sample information.........................\n");
+	if((&table) == NULL){
+		panic("Table uninitialized");
+	}
+	if(sampleNumber<=0){
+		sprintf(buffer,"\nNumber of Samples Evaluated so far: %d\n",(table.no_of_samples_evaled)+1);
+		return;
+	}
+	if(((table.num_of_rows)-1)*10>SINGLE_SAMPLE_DATA_BUFFER_DEFAULT_SIZE){
+		buffer = realloc(buffer,50+25*(table.num_of_rows));
+		//resizing the buffer, keeping 50 for display related jazz, around 12-15 characs for param names
+		//and 10 characs for Fl.pt. display of the value
+		if(buffer == NULL){
+			panic("\nError: Could not reallocate space for sample data buffer");
+		}
+	}
+	for(i=0;i<(table.num_of_rows);i++){
+		if(i==0){
+			sprintf(buffer,"\nSample Number %d ----> Fitness: %lf  ",sampleNumber,table.data[i][sampleNumber-1]);
+		}else{
+			sprintf(tempBuff,"Param %d: %lf  ",i,table.data[i][sampleNumber-1]);
+			strcat(buffer,tempBuff);
+		}
+	}
+	strcat(buffer,"\n");
+}
Index: /trunk/packages/optimizer/src/rp_optimizer.h
===================================================================
--- /trunk/packages/optimizer/src/rp_optimizer.h	(revision 1061)
+++ /trunk/packages/optimizer/src/rp_optimizer.h	(revision 1062)
@@ -24,4 +24,7 @@
 #include <malloc.h>
 #include "rp_tcloptions.h"
+
+#define PGAPACK_RUNTIME_TABLE_DEFAULT_SIZE 5000 /*Approx Number of Samples in a run*/
+#define SINGLE_SAMPLE_DATA_BUFFER_DEFAULT_SIZE 5000
 
 /*
@@ -140,3 +143,4 @@
 EXTERN void RpOptimDelete _ANSI_ARGS_((RpOptimEnv *envPtr));
 
+
 #endif
Index: /trunk/packages/optimizer/src/rp_optimizer_tcl.c
===================================================================
--- /trunk/packages/optimizer/src/rp_optimizer_tcl.c	(revision 1061)
+++ /trunk/packages/optimizer/src/rp_optimizer_tcl.c	(revision 1062)
@@ -71,4 +71,7 @@
 
 extern int pgapack_abort;
+extern void PGARuntimeDataTableInit();
+extern void PGARuntimeDataTableDeInit();
+extern void GetSampleInformation();
 
 int
@@ -224,8 +227,6 @@
     toolDataPtr->updateCmdPtr = NULL;
     envPtr->toolData = (ClientData)toolDataPtr;
-
     Tcl_CreateObjCommand(interp, name, RpOptimInstanceCmd,
         (ClientData)envPtr, (Tcl_CmdDeleteProc*)RpOptimCmdDelete);
-
     Tcl_SetResult(interp, name, TCL_VOLATILE);
     return TCL_OK;
@@ -250,4 +251,5 @@
     ClientData paramdata;
 
+    PGARuntimeDataTableDeInit();/*Free space allocated to data table here*/
     if (envPtr->toolData) {
         toolDataPtr = (RpOptimToolData*)envPtr->toolData;
@@ -290,8 +292,9 @@
  *                     ?-updatecommand <varName>?
  *      <name> using
+ *      <name> samples ?number?
  *
  *  The "add" command is used to add various parameter types to the
  *  optimizer context.  The "perform" command kicks off an optimization
- *  run.
+ *  run. The "samples" command displays sample info during an optimization run.
  * ------------------------------------------------------------------------
  */
@@ -313,5 +316,5 @@
     RpTclOption *optSpecPtr;
     Tcl_Obj *rval, *rrval, *toolPtr, *updateCmdPtr;
-
+    
     if (objc < 2) {
         Tcl_WrongNumArgs(interp, 1, objv, "option ?args...?");
@@ -580,5 +583,7 @@
         /* no -updatecommand by default */
         updateCmdPtr = NULL;
-
+		
+		PGARuntimeDataTableInit(envPtr);/*Initialize Data table here....*/
+		
         n = 2;
         while (n < objc) {
@@ -632,10 +637,10 @@
             toolDataPtr->updateCmdPtr = updateCmdPtr;
         }
-
+		
         /* call the main optimization routine here */
         status = (*envPtr->pluginDefn->runProc)(envPtr,
             RpOptimizerPerformInTcl, fitnessExpr);
-
-	fprintf(stderr, ">>>status=%d\n", status);
+		
+		fprintf(stderr, ">>>status=%d\n", status);
 
         Tcl_DecrRefCount(toolPtr);
@@ -682,9 +687,36 @@
         return TCL_OK;
     }
+    
+    else if(*option == 's' && strcmp(option,"samples") == 0){
+    	int sampleNumber = -1; /*initing sampnum to -1, use it when no sample number is specified*/
+    	char *sampleDataBuffer;
+    	if(objc>3){
+    		Tcl_WrongNumArgs(interp, 2, objv, "?sampleNumber?");
+            return TCL_ERROR;
+    	}
+    	
+    	if(objc == 3){
+	    	if(Tcl_GetIntFromObj(interp,objv[2],&sampleNumber) != TCL_OK){
+	    		return TCL_ERROR; 
+	    	}
+    		sampleDataBuffer = malloc(sizeof(char)*SINGLE_SAMPLE_DATA_BUFFER_DEFAULT_SIZE);
+    	}else{
+    		sampleDataBuffer = malloc(sizeof(char)*50);
+    	}
+    	
+    	if(sampleDataBuffer == NULL){
+    		panic("Error: Could not allocate memory for sample data buffer.");
+    	}
+    	GetSampleInformation(sampleDataBuffer,sampleNumber);
+		fprintf(stdout,sampleDataBuffer);/**TODO GTG check if this should be fprintf or something else*/
+		free(sampleDataBuffer);
+    	return TCL_OK;
+    	
+    }
 
     else {
         Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
             "bad option \"", option, "\": should be add, configure, "
-            "get, perform, using", (char*)NULL);
+            "get, perform, using, samples", (char*)NULL);
         return TCL_ERROR;
     }
