4 * Copyright: (c) Universitaet Karlsruhe
5 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
8 * ILP formalization using:
9 * - 2 classes of vars: Nodes- and optimality variables.
10 * - Clique constraints
12 * - Clique path constraints
15 #include "becopyilp_t.h"
24 #include "iredges_t.h"
26 #include "becopystat.h"
27 #include "besched_t.h"
32 #define PATH_CONSTRAINTS_FOR_CLASSES
35 static firm_dbg_module_t *dbg = NULL;
36 #define SLOTS_LIVING 32
38 typedef struct _problem_instance_t {
39 const copy_opt_t *co; /**< the copy opt problem */
40 size_red_t *sr; /**< problem size reduction. removes simple nodes */
41 lpp_t *lp; /**< the linear programming problem */
43 /* Helpers for maintaining indices and finding variables */
44 int first_nnc_var_idx; /**< the first index of a constraint belonging to no-null-colors stuff*/
45 int cst_counter, first_x_var, last_x_var;
50 #define is_color_possible(irn,color) arch_reg_is_allocatable(pi->co->aenv, irn, -1, arch_register_for_index(pi->co->cls, color))
53 * Some stuff for variable name handling.
55 #define mangle_cst(buf, prefix, nr) \
56 snprintf((buf), sizeof(buf), "%c%d", (prefix), (nr))
58 #define mangle_var1(buf, prefix, color) \
59 snprintf((buf), sizeof(buf), "%c%d", (prefix), (color))
61 #define mangle_var2(buf, prefix, node_nr, color) \
62 snprintf((buf), sizeof(buf), "%c%d_%d", (prefix), (node_nr), (color))
64 #define mangle_var3(buf, prefix, n1, n2, col) \
65 snprintf((buf), sizeof(buf), "%c%d_%d_%d", (prefix), (n1), (n2), (col))
67 #define mangle_var_irn(buf, prefix, irn, color) \
68 mangle_var2((buf), (prefix), get_irn_graph_nr(irn), (color))
70 #define split_var(var, nnr, col) \
71 sscanf(var, "x%d_%d", (nnr), (col))
75 * Add coloring-force conditions
76 * Matrix A: knapsack constraint for each node
78 static void pi_add_constr_A(problem_instance_t *pi) {
81 DBG((dbg, LEVEL_2, "Add A constraints...\n"));
82 /* iterate over all blocks */
83 pmap_foreach(pi->co->cenv->border_heads, pme) {
84 struct list_head *head = pme->value;
86 bitset_t *pos_regs = bitset_alloca(pi->co->cenv->cls->n_regs);
88 list_for_each_entry_reverse(border_t, curr, head, list)
89 if (curr->is_def && curr->is_real && !sr_is_removed(pi->sr->curr->irn)) {
90 int cst_idx, nnr, col;
92 nnr = get_irn_graph_nr(curr->irn);
93 mangle_cst(pi->buf, 'A', nnr);
94 cst_idx = lpp_add_cst(pi->curr_lp, pi->buf, lpp_equal, 1);
96 /* iterate over all possible colors in order */
97 bitset_clear_all(pos_regs);
98 arch_get_allocatable_regs(pi->co->aenv, curr->irn, -1, pos_regs);
99 bitset_foreach(pos_regs, col) {
101 mangle_var2(pi->buf, 'x', nnr, col);
102 var_idx = lpp_add_var(pi->curr_lp, pi->buf, lpp_binary, 0);
103 if (!pi->first_x_var)
104 pi->first_x_var = var_idx;
105 pi->last_x_var = var_idx;
106 lpp_set_factor_fast(pi->curr_lp, cst_idx, var_idx, 1);
113 * Checks if all nodes in @p living are live in in block @p block.
114 * @return 1 if all are live in
117 static INLINE int all_live_in(ir_node *block, pset *living) {
119 for (n = pset_first(living); n; n = pset_next(living))
120 if (!is_live_in(block, n)) {
128 * Finds cliques in the interference graph, considering only nodes
129 * for which the color @p color is possible. Finds only 'maximal-cliques',
130 * viz cliques which are not contained in another one.
131 * Matrix B: interference constraints using cliques
133 static void pi_add_constr_B(problem_instance_t *pi, int color) {
134 enum phase_t {growing, shrinking} phase = growing;
137 pset *living = pset_new_ptr(SLOTS_LIVING);
139 DBG((dbg, LEVEL_2, "Add B constraints (col = %d)...\n", color));
140 /* iterate over all blocks */
141 pmap_foreach(pi->co->cenv->border_heads, pme) {
142 ir_node *block = pme->key;
143 struct list_head *head = pme->value;
145 list_for_each_entry_reverse(border_t, b, head, list) {
146 const ir_node *irn = b->irn;
147 if (is_removed(irn) || !is_color_possible(irn, color))
151 DBG((dbg, LEVEL_2, "Def %n\n", irn));
152 pset_insert_ptr(living, irn);
154 } else { /* is_use */
155 DBG((dbg, LEVEL_2, "Use %n\n", irn));
157 /* before shrinking the set, store the current 'maximum' clique;
158 * do NOT if clique is a single node
159 * do NOT if all values are live_in (in this case they were contained in a live-out clique elsewhere) */
160 if (phase == growing && pset_count(living) >= 2 && !all_live_in(block, living)) {
163 mangle_cst(pi->buf, 'B', pi->cst_counter);
164 cst_idx = lpp_add_cst(pi->curr_lp, pi->buf, lpp_less, 1);
165 for (n = pset_first(living); n; n = pset_next(living)) {
167 mangle_var_irn(pi->buf, 'x', n, color);
168 var_idx = lpp_get_var_idx(pi->curr_lp, pi->buf);
169 lpp_set_factor_fast(pi->curr_lp, cst_idx, var_idx, 1);
173 pset_remove_ptr(living, irn);
178 assert(0 == pset_count(living));
183 * Generates constraints which interrelate x with y variables.
184 * x1 and x2 have the different colors ==> y_12 = 1
186 static void pi_add_constr_E(problem_instance_t *pi) {
188 bitset_t *root_regs, *arg_regs, *work_regs;
190 unsigned nregs = pi->co->cenv->cls->n_regs;
191 root_regs = bitset_alloca(nregs);
192 arg_regs = bitset_alloca(nregs);
193 work_regs = bitset_alloca(nregs);
195 DBG((dbg, LEVEL_2, "Add E constraints...\n"));
196 /* for all roots of optimization units */
197 list_for_each_entry(unit_t, curr, &pi->co->units, units) {
199 int rootnr, argnr, color;
203 root = curr->nodes[0];
204 rootnr = get_irn_graph_nr(root);
205 bitset_clear_all(root_regs);
206 arch_get_allocatable_regs(pi->co->aenv, root, -1, root_regs);
208 /* for all arguments of root */
209 for (i = 1; i < curr->node_count; ++i) {
210 arg = curr->nodes[i];
211 argnr = get_irn_graph_nr(arg);
212 bitset_clear_all(arg_regs);
213 arch_get_allocatable_regs(pi->co->aenv, arg, -1, arg_regs);
215 /* Introduce new variable and set factor in objective function */
216 mangle_var2(buf, 'y', rootnr, argnr);
217 y_idx = lpp_add_var(pi->curr_lp, buf, lpp_binary, curr->costs[i]);
219 /* set starting value */
220 lpp_set_start_value(pi->curr_lp, y_idx, (get_irn_col(pi->co, root) != get_irn_col(pi->co, arg)));
222 /* For all colors root and arg have in common, add 2 constraints to E */
223 bitset_copy(work_regs, root_regs);
224 bitset_and(work_regs, arg_regs);
225 bitset_foreach(work_regs, color) {
226 int root_idx, arg_idx, cst_idx;
227 mangle_var2(buf, 'x', rootnr, color);
228 root_idx = lpp_get_var_idx(pi->curr_lp, buf);
229 mangle_var2(buf, 'x', argnr, color);
230 arg_idx = lpp_get_var_idx(pi->curr_lp, buf);
232 /* add root-arg-y <= 0 */
233 mangle_cst(buf, 'E', cst_counter++);
234 cst_idx = lpp_add_cst(pi->curr_lp, buf, lpp_less, 0);
235 lpp_set_factor_fast(pi->curr_lp, cst_idx, root_idx, 1);
236 lpp_set_factor_fast(pi->curr_lp, cst_idx, arg_idx, -1);
237 lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, -1);
239 /* add arg-root-y <= 0 */
240 mangle_cst(buf, 'E', cst_counter++);
241 cst_idx = lpp_add_cst(pi->curr_lp, buf, lpp_less, 0);
242 lpp_set_factor_fast(pi->curr_lp, cst_idx, root_idx, -1);
243 lpp_set_factor_fast(pi->curr_lp, cst_idx, arg_idx, 1);
244 lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, -1);
246 /* For all colors root and arg have "disjunct", add 1 constraints to E.
247 * If root gets a color the arg is not possible to get then they will
248 * definetly get different colors. So y has to be 1.
249 * Vice versa for arg.
251 bitset_copy(work_regs, root_regs);
252 bitset_xor(work_regs, arg_regs);
253 bitset_foreach(work_regs, color) {
254 int root_idx, arg_idx, cst_idx;
255 mangle_var2(buf, 'x', rootnr, color);
256 root_idx = lpp_get_var_idx(pi->curr_lp, buf);
257 mangle_var2(buf, 'x', argnr, color);
258 arg_idx = lpp_get_var_idx(pi->curr_lp, buf);
260 mangle_cst(buf, 'E', cst_counter++);
261 cst_idx = lpp_add_cst(pi->curr_lp, buf, lpp_less, 0);
262 if (bitset_is_set(root_regs, color)) {
263 /* add root-y <= 0 */
264 lpp_set_factor_fast(pi->curr_lp, cst_idx, root_idx, 1);
265 lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, -1);
267 assert(bitset_is_set(arg_regs, color) && "bitset_xor is buggy");
269 lpp_set_factor_fast(pi->curr_lp, cst_idx, arg_idx, 1);
270 lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, -1);
277 static void clique_path_walker(ir_node *block, void *env) {
278 problem_instance_t *pi = env;
279 int count, arity, row, col, other_row, *costs;
280 ir_node **phis, *phi, *irn, **phi_matrix;
282 bitset_t *candidates;
284 /* Count all phi nodes of this block */
285 for (count=0, irn = sched_first(block); is_Phi(irn); irn = sched_next(irn))
288 /* We at least 2 phi nodes for this class of inequalities */
292 /* Build the \Phi-Matrix */
293 arity = get_irn_arity(sched_first(block));
294 phis = alloca(count * sizeof(*phis));
295 costs = alloca(count * sizeof(costs));
296 phi_matrix = alloca(count*arity * sizeof(*phi_matrix));
297 candidates = bitset_alloca(count);
299 phi = sched_first(block);
300 for (row=0; row<count; ++row) {
302 for (col=0; col<arity; ++col) {
303 ir_node *arg = get_irn_n(phi, col);
304 /* Sort out all arguments interfering with its phi */
305 if (nodes_interfere(pi->co->cenv, phi, arg)) {
306 phi_matrix[row*arity + col] = NULL;
308 phi_matrix[row*arity + col] = arg;
310 phi = sched_next(phi);
313 /* Now find the interesting patterns in the matrix:
314 * All nodes which are used at least twice in a column. */
316 for (col=0; col<arity; ++col) {
317 done = pset_new_ptr_default();
318 for (row=0; row<count; ++row) {
319 irn = phi_matrix[row*arity + col];
321 * is this an interfering arg (NULL)
322 * or has the irn already been processed in this col?
324 if (!irn || pset_find_ptr(done, irn))
327 pset_insert_ptr(done, irn);
329 /* insert irn in candidates */
330 bitset_clear_all(candidates);
331 bitset_set(candidates, row);
332 /* search the irn in the rows below */
333 for (other_row = row+1; other_row<count; ++other_row)
334 if (irn == phi_matrix[other_row*arity + col]) {
335 /* found the irn in the same col in another row */
336 bitset_set(candidates, other_row);
339 /* now we know all occurences of irn in this col */
340 if (bitset_popcnt(candidates) < 2)
343 /* generate an unequation finally.
344 * phis are indexed in the bitset,
345 * shared argument is irn
346 * rhs is phi_count - 1 */
350 int pos, irnnr, rootnr, cst_idx, y_idx, cst_counter = 0;
351 int minimal_unequal_count = bitset_popcnt(candidates)-1;
353 irnnr = get_irn_graph_nr(irn);
354 mangle_cst(buf, 'M', cst_counter++);
355 cst_idx = lpp_add_cst(pi->curr_lp, buf, lpp_greater, minimal_unequal_count);
358 bitset_foreach(candidates, pos) {
360 rootnr = get_irn_graph_nr(root);
361 mangle_var2(buf, 'y', rootnr, irnnr);
362 y_idx = lpp_get_var_idx(pi->curr_lp, buf);
363 lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, 1);
367 del_pset(done); /* clear set for next row */
372 * Matrix M: Multi-Arg-Use. Interrelates different \phi-functions
373 * in the same block, iff they use the same arg at the same pos.
374 * Only one of the phis can get the arg.
376 static void pi_add_clique_path_cstr(problem_instance_t *pi) {
377 DBG((dbg, LEVEL_2, "Adding clique path constraints...\n"));
378 dom_tree_walk_irg(pi->co->irg, clique_path_walker, NULL, pi);
381 #ifndef PATH_CONSTRAINTS_FOR_CLASSES
383 * Matrix P: Path contraints.
384 * If 2 nodes interfere and there is a path of equal-color-edges
385 * connecting them, then at least one of those equal-color-edges
386 * will break and cause some costs.
388 static void pi_add_path_cstr(problem_instance_t *pi) {
391 DBG((dbg, LEVEL_2, "Adding path constraints...\n"));
393 /* for all optimization units (only phis) */
394 list_for_each_entry(unit_t, curr, &pi->co->units, units) {
397 if (curr->min_nodes_costs == 0)
400 rootnr = get_irn_graph_nr(curr->nodes[0]);
401 /* check all argument pairs for interference */
402 for (i=1; i<curr->node_count; ++i) {
403 const ir_node *arg1 = curr->nodes[i];
404 int arg1nr = get_irn_graph_nr(arg1);
405 for (o=i+1; o<curr->node_count; ++o) {
406 const ir_node *arg2 = curr->nodes[o];
407 int arg2nr = get_irn_graph_nr(arg2);
408 if (nodes_interfere(pi->co->cenv, arg1, arg2)) {
412 mangle_cst(buf, 'P', cst_counter++);
413 cst_idx = lpp_add_cst(pi->curr_lp, buf, lpp_greater, 1);
415 mangle_var2(buf, 'y', rootnr, arg1nr);
416 y_idx = lpp_get_var_idx(pi->curr_lp, buf);
417 lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, 1);
419 mangle_var2(buf, 'y', rootnr, arg2nr);
420 y_idx = lpp_get_var_idx(pi->curr_lp, buf);
421 lpp_set_factor_fast(pi->curr_lp, cst_idx, y_idx, 1);
429 #ifdef PATH_CONSTRAINTS_FOR_CLASSES
430 static INLINE int get_y_var_idx(problem_instance_t *pi, int nnr1, int nnr2) {
434 mangle_var2(buf, 'y', nnr1, nnr2);
435 if ((res = lpp_get_var_idx(pi->curr_lp, buf)) != -1)
438 mangle_var2(buf, 'y', nnr2, nnr1);
439 if ((res = lpp_get_var_idx(pi->curr_lp, buf)) != -1)
442 assert(0 && "One of them must work");
446 static void check_ecc_and_add_cut(problem_instance_t *pi, ir_node **path, int length, pset *remain, ir_node *tgt) {
447 if (path[length-1] == tgt) { /* we found a path */
448 int cst_idx, var_idx, i, nnr1, nnr2;
452 mangle_cst(buf, 'Q', pi->cst_counter++);
453 cst_idx = lpp_add_cst(pi->curr_lp, buf, lpp_greater, 1);
455 /* add all vars along the path */
456 nnr2 = get_irn_graph_nr(path[0]);
457 for (i=1; i<length; ++i) {
459 nnr2 = get_irn_graph_nr(path[i]);
460 var_idx = get_y_var_idx(pi, nnr1, nnr2);
461 lpp_set_factor_fast(pi->curr_lp, cst_idx, var_idx, 1);
463 } else { /* try to extend the path */
464 be_chordal_env_t *cenv = pi->co->cenv;
465 const ir_edge_t *edge;
466 ir_node *end = path[length-1];
467 ir_node **next = alloca(pset_count(remain) * sizeof(*next));
468 int i, o, max, next_pos = 0;
469 pset *done = pset_new_ptr_default();
471 /* find all potential next nodes on path */
474 for(i=0, max=get_irn_arity(end); i<max; ++i) {
475 ir_node *arg = get_irn_n(end, i);
476 if (!pset_find_ptr(done, arg) && pset_find_ptr(remain, arg)) {
477 next[next_pos++] = arg;
478 pset_insert_ptr(done, arg);
481 /* outs of phis and other nodes */
482 foreach_out_edge(end, edge) {
483 ir_node *user = edge->src;
484 if (is_Phi(user) && !pset_find_ptr(done, user) && pset_find_ptr(remain, user)) {
485 next[next_pos++] = user;
486 pset_insert_ptr(done, user);
492 /* delete all potential nodes with interferences to other nodes in the path */
493 for (i=0; i<next_pos; ++i) {
494 ir_node *nn = next[i];
496 /* if next is the tgt, it may interfere with path[0],
497 * so skip the first check */
498 o = (nn == tgt && length > 1) ? 1 : 0;
501 if (nodes_interfere(cenv, nn, path[o])) {
506 /* now we have all possible nodes in next; impossibles are NULL */
508 /* try to finish path with all possible nodes */
509 for (i=0; i<next_pos; ++i) {
510 if (!next[i]) /* this was an impossible node */
513 path[length] = next[i];
514 pset_remove_ptr(remain, next[i]);
515 check_ecc_and_add_cut(pi, path, length+1, remain, tgt);
516 pset_insert_ptr(remain, next[i]);
521 static void path_cstr_for_classes_walker(ir_node *irn, void *env) {
522 problem_instance_t *pi = env;
523 be_chordal_env_t *cenv;
526 pset *class = get_phi_class(irn);
527 if (!class || pset_find_ptr(pi->done, class))
530 pset_insert_ptr(pi->done, class);
533 max = pset_count(class);
534 cls = alloca(max * sizeof(*cls));
535 for(i=0, m = pset_first(class); m; i++, m = pset_next(class)) {
536 DBG((dbg, LEVEL_1, " class member: %+F\n", m));
541 for(i=0; i<max; ++i) {
542 ir_node **path = alloca(max * sizeof(*path));
543 pset *remain = pset_new_ptr(8);
544 pset_insert_pset_ptr(remain, class);
546 /* add cls[i] to path and remove it from remainder */
548 pset_remove_ptr(remain, cls[i]);
550 for(o=i+1; o<max; ++o)
551 if (nodes_interfere(cenv, cls[i], cls[o]))
552 check_ecc_and_add_cut(pi, path, 1, remain, cls[o]);
554 /* insert back into remainder */
555 pset_insert_ptr(remain, cls[i]);
561 * Matrix P: Path contraints.
562 * If 2 nodes interfere and there is a path of equal-color-edges
563 * connecting them, then at least one of those equal-color-edges
564 * will break and cause some costs.
566 static void pi_add_path_cstr_for_classes(problem_instance_t *pi) {
567 DBG((dbg, LEVEL_2, "Adding path constraints for phi classes...\n"));
569 pi->done = pset_new_ptr_default();
570 irg_walk_graph(pi->co->irg, path_cstr_for_classes_walker, NULL, pi);
578 * Generate the initial problem matrices and vectors.
580 static problem_instance_t *new_pi(const copy_opt_t *co) {
581 problem_instance_t *pi;
584 DBG((dbg, LEVEL_2, "Generating new instance...\n"));
585 pi = xcalloc(1, sizeof(*pi));
587 pi->sr = new_size_red(co);
588 pi->lp = new_lpp(co->name, lpp_minimize);
593 static void pi_construct(problem_instance_t *pi) {
595 for (col = 0; col < pi->co->cls->n_regs; ++col)
596 pi_add_constr_B(pi, col);
599 #ifdef PATH_CONSTRAINTS_FOR_CLASSES
600 pi_add_path_cstr_for_classes(pi);
602 pi_add_path_cstr(pi);
604 pi_add_clique_path_cstr(pi);
608 * Clean the problem instance
610 static void free_pi(problem_instance_t *pi) {
611 simpl_t *simpl, *tmp;
613 DBG((dbg, LEVEL_2, "Free instance...\n"));
615 free_size_red(pi->sr);
621 * Set starting values for the mip problem according
622 * to the current coloring of the graph.
624 static void pi_set_start_sol(problem_instance_t *pi) {
627 DBG((dbg, LEVEL_2, "Set start solution...\n"));
628 for (i=pi->first_x_var; i<=pi->last_x_var; ++i) {
631 /* get variable name */
632 lpp_get_var_name(pi->curr_lp, i, var_name, sizeof(var_name));
633 /* split into components */
634 if (split_var(var_name, &nnr, &col) == 2) {
635 assert(get_irn_col(pi->co, get_irn_for_graph_nr(pi->co->irg, nnr)) != -1);
636 val = (get_irn_col(pi->co, get_irn_for_graph_nr(pi->co->irg, nnr)) == col) ? 1 : 0;
637 lpp_set_start_value(pi->curr_lp, i, val);
639 fprintf(stderr, "Variable name is: %s\n", var_name);
640 assert(0 && "x vars always look like this 'x123_45'");
649 static void pi_solve_ilp(problem_instance_t *pi, double time_limit) {
653 snprintf(buf, sizeof(buf), "%s.ilp1", co->name);
654 lpp_dump(pi->lp, buf);
657 pi_set_start_sol(pi);
659 lower_bound = co_get_lower_bound(pi->co) - co_get_inevit_copy_costs(pi->co);
660 lpp_set_bound(pi->curr_lp, lower_bound);
662 lpp_set_time_limit(pi->curr_lp, time_limit);
664 #ifdef LPP_SOLVE_REMOTE
665 lpp_solve_net(pi->curr_lp, LPP_HOST, LPP_SOLVER);
667 lpp_solve_cplex(pi->curr_lp);
669 DBG((dbg, LEVEL_1, "Solution time: %.2f\n", pi->curr_lp->sol_time));
674 * Sets the colors of irns according to the values of variables
675 * provided by the solution of the solver.
677 static int pi_apply_solution(problem_instance_t *pi) {
680 lpp_sol_state_t state;
681 DBG((dbg, LEVEL_2, "Applying solution...\n"));
684 copystat_add_ilp_time((int)(1000.0*lpp_get_sol_time(pi->curr_lp))); //now we have ms
685 copystat_add_ilp_vars(lpp_get_var_count(pi->curr_lp));
686 copystat_add_ilp_csts(lpp_get_cst_count(pi->curr_lp));
687 copystat_add_ilp_iter(lpp_get_iter_cnt(pi->curr_lp));
690 sol = xmalloc((pi->last_x_var - pi->first_x_var + 1) * sizeof(*sol));
691 state = lpp_get_solution(pi->curr_lp, sol, pi->first_x_var, pi->last_x_var);
692 if (state != lpp_optimal) {
693 printf("WARNING %s: Solution state is not 'optimal': %d\n", pi->co->name, state);
694 assert(state >= lpp_feasible && "The solution should at least be feasible!");
697 for (i=0; i<pi->last_x_var - pi->first_x_var + 1; ++i) {
701 if (sol[i] > 1-EPSILON) { /* split varibale name into components */
702 lpp_get_var_name(pi->curr_lp, pi->first_x_var+i, var_name, sizeof(var_name));
703 if (split_var(var_name, &nnr, &col) == 2) {
704 DBG((dbg, LEVEL_2, "Irn %n Idx %d Var %s Val %f\n", get_irn_for_graph_nr(pi->co->irg, nnr), i, var_name, sol[i]));
705 DBG((dbg, LEVEL_2, "x%d = %d\n", nnr, col));
706 set_irn_col(pi->co, get_irn_for_graph_nr(pi->co->irg, nnr), col);
708 assert(0 && "This should be a x-var");
715 int co_solve_ilp11(copy_opt_t *co, double time_limit) {
717 problem_instance_t *pi;
719 dbg = firm_dbg_register("ir.be.copyoptilp1");
723 sr_remove(pi->sr); /* problem size reduction */
724 pi_construct(pi); /* set up the problem */
725 pi_solve_ilp(pi, time_limit); /* solve it */
726 res = pi_apply_solution(pi); /* apply solution */
727 sr_reinsert(pi->sr); /* complete the partial solution */
734 #include "becopyilp_t.h"
738 typedef struct _my_env_t {
743 static void ilp2_build(ilp_env_t *ienv) {
744 ienv->lp = new_lpp(ienv->co->name, lpp_minimize);
748 static void ilp2_apply(ilp_env_t *ienv) {
752 int co_solve_ilp1(copy_opt_t *co, double time_limit) {
753 lpp_sol_state_t sol_state;
756 firm_dbg_module_t *dbg = firm_dbg_register("ir.be.coilp2");
758 firm_dbg_set_mask(dbg, DEBUG_LVL);
762 ienv = new_ilp_env(co, dbg, ilp2_build, ilp2_apply, &my);
764 sol_state = ilp_go(ienv, time_limit);
768 return sol_state == lpp_optimal;