3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <mao@gnu.org>.
11 * GLPK is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************/
27 NPP *npp_create_wksp(void)
28 { /* create LP/MIP preprocessor workspace */
30 npp = xmalloc(sizeof(NPP));
32 npp->orig_m = npp->orig_n = npp->orig_nnz = 0;
33 npp->pool = dmp_create_pool();
34 npp->name = npp->obj = NULL;
36 npp->nrows = npp->ncols = 0;
37 npp->r_head = npp->r_tail = NULL;
38 npp->c_head = npp->c_tail = NULL;
39 npp->stack = dmp_create_pool();
41 #if 0 /* 16/XII-2009 */
42 memset(&npp->count, 0, sizeof(npp->count));
44 npp->m = npp->n = npp->nnz = 0;
45 npp->row_ref = npp->col_ref = NULL;
46 npp->sol = npp->scaling = 0;
47 npp->p_stat = npp->d_stat = npp->t_stat = npp->i_stat = 0;
49 /*npp->r_prim =*/ npp->r_pi = NULL;
51 npp->c_value = /*npp->c_dual =*/ NULL;
55 void npp_insert_row(NPP *npp, NPPROW *row, int where)
56 { /* insert row to the row list */
58 { /* insert row to the beginning of the row list */
60 row->next = npp->r_head;
61 if (row->next == NULL)
64 row->next->prev = row;
68 { /* insert row to the end of the row list */
69 row->prev = npp->r_tail;
71 if (row->prev == NULL)
74 row->prev->next = row;
80 void npp_remove_row(NPP *npp, NPPROW *row)
81 { /* remove row from the row list */
82 if (row->prev == NULL)
83 npp->r_head = row->next;
85 row->prev->next = row->next;
86 if (row->next == NULL)
87 npp->r_tail = row->prev;
89 row->next->prev = row->prev;
93 void npp_activate_row(NPP *npp, NPPROW *row)
94 { /* make row active */
97 /* move the row to the beginning of the row list */
98 npp_remove_row(npp, row);
99 npp_insert_row(npp, row, 0);
104 void npp_deactivate_row(NPP *npp, NPPROW *row)
105 { /* make row inactive */
108 /* move the row to the end of the row list */
109 npp_remove_row(npp, row);
110 npp_insert_row(npp, row, 1);
115 void npp_insert_col(NPP *npp, NPPCOL *col, int where)
116 { /* insert column to the column list */
118 { /* insert column to the beginning of the column list */
120 col->next = npp->c_head;
121 if (col->next == NULL)
124 col->next->prev = col;
128 { /* insert column to the end of the column list */
129 col->prev = npp->c_tail;
131 if (col->prev == NULL)
134 col->prev->next = col;
140 void npp_remove_col(NPP *npp, NPPCOL *col)
141 { /* remove column from the column list */
142 if (col->prev == NULL)
143 npp->c_head = col->next;
145 col->prev->next = col->next;
146 if (col->next == NULL)
147 npp->c_tail = col->prev;
149 col->next->prev = col->prev;
153 void npp_activate_col(NPP *npp, NPPCOL *col)
154 { /* make column active */
157 /* move the column to the beginning of the column list */
158 npp_remove_col(npp, col);
159 npp_insert_col(npp, col, 0);
164 void npp_deactivate_col(NPP *npp, NPPCOL *col)
165 { /* make column inactive */
168 /* move the column to the end of the column list */
169 npp_remove_col(npp, col);
170 npp_insert_col(npp, col, 1);
175 NPPROW *npp_add_row(NPP *npp)
176 { /* add new row to the current problem */
178 row = dmp_get_atom(npp->pool, sizeof(NPPROW));
179 row->i = ++(npp->nrows);
181 row->lb = -DBL_MAX, row->ub = +DBL_MAX;
184 npp_insert_row(npp, row, 1);
188 NPPCOL *npp_add_col(NPP *npp)
189 { /* add new column to the current problem */
191 col = dmp_get_atom(npp->pool, sizeof(NPPCOL));
192 col->j = ++(npp->ncols);
199 col->lb = col->ub = col->coef = 0.0;
202 npp_insert_col(npp, col, 1);
206 NPPAIJ *npp_add_aij(NPP *npp, NPPROW *row, NPPCOL *col, double val)
207 { /* add new element to the constraint matrix */
209 aij = dmp_get_atom(npp->pool, sizeof(NPPAIJ));
214 aij->r_next = row->ptr;
216 aij->c_next = col->ptr;
217 if (aij->r_next != NULL)
218 aij->r_next->r_prev = aij;
219 if (aij->c_next != NULL)
220 aij->c_next->c_prev = aij;
221 row->ptr = col->ptr = aij;
225 int npp_row_nnz(NPP *npp, NPPROW *row)
226 { /* count number of non-zero coefficients in row */
231 for (aij = row->ptr; aij != NULL; aij = aij->r_next)
236 int npp_col_nnz(NPP *npp, NPPCOL *col)
237 { /* count number of non-zero coefficients in column */
242 for (aij = col->ptr; aij != NULL; aij = aij->c_next)
247 void *npp_push_tse(NPP *npp, int (*func)(NPP *npp, void *info),
249 { /* push new entry to the transformation stack */
251 tse = dmp_get_atom(npp->stack, sizeof(NPPTSE));
253 tse->info = dmp_get_atom(npp->stack, size);
254 tse->link = npp->top;
259 #if 1 /* 23/XII-2009 */
260 void npp_erase_row(NPP *npp, NPPROW *row)
261 { /* erase row content to make it empty */
263 while (row->ptr != NULL)
265 row->ptr = aij->r_next;
266 if (aij->c_prev == NULL)
267 aij->col->ptr = aij->c_next;
269 aij->c_prev->c_next = aij->c_next;
270 if (aij->c_next == NULL)
273 aij->c_next->c_prev = aij->c_prev;
274 dmp_free_atom(npp->pool, aij, sizeof(NPPAIJ));
280 void npp_del_row(NPP *npp, NPPROW *row)
281 { /* remove row from the current problem */
282 #if 0 /* 23/XII-2009 */
285 if (row->name != NULL)
286 dmp_free_atom(npp->pool, row->name, strlen(row->name)+1);
287 #if 0 /* 23/XII-2009 */
288 while (row->ptr != NULL)
290 row->ptr = aij->r_next;
291 if (aij->c_prev == NULL)
292 aij->col->ptr = aij->c_next;
294 aij->c_prev->c_next = aij->c_next;
295 if (aij->c_next == NULL)
298 aij->c_next->c_prev = aij->c_prev;
299 dmp_free_atom(npp->pool, aij, sizeof(NPPAIJ));
302 npp_erase_row(npp, row);
304 npp_remove_row(npp, row);
305 dmp_free_atom(npp->pool, row, sizeof(NPPROW));
309 void npp_del_col(NPP *npp, NPPCOL *col)
310 { /* remove column from the current problem */
312 if (col->name != NULL)
313 dmp_free_atom(npp->pool, col->name, strlen(col->name)+1);
314 while (col->ptr != NULL)
316 col->ptr = aij->c_next;
317 if (aij->r_prev == NULL)
318 aij->row->ptr = aij->r_next;
320 aij->r_prev->r_next = aij->r_next;
321 if (aij->r_next == NULL)
324 aij->r_next->r_prev = aij->r_prev;
325 dmp_free_atom(npp->pool, aij, sizeof(NPPAIJ));
327 npp_remove_col(npp, col);
328 dmp_free_atom(npp->pool, col, sizeof(NPPCOL));
332 void npp_del_aij(NPP *npp, NPPAIJ *aij)
333 { /* remove element from the constraint matrix */
334 if (aij->r_prev == NULL)
335 aij->row->ptr = aij->r_next;
337 aij->r_prev->r_next = aij->r_next;
338 if (aij->r_next == NULL)
341 aij->r_next->r_prev = aij->r_prev;
342 if (aij->c_prev == NULL)
343 aij->col->ptr = aij->c_next;
345 aij->c_prev->c_next = aij->c_next;
346 if (aij->c_next == NULL)
349 aij->c_next->c_prev = aij->c_prev;
350 dmp_free_atom(npp->pool, aij, sizeof(NPPAIJ));
354 void npp_load_prob(NPP *npp, glp_prob *orig, int names, int sol,
356 { /* load original problem into the preprocessor workspace */
362 xassert(names == GLP_OFF || names == GLP_ON);
363 xassert(sol == GLP_SOL || sol == GLP_IPT || sol == GLP_MIP);
364 xassert(scaling == GLP_OFF || scaling == GLP_ON);
365 if (sol == GLP_MIP) xassert(!scaling);
366 npp->orig_dir = orig->dir;
367 if (npp->orig_dir == GLP_MIN)
369 else if (npp->orig_dir == GLP_MAX)
375 npp->orig_nnz = orig->nnz;
376 if (names && orig->name != NULL)
377 { npp->name = dmp_get_atom(npp->pool, strlen(orig->name)+1);
378 strcpy(npp->name, orig->name);
380 if (names && orig->obj != NULL)
381 { npp->obj = dmp_get_atom(npp->pool, strlen(orig->obj)+1);
382 strcpy(npp->obj, orig->obj);
384 npp->c0 = dir * orig->c0;
386 link = xcalloc(1+m, sizeof(NPPROW *));
387 for (i = 1; i <= m; i++)
388 { GLPROW *rrr = orig->row[i];
390 link[i] = row = npp_add_row(npp);
391 xassert(row->i == i);
392 if (names && rrr->name != NULL)
393 { row->name = dmp_get_atom(npp->pool, strlen(rrr->name)+1);
394 strcpy(row->name, rrr->name);
397 { if (rrr->type == GLP_FR)
398 row->lb = -DBL_MAX, row->ub = +DBL_MAX;
399 else if (rrr->type == GLP_LO)
400 row->lb = rrr->lb, row->ub = +DBL_MAX;
401 else if (rrr->type == GLP_UP)
402 row->lb = -DBL_MAX, row->ub = rrr->ub;
403 else if (rrr->type == GLP_DB)
404 row->lb = rrr->lb, row->ub = rrr->ub;
405 else if (rrr->type == GLP_FX)
406 row->lb = row->ub = rrr->lb;
411 { double rii = rrr->rii;
412 if (rrr->type == GLP_FR)
413 row->lb = -DBL_MAX, row->ub = +DBL_MAX;
414 else if (rrr->type == GLP_LO)
415 row->lb = rrr->lb * rii, row->ub = +DBL_MAX;
416 else if (rrr->type == GLP_UP)
417 row->lb = -DBL_MAX, row->ub = rrr->ub * rii;
418 else if (rrr->type == GLP_DB)
419 row->lb = rrr->lb * rii, row->ub = rrr->ub * rii;
420 else if (rrr->type == GLP_FX)
421 row->lb = row->ub = rrr->lb * rii;
426 /* load columns and constraint coefficients */
427 for (j = 1; j <= n; j++)
428 { GLPCOL *ccc = orig->col[j];
431 col = npp_add_col(npp);
432 xassert(col->j == j);
433 if (names && ccc->name != NULL)
434 { col->name = dmp_get_atom(npp->pool, strlen(ccc->name)+1);
435 strcpy(col->name, ccc->name);
439 col->kind = ccc->kind;
441 col->is_int = (char)(ccc->kind == GLP_IV);
444 { if (ccc->type == GLP_FR)
445 col->lb = -DBL_MAX, col->ub = +DBL_MAX;
446 else if (ccc->type == GLP_LO)
447 col->lb = ccc->lb, col->ub = +DBL_MAX;
448 else if (ccc->type == GLP_UP)
449 col->lb = -DBL_MAX, col->ub = ccc->ub;
450 else if (ccc->type == GLP_DB)
451 col->lb = ccc->lb, col->ub = ccc->ub;
452 else if (ccc->type == GLP_FX)
453 col->lb = col->ub = ccc->lb;
456 col->coef = dir * ccc->coef;
457 for (aaa = ccc->ptr; aaa != NULL; aaa = aaa->c_next)
458 npp_add_aij(npp, link[aaa->row->i], col, aaa->val);
461 { double sjj = ccc->sjj;
462 if (ccc->type == GLP_FR)
463 col->lb = -DBL_MAX, col->ub = +DBL_MAX;
464 else if (ccc->type == GLP_LO)
465 col->lb = ccc->lb / sjj, col->ub = +DBL_MAX;
466 else if (ccc->type == GLP_UP)
467 col->lb = -DBL_MAX, col->ub = ccc->ub / sjj;
468 else if (ccc->type == GLP_DB)
469 col->lb = ccc->lb / sjj, col->ub = ccc->ub / sjj;
470 else if (ccc->type == GLP_FX)
471 col->lb = col->ub = ccc->lb / sjj;
474 col->coef = dir * ccc->coef * sjj;
475 for (aaa = ccc->ptr; aaa != NULL; aaa = aaa->c_next)
476 npp_add_aij(npp, link[aaa->row->i], col,
477 aaa->row->rii * aaa->val * sjj);
481 /* keep solution indicator and scaling option */
483 npp->scaling = scaling;
487 void npp_build_prob(NPP *npp, glp_prob *prob)
488 { /* build resultant (preprocessed) problem */
492 int i, j, type, len, *ind;
494 glp_erase_prob(prob);
495 glp_set_prob_name(prob, npp->name);
496 glp_set_obj_name(prob, npp->obj);
497 glp_set_obj_dir(prob, npp->orig_dir);
498 if (npp->orig_dir == GLP_MIN)
500 else if (npp->orig_dir == GLP_MAX)
504 glp_set_obj_coef(prob, 0, dir * npp->c0);
506 for (row = npp->r_head; row != NULL; row = row->next)
507 { row->temp = i = glp_add_rows(prob, 1);
508 glp_set_row_name(prob, i, row->name);
509 if (row->lb == -DBL_MAX && row->ub == +DBL_MAX)
511 else if (row->ub == +DBL_MAX)
513 else if (row->lb == -DBL_MAX)
515 else if (row->lb != row->ub)
519 glp_set_row_bnds(prob, i, type, row->lb, row->ub);
521 /* build columns and the constraint matrix */
522 ind = xcalloc(1+prob->m, sizeof(int));
523 val = xcalloc(1+prob->m, sizeof(double));
524 for (col = npp->c_head; col != NULL; col = col->next)
525 { j = glp_add_cols(prob, 1);
526 glp_set_col_name(prob, j, col->name);
528 glp_set_col_kind(prob, j, col->kind);
530 glp_set_col_kind(prob, j, col->is_int ? GLP_IV : GLP_CV);
532 if (col->lb == -DBL_MAX && col->ub == +DBL_MAX)
534 else if (col->ub == +DBL_MAX)
536 else if (col->lb == -DBL_MAX)
538 else if (col->lb != col->ub)
542 glp_set_col_bnds(prob, j, type, col->lb, col->ub);
543 glp_set_obj_coef(prob, j, dir * col->coef);
545 for (aij = col->ptr; aij != NULL; aij = aij->c_next)
547 ind[len] = aij->row->temp;
550 glp_set_mat_col(prob, j, len, ind, val);
554 /* resultant problem has been built */
557 npp->nnz = prob->nnz;
558 npp->row_ref = xcalloc(1+npp->m, sizeof(int));
559 npp->col_ref = xcalloc(1+npp->n, sizeof(int));
560 for (row = npp->r_head, i = 0; row != NULL; row = row->next)
561 npp->row_ref[++i] = row->i;
562 for (col = npp->c_head, j = 0; col != NULL; col = col->next)
563 npp->col_ref[++j] = col->j;
564 /* transformed problem segment is no longer needed */
565 dmp_delete_pool(npp->pool), npp->pool = NULL;
566 npp->name = npp->obj = NULL;
568 npp->r_head = npp->r_tail = NULL;
569 npp->c_head = npp->c_tail = NULL;
573 void npp_postprocess(NPP *npp, glp_prob *prob)
574 { /* postprocess solution from the resultant problem */
580 xassert(npp->orig_dir == prob->dir);
581 if (npp->orig_dir == GLP_MIN)
583 else if (npp->orig_dir == GLP_MAX)
587 xassert(npp->m == prob->m);
588 xassert(npp->n == prob->n);
589 xassert(npp->nnz == prob->nnz);
590 /* copy solution status */
591 if (npp->sol == GLP_SOL)
592 { npp->p_stat = prob->pbs_stat;
593 npp->d_stat = prob->dbs_stat;
595 else if (npp->sol == GLP_IPT)
596 npp->t_stat = prob->ipt_stat;
597 else if (npp->sol == GLP_MIP)
598 npp->i_stat = prob->mip_stat;
601 /* allocate solution arrays */
602 if (npp->sol == GLP_SOL)
603 { if (npp->r_stat == NULL)
604 npp->r_stat = xcalloc(1+npp->nrows, sizeof(char));
605 for (i = 1; i <= npp->nrows; i++)
607 if (npp->c_stat == NULL)
608 npp->c_stat = xcalloc(1+npp->ncols, sizeof(char));
609 for (j = 1; j <= npp->ncols; j++)
613 if (npp->r_prim == NULL)
614 npp->r_prim = xcalloc(1+npp->nrows, sizeof(double));
615 for (i = 1; i <= npp->nrows; i++)
616 npp->r_prim[i] = DBL_MAX;
618 if (npp->c_value == NULL)
619 npp->c_value = xcalloc(1+npp->ncols, sizeof(double));
620 for (j = 1; j <= npp->ncols; j++)
621 npp->c_value[j] = DBL_MAX;
622 if (npp->sol != GLP_MIP)
623 { if (npp->r_pi == NULL)
624 npp->r_pi = xcalloc(1+npp->nrows, sizeof(double));
625 for (i = 1; i <= npp->nrows; i++)
626 npp->r_pi[i] = DBL_MAX;
628 if (npp->c_dual == NULL)
629 npp->c_dual = xcalloc(1+npp->ncols, sizeof(double));
630 for (j = 1; j <= npp->ncols; j++)
631 npp->c_dual[j] = DBL_MAX;
634 /* copy solution components from the resultant problem */
635 if (npp->sol == GLP_SOL)
636 { for (i = 1; i <= npp->m; i++)
637 { row = prob->row[i];
639 npp->r_stat[k] = (char)row->stat;
640 /*npp->r_prim[k] = row->prim;*/
641 npp->r_pi[k] = dir * row->dual;
643 for (j = 1; j <= npp->n; j++)
644 { col = prob->col[j];
646 npp->c_stat[k] = (char)col->stat;
647 npp->c_value[k] = col->prim;
648 /*npp->c_dual[k] = dir * col->dual;*/
651 else if (npp->sol == GLP_IPT)
652 { for (i = 1; i <= npp->m; i++)
653 { row = prob->row[i];
655 /*npp->r_prim[k] = row->pval;*/
656 npp->r_pi[k] = dir * row->dval;
658 for (j = 1; j <= npp->n; j++)
659 { col = prob->col[j];
661 npp->c_value[k] = col->pval;
662 /*npp->c_dual[k] = dir * col->dval;*/
665 else if (npp->sol == GLP_MIP)
668 for (i = 1; i <= npp->m; i++)
669 { row = prob->row[i];
671 /*npp->r_prim[k] = row->mipx;*/
674 for (j = 1; j <= npp->n; j++)
675 { col = prob->col[j];
677 npp->c_value[k] = col->mipx;
682 /* perform postprocessing to construct solution to the original
684 for (tse = npp->top; tse != NULL; tse = tse->link)
685 { xassert(tse->func != NULL);
686 xassert(tse->func(npp, tse->info) == 0);
691 void npp_unload_sol(NPP *npp, glp_prob *orig)
692 { /* store solution to the original problem */
697 xassert(npp->orig_dir == orig->dir);
698 if (npp->orig_dir == GLP_MIN)
700 else if (npp->orig_dir == GLP_MAX)
704 xassert(npp->orig_m == orig->m);
705 xassert(npp->orig_n == orig->n);
706 xassert(npp->orig_nnz == orig->nnz);
707 if (npp->sol == GLP_SOL)
708 { /* store basic solution */
710 orig->pbs_stat = npp->p_stat;
711 orig->dbs_stat = npp->d_stat;
712 orig->obj_val = orig->c0;
714 for (i = 1; i <= orig->m; i++)
715 { row = orig->row[i];
716 row->stat = npp->r_stat[i];
718 { /*row->prim = npp->r_prim[i];*/
719 row->dual = dir * npp->r_pi[i];
722 { /*row->prim = npp->r_prim[i] / row->rii;*/
723 row->dual = dir * npp->r_pi[i] * row->rii;
725 if (row->stat == GLP_BS)
727 else if (row->stat == GLP_NL)
728 { xassert(row->type == GLP_LO || row->type == GLP_DB);
731 else if (row->stat == GLP_NU)
732 { xassert(row->type == GLP_UP || row->type == GLP_DB);
735 else if (row->stat == GLP_NF)
736 { xassert(row->type == GLP_FR);
739 else if (row->stat == GLP_NS)
740 { xassert(row->type == GLP_FX);
746 for (j = 1; j <= orig->n; j++)
747 { col = orig->col[j];
748 col->stat = npp->c_stat[j];
750 { col->prim = npp->c_value[j];
751 /*col->dual = dir * npp->c_dual[j];*/
754 { col->prim = npp->c_value[j] * col->sjj;
755 /*col->dual = dir * npp->c_dual[j] / col->sjj;*/
757 if (col->stat == GLP_BS)
760 else if (col->stat == GLP_NL)
761 { xassert(col->type == GLP_LO || col->type == GLP_DB);
764 else if (col->stat == GLP_NU)
765 { xassert(col->type == GLP_UP || col->type == GLP_DB);
768 else if (col->stat == GLP_NF)
769 { xassert(col->type == GLP_FR);
772 else if (col->stat == GLP_NS)
773 { xassert(col->type == GLP_FX);
779 orig->obj_val += col->coef * col->prim;
782 /* compute primal values of inactive rows */
783 for (i = 1; i <= orig->m; i++)
784 { row = orig->row[i];
785 if (row->stat == GLP_BS)
789 for (aij = row->ptr; aij != NULL; aij = aij->r_next)
790 temp += aij->val * aij->col->prim;
794 /* compute reduced costs of active columns */
795 for (j = 1; j <= orig->n; j++)
796 { col = orig->col[j];
797 if (col->stat != GLP_BS)
801 for (aij = col->ptr; aij != NULL; aij = aij->c_next)
802 temp -= aij->val * aij->row->dual;
808 else if (npp->sol == GLP_IPT)
809 { /* store interior-point solution */
810 orig->ipt_stat = npp->t_stat;
811 orig->ipt_obj = orig->c0;
812 for (i = 1; i <= orig->m; i++)
813 { row = orig->row[i];
815 { /*row->pval = npp->r_prim[i];*/
816 row->dval = dir * npp->r_pi[i];
819 { /*row->pval = npp->r_prim[i] / row->rii;*/
820 row->dval = dir * npp->r_pi[i] * row->rii;
823 for (j = 1; j <= orig->n; j++)
824 { col = orig->col[j];
826 { col->pval = npp->c_value[j];
827 /*col->dval = dir * npp->c_dual[j];*/
830 { col->pval = npp->c_value[j] * col->sjj;
831 /*col->dval = dir * npp->c_dual[j] / col->sjj;*/
833 orig->ipt_obj += col->coef * col->pval;
836 /* compute row primal values */
837 for (i = 1; i <= orig->m; i++)
838 { row = orig->row[i];
842 for (aij = row->ptr; aij != NULL; aij = aij->r_next)
843 temp += aij->val * aij->col->pval;
847 /* compute column dual values */
848 for (j = 1; j <= orig->n; j++)
849 { col = orig->col[j];
853 for (aij = col->ptr; aij != NULL; aij = aij->c_next)
854 temp -= aij->val * aij->row->dval;
860 else if (npp->sol == GLP_MIP)
861 { /* store MIP solution */
862 xassert(!npp->scaling);
863 orig->mip_stat = npp->i_stat;
864 orig->mip_obj = orig->c0;
866 for (i = 1; i <= orig->m; i++)
867 { row = orig->row[i];
868 /*row->mipx = npp->r_prim[i];*/
871 for (j = 1; j <= orig->n; j++)
872 { col = orig->col[j];
873 col->mipx = npp->c_value[j];
874 if (col->kind == GLP_IV)
875 xassert(col->mipx == floor(col->mipx));
876 orig->mip_obj += col->coef * col->mipx;
879 /* compute row primal values */
880 for (i = 1; i <= orig->m; i++)
881 { row = orig->row[i];
885 for (aij = row->ptr; aij != NULL; aij = aij->r_next)
886 temp += aij->val * aij->col->mipx;
897 void npp_delete_wksp(NPP *npp)
898 { /* delete LP/MIP preprocessor workspace */
899 if (npp->pool != NULL)
900 dmp_delete_pool(npp->pool);
901 if (npp->stack != NULL)
902 dmp_delete_pool(npp->stack);
903 if (npp->row_ref != NULL)
905 if (npp->col_ref != NULL)
907 if (npp->r_stat != NULL)
910 if (npp->r_prim != NULL)
913 if (npp->r_pi != NULL)
915 if (npp->c_stat != NULL)
917 if (npp->c_value != NULL)
920 if (npp->c_dual != NULL)