Index: vtcross/branches/trnewman/CR_engines/CBR/src/main_cognitive_engine.c
===================================================================
--- vtcross/branches/trnewman/CR_engines/CBR/src/main_cognitive_engine.c	(revision 79)
+++ vtcross/branches/trnewman/CR_engines/CBR/src/main_cognitive_engine.c	(revision 83)
@@ -252,22 +252,4 @@
 
     
-int GetXMLFromServer(int sockfd, struct Utility uList[], struct Parameter pList[], 
-        struct Observable oList[], struct CE_Info *ce_info)
-{
-    // get utilities
-    GetUtility(sockfd, uList, ce_info);
-    
-    // get parameters
-    GetParameter(sockfd, pList, ce_info);
-
-    // read obervables
-    GetObservable(sockfd, oList, ce_info);
-
-    printf("xml reception done\n");
-    
-    return 1;
-}
-
-
 int SendMessage(int socketfd, char *message) 
 {
@@ -284,4 +266,26 @@
     
     return n;
+}
+
+
+int GetXMLFromServer(int sockfd, struct Utility uList[], struct Parameter pList[], 
+        struct Observable oList[], struct CE_Info *ce_info)
+{
+    // get utilities
+    GetUtility(sockfd, uList, ce_info);
+    
+    // get parameters
+    GetParameter(sockfd, pList, ce_info);
+
+    // read obervables
+    GetObservable(sockfd, oList, ce_info);
+
+    // send ack back to server
+    char buffer[256];
+    strcpy(buffer, "xml received");
+    SendMessage(sockfd, buffer);
+    printf("xml reception done\n");
+    
+    return 1;
 }
 
@@ -401,7 +405,20 @@
     // simple search: find entry where...
     //   log10_ber < 1e-2 and SNR > 5
-    char * search_names[] = {"log10_ber", "SNR"};
-    int search_ops[] = {LT, GT};
-    float search_vals[] = {1e-2f, 5.f};
+    //char * search_names[] = {"log10_ber", "SNR"};
+    char ** search_names;
+    search_names
+        = (char **)malloc(sizeof(char)*(ce_info->numUtilities));
+    for (i = 0; i < ce_info->numUtilities; i++){
+        search_names[i] 
+            = malloc(sizeof(char)*(strlen(uList[i].name)+1));
+        search_names[i] = uList[i].name;
+    }
+    int search_ops[] = {GT, GT, LT};
+    //float search_vals[] = {1e-2f, 5.f};
+    float *search_vals;
+    search_vals = malloc(sizeof(float)*(ce_info->numUtilities));
+    for (i = 0; i < ce_info->numUtilities; i++){
+        search_vals[i] = uList[i].target;
+    }
     float retvals[num_cols];
     rc = cbr_search(mycbr, search_names, search_ops, 
@@ -428,4 +445,34 @@
     return 1;
 }
+
+
+int SendCEResults(int sockfd, struct Utility uList[], struct Parameter pList[], 
+        struct Observable oList[], struct CE_Info *ce_info)
+{
+    // send results back to server
+    char var[50];
+    int i;
+ 
+    /*// utility
+    for (i = 0; i < ce_info->numUtilities; i++){
+        sprintf(var, "%f", uList[i].value);
+        SendMessage(sockfd, var);
+    }*/
+    
+    // parameter
+    for (i = 0; i < ce_info->numParameters; i++){
+        sprintf(var, "%f", pList[i].value);
+        SendMessage(sockfd, var);
+    }
+    
+    /*// observable
+    for (i = 0; i < ce_info->numObservables; i++){
+        sprintf(var, "%f", oList[i].value);
+        SendMessage(sockfd, var);
+    }*/
+
+    return 1;
+}
+
 
 // main client socket
@@ -464,32 +511,23 @@
     
     // send results back to server
-    char counter[50];
+    SendCEResults(sockfd, uList, pList, oList, &ce_info);
+
+/*    char counter[50];
     char var[50];
     // utility
-    sprintf(counter, "%d", ce_info.numUtilities);
-    SendMessage(sockfd, counter);
-    // send utilities
     for (i = 0; i < ce_info.numUtilities; i++){
         sprintf(var, "%f", uList[i].value);
         SendMessage(sockfd, var);
     }
-
     // parameter
-    sprintf(counter, "%d", ce_info.numParameters);
-    SendMessage(sockfd, counter);
-    // send parameters
     for (i = 0; i < ce_info.numParameters; i++){
         sprintf(var, "%f", pList[i].value);
         SendMessage(sockfd, var);
     }
-
     // observable
-    sprintf(counter, "%d", ce_info.numObservables);
-    SendMessage(sockfd, counter);
-    // send utilities
     for (i = 0; i < ce_info.numObservables; i++){
         sprintf(var, "%f", oList[i].value);
         SendMessage(sockfd, var);
-    }
+    }*/
 
 
