/* find one feasible solution coefficients are read from a file matrices are allocated dynamically sample data files feas-t1-0.dat feas-t1-1.dat feas-t1-2.dat Usage: feas-t1.out or feas-t1.out filename */ #include #include "opt.h" main(int argc, char **argv) { FILE *fd; char *filename = "feas-t1-0.dat"; int m, n; double *a, *b, *ox; double eps; status st; if (argc >= 2) { filename = argv[1]; } if ((fd = fopen(filename,"r")) == NULL) { fprintf(stderr, "cannot open file %s\n", filename); exit(1); } fprintf(stderr, "\n Feasibility check in file %s\n\n", filename); fscanf(fd, "%d %d", &m, &n); matrixallocfscan(fd, m, n, &a); /* a : m x n matrix */ matrixallocfscan(fd, m, 1, &b); /* b : m x 1 matrix */ fclose(fd); matrixfprint(stdout, m, n, a); matrixfprint(stdout, m, 1, b); ox = allc(dbl,n*1); eps = 1e-5; st = LPfeasiblesolution(m, n, a, b, eps, ox); if (st == success) { puts("--- find one solution ---"); matrixfprint(stdout, n, 1, ox); } else { puts("--- no feasible solution ---"); } }