Index: vtcross/trunk/src/main_cognitive_radio.c
===================================================================
--- vtcross/trunk/src/main_cognitive_radio.c	(revision 27)
+++ vtcross/trunk/src/main_cognitive_radio.c	(revision 27)
@@ -0,0 +1,140 @@
+//
+// Cognitive radio simulator
+//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <sigprocc/sigprocc.h>
+#include "cbr.h"
+#include "cognitive_radio_test.h"
+
+// options
+#define PACKET_SIZE 1024    // packet size (number of bits)
+#define NUM_TRIALS 250      // number of epochs
+#define REPORT_TRIALS 10    // print report every so often
+
+int main() {
+    // bookkeeping variables and buffers
+    unsigned int num_bits=PACKET_SIZE;
+    char msg_in[num_bits], msg_out[num_bits];
+    float I[num_bits], Q[num_bits];
+    unsigned int num_symbols, num_bits_out;
+
+    float noise_psd = -100.0f; // noise power spectral density
+    float noise_power, noise_std;
+    
+    // quality of service metrics
+    unsigned int num_bit_errors;
+    float throughput_bps;
+
+    // metadata defaults
+    struct metadata_t mdt;
+    metadata md = &mdt;
+
+    md->mod_scheme = MOD_QAM;   // MOD_PSK, MOD_QAM, MOD_PAM, MOD_DPSK
+    md->mod_bps = 4;            // modulation scheme [bits/s]
+    md->tx_power_dBW = -3.0f;   // transmit power [dBW]
+    md->symbol_rate = 250e3f;   // symbol rate [symbols/s]
+
+    // case-based reasoner
+    unsigned int num_cols = 7;
+    char * cols[] = { 
+        "BER", "throughput",
+        "mod_scheme", "tx_power",
+        "noise_power", "path_loss",
+        "utility"
+    };  
+    float vals[num_cols];
+    vals[0] = 1e-3f;    // BER
+    vals[1] = 10e3f;    // throughput
+    vals[2] = 1;        // mod_scheme
+    vals[3] = -3.0f;    // tx_power
+    vals[4] = -50.0f;   // noise_power
+    vals[5] = 125.0f;   // path_loss
+    vals[6] = 0.762;    // utility
+    int rc; 
+
+    // create cbr database/table
+    cbr mycbr = cbr_create("ex1", "data", cols, num_cols);
+
+    // add row here
+    //rc = cbr_add_row(mycbr, cols, vals, num_cols);
+
+    // print
+    cbr_print(mycbr);
+
+    // cbr search setup
+    char * search_names[] = {"BER"};
+    int search_ops[] = {LT};
+    float search_vals[] = {30.0f/(float)PACKET_SIZE};
+    float retvals[num_cols];
+
+
+    unsigned int i;
+    // generate random message
+    for (i=0; i<num_bits; i++)
+        msg_in[i] = (char) (rand() % 2);
+
+    printf("epoch\tutility\n");
+    printf("-----\t-------\n");
+    for (i=0; i<NUM_TRIALS; i++) {
+        // compute internals
+        noise_power = noise_psd + 20*log10f(md->symbol_rate);
+        noise_std = powf(10.0f, (noise_power - md->tx_power_dBW) / 10.0f) / 2.0f;
+
+        // execute transmitter
+        execute_tx(md, msg_in, num_bits, I, Q, &num_symbols);
+
+        // execute channel
+        execute_channel(md, noise_std, I, Q, num_symbols);
+
+        // execute receiver
+        execute_rx(md, I, Q, num_symbols, msg_out, &num_bits_out);
+
+        //
+        // *** compute quality of service metrics ***
+        //
+
+        // count errors, etc.
+        num_bit_errors = count_errors(msg_in, msg_out, num_bits);
+        throughput_bps = ((float)(md->mod_bps)) * md->symbol_rate;
+
+        if ( ((i+1)%REPORT_TRIALS)==0 || (i+1)==NUM_TRIALS) {
+            // print results
+            printf("%u\t%.2f\terrors:\t%u\t/ %u, power: %.1f dBW, Fs: %.3f kHz\n",
+                    i+1, 0.0f, num_bit_errors, num_bits, md->tx_power_dBW, md->symbol_rate/1e3 );
+        }
+
+        // 
+        // *** execute cognition here ***
+        //
+
+        // store result
+        vals[0] = (float) num_bit_errors / PACKET_SIZE; // BER
+        vals[1] = throughput_bps;
+        //vals[2] = // mod_scheme
+        vals[3] = md->tx_power_dBW; // tx_power
+        vals[6] = md->tx_power_dBW;// utility
+
+        rc = cbr_add_row(mycbr, cols, vals, num_cols);
+            
+        // execute cbr search
+        rc = cbr_search(mycbr, search_names, search_ops, search_vals, 1, retvals);
+
+        if (rc==0) {
+            // no solution found
+            md->tx_power_dBW += 0.2f;
+            //printf("no solution found\n");
+        } else {
+            // set values
+            md->tx_power_dBW = retvals[3];
+        }
+
+    }
+
+    cbr_free(mycbr);
+
+    printf("done.\n");
+    return 0;
+}
Index: vtcross/trunk/src/main_test.c
===================================================================
--- vtcross/trunk/src/main_test.c	(revision 26)
+++ 	(revision )
@@ -1,140 +1,0 @@
-//
-// Cognitive radio simulator
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <sigprocc/sigprocc.h>
-#include "cbr.h"
-#include "cognitive_radio_test.h"
-
-// options
-#define PACKET_SIZE 1024    // packet size (number of bits)
-#define NUM_TRIALS 250      // number of epochs
-#define REPORT_TRIALS 10    // print report every so often
-
-int main() {
-    // bookkeeping variables and buffers
-    unsigned int num_bits=PACKET_SIZE;
-    char msg_in[num_bits], msg_out[num_bits];
-    float I[num_bits], Q[num_bits];
-    unsigned int num_symbols, num_bits_out;
-
-    float noise_psd = -100.0f; // noise power spectral density
-    float noise_power, noise_std;
-    
-    // quality of service metrics
-    unsigned int num_bit_errors;
-    float throughput_bps;
-
-    // metadata defaults
-    struct metadata_t mdt;
-    metadata md = &mdt;
-
-    md->mod_scheme = MOD_QAM;   // MOD_PSK, MOD_QAM, MOD_PAM, MOD_DPSK
-    md->mod_bps = 4;            // modulation scheme [bits/s]
-    md->tx_power_dBW = -3.0f;   // transmit power [dBW]
-    md->symbol_rate = 250e3f;   // symbol rate [symbols/s]
-
-    // case-based reasoner
-    unsigned int num_cols = 7;
-    char * cols[] = { 
-        "BER", "throughput",
-        "mod_scheme", "tx_power",
-        "noise_power", "path_loss",
-        "utility"
-    };  
-    float vals[num_cols];
-    vals[0] = 1e-3f;    // BER
-    vals[1] = 10e3f;    // throughput
-    vals[2] = 1;        // mod_scheme
-    vals[3] = -3.0f;    // tx_power
-    vals[4] = -50.0f;   // noise_power
-    vals[5] = 125.0f;   // path_loss
-    vals[6] = 0.762;    // utility
-    int rc; 
-
-    // create cbr database/table
-    cbr mycbr = cbr_create("ex1", "data", cols, num_cols);
-
-    // add row here
-    //rc = cbr_add_row(mycbr, cols, vals, num_cols);
-
-    // print
-    cbr_print(mycbr);
-
-    // cbr search setup
-    char * search_names[] = {"BER"};
-    int search_ops[] = {LT};
-    float search_vals[] = {30.0f/(float)PACKET_SIZE};
-    float retvals[num_cols];
-
-
-    unsigned int i;
-    // generate random message
-    for (i=0; i<num_bits; i++)
-        msg_in[i] = (char) (rand() % 2);
-
-    printf("epoch\tutility\n");
-    printf("-----\t-------\n");
-    for (i=0; i<NUM_TRIALS; i++) {
-        // compute internals
-        noise_power = noise_psd + 20*log10f(md->symbol_rate);
-        noise_std = powf(10.0f, (noise_power - md->tx_power_dBW) / 10.0f) / 2.0f;
-
-        // execute transmitter
-        execute_tx(md, msg_in, num_bits, I, Q, &num_symbols);
-
-        // execute channel
-        execute_channel(md, noise_std, I, Q, num_symbols);
-
-        // execute receiver
-        execute_rx(md, I, Q, num_symbols, msg_out, &num_bits_out);
-
-        //
-        // *** compute quality of service metrics ***
-        //
-
-        // count errors, etc.
-        num_bit_errors = count_errors(msg_in, msg_out, num_bits);
-        throughput_bps = ((float)(md->mod_bps)) * md->symbol_rate;
-
-        if ( ((i+1)%REPORT_TRIALS)==0 || (i+1)==NUM_TRIALS) {
-            // print results
-            printf("%u\t%.2f\terrors:\t%u\t/ %u, power: %.1f dBW, Fs: %.3f kHz\n",
-                    i+1, 0.0f, num_bit_errors, num_bits, md->tx_power_dBW, md->symbol_rate/1e3 );
-        }
-
-        // 
-        // *** execute cognition here ***
-        //
-
-        // store result
-        vals[0] = (float) num_bit_errors / PACKET_SIZE; // BER
-        vals[1] = throughput_bps;
-        //vals[2] = // mod_scheme
-        vals[3] = md->tx_power_dBW; // tx_power
-        vals[6] = md->tx_power_dBW;// utility
-
-        rc = cbr_add_row(mycbr, cols, vals, num_cols);
-            
-        // execute cbr search
-        rc = cbr_search(mycbr, search_names, search_ops, search_vals, 1, retvals);
-
-        if (rc==0) {
-            // no solution found
-            md->tx_power_dBW += 0.2f;
-            //printf("no solution found\n");
-        } else {
-            // set values
-            md->tx_power_dBW = retvals[3];
-        }
-
-    }
-
-    cbr_free(mycbr);
-
-    printf("done.\n");
-    return 0;
-}
