1 /* This is a very simple example of how to use the PipLib inside your programs.
2 * You should compile it by typing 'make' (after edition of the makefile), then
3 * test it for instance by typing 'more FILE.pol | ./example'. Finally you can
4 * compare results given by PIP by typing 'pip32 FILE.dat'
10 #include <piplib/piplib.h>
12 static PipOptions
*options_read(FILE *f
)
15 PipOptions
*options
= pip_options_init();
16 while (fgets(s
, 1024, f
)) {
17 if (strncasecmp(s
, "Maximize", 8) == 0)
18 options
->Maximize
= 1;
19 if (strncasecmp(s
, "Urs_parms", 9) == 0)
20 options
->Urs_parms
= 1;
21 if (strncasecmp(s
, "Urs_unknowns", 12) == 0)
22 options
->Urs_unknowns
= 1;
23 if (strncasecmp(s
, "Rational", 8) == 0)
25 if (strncasecmp(s
, "Dual", 4) == 0)
26 options
->Compute_dual
= 1;
31 int main(int argc
, const char **argv
)
33 PipMatrix
* domain
, * context
;
35 PipOptions
* options
;
39 if (strncmp(argv
[1], "-v", 2) == 0) {
40 const char *v
= argv
[1]+2;
50 printf("[PIP2-like future input] Please enter:\n- the context matrix,\n") ;
51 context
= pip_matrix_read(stdin
) ;
52 pip_matrix_print(stdout
,context
) ;
54 printf("- the bignum column (start at 0, -1 if no bignum),\n") ;
55 fscanf(stdin
," %d",&bignum
) ;
56 printf("%d\n",bignum
) ;
58 printf("- the constraint matrix.\n") ;
59 domain
= pip_matrix_read(stdin
) ;
60 pip_matrix_print(stdout
,domain
) ;
64 printf("- options (EOF to stop).\n") ;
65 options
= options_read(stdin
);
66 options
->Verbose
= verbose
;
68 pip_options_print(stdout
, options
);
70 /* The bignum in PIP1 is fixed on the constraint matrix, here is
74 bignum
+= domain
->NbColumns
- context
->NbColumns
;
76 solution
= pip_solve(domain
,context
,bignum
,options
) ;
78 pip_options_free(options
) ;
79 pip_matrix_free(domain
) ;
80 pip_matrix_free(context
) ;
82 pip_quast_print(stdout
,solution
,0) ;
84 pip_quast_free(solution
) ;