4 #include "isl_piplib.h"
5 #include "isl_map_piplib.h"
7 static void copy_solution(struct isl_vec
*vec
, int maximize
, isl_int
*opt
,
8 isl_int
*opt_denom
, PipQuast
*sol
)
16 isl_seq_cpy_from_pip(opt
,
17 &sol
->list
->vector
->the_vector
[0], 1);
18 isl_seq_cpy_from_pip(opt_denom
,
19 &sol
->list
->vector
->the_deno
[0], 1);
21 mpz_fdiv_q(*opt
, sol
->list
->vector
->the_vector
[0],
22 sol
->list
->vector
->the_deno
[0]);
24 mpz_cdiv_q(*opt
, sol
->list
->vector
->the_vector
[0],
25 sol
->list
->vector
->the_deno
[0]);
32 isl_int_set_si(vec
->el
[0], 1);
33 for (i
= 0, list
= sol
->list
->next
; list
; ++i
, list
= list
->next
) {
34 isl_seq_cpy_from_pip(&vec
->el
[1 + i
],
35 &list
->vector
->the_deno
[0], 1);
36 isl_int_lcm(vec
->el
[0], vec
->el
[0], vec
->el
[1 + i
]);
38 for (i
= 0, list
= sol
->list
->next
; list
; ++i
, list
= list
->next
) {
39 isl_seq_cpy_from_pip(&tmp
, &list
->vector
->the_deno
[0], 1);
40 isl_int_divexact(tmp
, vec
->el
[0], tmp
);
41 isl_seq_cpy_from_pip(&vec
->el
[1 + i
],
42 &list
->vector
->the_vector
[0], 1);
43 isl_int_mul(vec
->el
[1 + i
], vec
->el
[1 + i
], tmp
);
48 enum isl_lp_result
isl_pip_solve_lp(struct isl_basic_map
*bmap
, int maximize
,
49 isl_int
*f
, isl_int denom
, isl_int
*opt
,
53 enum isl_lp_result res
= isl_lp_ok
;
54 PipMatrix
*domain
= NULL
;
59 total
= isl_basic_map_total_dim(bmap
);
60 domain
= isl_basic_map_to_pip(bmap
, 0, 1, 0);
63 entier_set_si(domain
->p
[0][1], -1);
64 isl_int_set(domain
->p
[0][domain
->NbColumns
- 1], f
[0]);
65 isl_seq_cpy_to_pip(domain
->p
[0]+2, f
+1, total
);
67 options
= pip_options_init();
70 options
->Urs_unknowns
= -1;
71 options
->Maximize
= maximize
;
73 sol
= pip_solve(domain
, NULL
, -1, options
);
74 pip_options_free(options
);
79 *vec
= isl_vec_alloc(bmap
->ctx
, 1 + total
);
84 else if (entier_zero_p(sol
->list
->vector
->the_deno
[0]))
85 res
= isl_lp_unbounded
;
87 copy_solution(*vec
, maximize
, opt
, opt_denom
, sol
);
88 pip_matrix_free(domain
);
93 pip_matrix_free(domain
);