| 1 | /* glpapi04.c (problem scaling routines) */cxx . . $ `<file>/external/glpk/glpapi04.c`/ |
| 2 | |
| 3 | /*********************************************************************** |
| 4 | * This code is part of GLPK (GNU Linear Programming Kit). |
| 5 | * |
| 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: <[email protected]>. |
| 10 | * |
| 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. |
| 15 | * |
| 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. |
| 20 | * |
| 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 | ***********************************************************************/ |
| 24 | |
| 25 | #include "glpapi.h"cxx . . $ `<file>/external/glpk/glpapi.h`/ |
| 26 | |
| 27 | /*********************************************************************** |
| 28 | * NAME |
| 29 | * |
| 30 | * glp_set_rii - set (change) row scale factor |
| 31 | * |
| 32 | * SYNOPSIS |
| 33 | * |
| 34 | * void glp_set_rii(glp_prob *lp, int i, double rii); |
| 35 | * |
| 36 | * DESCRIPTION |
| 37 | * |
| 38 | * The routine glp_set_rii sets (changes) the scale factor r[i,i] for |
| 39 | * i-th row of the specified problem object. */ |
| 40 | |
| 41 | void glp_set_riicxx . . $ glp_set_rii(d60e14834b632e5e).(glp_probcxx . . $ glp_prob# *lp, int i, double rii) |
| 42 | { if (!(1 <= i && i <= lp->mcxx . . $ glp_prob#m.)) |
| 43 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_set_rii: i = %d; row number out of range\n", i); |
| 44 | if (rii <= 0.0) |
| 45 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_set_rii: i = %d; rii = %g; invalid scale factor\n", |
| 46 | i, rii); |
| 47 | if (lp->validcxx . . $ glp_prob#valid. && lp->rowcxx . . $ glp_prob#row.[i]->riicxx . . $ GLPROW#rii. != rii) |
| 48 | { GLPAIJcxx . . $ GLPAIJ# *aij; |
| 49 | for (aij = lp->rowcxx . . $ glp_prob#row.[i]->ptrcxx . . $ GLPROW#ptr.; aij != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; aij = aij->r_nextcxx . . $ GLPAIJ#r_next.) |
| 50 | { if (aij->colcxx . . $ GLPAIJ#col.->statcxx . . $ GLPCOL#stat. == GLP_BScxx . . $ `external/glpk/glpk.h:66:9`!) |
| 51 | { /* invalidate the basis factorization */ |
| 52 | lp->validcxx . . $ glp_prob#valid. = 0; |
| 53 | break; |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | lp->rowcxx . . $ glp_prob#row.[i]->riicxx . . $ GLPROW#rii. = rii; |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | /*********************************************************************** |
| 62 | * NAME |
| 63 | * |
| 64 | * glp_set sjj - set (change) column scale factor |
| 65 | * |
| 66 | * SYNOPSIS |
| 67 | * |
| 68 | * void glp_set_sjj(glp_prob *lp, int j, double sjj); |
| 69 | * |
| 70 | * DESCRIPTION |
| 71 | * |
| 72 | * The routine glp_set_sjj sets (changes) the scale factor s[j,j] for |
| 73 | * j-th column of the specified problem object. */ |
| 74 | |
| 75 | void glp_set_sjjcxx . . $ glp_set_sjj(d60e14834b632e5e).(glp_probcxx . . $ glp_prob# *lp, int j, double sjj) |
| 76 | { if (!(1 <= j && j <= lp->ncxx . . $ glp_prob#n.)) |
| 77 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_set_sjj: j = %d; column number out of range\n", j); |
| 78 | if (sjj <= 0.0) |
| 79 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_set_sjj: j = %d; sjj = %g; invalid scale factor\n", |
| 80 | j, sjj); |
| 81 | if (lp->validcxx . . $ glp_prob#valid. && lp->colcxx . . $ glp_prob#col.[j]->sjjcxx . . $ GLPCOL#sjj. != sjj && lp->colcxx . . $ glp_prob#col.[j]->statcxx . . $ GLPCOL#stat. == |
| 82 | GLP_BScxx . . $ `external/glpk/glpk.h:66:9`!) |
| 83 | { /* invalidate the basis factorization */ |
| 84 | lp->validcxx . . $ glp_prob#valid. = 0; |
| 85 | } |
| 86 | lp->colcxx . . $ glp_prob#col.[j]->sjjcxx . . $ GLPCOL#sjj. = sjj; |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | /*********************************************************************** |
| 91 | * NAME |
| 92 | * |
| 93 | * glp_get_rii - retrieve row scale factor |
| 94 | * |
| 95 | * SYNOPSIS |
| 96 | * |
| 97 | * double glp_get_rii(glp_prob *lp, int i); |
| 98 | * |
| 99 | * RETURNS |
| 100 | * |
| 101 | * The routine glp_get_rii returns current scale factor r[i,i] for i-th |
| 102 | * row of the specified problem object. */ |
| 103 | |
| 104 | double glp_get_riicxx . . $ glp_get_rii(68c5770eb0f32231).(glp_probcxx . . $ glp_prob# *lp, int i) |
| 105 | { if (!(1 <= i && i <= lp->mcxx . . $ glp_prob#m.)) |
| 106 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_get_rii: i = %d; row number out of range\n", i); |
| 107 | return lp->rowcxx . . $ glp_prob#row.[i]->riicxx . . $ GLPROW#rii.; |
| 108 | } |
| 109 | |
| 110 | /*********************************************************************** |
| 111 | * NAME |
| 112 | * |
| 113 | * glp_get_sjj - retrieve column scale factor |
| 114 | * |
| 115 | * SYNOPSIS |
| 116 | * |
| 117 | * double glp_get_sjj(glp_prob *lp, int j); |
| 118 | * |
| 119 | * RETURNS |
| 120 | * |
| 121 | * The routine glp_get_sjj returns current scale factor s[j,j] for j-th |
| 122 | * column of the specified problem object. */ |
| 123 | |
| 124 | double glp_get_sjjcxx . . $ glp_get_sjj(68c5770eb0f32231).(glp_probcxx . . $ glp_prob# *lp, int j) |
| 125 | { if (!(1 <= j && j <= lp->ncxx . . $ glp_prob#n.)) |
| 126 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_get_sjj: j = %d; column number out of range\n", j); |
| 127 | return lp->colcxx . . $ glp_prob#col.[j]->sjjcxx . . $ GLPCOL#sjj.; |
| 128 | } |
| 129 | |
| 130 | /*********************************************************************** |
| 131 | * NAME |
| 132 | * |
| 133 | * glp_unscale_prob - unscale problem data |
| 134 | * |
| 135 | * SYNOPSIS |
| 136 | * |
| 137 | * void glp_unscale_prob(glp_prob *lp); |
| 138 | * |
| 139 | * DESCRIPTION |
| 140 | * |
| 141 | * The routine glp_unscale_prob performs unscaling of problem data for |
| 142 | * the specified problem object. |
| 143 | * |
| 144 | * "Unscaling" means replacing the current scaling matrices R and S by |
| 145 | * unity matrices that cancels the scaling effect. */ |
| 146 | |
| 147 | void glp_unscale_probcxx . . $ glp_unscale_prob(84c60d68cac39b9a).(glp_probcxx . . $ glp_prob# *lp) |
| 148 | { int m = glp_get_num_rowscxx . . $ glp_get_num_rows(317ecc1aeadfe2b7).(lp); |
| 149 | int n = glp_get_num_colscxx . . $ glp_get_num_cols(317ecc1aeadfe2b7).(lp); |
| 150 | int i, j; |
| 151 | for (i = 1; i <= m; i++) glp_set_riicxx . . $ glp_set_rii(d60e14834b632e5e).(lp, i, 1.0); |
| 152 | for (j = 1; j <= n; j++) glp_set_sjjcxx . . $ glp_set_sjj(d60e14834b632e5e).(lp, j, 1.0); |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | /* eof */ |