root/vtcross/trunk/src/main_cbr.c @ 27

Revision 25, 1.2 KB (checked in by jgaeddert, 16 years ago)

modifying cbr search to return 0 when no solution is found

Line 
1//
2//
3//
4
5#include <stdio.h>
6#include "cbr.h"
7
8int main() {
9    unsigned int num_cols = 7;
10    char * cols[] = {
11        "BER", "throughput",
12        "mod_scheme", "tx_power",
13        "noise_power", "path_loss",
14        "utility"
15    };
16    float vals[num_cols];
17    vals[0] = 1e-3f;    // BER
18    vals[1] = 10e3f;    // throughput
19    vals[2] = 1;        // mod_scheme
20    vals[3] = -3.0f;    // tx_power
21    vals[4] = -50.0f;   // noise_power
22    vals[5] = 125.0f;   // path_loss
23    vals[6] = 0.762;    // utility
24    int rc;
25
26    // create cbr database/table
27    cbr mycbr = cbr_create("ex1", "data", cols, num_cols);
28
29    // add row here
30    rc = cbr_add_row(mycbr, cols, vals, num_cols);
31
32    // print
33    cbr_print(mycbr);
34
35    // simple search: find entry where...
36    //   BER < 1e-2 and path_loss > 100
37    char * search_names[] = {"BER", "path_loss"};
38    int search_ops[] = {LT, GT};
39    float search_vals[] = {1e-2f, 100.f};
40    float retvals[num_cols];
41    rc = cbr_search(mycbr, search_names, search_ops, search_vals, 2, retvals);
42    if (rc)
43        printf("solution found!\n");
44    else
45        printf("warning! no solution found\n");
46
47    // clean up
48    cbr_free(mycbr);
49
50    printf("done.\n");
51    return 0;
52}
53
Note: See TracBrowser for help on using the browser.