| 1 | /* glpios10.c (feasibility pump heuristic) */cxx . . $ `<file>/external/glpk/glpios10.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 "glprng.h"cxx . . $ `<file>/external/glpk/glprng.h`/ |
| 27 | |
| 28 | /*********************************************************************** |
| 29 | * NAME |
| 30 | * |
| 31 | * ios_feas_pump - feasibility pump heuristic |
| 32 | * |
| 33 | * SYNOPSIS |
| 34 | * |
| 35 | * #include "glpios.h" |
| 36 | * void ios_feas_pump(glp_tree *T); |
| 37 | * |
| 38 | * DESCRIPTION |
| 39 | * |
| 40 | * The routine ios_feas_pump is a simple implementation of the Feasi- |
| 41 | * bility Pump heuristic. |
| 42 | * |
| 43 | * REFERENCES |
| 44 | * |
| 45 | * M.Fischetti, F.Glover, and A.Lodi. "The feasibility pump." Math. |
| 46 | * Program., Ser. A 104, pp. 91-104 (2005). */ |
| 47 | |
| 48 | struct VARcxx . . $ VAR# |
| 49 | { /* binary variable */ |
| 50 | int jcxx . . $ VAR#j.; |
| 51 | /* ordinal number */ |
| 52 | int xcxx . . $ VAR#x.; |
| 53 | /* value in the rounded solution (0 or 1) */ |
| 54 | double dcxx . . $ VAR#d.; |
| 55 | /* sorting key */ |
| 56 | }; |
| 57 | |
| 58 | static int fcmpcxx . . $ fcmp(9148c8c3ff42c9d8).(const void *x, const void *y) |
| 59 | { /* comparison routine */ |
| 60 | const struct VARcxx . . $ VAR# *vx = x, *vy = y; |
| 61 | if (vx->dcxx . . $ VAR#d. > vy->dcxx . . $ VAR#d.) |
| 62 | return -1; |
| 63 | else if (vx->dcxx . . $ VAR#d. < vy->dcxx . . $ VAR#d.) |
| 64 | return +1; |
| 65 | else |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | void ios_feas_pumpcxx . . $ `external/glpk/glpios.h:575:9`!(glp_treecxx . . $ glp_tree# *T) |
| 70 | { glp_probcxx . . $ glp_prob# *P = T->mipcxx . . $ glp_tree#mip.; |
| 71 | int n = P->ncxx . . $ glp_prob#n.; |
| 72 | glp_probcxx . . $ glp_prob# *lp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 73 | struct VARcxx . . $ VAR# *var = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 74 | RNGcxx . . $ RNG# *rand = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 75 | GLPCOLcxx . . $ GLPCOL# *col; |
| 76 | glp_smcpcxx . . $ glp_smcp# parm; |
| 77 | int j, k, new_x, nfail, npass, nv, ret, stalling; |
| 78 | double dist, tol; |
| 79 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(glp_get_status(P) == GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`!); |
| 80 | /* this heuristic is applied only once on the root level */ |
| 81 | if (!(T->currcxx . . $ glp_tree#curr.->levelcxx . . $ IOSNPD#level. == 0 && T->currcxx . . $ glp_tree#curr.->solvedcxx . . $ IOSNPD#solved. == 1)) goto done; |
| 82 | /* determine number of binary variables */ |
| 83 | nv = 0; |
| 84 | for (j = 1; j <= n; j++) |
| 85 | { col = P->colcxx . . $ glp_prob#col.[j]; |
| 86 | /* if x[j] is continuous, skip it */ |
| 87 | if (col->kindcxx . . $ GLPCOL#kind. == GLP_CVcxx . . $ `external/glpk/glpk.h:54:9`!) continue; |
| 88 | /* if x[j] is fixed, skip it */ |
| 89 | if (col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!) continue; |
| 90 | /* x[j] is non-fixed integer */ |
| 91 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(col->kind == GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`!); |
| 92 | if (col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! && col->lbcxx . . $ GLPCOL#lb. == 0.0 && col->ubcxx . . $ GLPCOL#ub. == 1.0) |
| 93 | { /* x[j] is binary */ |
| 94 | nv++; |
| 95 | } |
| 96 | else |
| 97 | { /* x[j] is general integer */ |
| 98 | if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 99 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("FPUMP heuristic cannot be applied due to genera" |
| 100 | "l integer variables\n"); |
| 101 | goto done; |
| 102 | } |
| 103 | } |
| 104 | /* there must be at least one binary variable */ |
| 105 | if (nv == 0) goto done; |
| 106 | if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 107 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Applying FPUMP heuristic...\n"); |
| 108 | /* build the list of binary variables */ |
| 109 | var = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+nv, sizeof(struct VARcxx . . $ VAR#)); |
| 110 | k = 0; |
| 111 | for (j = 1; j <= n; j++) |
| 112 | { col = P->colcxx . . $ glp_prob#col.[j]; |
| 113 | if (col->kindcxx . . $ GLPCOL#kind. == GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`! && col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!) |
| 114 | var[++k].jcxx . . $ VAR#j. = j; |
| 115 | } |
| 116 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(k == nv); |
| 117 | /* create working problem object */ |
| 118 | lp = glp_create_probcxx . . $ glp_create_prob(7c2d8bedb6abbdaf).(); |
| 119 | more: /* copy the original problem object to keep it intact */ |
| 120 | glp_copy_probcxx . . $ glp_copy_prob(8739005a9a0f7ee6).(lp, P, GLP_OFFcxx . . $ `external/glpk/glpk.h:222:9`!); |
| 121 | /* we are interested to find an integer feasible solution, which |
| 122 | is better than the best known one */ |
| 123 | if (P->mip_statcxx . . $ glp_prob#mip_stat. == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`!) |
| 124 | { int *ind; |
| 125 | double *val, bnd; |
| 126 | /* add a row and make it identical to the objective row */ |
| 127 | glp_add_rowscxx . . $ glp_add_rows(423829e847ef1a83).(lp, 1); |
| 128 | ind = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(int)); |
| 129 | val = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(double)); |
| 130 | for (j = 1; j <= n; j++) |
| 131 | { ind[j] = j; |
| 132 | val[j] = P->colcxx . . $ glp_prob#col.[j]->coefcxx . . $ GLPCOL#coef.; |
| 133 | } |
| 134 | glp_set_mat_rowcxx . . $ glp_set_mat_row(9cc64c3737aa01c2).(lp, lp->mcxx . . $ glp_prob#m., n, ind, val); |
| 135 | xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(ind); |
| 136 | xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(val); |
| 137 | /* introduce upper (minimization) or lower (maximization) |
| 138 | bound to the original objective function; note that this |
| 139 | additional constraint is not violated at the optimal point |
| 140 | to LP relaxation */ |
| 141 | #if 0 /* modified by xypron <[email protected]> */ |
| 142 | if (P->dir == GLP_MIN) |
| 143 | { bnd = P->mip_obj - 0.10 * (1.0 + fabs(P->mip_obj)); |
| 144 | if (bnd < P->obj_val) bnd = P->obj_val; |
| 145 | glp_set_row_bnds(lp, lp->m, GLP_UP, 0.0, bnd - P->c0); |
| 146 | } |
| 147 | else if (P->dir == GLP_MAX) |
| 148 | { bnd = P->mip_obj + 0.10 * (1.0 + fabs(P->mip_obj)); |
| 149 | if (bnd > P->obj_val) bnd = P->obj_val; |
| 150 | glp_set_row_bnds(lp, lp->m, GLP_LO, bnd - P->c0, 0.0); |
| 151 | } |
| 152 | else |
| 153 | xassert(P != P); |
| 154 | #else |
| 155 | bnd = 0.1 * P->obj_valcxx . . $ glp_prob#obj_val. + 0.9 * P->mip_objcxx . . $ glp_prob#mip_obj.; |
| 156 | /* xprintf("bnd = %f\n", bnd); */ |
| 157 | if (P->dircxx . . $ glp_prob#dir. == GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`!) |
| 158 | glp_set_row_bndscxx . . $ glp_set_row_bnds(9376c6e48e598b7a).(lp, lp->mcxx . . $ glp_prob#m., GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`!, 0.0, bnd - P->c0cxx . . $ glp_prob#c0.); |
| 159 | else if (P->dircxx . . $ glp_prob#dir. == GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`!) |
| 160 | glp_set_row_bndscxx . . $ glp_set_row_bnds(9376c6e48e598b7a).(lp, lp->mcxx . . $ glp_prob#m., GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!, bnd - P->c0cxx . . $ glp_prob#c0., 0.0); |
| 161 | else |
| 162 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(P != P); |
| 163 | #endif |
| 164 | } |
| 165 | /* reset pass count */ |
| 166 | npass = 0; |
| 167 | /* invalidate the rounded point */ |
| 168 | for (k = 1; k <= nv; k++) |
| 169 | var[k].xcxx . . $ VAR#x. = -1; |
| 170 | pass: /* next pass starts here */ |
| 171 | npass++; |
| 172 | if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. >= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 173 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Pass %d\n", npass); |
| 174 | /* initialize minimal distance between the basic point and the |
| 175 | rounded one obtained during this pass */ |
| 176 | dist = DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!; |
| 177 | /* reset failure count (the number of succeeded iterations failed |
| 178 | to improve the distance) */ |
| 179 | nfail = 0; |
| 180 | /* if it is not the first pass, perturb the last rounded point |
| 181 | rather than construct it from the basic solution */ |
| 182 | if (npass > 1) |
| 183 | { double rho, temp; |
| 184 | if (rand == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 185 | rand = rng_create_randcxx . . $ `external/glpk/glprng.h:38:9`!(); |
| 186 | for (k = 1; k <= nv; k++) |
| 187 | { j = var[k].jcxx . . $ VAR#j.; |
| 188 | col = lp->colcxx . . $ glp_prob#col.[j]; |
| 189 | rho = rng_uniformcxx . . $ `external/glpk/glprng.h:62:9`!(rand, -0.3, 0.7); |
| 190 | if (rho < 0.0) rho = 0.0; |
| 191 | temp = fabscxx . . $ fabs(447c67c6676f75c3).((double)var[k].xcxx . . $ VAR#x. - col->primcxx . . $ GLPCOL#prim.); |
| 192 | if (temp + rho > 0.5) var[k].xcxx . . $ VAR#x. = 1 - var[k].xcxx . . $ VAR#x.; |
| 193 | } |
| 194 | goto skip; |
| 195 | } |
| 196 | loop: /* innermost loop begins here */ |
| 197 | /* round basic solution (which is assumed primal feasible) */ |
| 198 | stalling = 1; |
| 199 | for (k = 1; k <= nv; k++) |
| 200 | { col = lp->colcxx . . $ glp_prob#col.[var[k].jcxx . . $ VAR#j.]; |
| 201 | if (col->primcxx . . $ GLPCOL#prim. < 0.5) |
| 202 | { /* rounded value is 0 */ |
| 203 | new_x = 0; |
| 204 | } |
| 205 | else |
| 206 | { /* rounded value is 1 */ |
| 207 | new_x = 1; |
| 208 | } |
| 209 | if (var[k].xcxx . . $ VAR#x. != new_x) |
| 210 | { stalling = 0; |
| 211 | var[k].xcxx . . $ VAR#x. = new_x; |
| 212 | } |
| 213 | } |
| 214 | /* if the rounded point has not changed (stalling), choose and |
| 215 | flip some its entries heuristically */ |
| 216 | if (stalling) |
| 217 | { /* compute d[j] = |x[j] - round(x[j])| */ |
| 218 | for (k = 1; k <= nv; k++) |
| 219 | { col = lp->colcxx . . $ glp_prob#col.[var[k].jcxx . . $ VAR#j.]; |
| 220 | var[k].dcxx . . $ VAR#d. = fabscxx . . $ fabs(447c67c6676f75c3).(col->primcxx . . $ GLPCOL#prim. - (double)var[k].xcxx . . $ VAR#x.); |
| 221 | } |
| 222 | /* sort the list of binary variables by descending d[j] */ |
| 223 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(&var[1], nv, sizeof(struct VARcxx . . $ VAR#), fcmpcxx . . $ fcmp(9148c8c3ff42c9d8).); |
| 224 | /* choose and flip some rounded components */ |
| 225 | for (k = 1; k <= nv; k++) |
| 226 | { if (k >= 5 && var[k].dcxx . . $ VAR#d. < 0.35 || k >= 10) break; |
| 227 | var[k].xcxx . . $ VAR#x. = 1 - var[k].xcxx . . $ VAR#x.; |
| 228 | } |
| 229 | } |
| 230 | skip: /* check if the time limit has been exhausted */ |
| 231 | if (T->parmcxx . . $ glp_tree#parm.->tm_limcxx . . $ $anonymous_type_2d15b5456314bbc5_3#tm_lim. < INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`! && |
| 232 | (double)(T->parmcxx . . $ glp_tree#parm.->tm_limcxx . . $ $anonymous_type_2d15b5456314bbc5_3#tm_lim. - 1) <= |
| 233 | 1000.0 * xdifftimecxx . . $ `external/glpk/glpenv.h:183:9`!(xtimecxx . . $ `external/glpk/glpenv.h:179:9`!(), T->tm_begcxx . . $ glp_tree#tm_beg.)) goto done; |
| 234 | /* build the objective, which is the distance between the current |
| 235 | (basic) point and the rounded one */ |
| 236 | lp->dircxx . . $ glp_prob#dir. = GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`!; |
| 237 | lp->c0cxx . . $ glp_prob#c0. = 0.0; |
| 238 | for (j = 1; j <= n; j++) |
| 239 | lp->colcxx . . $ glp_prob#col.[j]->coefcxx . . $ GLPCOL#coef. = 0.0; |
| 240 | for (k = 1; k <= nv; k++) |
| 241 | { j = var[k].jcxx . . $ VAR#j.; |
| 242 | if (var[k].xcxx . . $ VAR#x. == 0) |
| 243 | lp->colcxx . . $ glp_prob#col.[j]->coefcxx . . $ GLPCOL#coef. = +1.0; |
| 244 | else |
| 245 | { lp->colcxx . . $ glp_prob#col.[j]->coefcxx . . $ GLPCOL#coef. = -1.0; |
| 246 | lp->c0cxx . . $ glp_prob#c0. += 1.0; |
| 247 | } |
| 248 | } |
| 249 | /* minimize the distance with the simplex method */ |
| 250 | glp_init_smcpcxx . . $ glp_init_smcp(719730d4b69ecbe).(&parm); |
| 251 | if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. <= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 252 | parm.msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. = T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev.; |
| 253 | else if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. <= GLP_MSG_ALLcxx . . $ `external/glpk/glpk.h:118:9`!) |
| 254 | { parm.msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_1#msg_lev. = GLP_MSG_ONcxx . . $ `external/glpk/glpk.h:117:9`!; |
| 255 | parm.out_dlycxx . . $ $anonymous_type_2d15b5456314bbc5_1#out_dly. = 10000; |
| 256 | } |
| 257 | ret = glp_simplexcxx . . $ glp_simplex(115ca84ce6c1686e).(lp, &parm); |
| 258 | if (ret != 0) |
| 259 | { if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 260 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Warning: glp_simplex returned %d\n", ret); |
| 261 | goto done; |
| 262 | } |
| 263 | ret = glp_get_statuscxx . . $ glp_get_status(317ecc1aeadfe2b7).(lp); |
| 264 | if (ret != GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`!) |
| 265 | { if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 266 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Warning: glp_get_status returned %d\n", ret); |
| 267 | goto done; |
| 268 | } |
| 269 | if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. >= GLP_MSG_DBGcxx . . $ `external/glpk/glpk.h:119:9`!) |
| 270 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("delta = %g\n", lp->obj_valcxx . . $ glp_prob#obj_val.); |
| 271 | /* check if the basic solution is integer feasible; note that it |
| 272 | may be so even if the minimial distance is positive */ |
| 273 | tol = 0.3 * T->parmcxx . . $ glp_tree#parm.->tol_intcxx . . $ $anonymous_type_2d15b5456314bbc5_3#tol_int.; |
| 274 | for (k = 1; k <= nv; k++) |
| 275 | { col = lp->colcxx . . $ glp_prob#col.[var[k].jcxx . . $ VAR#j.]; |
| 276 | if (tol < col->primcxx . . $ GLPCOL#prim. && col->primcxx . . $ GLPCOL#prim. < 1.0 - tol) break; |
| 277 | } |
| 278 | if (k > nv) |
| 279 | { /* okay; the basic solution seems to be integer feasible */ |
| 280 | double *x = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(double)); |
| 281 | for (j = 1; j <= n; j++) |
| 282 | { x[j] = lp->colcxx . . $ glp_prob#col.[j]->primcxx . . $ GLPCOL#prim.; |
| 283 | if (P->colcxx . . $ glp_prob#col.[j]->kindcxx . . $ GLPCOL#kind. == GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`!) x[j] = floorcxx . . $ floor(447c67c6676f75c3).(x[j] + 0.5); |
| 284 | } |
| 285 | #if 1 /* modified by xypron <[email protected]> */ |
| 286 | /* reset direction and right-hand side of objective */ |
| 287 | lp->c0cxx . . $ glp_prob#c0. = P->c0cxx . . $ glp_prob#c0.; |
| 288 | lp->dircxx . . $ glp_prob#dir. = P->dircxx . . $ glp_prob#dir.; |
| 289 | /* fix integer variables */ |
| 290 | for (k = 1; k <= nv; k++) |
| 291 | { lp->colcxx . . $ glp_prob#col.[var[k].jcxx . . $ VAR#j.]->lbcxx . . $ GLPCOL#lb. = x[var[k].jcxx . . $ VAR#j.]; |
| 292 | lp->colcxx . . $ glp_prob#col.[var[k].jcxx . . $ VAR#j.]->ubcxx . . $ GLPCOL#ub. = x[var[k].jcxx . . $ VAR#j.]; |
| 293 | lp->colcxx . . $ glp_prob#col.[var[k].jcxx . . $ VAR#j.]->typecxx . . $ GLPCOL#type. = GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!; |
| 294 | } |
| 295 | /* copy original objective function */ |
| 296 | for (j = 1; j <= n; j++) |
| 297 | lp->colcxx . . $ glp_prob#col.[j]->coefcxx . . $ GLPCOL#coef. = P->colcxx . . $ glp_prob#col.[j]->coefcxx . . $ GLPCOL#coef.; |
| 298 | /* solve original LP and copy result */ |
| 299 | ret = glp_simplexcxx . . $ glp_simplex(115ca84ce6c1686e).(lp, &parm); |
| 300 | if (ret != 0) |
| 301 | { if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 302 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Warning: glp_simplex returned %d\n", ret); |
| 303 | goto done; |
| 304 | } |
| 305 | ret = glp_get_statuscxx . . $ glp_get_status(317ecc1aeadfe2b7).(lp); |
| 306 | if (ret != GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`!) |
| 307 | { if (T->parmcxx . . $ glp_tree#parm.->msg_levcxx . . $ $anonymous_type_2d15b5456314bbc5_3#msg_lev. >= GLP_MSG_ERRcxx . . $ `external/glpk/glpk.h:116:9`!) |
| 308 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Warning: glp_get_status returned %d\n", ret); |
| 309 | goto done; |
| 310 | } |
| 311 | for (j = 1; j <= n; j++) |
| 312 | if (P->colcxx . . $ glp_prob#col.[j]->kindcxx . . $ GLPCOL#kind. != GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`!) x[j] = lp->colcxx . . $ glp_prob#col.[j]->primcxx . . $ GLPCOL#prim.; |
| 313 | #endif |
| 314 | ret = glp_ios_heur_solcxx . . $ glp_ios_heur_sol(a66a421d2fc7be38).(T, x); |
| 315 | xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(x); |
| 316 | if (ret == 0) |
| 317 | { /* the integer solution is accepted */ |
| 318 | if (ios_is_hopefulcxx . . $ `external/glpk/glpios.h:419:9`!(T, T->currcxx . . $ glp_tree#curr.->boundcxx . . $ IOSNPD#bound.)) |
| 319 | { /* it is reasonable to apply the heuristic once again */ |
| 320 | goto more; |
| 321 | } |
| 322 | else |
| 323 | { /* the best known integer feasible solution just found |
| 324 | is close to optimal solution to LP relaxation */ |
| 325 | goto done; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | /* the basic solution is fractional */ |
| 330 | if (dist == DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`! || |
| 331 | lp->obj_valcxx . . $ glp_prob#obj_val. <= dist - 1e-6 * (1.0 + dist)) |
| 332 | { /* the distance is reducing */ |
| 333 | nfail = 0, dist = lp->obj_valcxx . . $ glp_prob#obj_val.; |
| 334 | } |
| 335 | else |
| 336 | { /* improving the distance failed */ |
| 337 | nfail++; |
| 338 | } |
| 339 | if (nfail < 3) goto loop; |
| 340 | if (npass < 5) goto pass; |
| 341 | done: /* delete working objects */ |
| 342 | if (lp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) glp_delete_probcxx . . $ glp_delete_prob(84c60d68cac39b9a).(lp); |
| 343 | if (var != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(var); |
| 344 | if (rand != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) rng_delete_randcxx . . $ `external/glpk/glprng.h:54:9`!(rand); |
| 345 | return; |
| 346 | } |
| 347 | |
| 348 | /* eof */ |