| 1 | /* glpapi06.c (simplex method routines) */cxx . . $ `<file>/external/glpk/glpapi06.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 "glpios.h"cxx . . $ `<file>/external/glpk/glpios.h`/ |
| 26 | #include "glpnpp.h"cxx . . $ `<file>/external/glpk/glpnpp.h`/ |
| 27 | #include "glpspx.h"cxx . . $ `<file>/external/glpk/glpspx.h`/ |
| 28 | |
| 29 | /*********************************************************************** |
| 30 | * NAME |
| 31 | * |
| 32 | * glp_simplex - solve LP problem with the simplex method |
| 33 | * |
| 34 | * SYNOPSIS |
| 35 | * |
| 36 | * int glp_simplex(glp_prob *P, const glp_smcp *parm); |
| 37 | * |
| 38 | * DESCRIPTION |
| 39 | * |
| 40 | * The routine glp_simplex is a driver to the LP solver based on the |
| 41 | * simplex method. This routine retrieves problem data from the |
| 42 | * specified problem object, calls the solver to solve the problem |
| 43 | * instance, and stores results of computations back into the problem |
| 44 | * object. |
| 45 | * |
| 46 | * The simplex solver has a set of control parameters. Values of the |
| 47 | * control parameters can be passed in a structure glp_smcp, which the |
| 48 | * parameter parm points to. |
| 49 | * |
| 50 | * The parameter parm can be specified as NULL, in which case the LP |
| 51 | * solver uses default settings. |
| 52 | * |
| 53 | * RETURNS |
| 54 | * |
| 55 | * 0 The LP problem instance has been successfully solved. This code |
| 56 | * does not necessarily mean that the solver has found optimal |
| 57 | * solution. It only means that the solution process was successful. |
| 58 | * |
| 59 | * GLP_EBADB |
| 60 | * Unable to start the search, because the initial basis specified |
| 61 | * in the problem object is invalid--the number of basic (auxiliary |
| 62 | * and structural) variables is not the same as the number of rows in |
| 63 | * the problem object. |
| 64 | * |
| 65 | * GLP_ESING |
| 66 | * Unable to start the search, because the basis matrix correspodning |
| 67 | * to the initial basis is singular within the working precision. |
| 68 | * |
| 69 | * GLP_ECOND |
| 70 | * Unable to start the search, because the basis matrix correspodning |
| 71 | * to the initial basis is ill-conditioned, i.e. its condition number |
| 72 | * is too large. |
| 73 | * |
| 74 | * GLP_EBOUND |
| 75 | * Unable to start the search, because some double-bounded variables |
| 76 | * have incorrect bounds. |
| 77 | * |
| 78 | * GLP_EFAIL |
| 79 | * The search was prematurely terminated due to the solver failure. |
| 80 | * |
| 81 | * GLP_EOBJLL |
| 82 | * The search was prematurely terminated, because the objective |
| 83 | * function being maximized has reached its lower limit and continues |
| 84 | * decreasing (dual simplex only). |
| 85 | * |
| 86 | * GLP_EOBJUL |
| 87 | * The search was prematurely terminated, because the objective |
| 88 | * function being minimized has reached its upper limit and continues |
| 89 | * increasing (dual simplex only). |
| 90 | * |
| 91 | * GLP_EITLIM |
| 92 | * The search was prematurely terminated, because the simplex |
| 93 | * iteration limit has been exceeded. |
| 94 | * |
| 95 | * GLP_ETMLIM |
| 96 | * The search was prematurely terminated, because the time limit has |
| 97 | * been exceeded. |
| 98 | * |
| 99 | * GLP_ENOPFS |
| 100 | * The LP problem instance has no primal feasible solution (only if |
| 101 | * the LP presolver is used). |
| 102 | * |
| 103 | * GLP_ENODFS |
| 104 | * The LP problem instance has no dual feasible solution (only if the |
| 105 | * LP presolver is used). */ |
| 106 | |
| 107 | static void trivial_lpcxx . . $ trivial_lp(92f1dac111cd7bc1).(glp_probcxx . . $ glp_prob# *P, const glp_smcpcxx . . $ glp_smcp# *parm) |
| 108 | { /* solve trivial LP which has empty constraint matrix */ |
| 109 | GLPROWcxx . . $ GLPROW# *row; |
| 110 | GLPCOLcxx . . $ GLPCOL# *col; |
| 111 | int i, j; |
| 112 | double p_infeas, d_infeas, zeta; |
| 113 | P->validcxx . . $ glp_prob#valid. = 0; |
| 114 | P->pbs_statcxx . . $ glp_prob#pbs_stat. = P->dbs_statcxx . . $ glp_prob#dbs_stat. = GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`!; |
| 115 | P->obj_valcxx . . $ glp_prob#obj_val. = P->c0cxx . . $ glp_prob#c0.; |
| 116 | P->somecxx . . $ glp_prob#some. = 0; |
| 117 | p_infeas = d_infeas = 0.0; |
| 118 | /* make all auxiliary variables basic */ |
| 119 | for (i = 1; i <= P->mcxx . . $ glp_prob#m.; i++) |
| 120 | { row = P->rowcxx . . $ glp_prob#row.[i]; |
| 121 | row->statcxx . . $ GLPROW#stat. = GLP_BScxx . . $ `external/glpk/glpk.h:66:9`!; |
| 122 | row->primcxx . . $ GLPROW#prim. = row->dualcxx . . $ GLPROW#dual. = 0.0; |
| 123 | /* check primal feasibility */ |
| 124 | if (row->typecxx . . $ GLPROW#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! || |
| 125 | row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!) |
| 126 | { /* row has lower bound */ |
| 127 | if (row->lbcxx . . $ GLPROW#lb. > + parm->tol_bndcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_bnd.) |
| 128 | { P->pbs_statcxx . . $ glp_prob#pbs_stat. = GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!; |
| 129 | if (P->somecxx . . $ glp_prob#some. == 0 && parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. != GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`!) |
| 130 | P->somecxx . . $ glp_prob#some. = i; |
| 131 | } |
| 132 | if (p_infeas < + row->lbcxx . . $ GLPROW#lb.) |
| 133 | p_infeas = + row->lbcxx . . $ GLPROW#lb.; |
| 134 | } |
| 135 | if (row->typecxx . . $ GLPROW#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! || |
| 136 | row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!) |
| 137 | { /* row has upper bound */ |
| 138 | if (row->ubcxx . . $ GLPROW#ub. < - parm->tol_bndcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_bnd.) |
| 139 | { P->pbs_statcxx . . $ glp_prob#pbs_stat. = GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!; |
| 140 | if (P->somecxx . . $ glp_prob#some. == 0 && parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. != GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`!) |
| 141 | P->somecxx . . $ glp_prob#some. = i; |
| 142 | } |
| 143 | if (p_infeas < - row->ubcxx . . $ GLPROW#ub.) |
| 144 | p_infeas = - row->ubcxx . . $ GLPROW#ub.; |
| 145 | } |
| 146 | } |
| 147 | /* determine scale factor for the objective row */ |
| 148 | zeta = 1.0; |
| 149 | for (j = 1; j <= P->ncxx . . $ glp_prob#n.; j++) |
| 150 | { col = P->colcxx . . $ glp_prob#col.[j]; |
| 151 | if (zeta < fabs(col->coefcxx . . $ GLPCOL#coef.)) zeta = fabs(col->coefcxx . . $ GLPCOL#coef.); |
| 152 | } |
| 153 | zeta = (P->dircxx . . $ glp_prob#dir. == GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`! ? +1.0 : -1.0) / zeta; |
| 154 | /* make all structural variables non-basic */ |
| 155 | for (j = 1; j <= P->ncxx . . $ glp_prob#n.; j++) |
| 156 | { col = P->colcxx . . $ glp_prob#col.[j]; |
| 157 | if (col->typecxx . . $ GLPCOL#type. == GLP_FRcxx . . $ `external/glpk/glpk.h:59:9`!) |
| 158 | col->statcxx . . $ GLPCOL#stat. = GLP_NFcxx . . $ `external/glpk/glpk.h:69:9`!, col->primcxx . . $ GLPCOL#prim. = 0.0; |
| 159 | else if (col->typecxx . . $ GLPCOL#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!) |
| 160 | lo: col->statcxx . . $ GLPCOL#stat. = GLP_NLcxx . . $ `external/glpk/glpk.h:67:9`!, col->primcxx . . $ GLPCOL#prim. = col->lbcxx . . $ GLPCOL#lb.; |
| 161 | else if (col->typecxx . . $ GLPCOL#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`!) |
| 162 | up: col->statcxx . . $ GLPCOL#stat. = GLP_NUcxx . . $ `external/glpk/glpk.h:68:9`!, col->primcxx . . $ GLPCOL#prim. = col->ubcxx . . $ GLPCOL#ub.; |
| 163 | else if (col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!) |
| 164 | { if (zeta * col->coefcxx . . $ GLPCOL#coef. > 0.0) |
| 165 | goto lo; |
| 166 | else if (zeta * col->coefcxx . . $ GLPCOL#coef. < 0.0) |
| 167 | goto up; |
| 168 | else if (fabs(col->lbcxx . . $ GLPCOL#lb.) <= fabs(col->ubcxx . . $ GLPCOL#ub.)) |
| 169 | goto lo; |
| 170 | else |
| 171 | goto up; |
| 172 | } |
| 173 | else if (col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!) |
| 174 | col->statcxx . . $ GLPCOL#stat. = GLP_NScxx . . $ `external/glpk/glpk.h:70:9`!, col->primcxx . . $ GLPCOL#prim. = col->lbcxx . . $ GLPCOL#lb.; |
| 175 | col->dualcxx . . $ GLPCOL#dual. = col->coefcxx . . $ GLPCOL#coef.; |
| 176 | P->obj_valcxx . . $ glp_prob#obj_val. += col->coefcxx . . $ GLPCOL#coef. * col->primcxx . . $ GLPCOL#prim.; |
| 177 | /* check dual feasibility */ |
| 178 | if (col->typecxx . . $ GLPCOL#type. == GLP_FRcxx . . $ `external/glpk/glpk.h:59:9`! || col->typecxx . . $ GLPCOL#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!) |
| 179 | { /* column has no upper bound */ |
| 180 | if (zeta * col->dualcxx . . $ GLPCOL#dual. < - parm->tol_djcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_dj.) |
| 181 | { P->dbs_statcxx . . $ glp_prob#dbs_stat. = GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!; |
| 182 | if (P->somecxx . . $ glp_prob#some. == 0 && parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`!) |
| 183 | P->somecxx . . $ glp_prob#some. = P->mcxx . . $ glp_prob#m. + j; |
| 184 | } |
| 185 | if (d_infeas < - zeta * col->dualcxx . . $ GLPCOL#dual.) |
| 186 | d_infeas = - zeta * col->dualcxx . . $ GLPCOL#dual.; |
| 187 | } |
| 188 | if (col->typecxx . . $ GLPCOL#type. == GLP_FRcxx . . $ `external/glpk/glpk.h:59:9`! || col->typecxx . . $ GLPCOL#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`!) |
| 189 | { /* column has no lower bound */ |
| 190 | if (zeta * col->dualcxx . . $ GLPCOL#dual. > + parm->tol_djcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_dj.) |
| 191 | { P->dbs_statcxx . . $ glp_prob#dbs_stat. = GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!; |
| 192 | if (P->somecxx . . $ glp_prob#some. == 0 && parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`!) |
| 193 | P->somecxx . . $ glp_prob#some. = P->mcxx . . $ glp_prob#m. + j; |
| 194 | } |
| 195 | if (d_infeas < + zeta * col->dualcxx . . $ GLPCOL#dual.) |
| 196 | d_infeas = + zeta * col->dualcxx . . $ GLPCOL#dual.; |
| 197 | } |
| 198 | } |
| 199 | /* simulate the simplex solver output */ |
| 200 | if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ONcxx . . $ `external/glpk/glpk.h:117:9`! && parm->out_dlycxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_dly. == 0) |
| 201 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("~%6d: obj = %17.9e infeas = %10.3e\n", P->it_cntcxx . . $ glp_prob#it_cnt., |
| 202 | P->obj_valcxx . . $ glp_prob#obj_val., parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`! ? p_infeas : d_infeas); |
| 203 | } |
| 204 | if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`! && parm->out_dlycxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_dly. == 0) |
| 205 | { if (P->pbs_statcxx . . $ glp_prob#pbs_stat. == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`! && P->dbs_statcxx . . $ glp_prob#dbs_stat. == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`!) |
| 206 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("OPTIMAL SOLUTION FOUND\n"); |
| 207 | else if (P->pbs_statcxx . . $ glp_prob#pbs_stat. == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!) |
| 208 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("PROBLEM HAS NO FEASIBLE SOLUTION\n"); |
| 209 | else if (parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`!) |
| 210 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("PROBLEM HAS UNBOUNDED SOLUTION\n"); |
| 211 | else |
| 212 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("PROBLEM HAS NO DUAL FEASIBLE SOLUTION\n"); |
| 213 | } |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | static int solve_lpcxx . . $ solve_lp(115ca84ce6c1686e).(glp_probcxx . . $ glp_prob# *P, const glp_smcpcxx . . $ glp_smcp# *parm) |
| 218 | { /* solve LP directly without using the preprocessor */ |
| 219 | int ret; |
| 220 | if (!glp_bf_existscxx . . $ glp_bf_exists(317ecc1aeadfe2b7).(P)) |
| 221 | { ret = glp_factorizecxx . . $ glp_factorize(317ecc1aeadfe2b7).(P); |
| 222 | if (ret == 0) |
| 223 | ; |
| 224 | else if (ret == GLP_EBADBcxx . . $ `external/glpk/glpk.h:239:9`!) |
| 225 | { if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 226 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("glp_simplex: initial basis is invalid\n"); |
| 227 | } |
| 228 | else if (ret == GLP_ESINGcxx . . $ `external/glpk/glpk.h:240:9`!) |
| 229 | { if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 230 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("glp_simplex: initial basis is singular\n"); |
| 231 | } |
| 232 | else if (ret == GLP_ECONDcxx . . $ `external/glpk/glpk.h:241:9`!) |
| 233 | { if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 234 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!( |
| 235 | "glp_simplex: initial basis is ill-conditioned\n"); |
| 236 | } |
| 237 | else |
| 238 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(ret != ret); |
| 239 | if (ret != 0) goto done; |
| 240 | } |
| 241 | if (parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`!) |
| 242 | ret = spx_primalcxx . . $ `external/glpk/glpspx.h:30:9`!(P, parm); |
| 243 | else if (parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_DUALPcxx . . $ `external/glpk/glpk.h:122:9`!) |
| 244 | { ret = spx_dualcxx . . $ `external/glpk/glpspx.h:34:9`!(P, parm); |
| 245 | if (ret == GLP_EFAILcxx . . $ `external/glpk/glpk.h:243:9`! && P->validcxx . . $ glp_prob#valid.) |
| 246 | ret = spx_primalcxx . . $ `external/glpk/glpspx.h:30:9`!(P, parm); |
| 247 | } |
| 248 | else if (parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_DUALcxx . . $ `external/glpk/glpk.h:123:9`!) |
| 249 | ret = spx_dualcxx . . $ `external/glpk/glpspx.h:34:9`!(P, parm); |
| 250 | else |
| 251 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(parm != parm); |
| 252 | done: return ret; |
| 253 | } |
| 254 | |
| 255 | static int preprocess_and_solve_lpcxx . . $ preprocess_and_solve_lp(115ca84ce6c1686e).(glp_probcxx . . $ glp_prob# *P, const glp_smcpcxx . . $ glp_smcp# *parm) |
| 256 | { /* solve LP using the preprocessor */ |
| 257 | NPPcxx . . $ NPP# *npp; |
| 258 | glp_probcxx . . $ glp_prob# *lp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 259 | glp_bfcpcxx . . $ glp_bfcp# bfcp; |
| 260 | int ret; |
| 261 | if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 262 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Preprocessing...\n"); |
| 263 | /* create preprocessor workspace */ |
| 264 | npp = npp_create_wkspcxx . . $ `external/glpk/glpnpp.h:261:9`!(); |
| 265 | /* load original problem into the preprocessor workspace */ |
| 266 | npp_load_probcxx . . $ `external/glpk/glpnpp.h:338:9`!(npp, P, GLP_OFFcxx . . $ `external/glpk/glpk.h:222:9`!, GLP_SOLcxx . . $ `external/glpk/glpk.h:80:9`!, GLP_OFFcxx . . $ `external/glpk/glpk.h:222:9`!); |
| 267 | /* process LP prior to applying primal/dual simplex method */ |
| 268 | ret = npp_simplexcxx . . $ `external/glpk/glpnpp.h:510:9`!(npp, parm); |
| 269 | if (ret == 0) |
| 270 | ; |
| 271 | else if (ret == GLP_ENOPFScxx . . $ `external/glpk/glpk.h:248:9`!) |
| 272 | { if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 273 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("PROBLEM HAS NO PRIMAL FEASIBLE SOLUTION\n"); |
| 274 | } |
| 275 | else if (ret == GLP_ENODFScxx . . $ `external/glpk/glpk.h:249:9`!) |
| 276 | { if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 277 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("PROBLEM HAS NO DUAL FEASIBLE SOLUTION\n"); |
| 278 | } |
| 279 | else |
| 280 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(ret != ret); |
| 281 | if (ret != 0) goto done; |
| 282 | /* build transformed LP */ |
| 283 | lp = glp_create_probcxx . . $ glp_create_prob(7c2d8bedb6abbdaf).(); |
| 284 | npp_build_probcxx . . $ `external/glpk/glpnpp.h:343:9`!(npp, lp); |
| 285 | /* if the transformed LP is empty, it has empty solution, which |
| 286 | is optimal */ |
| 287 | if (lp->mcxx . . $ glp_prob#m. == 0 && lp->ncxx . . $ glp_prob#n. == 0) |
| 288 | { lp->pbs_statcxx . . $ glp_prob#pbs_stat. = lp->dbs_statcxx . . $ glp_prob#dbs_stat. = GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`!; |
| 289 | lp->obj_valcxx . . $ glp_prob#obj_val. = lp->c0cxx . . $ glp_prob#c0.; |
| 290 | if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ONcxx . . $ `external/glpk/glpk.h:117:9`! && parm->out_dlycxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_dly. == 0) |
| 291 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("~%6d: obj = %17.9e infeas = %10.3e\n", P->it_cntcxx . . $ glp_prob#it_cnt., |
| 292 | lp->obj_valcxx . . $ glp_prob#obj_val., 0.0); |
| 293 | } |
| 294 | if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 295 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("OPTIMAL SOLUTION FOUND BY LP PREPROCESSOR\n"); |
| 296 | goto post; |
| 297 | } |
| 298 | if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 299 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d row%s, %d column%s, %d non-zero%s\n", |
| 300 | lp->mcxx . . $ glp_prob#m., lp->mcxx . . $ glp_prob#m. == 1 ? "" : "s", lp->ncxx . . $ glp_prob#n., lp->ncxx . . $ glp_prob#n. == 1 ? "" : "s", |
| 301 | lp->nnzcxx . . $ glp_prob#nnz., lp->nnzcxx . . $ glp_prob#nnz. == 1 ? "" : "s"); |
| 302 | } |
| 303 | /* inherit basis factorization control parameters */ |
| 304 | glp_get_bfcpcxx . . $ glp_get_bfcp(cc8cafde03995f03).(P, &bfcp); |
| 305 | glp_set_bfcpcxx . . $ glp_set_bfcp(cfafdb23988eec12).(lp, &bfcp); |
| 306 | /* scale the transformed problem */ |
| 307 | { ENVcxx . . $ ENV# *env = get_env_ptrcxx . . $ `external/glpk/glpenv.h:133:9`!(); |
| 308 | int term_out = env->term_outcxx . . $ ENV#term_out.; |
| 309 | if (!term_out || parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. < GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 310 | env->term_outcxx . . $ ENV#term_out. = GLP_OFFcxx . . $ `external/glpk/glpk.h:222:9`!; |
| 311 | else |
| 312 | env->term_outcxx . . $ ENV#term_out. = GLP_ONcxx . . $ `external/glpk/glpk.h:221:9`!; |
| 313 | glp_scale_probcxx . . $ glp_scale_prob(e00ef8be97973834).(lp, GLP_SF_AUTOcxx . . $ `external/glpk/glpk.h:77:9`!); |
| 314 | env->term_outcxx . . $ ENV#term_out. = term_out; |
| 315 | } |
| 316 | /* build advanced initial basis */ |
| 317 | { ENVcxx . . $ ENV# *env = get_env_ptrcxx . . $ `external/glpk/glpenv.h:133:9`!(); |
| 318 | int term_out = env->term_outcxx . . $ ENV#term_out.; |
| 319 | if (!term_out || parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. < GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 320 | env->term_outcxx . . $ ENV#term_out. = GLP_OFFcxx . . $ `external/glpk/glpk.h:222:9`!; |
| 321 | else |
| 322 | env->term_outcxx . . $ ENV#term_out. = GLP_ONcxx . . $ `external/glpk/glpk.h:221:9`!; |
| 323 | glp_adv_basiscxx . . $ glp_adv_basis(e00ef8be97973834).(lp, 0); |
| 324 | env->term_outcxx . . $ ENV#term_out. = term_out; |
| 325 | } |
| 326 | /* solve the transformed LP */ |
| 327 | lp->it_cntcxx . . $ glp_prob#it_cnt. = P->it_cntcxx . . $ glp_prob#it_cnt.; |
| 328 | ret = solve_lpcxx . . $ solve_lp(115ca84ce6c1686e).(lp, parm); |
| 329 | P->it_cntcxx . . $ glp_prob#it_cnt. = lp->it_cntcxx . . $ glp_prob#it_cnt.; |
| 330 | /* only optimal solution can be postprocessed */ |
| 331 | if (!(ret == 0 && lp->pbs_statcxx . . $ glp_prob#pbs_stat. == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`! && lp->dbs_statcxx . . $ glp_prob#dbs_stat. == |
| 332 | GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`!)) |
| 333 | { if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 334 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("glp_simplex: unable to recover undefined or non-op" |
| 335 | "timal solution\n"); |
| 336 | if (ret == 0) |
| 337 | { if (lp->pbs_statcxx . . $ glp_prob#pbs_stat. == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!) |
| 338 | ret = GLP_ENOPFScxx . . $ `external/glpk/glpk.h:248:9`!; |
| 339 | else if (lp->dbs_statcxx . . $ glp_prob#dbs_stat. == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!) |
| 340 | ret = GLP_ENODFScxx . . $ `external/glpk/glpk.h:249:9`!; |
| 341 | else |
| 342 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(lp != lp); |
| 343 | } |
| 344 | goto done; |
| 345 | } |
| 346 | post: /* postprocess solution from the transformed LP */ |
| 347 | npp_postprocesscxx . . $ `external/glpk/glpnpp.h:347:9`!(npp, lp); |
| 348 | /* the transformed LP is no longer needed */ |
| 349 | glp_delete_probcxx . . $ glp_delete_prob(84c60d68cac39b9a).(lp), lp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 350 | /* store solution to the original problem */ |
| 351 | npp_unload_solcxx . . $ `external/glpk/glpnpp.h:351:9`!(npp, P); |
| 352 | /* the original LP has been successfully solved */ |
| 353 | ret = 0; |
| 354 | done: /* delete the transformed LP, if it exists */ |
| 355 | if (lp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) glp_delete_probcxx . . $ glp_delete_prob(84c60d68cac39b9a).(lp); |
| 356 | /* delete preprocessor workspace */ |
| 357 | npp_delete_wkspcxx . . $ `external/glpk/glpnpp.h:355:9`!(npp); |
| 358 | return ret; |
| 359 | } |
| 360 | |
| 361 | int glp_simplexcxx . . $ glp_simplex(115ca84ce6c1686e).(glp_probcxx . . $ glp_prob# *P, const glp_smcpcxx . . $ glp_smcp# *parm) |
| 362 | { /* solve LP problem with the simplex method */ |
| 363 | glp_smcpcxx . . $ glp_smcp# _parm; |
| 364 | int i, j, ret; |
| 365 | /* check problem object */ |
| 366 | if (P == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || P->magiccxx . . $ glp_prob#magic. != GLP_PROB_MAGICcxx . . $ `external/glpk/glpapi.h:39:9`!) |
| 367 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: P = %p; invalid problem object\n", P); |
| 368 | if (P->treecxx . . $ glp_prob#tree. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && P->treecxx . . $ glp_prob#tree.->reasoncxx . . $ glp_tree#reason. != 0) |
| 369 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: operation not allowed\n"); |
| 370 | /* check control parameters */ |
| 371 | if (parm == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 372 | parm = &_parm, glp_init_smcpcxx . . $ glp_init_smcp(719730d4b69ecbe).((glp_smcpcxx . . $ glp_smcp# *)parm); |
| 373 | if (!(parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. == GLP_MSG_OFFcxx . . $ `external/glpk/glpk.h:115:9`! || |
| 374 | parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. == GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`! || |
| 375 | parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. == GLP_MSG_ONcxx . . $ `external/glpk/glpk.h:117:9`! || |
| 376 | parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. == GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`! || |
| 377 | parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. == GLP_MSG_DBGcxx . . $ `external/glpk/glpk.h:119:9`!)) |
| 378 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: msg_lev = %d; invalid parameter\n", |
| 379 | parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev.); |
| 380 | if (!(parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`! || |
| 381 | parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_DUALPcxx . . $ `external/glpk/glpk.h:122:9`! || |
| 382 | parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. == GLP_DUALcxx . . $ `external/glpk/glpk.h:123:9`!)) |
| 383 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: meth = %d; invalid parameter\n", |
| 384 | parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth.); |
| 385 | if (!(parm->pricingcxx . . $ $anonymous_type_2d15b5456314bbc5_1#pricing. == GLP_PT_STDcxx . . $ `external/glpk/glpk.h:125:9`! || |
| 386 | parm->pricingcxx . . $ $anonymous_type_2d15b5456314bbc5_1#pricing. == GLP_PT_PSEcxx . . $ `external/glpk/glpk.h:126:9`!)) |
| 387 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: pricing = %d; invalid parameter\n", |
| 388 | parm->pricingcxx . . $ $anonymous_type_2d15b5456314bbc5_1#pricing.); |
| 389 | if (!(parm->r_testcxx . . $ $anonymous_type_2d15b5456314bbc5_1#r_test. == GLP_RT_STDcxx . . $ `external/glpk/glpk.h:128:9`! || |
| 390 | parm->r_testcxx . . $ $anonymous_type_2d15b5456314bbc5_1#r_test. == GLP_RT_HARcxx . . $ `external/glpk/glpk.h:129:9`!)) |
| 391 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: r_test = %d; invalid parameter\n", |
| 392 | parm->r_testcxx . . $ $anonymous_type_2d15b5456314bbc5_1#r_test.); |
| 393 | if (!(0.0 < parm->tol_bndcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_bnd. && parm->tol_bndcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_bnd. < 1.0)) |
| 394 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: tol_bnd = %g; invalid parameter\n", |
| 395 | parm->tol_bndcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_bnd.); |
| 396 | if (!(0.0 < parm->tol_djcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_dj. && parm->tol_djcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_dj. < 1.0)) |
| 397 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: tol_dj = %g; invalid parameter\n", |
| 398 | parm->tol_djcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_dj.); |
| 399 | if (!(0.0 < parm->tol_pivcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_piv. && parm->tol_pivcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_piv. < 1.0)) |
| 400 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: tol_piv = %g; invalid parameter\n", |
| 401 | parm->tol_pivcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_piv.); |
| 402 | if (parm->it_limcxx . . $ $anonymous_type_2d15b5456314bbc5_1#it_lim. < 0) |
| 403 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: it_lim = %d; invalid parameter\n", |
| 404 | parm->it_limcxx . . $ $anonymous_type_2d15b5456314bbc5_1#it_lim.); |
| 405 | if (parm->tm_limcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tm_lim. < 0) |
| 406 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: tm_lim = %d; invalid parameter\n", |
| 407 | parm->tm_limcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tm_lim.); |
| 408 | if (parm->out_frqcxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_frq. < 1) |
| 409 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: out_frq = %d; invalid parameter\n", |
| 410 | parm->out_frqcxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_frq.); |
| 411 | if (parm->out_dlycxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_dly. < 0) |
| 412 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: out_dly = %d; invalid parameter\n", |
| 413 | parm->out_dlycxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_dly.); |
| 414 | if (!(parm->presolvecxx . . $ $anonymous_type_2d15b5456314bbc5_1#presolve. == GLP_ONcxx . . $ `external/glpk/glpk.h:221:9`! || parm->presolvecxx . . $ $anonymous_type_2d15b5456314bbc5_1#presolve. == GLP_OFFcxx . . $ `external/glpk/glpk.h:222:9`!)) |
| 415 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_simplex: presolve = %d; invalid parameter\n", |
| 416 | parm->presolvecxx . . $ $anonymous_type_2d15b5456314bbc5_1#presolve.); |
| 417 | /* basic solution is currently undefined */ |
| 418 | P->pbs_statcxx . . $ glp_prob#pbs_stat. = P->dbs_statcxx . . $ glp_prob#dbs_stat. = GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`!; |
| 419 | P->obj_valcxx . . $ glp_prob#obj_val. = 0.0; |
| 420 | P->somecxx . . $ glp_prob#some. = 0; |
| 421 | /* check bounds of double-bounded variables */ |
| 422 | for (i = 1; i <= P->mcxx . . $ glp_prob#m.; i++) |
| 423 | { GLPROWcxx . . $ GLPROW# *row = P->rowcxx . . $ glp_prob#row.[i]; |
| 424 | if (row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! && row->lbcxx . . $ GLPROW#lb. >= row->ubcxx . . $ GLPROW#ub.) |
| 425 | { if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 426 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("glp_simplex: row %d: lb = %g, ub = %g; incorrec" |
| 427 | "t bounds\n", i, row->lbcxx . . $ GLPROW#lb., row->ubcxx . . $ GLPROW#ub.); |
| 428 | ret = GLP_EBOUNDcxx . . $ `external/glpk/glpk.h:242:9`!; |
| 429 | goto done; |
| 430 | } |
| 431 | } |
| 432 | for (j = 1; j <= P->ncxx . . $ glp_prob#n.; j++) |
| 433 | { GLPCOLcxx . . $ GLPCOL# *col = P->colcxx . . $ glp_prob#col.[j]; |
| 434 | if (col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! && col->lbcxx . . $ GLPCOL#lb. >= col->ubcxx . . $ GLPCOL#ub.) |
| 435 | { if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 436 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("glp_simplex: column %d: lb = %g, ub = %g; incor" |
| 437 | "rect bounds\n", j, col->lbcxx . . $ GLPCOL#lb., col->ubcxx . . $ GLPCOL#ub.); |
| 438 | ret = GLP_EBOUNDcxx . . $ `external/glpk/glpk.h:242:9`!; |
| 439 | goto done; |
| 440 | } |
| 441 | } |
| 442 | /* solve LP problem */ |
| 443 | if (parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 444 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("GLPK Simplex Optimizer, v%s\n", glp_versioncxx . . $ glp_version(33a1f659e94feb42).()); |
| 445 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d row%s, %d column%s, %d non-zero%s\n", |
| 446 | P->mcxx . . $ glp_prob#m., P->mcxx . . $ glp_prob#m. == 1 ? "" : "s", P->ncxx . . $ glp_prob#n., P->ncxx . . $ glp_prob#n. == 1 ? "" : "s", |
| 447 | P->nnzcxx . . $ glp_prob#nnz., P->nnzcxx . . $ glp_prob#nnz. == 1 ? "" : "s"); |
| 448 | } |
| 449 | if (P->nnzcxx . . $ glp_prob#nnz. == 0) |
| 450 | trivial_lpcxx . . $ trivial_lp(92f1dac111cd7bc1).(P, parm), ret = 0; |
| 451 | else if (!parm->presolvecxx . . $ $anonymous_type_2d15b5456314bbc5_1#presolve.) |
| 452 | ret = solve_lpcxx . . $ solve_lp(115ca84ce6c1686e).(P, parm); |
| 453 | else |
| 454 | ret = preprocess_and_solve_lpcxx . . $ preprocess_and_solve_lp(115ca84ce6c1686e).(P, parm); |
| 455 | done: /* return to the application program */ |
| 456 | return ret; |
| 457 | } |
| 458 | |
| 459 | /*********************************************************************** |
| 460 | * NAME |
| 461 | * |
| 462 | * glp_init_smcp - initialize simplex method control parameters |
| 463 | * |
| 464 | * SYNOPSIS |
| 465 | * |
| 466 | * void glp_init_smcp(glp_smcp *parm); |
| 467 | * |
| 468 | * DESCRIPTION |
| 469 | * |
| 470 | * The routine glp_init_smcp initializes control parameters, which are |
| 471 | * used by the simplex solver, with default values. |
| 472 | * |
| 473 | * Default values of the control parameters are stored in a glp_smcp |
| 474 | * structure, which the parameter parm points to. */ |
| 475 | |
| 476 | void glp_init_smcpcxx . . $ glp_init_smcp(719730d4b69ecbe).(glp_smcpcxx . . $ glp_smcp# *parm) |
| 477 | { parm->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. = GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!; |
| 478 | parm->methcxx . . $ $anonymous_type_2d15b5456314bbc5_1#meth. = GLP_PRIMALcxx . . $ `external/glpk/glpk.h:121:9`!; |
| 479 | parm->pricingcxx . . $ $anonymous_type_2d15b5456314bbc5_1#pricing. = GLP_PT_PSEcxx . . $ `external/glpk/glpk.h:126:9`!; |
| 480 | parm->r_testcxx . . $ $anonymous_type_2d15b5456314bbc5_1#r_test. = GLP_RT_HARcxx . . $ `external/glpk/glpk.h:129:9`!; |
| 481 | parm->tol_bndcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_bnd. = 1e-7; |
| 482 | parm->tol_djcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_dj. = 1e-7; |
| 483 | parm->tol_pivcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tol_piv. = 1e-10; |
| 484 | parm->obj_llcxx . . $ $anonymous_type_2d15b5456314bbc5_1#obj_ll. = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!; |
| 485 | parm->obj_ulcxx . . $ $anonymous_type_2d15b5456314bbc5_1#obj_ul. = +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!; |
| 486 | parm->it_limcxx . . $ $anonymous_type_2d15b5456314bbc5_1#it_lim. = INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!; |
| 487 | parm->tm_limcxx . . $ $anonymous_type_2d15b5456314bbc5_1#tm_lim. = INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!; |
| 488 | parm->out_frqcxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_frq. = 500; |
| 489 | parm->out_dlycxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_dly. = 0; |
| 490 | parm->presolvecxx . . $ $anonymous_type_2d15b5456314bbc5_1#presolve. = GLP_OFFcxx . . $ `external/glpk/glpk.h:222:9`!; |
| 491 | return; |
| 492 | } |
| 493 | |
| 494 | /*********************************************************************** |
| 495 | * NAME |
| 496 | * |
| 497 | * glp_get_status - retrieve generic status of basic solution |
| 498 | * |
| 499 | * SYNOPSIS |
| 500 | * |
| 501 | * int glp_get_status(glp_prob *lp); |
| 502 | * |
| 503 | * RETURNS |
| 504 | * |
| 505 | * The routine glp_get_status reports the generic status of the basic |
| 506 | * solution for the specified problem object as follows: |
| 507 | * |
| 508 | * GLP_OPT - solution is optimal; |
| 509 | * GLP_FEAS - solution is feasible; |
| 510 | * GLP_INFEAS - solution is infeasible; |
| 511 | * GLP_NOFEAS - problem has no feasible solution; |
| 512 | * GLP_UNBND - problem has unbounded solution; |
| 513 | * GLP_UNDEF - solution is undefined. */ |
| 514 | |
| 515 | int glp_get_statuscxx . . $ glp_get_status(317ecc1aeadfe2b7).(glp_probcxx . . $ glp_prob# *lp) |
| 516 | { int status; |
| 517 | status = glp_get_prim_statcxx . . $ glp_get_prim_stat(317ecc1aeadfe2b7).(lp); |
| 518 | switch (status) |
| 519 | { case GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`!: |
| 520 | switch (glp_get_dual_statcxx . . $ glp_get_dual_stat(317ecc1aeadfe2b7).(lp)) |
| 521 | { case GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`!: |
| 522 | status = GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`!; |
| 523 | break; |
| 524 | case GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!: |
| 525 | status = GLP_UNBNDcxx . . $ `external/glpk/glpk.h:90:9`!; |
| 526 | break; |
| 527 | case GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`!: |
| 528 | case GLP_INFEAScxx . . $ `external/glpk/glpk.h:87:9`!: |
| 529 | status = status; |
| 530 | break; |
| 531 | default: |
| 532 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(lp != lp); |
| 533 | } |
| 534 | break; |
| 535 | case GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`!: |
| 536 | case GLP_INFEAScxx . . $ `external/glpk/glpk.h:87:9`!: |
| 537 | case GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!: |
| 538 | status = status; |
| 539 | break; |
| 540 | default: |
| 541 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(lp != lp); |
| 542 | } |
| 543 | return status; |
| 544 | } |
| 545 | |
| 546 | /*********************************************************************** |
| 547 | * NAME |
| 548 | * |
| 549 | * glp_get_prim_stat - retrieve status of primal basic solution |
| 550 | * |
| 551 | * SYNOPSIS |
| 552 | * |
| 553 | * int glp_get_prim_stat(glp_prob *lp); |
| 554 | * |
| 555 | * RETURNS |
| 556 | * |
| 557 | * The routine glp_get_prim_stat reports the status of the primal basic |
| 558 | * solution for the specified problem object as follows: |
| 559 | * |
| 560 | * GLP_UNDEF - primal solution is undefined; |
| 561 | * GLP_FEAS - primal solution is feasible; |
| 562 | * GLP_INFEAS - primal solution is infeasible; |
| 563 | * GLP_NOFEAS - no primal feasible solution exists. */ |
| 564 | |
| 565 | int glp_get_prim_statcxx . . $ glp_get_prim_stat(317ecc1aeadfe2b7).(glp_probcxx . . $ glp_prob# *lp) |
| 566 | { int pbs_stat = lp->pbs_statcxx . . $ glp_prob#pbs_stat.; |
| 567 | return pbs_stat; |
| 568 | } |
| 569 | |
| 570 | /*********************************************************************** |
| 571 | * NAME |
| 572 | * |
| 573 | * glp_get_dual_stat - retrieve status of dual basic solution |
| 574 | * |
| 575 | * SYNOPSIS |
| 576 | * |
| 577 | * int glp_get_dual_stat(glp_prob *lp); |
| 578 | * |
| 579 | * RETURNS |
| 580 | * |
| 581 | * The routine glp_get_dual_stat reports the status of the dual basic |
| 582 | * solution for the specified problem object as follows: |
| 583 | * |
| 584 | * GLP_UNDEF - dual solution is undefined; |
| 585 | * GLP_FEAS - dual solution is feasible; |
| 586 | * GLP_INFEAS - dual solution is infeasible; |
| 587 | * GLP_NOFEAS - no dual feasible solution exists. */ |
| 588 | |
| 589 | int glp_get_dual_statcxx . . $ glp_get_dual_stat(317ecc1aeadfe2b7).(glp_probcxx . . $ glp_prob# *lp) |
| 590 | { int dbs_stat = lp->dbs_statcxx . . $ glp_prob#dbs_stat.; |
| 591 | return dbs_stat; |
| 592 | } |
| 593 | |
| 594 | /*********************************************************************** |
| 595 | * NAME |
| 596 | * |
| 597 | * glp_get_obj_val - retrieve objective value (basic solution) |
| 598 | * |
| 599 | * SYNOPSIS |
| 600 | * |
| 601 | * double glp_get_obj_val(glp_prob *lp); |
| 602 | * |
| 603 | * RETURNS |
| 604 | * |
| 605 | * The routine glp_get_obj_val returns value of the objective function |
| 606 | * for basic solution. */ |
| 607 | |
| 608 | double glp_get_obj_valcxx . . $ glp_get_obj_val(cf94942ae12487e5).(glp_probcxx . . $ glp_prob# *lp) |
| 609 | { /*struct LPXCPS *cps = lp->cps;*/ |
| 610 | double z; |
| 611 | z = lp->obj_valcxx . . $ glp_prob#obj_val.; |
| 612 | /*if (cps->round && fabs(z) < 1e-9) z = 0.0;*/ |
| 613 | return z; |
| 614 | } |
| 615 | |
| 616 | /*********************************************************************** |
| 617 | * NAME |
| 618 | * |
| 619 | * glp_get_row_stat - retrieve row status |
| 620 | * |
| 621 | * SYNOPSIS |
| 622 | * |
| 623 | * int glp_get_row_stat(glp_prob *lp, int i); |
| 624 | * |
| 625 | * RETURNS |
| 626 | * |
| 627 | * The routine glp_get_row_stat returns current status assigned to the |
| 628 | * auxiliary variable associated with i-th row as follows: |
| 629 | * |
| 630 | * GLP_BS - basic variable; |
| 631 | * GLP_NL - non-basic variable on its lower bound; |
| 632 | * GLP_NU - non-basic variable on its upper bound; |
| 633 | * GLP_NF - non-basic free (unbounded) variable; |
| 634 | * GLP_NS - non-basic fixed variable. */ |
| 635 | |
| 636 | int glp_get_row_statcxx . . $ glp_get_row_stat(423829e847ef1a83).(glp_probcxx . . $ glp_prob# *lp, int i) |
| 637 | { if (!(1 <= i && i <= lp->mcxx . . $ glp_prob#m.)) |
| 638 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_get_row_stat: i = %d; row number out of range\n", |
| 639 | i); |
| 640 | return lp->rowcxx . . $ glp_prob#row.[i]->statcxx . . $ GLPROW#stat.; |
| 641 | } |
| 642 | |
| 643 | /*********************************************************************** |
| 644 | * NAME |
| 645 | * |
| 646 | * glp_get_row_prim - retrieve row primal value (basic solution) |
| 647 | * |
| 648 | * SYNOPSIS |
| 649 | * |
| 650 | * double glp_get_row_prim(glp_prob *lp, int i); |
| 651 | * |
| 652 | * RETURNS |
| 653 | * |
| 654 | * The routine glp_get_row_prim returns primal value of the auxiliary |
| 655 | * variable associated with i-th row. */ |
| 656 | |
| 657 | double glp_get_row_primcxx . . $ glp_get_row_prim(68c5770eb0f32231).(glp_probcxx . . $ glp_prob# *lp, int i) |
| 658 | { /*struct LPXCPS *cps = lp->cps;*/ |
| 659 | double prim; |
| 660 | if (!(1 <= i && i <= lp->mcxx . . $ glp_prob#m.)) |
| 661 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_get_row_prim: i = %d; row number out of range\n", |
| 662 | i); |
| 663 | prim = lp->rowcxx . . $ glp_prob#row.[i]->primcxx . . $ GLPROW#prim.; |
| 664 | /*if (cps->round && fabs(prim) < 1e-9) prim = 0.0;*/ |
| 665 | return prim; |
| 666 | } |
| 667 | |
| 668 | /*********************************************************************** |
| 669 | * NAME |
| 670 | * |
| 671 | * glp_get_row_dual - retrieve row dual value (basic solution) |
| 672 | * |
| 673 | * SYNOPSIS |
| 674 | * |
| 675 | * double glp_get_row_dual(glp_prob *lp, int i); |
| 676 | * |
| 677 | * RETURNS |
| 678 | * |
| 679 | * The routine glp_get_row_dual returns dual value (i.e. reduced cost) |
| 680 | * of the auxiliary variable associated with i-th row. */ |
| 681 | |
| 682 | double glp_get_row_dualcxx . . $ glp_get_row_dual(68c5770eb0f32231).(glp_probcxx . . $ glp_prob# *lp, int i) |
| 683 | { /*struct LPXCPS *cps = lp->cps;*/ |
| 684 | double dual; |
| 685 | if (!(1 <= i && i <= lp->mcxx . . $ glp_prob#m.)) |
| 686 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_get_row_dual: i = %d; row number out of range\n", |
| 687 | i); |
| 688 | dual = lp->rowcxx . . $ glp_prob#row.[i]->dualcxx . . $ GLPROW#dual.; |
| 689 | /*if (cps->round && fabs(dual) < 1e-9) dual = 0.0;*/ |
| 690 | return dual; |
| 691 | } |
| 692 | |
| 693 | /*********************************************************************** |
| 694 | * NAME |
| 695 | * |
| 696 | * glp_get_col_stat - retrieve column status |
| 697 | * |
| 698 | * SYNOPSIS |
| 699 | * |
| 700 | * int glp_get_col_stat(glp_prob *lp, int j); |
| 701 | * |
| 702 | * RETURNS |
| 703 | * |
| 704 | * The routine glp_get_col_stat returns current status assigned to the |
| 705 | * structural variable associated with j-th column as follows: |
| 706 | * |
| 707 | * GLP_BS - basic variable; |
| 708 | * GLP_NL - non-basic variable on its lower bound; |
| 709 | * GLP_NU - non-basic variable on its upper bound; |
| 710 | * GLP_NF - non-basic free (unbounded) variable; |
| 711 | * GLP_NS - non-basic fixed variable. */ |
| 712 | |
| 713 | int glp_get_col_statcxx . . $ glp_get_col_stat(423829e847ef1a83).(glp_probcxx . . $ glp_prob# *lp, int j) |
| 714 | { if (!(1 <= j && j <= lp->ncxx . . $ glp_prob#n.)) |
| 715 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_get_col_stat: j = %d; column number out of range\n" |
| 716 | , j); |
| 717 | return lp->colcxx . . $ glp_prob#col.[j]->statcxx . . $ GLPCOL#stat.; |
| 718 | } |
| 719 | |
| 720 | /*********************************************************************** |
| 721 | * NAME |
| 722 | * |
| 723 | * glp_get_col_prim - retrieve column primal value (basic solution) |
| 724 | * |
| 725 | * SYNOPSIS |
| 726 | * |
| 727 | * double glp_get_col_prim(glp_prob *lp, int j); |
| 728 | * |
| 729 | * RETURNS |
| 730 | * |
| 731 | * The routine glp_get_col_prim returns primal value of the structural |
| 732 | * variable associated with j-th column. */ |
| 733 | |
| 734 | double glp_get_col_primcxx . . $ glp_get_col_prim(68c5770eb0f32231).(glp_probcxx . . $ glp_prob# *lp, int j) |
| 735 | { /*struct LPXCPS *cps = lp->cps;*/ |
| 736 | double prim; |
| 737 | if (!(1 <= j && j <= lp->ncxx . . $ glp_prob#n.)) |
| 738 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_get_col_prim: j = %d; column number out of range\n" |
| 739 | , j); |
| 740 | prim = lp->colcxx . . $ glp_prob#col.[j]->primcxx . . $ GLPCOL#prim.; |
| 741 | /*if (cps->round && fabs(prim) < 1e-9) prim = 0.0;*/ |
| 742 | return prim; |
| 743 | } |
| 744 | |
| 745 | /*********************************************************************** |
| 746 | * NAME |
| 747 | * |
| 748 | * glp_get_col_dual - retrieve column dual value (basic solution) |
| 749 | * |
| 750 | * SYNOPSIS |
| 751 | * |
| 752 | * double glp_get_col_dual(glp_prob *lp, int j); |
| 753 | * |
| 754 | * RETURNS |
| 755 | * |
| 756 | * The routine glp_get_col_dual returns dual value (i.e. reduced cost) |
| 757 | * of the structural variable associated with j-th column. */ |
| 758 | |
| 759 | double glp_get_col_dualcxx . . $ glp_get_col_dual(68c5770eb0f32231).(glp_probcxx . . $ glp_prob# *lp, int j) |
| 760 | { /*struct LPXCPS *cps = lp->cps;*/ |
| 761 | double dual; |
| 762 | if (!(1 <= j && j <= lp->ncxx . . $ glp_prob#n.)) |
| 763 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_get_col_dual: j = %d; column number out of range\n" |
| 764 | , j); |
| 765 | dual = lp->colcxx . . $ glp_prob#col.[j]->dualcxx . . $ GLPCOL#dual.; |
| 766 | /*if (cps->round && fabs(dual) < 1e-9) dual = 0.0;*/ |
| 767 | return dual; |
| 768 | } |
| 769 | |
| 770 | /*********************************************************************** |
| 771 | * NAME |
| 772 | * |
| 773 | * glp_get_unbnd_ray - determine variable causing unboundedness |
| 774 | * |
| 775 | * SYNOPSIS |
| 776 | * |
| 777 | * int glp_get_unbnd_ray(glp_prob *lp); |
| 778 | * |
| 779 | * RETURNS |
| 780 | * |
| 781 | * The routine glp_get_unbnd_ray returns the number k of a variable, |
| 782 | * which causes primal or dual unboundedness. If 1 <= k <= m, it is |
| 783 | * k-th auxiliary variable, and if m+1 <= k <= m+n, it is (k-m)-th |
| 784 | * structural variable, where m is the number of rows, n is the number |
| 785 | * of columns in the problem object. If such variable is not defined, |
| 786 | * the routine returns 0. |
| 787 | * |
| 788 | * COMMENTS |
| 789 | * |
| 790 | * If it is not exactly known which version of the simplex solver |
| 791 | * detected unboundedness, i.e. whether the unboundedness is primal or |
| 792 | * dual, it is sufficient to check the status of the variable reported |
| 793 | * with the routine glp_get_row_stat or glp_get_col_stat. If the |
| 794 | * variable is non-basic, the unboundedness is primal, otherwise, if |
| 795 | * the variable is basic, the unboundedness is dual (the latter case |
| 796 | * means that the problem has no primal feasible dolution). */ |
| 797 | |
| 798 | int glp_get_unbnd_raycxx . . $ glp_get_unbnd_ray(317ecc1aeadfe2b7).(glp_probcxx . . $ glp_prob# *lp) |
| 799 | { int k; |
| 800 | k = lp->somecxx . . $ glp_prob#some.; |
| 801 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(k >= 0); |
| 802 | if (k > lp->mcxx . . $ glp_prob#m. + lp->ncxx . . $ glp_prob#n.) k = 0; |
| 803 | return k; |
| 804 | } |
| 805 | |
| 806 | /* eof */ |