Debian Codegraph @

external/glpk/glpios12.c

raw symbols SCIP
1 /* glpios12.c (node selection heuristics) */cxx . . $ `<file>/external/glpk/glpios12.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
27 /***********************************************************************
28 * NAME
29 *
30 * ios_choose_node - select subproblem to continue the search
31 *
32 * SYNOPSIS
33 *
34 * #include "glpios.h"
35 * int ios_choose_node(glp_tree *T);
36 *
37 * DESCRIPTION
38 *
39 * The routine ios_choose_node selects a subproblem from the active
40 * list to continue the search. The choice depends on the backtracking
41 * technique option.
42 *
43 * RETURNS
44 *
45 * The routine ios_choose_node return the reference number of the
46 * subproblem selected. */
47
48 static int most_feascxx . . $ most_feas(7a4b2b7bad94f670).(glp_treecxx . . $ glp_tree# *T);
49 static int best_projcxx . . $ best_proj(7a4b2b7bad94f670).(glp_treecxx . . $ glp_tree# *T);
50 static int best_nodecxx . . $ best_node(7a4b2b7bad94f670).(glp_treecxx . . $ glp_tree# *T);
51
52 int ios_choose_nodecxx . . $ `external/glpk/glpios.h:583:9`!(glp_treecxx . . $ glp_tree# *T)
53 { int p;
54 if (T->parmcxx . . $ glp_tree#parm.->bt_techcxx . . $ $anonymous_type_2d15b5456314bbc5_3#bt_tech. == GLP_BT_DFScxx . . $ `external/glpk/glpk.h:170:9`!)
55 { /* depth first search */
56 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(T->tail != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
57 p = T->tailcxx . . $ glp_tree#tail.->pcxx . . $ IOSNPD#p.;
58 }
59 else if (T->parmcxx . . $ glp_tree#parm.->bt_techcxx . . $ $anonymous_type_2d15b5456314bbc5_3#bt_tech. == GLP_BT_BFScxx . . $ `external/glpk/glpk.h:171:9`!)
60 { /* breadth first search */
61 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(T->head != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
62 p = T->headcxx . . $ glp_tree#head.->pcxx . . $ IOSNPD#p.;
63 }
64 else if (T->parmcxx . . $ glp_tree#parm.->bt_techcxx . . $ $anonymous_type_2d15b5456314bbc5_3#bt_tech. == GLP_BT_BLBcxx . . $ `external/glpk/glpk.h:172:9`!)
65 { /* select node with best local bound */
66 p = best_nodecxx . . $ best_node(7a4b2b7bad94f670).(T);
67 }
68 else if (T->parmcxx . . $ glp_tree#parm.->bt_techcxx . . $ $anonymous_type_2d15b5456314bbc5_3#bt_tech. == GLP_BT_BPHcxx . . $ `external/glpk/glpk.h:173:9`!)
69 { if (T->mipcxx . . $ glp_tree#mip.->mip_statcxx . . $ glp_prob#mip_stat. == GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`!)
70 { /* "most integer feasible" subproblem */
71 p = most_feascxx . . $ most_feas(7a4b2b7bad94f670).(T);
72 }
73 else
74 { /* best projection heuristic */
75 p = best_projcxx . . $ best_proj(7a4b2b7bad94f670).(T);
76 }
77 }
78 else
79 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(T != T);
80 return p;
81 }
82
83 static int most_feascxx . . $ most_feas(7a4b2b7bad94f670).(glp_treecxx . . $ glp_tree# *T)
84 { /* select subproblem whose parent has minimal sum of integer
85 infeasibilities */
86 IOSNPDcxx . . $ IOSNPD# *node;
87 int p;
88 double best;
89 p = 0, best = DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
90 for (node = T->headcxx . . $ glp_tree#head.; node != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; node = node->nextcxx . . $ IOSNPD#next.)
91 { xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(node->up != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
92 if (best > node->upcxx . . $ IOSNPD#up.->ii_sumcxx . . $ IOSNPD#ii_sum.)
93 p = node->pcxx . . $ IOSNPD#p., best = node->upcxx . . $ IOSNPD#up.->ii_sumcxx . . $ IOSNPD#ii_sum.;
94 }
95 return p;
96 }
97
98 static int best_projcxx . . $ best_proj(7a4b2b7bad94f670).(glp_treecxx . . $ glp_tree# *T)
99 { /* select subproblem using the best projection heuristic */
100 IOSNPDcxx . . $ IOSNPD# *root, *node;
101 int p;
102 double best, deg, obj;
103 /* the global bound must exist */
104 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(T->mip->mip_stat == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`!);
105 /* obtain pointer to the root node, which must exist */
106 root = T->slotcxx . . $ glp_tree#slot.[1].nodecxx . . $ IOSLOT#node.;
107 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(root != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
108 /* deg estimates degradation of the objective function per unit
109 of the sum of integer infeasibilities */
110 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(root->ii_sum > 0.0);
111 deg = (T->mipcxx . . $ glp_tree#mip.->mip_objcxx . . $ glp_prob#mip_obj. - root->boundcxx . . $ IOSNPD#bound.) / root->ii_sumcxx . . $ IOSNPD#ii_sum.;
112 /* nothing has been selected so far */
113 p = 0, best = DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
114 /* walk through the list of active subproblems */
115 for (node = T->headcxx . . $ glp_tree#head.; node != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; node = node->nextcxx . . $ IOSNPD#next.)
116 { xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(node->up != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
117 /* obj estimates optimal objective value if the sum of integer
118 infeasibilities were zero */
119 obj = node->upcxx . . $ IOSNPD#up.->boundcxx . . $ IOSNPD#bound. + deg * node->upcxx . . $ IOSNPD#up.->ii_sumcxx . . $ IOSNPD#ii_sum.;
120 if (T->mipcxx . . $ glp_tree#mip.->dircxx . . $ glp_prob#dir. == GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`!) obj = - obj;
121 /* select the subproblem which has the best estimated optimal
122 objective value */
123 if (best > obj) p = node->pcxx . . $ IOSNPD#p., best = obj;
124 }
125 return p;
126 }
127
128 static int best_nodecxx . . $ best_node(7a4b2b7bad94f670).(glp_treecxx . . $ glp_tree# *T)
129 { /* select subproblem with best local bound */
130 IOSNPDcxx . . $ IOSNPD# *node, *best = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
131 double bound, eps;
132 switch (T->mipcxx . . $ glp_tree#mip.->dircxx . . $ glp_prob#dir.)
133 { case GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`!:
134 bound = +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
135 for (node = T->headcxx . . $ glp_tree#head.; node != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; node = node->nextcxx . . $ IOSNPD#next.)
136 if (bound > node->boundcxx . . $ IOSNPD#bound.) bound = node->boundcxx . . $ IOSNPD#bound.;
137 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(bound != +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!);
138 eps = 0.001 * (1.0 + fabs(bound));
139 for (node = T->headcxx . . $ glp_tree#head.; node != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; node = node->nextcxx . . $ IOSNPD#next.)
140 { if (node->boundcxx . . $ IOSNPD#bound. <= bound + eps)
141 { xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(node->up != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
142 if (best == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ||
143 #if 1
144 best->upcxx . . $ IOSNPD#up.->ii_sumcxx . . $ IOSNPD#ii_sum. > node->upcxx . . $ IOSNPD#up.->ii_sumcxx . . $ IOSNPD#ii_sum.) best = node;
145 #else
146 best->lp_obj > node->lp_obj) best = node;
147 #endif
148 }
149 }
150 break;
151 case GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`!:
152 bound = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
153 for (node = T->headcxx . . $ glp_tree#head.; node != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; node = node->nextcxx . . $ IOSNPD#next.)
154 if (bound < node->boundcxx . . $ IOSNPD#bound.) bound = node->boundcxx . . $ IOSNPD#bound.;
155 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(bound != -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!);
156 eps = 0.001 * (1.0 + fabs(bound));
157 for (node = T->headcxx . . $ glp_tree#head.; node != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; node = node->nextcxx . . $ IOSNPD#next.)
158 { if (node->boundcxx . . $ IOSNPD#bound. >= bound - eps)
159 { xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(node->up != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
160 if (best == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ||
161 #if 1
162 best->upcxx . . $ IOSNPD#up.->ii_sumcxx . . $ IOSNPD#ii_sum. > node->upcxx . . $ IOSNPD#up.->ii_sumcxx . . $ IOSNPD#ii_sum.) best = node;
163 #else
164 best->lp_obj < node->lp_obj) best = node;
165 #endif
166 }
167 }
168 break;
169 default:
170 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(T != T);
171 }
172 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(best != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
173 return best->pcxx . . $ IOSNPD#p.;
174 }
175
176 /* eof */