APPFS
Advanced practical programming for scientists
|
Appfs Exercise 4: BIP Enumerator. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <stdbool.h>
#include <time.h>
#include "mshell.h"
#include "sid.h"
#include "allocate.h"
Go to the source code of this file.
Data Structures | |
struct | binary_program |
Macros | |
#define | BIP_SID 0x42495078 |
#define | BIP_COLS 32 |
#define | BIP_ROWS 32 |
#define | MAX_LINE_LEN 512 |
Maximum input line length. More... | |
#define | MAX_COEF_VAL 1e20 |
Maximum absolute value of a coefficient. More... | |
#define | GET_SEC(a, b) ((b - a) / (double)CLOCKS_PER_SEC) |
Typedefs | |
typedef struct binary_program | BIP |
Enumerations | |
enum | LINE_MODE { READ_COLS, READ_ROWS, READ_COEF } |
Functions | |
bool | bip_is_valid (const BIP *bip) |
Check whether BIP data structure is consistent. More... | |
void | bip_free (BIP *bip) |
Deallocate BIP data structure. More... | |
BIP * | bip_read (const char *filename) |
Read a bip file. More... | |
void | bip_print (FILE *fp, const BIP *bip) |
Print Binary Program from BIP. More... | |
void | print_solu (FILE *fp, int vars, const double *x) |
Print solution vector. More... | |
bool | bip_is_feasible (const BIP *bip, const double *x) |
Check whether a particular vector is a feasible solution to a BIP. More... | |
int | bip_enumerate (const BIP *bip, bool with_output) |
Enumerate all possible solution of a BIP. More... | |
int | main (int argc, const char **argv) |
Usage: ex4_enum bip_file. More... | |
gcc -O3 -Wall -std=c99 -o ex4_enum ex4_enum.c
Options: -DUSE_SCANF use sscanf() for input -DUSE_STRTOK use strtok() for input otherwise strtol() is used. -DNO_MSHELL don't compile with mshell
Definition in file ex4_enum.c.
#define BIP_COLS 32 |
Definition at line 28 of file ex4_enum.c.
#define BIP_ROWS 32 |
Definition at line 29 of file ex4_enum.c.
#define BIP_SID 0x42495078 |
Definition at line 27 of file ex4_enum.c.
#define GET_SEC | ( | a, | |
b | |||
) | ((b - a) / (double)CLOCKS_PER_SEC) |
Definition at line 46 of file ex4_enum.c.
#define MAX_COEF_VAL 1e20 |
Definition at line 44 of file ex4_enum.c.
#define MAX_LINE_LEN 512 |
Definition at line 42 of file ex4_enum.c.
typedef struct binary_program BIP |
Definition at line 40 of file ex4_enum.c.
enum LINE_MODE |
Enumerator | |
---|---|
READ_COLS | |
READ_ROWS | |
READ_COEF |
Definition at line 48 of file ex4_enum.c.
int bip_enumerate | ( | const BIP * | bip, |
bool | with_output | ||
) |
Prints all solutions.
Definition at line 382 of file ex4_enum.c.
void bip_free | ( | BIP * | bip | ) |
Definition at line 77 of file ex4_enum.c.
bool bip_is_feasible | ( | const BIP * | bip, |
const double * | x | ||
) |
Definition at line 356 of file ex4_enum.c.
bool bip_is_valid | ( | const BIP * | bip | ) |
void bip_print | ( | FILE * | fp, |
const BIP * | bip | ||
) |
Definition at line 323 of file ex4_enum.c.
BIP* bip_read | ( | const char * | filename | ) |
Format example:
4 # cols (variables) 3 # rows (constraints) 2 3 5 4 <= 8 3 6 0 8 <= 10 0 0 1 1 <= 1
comments (#) and empty lines are ignored.
filename | name of file to read |
Definition at line 102 of file ex4_enum.c.
int main | ( | int | argc, |
const char ** | argv | ||
) |
Definition at line 425 of file ex4_enum.c.
void print_solu | ( | FILE * | fp, |
int | vars, | ||
const double * | x | ||
) |
fp | file pointer to output to |
vars | number of variables |
x | ptr to solution vector |
Definition at line 338 of file ex4_enum.c.