-#ifdef DUMP_LP
-/**
- * Dumps the problem instance as a MILP. The original problem is transformed into:
- * min f = es - Mex
- * udN: Qx -y -s +Me = 0
- * Ax = e
- * Bx <= e
- * y <= 2M(e-x)
- * x \in N y, s >= 0
- *
- * with M >= max sum Q'ij * x_j
- * i j
- */
-static void pi_dump_lp(problem_instance_t *pi) {
- int i, max_abs_Qij;
- matrix_elem_t *e;
- FILE *out = ffopen(pi->name, "lpo", "wt");
-
- DBG((dbg, LEVEL_1, "Dumping lp...\n"));
- /* calc the big M for Q */
- max_abs_Qij = pi->maxQij;
- if (-pi->minQij > max_abs_Qij)
- max_abs_Qij = -pi->minQij;
- pi->bigM = pi->A_dim * max_abs_Qij;
- DBG((dbg, LEVEL_2, "BigM = %d\n", pi->bigM));
-
- /* generate objective function */
- fprintf(out, "min: ");
- for (i=0; i<pi->x_dim; ++i)
- fprintf(out, "+s%d_%d -%dx%d_%d ", pi->x[i].n, pi->x[i].c, pi->bigM, pi->x[i].n, pi->x[i].c);
- fprintf(out, ";\n\n");
-
- /* constraints for former objective function */
- for (i=0; i<pi->x_dim; ++i) {
- matrix_foreach_in_row(pi->Q, i, e) {
- int Qio = e->val;
- if (Qio == 1)
- fprintf(out, "+x%d_%d ", pi->x[e->col].n, pi->x[e->col].c);
- else if(Qio == -1)
- fprintf(out, "-x%d_%d ", pi->x[e->col].n, pi->x[e->col].c);
- else
- fprintf(out, "%+dx%d_%d ", Qio, pi->x[e->col].n, pi->x[e->col].c);
- }
- fprintf(out, "-y%d_%d -s%d_%d +%d= 0;\n", pi->x[i].n, pi->x[i].c, pi->x[i].n, pi->x[i].c, pi->bigM);
- }
- fprintf(out, "\n\n");
-
- /* constraints for (special) complementary condition */
- for (i=0; i<pi->x_dim; ++i)
- fprintf(out, "y%d_%d <= %d - %dx%d_%d;\n", pi->x[i].n, pi->x[i].c, 2*pi->bigM, 2*pi->bigM, pi->x[i].n, pi->x[i].c);
- fprintf(out, "\n\n");
-
- /* knapsack constraints */
- for (i=0; i<pi->A_dim; ++i) {
- matrix_foreach_in_row(pi->Q, i, e)
- fprintf(out, "+x%d_%d ", pi->x[e->col].n, pi->x[e->col].c);
- fprintf(out, " = 1;\n");
- }
- fprintf(out, "\n\n");