lemon-project-template-glpk

annotate deps/glpk/src/glpapi04.c @ 9:33de93886c88

Import GLPK 4.47
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 20:59:10 +0100
parents
children
rev   line source
alpar@9 1 /* glpapi04.c (problem scaling routines) */
alpar@9 2
alpar@9 3 /***********************************************************************
alpar@9 4 * This code is part of GLPK (GNU Linear Programming Kit).
alpar@9 5 *
alpar@9 6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
alpar@9 7 * 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics,
alpar@9 8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
alpar@9 9 * E-mail: <mao@gnu.org>.
alpar@9 10 *
alpar@9 11 * GLPK is free software: you can redistribute it and/or modify it
alpar@9 12 * under the terms of the GNU General Public License as published by
alpar@9 13 * the Free Software Foundation, either version 3 of the License, or
alpar@9 14 * (at your option) any later version.
alpar@9 15 *
alpar@9 16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
alpar@9 17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
alpar@9 18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
alpar@9 19 * License for more details.
alpar@9 20 *
alpar@9 21 * You should have received a copy of the GNU General Public License
alpar@9 22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
alpar@9 23 ***********************************************************************/
alpar@9 24
alpar@9 25 #include "glpapi.h"
alpar@9 26
alpar@9 27 /***********************************************************************
alpar@9 28 * NAME
alpar@9 29 *
alpar@9 30 * glp_set_rii - set (change) row scale factor
alpar@9 31 *
alpar@9 32 * SYNOPSIS
alpar@9 33 *
alpar@9 34 * void glp_set_rii(glp_prob *lp, int i, double rii);
alpar@9 35 *
alpar@9 36 * DESCRIPTION
alpar@9 37 *
alpar@9 38 * The routine glp_set_rii sets (changes) the scale factor r[i,i] for
alpar@9 39 * i-th row of the specified problem object. */
alpar@9 40
alpar@9 41 void glp_set_rii(glp_prob *lp, int i, double rii)
alpar@9 42 { if (!(1 <= i && i <= lp->m))
alpar@9 43 xerror("glp_set_rii: i = %d; row number out of range\n", i);
alpar@9 44 if (rii <= 0.0)
alpar@9 45 xerror("glp_set_rii: i = %d; rii = %g; invalid scale factor\n",
alpar@9 46 i, rii);
alpar@9 47 if (lp->valid && lp->row[i]->rii != rii)
alpar@9 48 { GLPAIJ *aij;
alpar@9 49 for (aij = lp->row[i]->ptr; aij != NULL; aij = aij->r_next)
alpar@9 50 { if (aij->col->stat == GLP_BS)
alpar@9 51 { /* invalidate the basis factorization */
alpar@9 52 lp->valid = 0;
alpar@9 53 break;
alpar@9 54 }
alpar@9 55 }
alpar@9 56 }
alpar@9 57 lp->row[i]->rii = rii;
alpar@9 58 return;
alpar@9 59 }
alpar@9 60
alpar@9 61 /***********************************************************************
alpar@9 62 * NAME
alpar@9 63 *
alpar@9 64 * glp_set sjj - set (change) column scale factor
alpar@9 65 *
alpar@9 66 * SYNOPSIS
alpar@9 67 *
alpar@9 68 * void glp_set_sjj(glp_prob *lp, int j, double sjj);
alpar@9 69 *
alpar@9 70 * DESCRIPTION
alpar@9 71 *
alpar@9 72 * The routine glp_set_sjj sets (changes) the scale factor s[j,j] for
alpar@9 73 * j-th column of the specified problem object. */
alpar@9 74
alpar@9 75 void glp_set_sjj(glp_prob *lp, int j, double sjj)
alpar@9 76 { if (!(1 <= j && j <= lp->n))
alpar@9 77 xerror("glp_set_sjj: j = %d; column number out of range\n", j);
alpar@9 78 if (sjj <= 0.0)
alpar@9 79 xerror("glp_set_sjj: j = %d; sjj = %g; invalid scale factor\n",
alpar@9 80 j, sjj);
alpar@9 81 if (lp->valid && lp->col[j]->sjj != sjj && lp->col[j]->stat ==
alpar@9 82 GLP_BS)
alpar@9 83 { /* invalidate the basis factorization */
alpar@9 84 lp->valid = 0;
alpar@9 85 }
alpar@9 86 lp->col[j]->sjj = sjj;
alpar@9 87 return;
alpar@9 88 }
alpar@9 89
alpar@9 90 /***********************************************************************
alpar@9 91 * NAME
alpar@9 92 *
alpar@9 93 * glp_get_rii - retrieve row scale factor
alpar@9 94 *
alpar@9 95 * SYNOPSIS
alpar@9 96 *
alpar@9 97 * double glp_get_rii(glp_prob *lp, int i);
alpar@9 98 *
alpar@9 99 * RETURNS
alpar@9 100 *
alpar@9 101 * The routine glp_get_rii returns current scale factor r[i,i] for i-th
alpar@9 102 * row of the specified problem object. */
alpar@9 103
alpar@9 104 double glp_get_rii(glp_prob *lp, int i)
alpar@9 105 { if (!(1 <= i && i <= lp->m))
alpar@9 106 xerror("glp_get_rii: i = %d; row number out of range\n", i);
alpar@9 107 return lp->row[i]->rii;
alpar@9 108 }
alpar@9 109
alpar@9 110 /***********************************************************************
alpar@9 111 * NAME
alpar@9 112 *
alpar@9 113 * glp_get_sjj - retrieve column scale factor
alpar@9 114 *
alpar@9 115 * SYNOPSIS
alpar@9 116 *
alpar@9 117 * double glp_get_sjj(glp_prob *lp, int j);
alpar@9 118 *
alpar@9 119 * RETURNS
alpar@9 120 *
alpar@9 121 * The routine glp_get_sjj returns current scale factor s[j,j] for j-th
alpar@9 122 * column of the specified problem object. */
alpar@9 123
alpar@9 124 double glp_get_sjj(glp_prob *lp, int j)
alpar@9 125 { if (!(1 <= j && j <= lp->n))
alpar@9 126 xerror("glp_get_sjj: j = %d; column number out of range\n", j);
alpar@9 127 return lp->col[j]->sjj;
alpar@9 128 }
alpar@9 129
alpar@9 130 /***********************************************************************
alpar@9 131 * NAME
alpar@9 132 *
alpar@9 133 * glp_unscale_prob - unscale problem data
alpar@9 134 *
alpar@9 135 * SYNOPSIS
alpar@9 136 *
alpar@9 137 * void glp_unscale_prob(glp_prob *lp);
alpar@9 138 *
alpar@9 139 * DESCRIPTION
alpar@9 140 *
alpar@9 141 * The routine glp_unscale_prob performs unscaling of problem data for
alpar@9 142 * the specified problem object.
alpar@9 143 *
alpar@9 144 * "Unscaling" means replacing the current scaling matrices R and S by
alpar@9 145 * unity matrices that cancels the scaling effect. */
alpar@9 146
alpar@9 147 void glp_unscale_prob(glp_prob *lp)
alpar@9 148 { int m = glp_get_num_rows(lp);
alpar@9 149 int n = glp_get_num_cols(lp);
alpar@9 150 int i, j;
alpar@9 151 for (i = 1; i <= m; i++) glp_set_rii(lp, i, 1.0);
alpar@9 152 for (j = 1; j <= n; j++) glp_set_sjj(lp, j, 1.0);
alpar@9 153 return;
alpar@9 154 }
alpar@9 155
alpar@9 156 /* eof */