59 CostCurrent =
p->nWidthCur;
60 else if (
p->fMinApl )
61 CostCurrent =
p->nAplCur;
63 CostCurrent =
p->nNodesCur;
69 for ( c = 0; c <
p->nSupp; c++ )
74 for ( v = 0; v <
p->nSupp; v++ )
77 if ( !
p->pPlanes[v].fSifted )
81 if ( CostBest < p->pPlanes[v].statsNodes )
84 CostBest =
p->pPlanes[v].statsNodes;
90 assert( VarCurrent != -1 );
92 p->pPlanes[VarCurrent].fSifted = 1;
95 p->pVarCosts[VarCurrent] = CostCurrent;
98 CostBest = CostCurrent;
105 if ( VarCurrent < p->nSupp/2 )
108 p->pPlanes[0].statsCostAbove = 0;
109 for ( v = 1; v <= VarCurrent; v++ )
110 p->pPlanes[v].statsCostAbove =
p->pPlanes[v-1].statsCostAbove +
p->pPlanes[v-1].statsCost;
112 p->pPlanes[
p->nSupp].statsCostBelow = 0;
113 for ( v =
p->nSupp - 1; v >= VarCurrent; v-- )
114 p->pPlanes[v].statsCostBelow =
p->pPlanes[v+1].statsCostBelow +
p->pPlanes[v+1].statsCost;
116 assert( CostCurrent ==
p->pPlanes[VarCurrent].statsCostAbove +
117 p->pPlanes[VarCurrent].statsCost +
118 p->pPlanes[VarCurrent].statsCostBelow );
121 for ( q = VarCurrent-1; q >= 0; q-- )
125 p->pVarCosts[q] = CostCurrent;
127 p->pPlanes[q].statsCostBelow =
p->pPlanes[q+1].statsCostBelow +
p->pPlanes[q+1].statsCost;
129 if ( CostCurrent >= CostLimit )
135 if ( CostBest > CostCurrent )
137 CostBest = CostCurrent;
146 if (
p->fMinWidth ||
p->fMinApl )
148 if (
p->nNodesCur >= 2 *
p->nNodesMaxAlloc )
161 for ( ; q <
p->nSupp-1; )
167 printf(
"reoReorderSift(): Error! On the backward move, the costs are different.\n");
168 p->pVarCosts[q] = CostCurrent;
170 p->pPlanes[q].statsCostAbove =
p->pPlanes[q-1].statsCostAbove +
p->pPlanes[q-1].statsCost;
175 if ( CostCurrent >= CostLimit )
182 if ( CostBest >= CostCurrent )
184 CostBest = CostCurrent;
193 if (
p->fMinWidth ||
p->fMinApl )
195 if (
p->nNodesCur >= 2 *
p->nNodesMaxAlloc )
204 for ( ; q > BestQ; q-- )
210 printf(
"reoReorderSift(): Error! On the return move, the costs are different.\n" );
218 p->pPlanes[0].statsCostAbove = 0;
219 for ( v = 1; v <= VarCurrent; v++ )
220 p->pPlanes[v].statsCostAbove =
p->pPlanes[v-1].statsCostAbove +
p->pPlanes[v-1].statsCost;
222 p->pPlanes[
p->nSupp].statsCostBelow = 0;
223 for ( v =
p->nSupp - 1; v >= VarCurrent; v-- )
224 p->pPlanes[v].statsCostBelow =
p->pPlanes[v+1].statsCostBelow +
p->pPlanes[v+1].statsCost;
226 assert( CostCurrent ==
p->pPlanes[VarCurrent].statsCostAbove +
227 p->pPlanes[VarCurrent].statsCost +
228 p->pPlanes[VarCurrent].statsCostBelow );
231 for ( q = VarCurrent; q <
p->nSupp-1; )
235 p->pVarCosts[q] = CostCurrent;
237 p->pPlanes[q].statsCostAbove =
p->pPlanes[q-1].statsCostAbove +
p->pPlanes[q-1].statsCost;
239 if ( CostCurrent >= CostLimit )
245 if ( CostBest > CostCurrent )
247 CostBest = CostCurrent;
256 if (
p->fMinWidth ||
p->fMinApl )
258 if (
p->nNodesCur >= 2 *
p->nNodesMaxAlloc )
267 for ( --q; q >= 0; q-- )
273 printf(
"reoReorderSift(): Error! On the backward move, the costs are different.\n");
274 p->pVarCosts[q] = CostCurrent;
276 p->pPlanes[q].statsCostBelow =
p->pPlanes[q+1].statsCostBelow +
p->pPlanes[q+1].statsCost;
281 if ( CostCurrent >= CostLimit )
288 if ( CostBest >= CostCurrent )
290 CostBest = CostCurrent;
299 if (
p->fMinWidth ||
p->fMinApl )
301 if (
p->nNodesCur >= 2 *
p->nNodesMaxAlloc )
314 for ( ; q < BestQ; q++ )
320 printf(
"reoReorderSift(): Error! On the return move, the costs are different.\n" );
329 p->nWidthCur = (int)CostBest;
330 else if (
p->fMinApl )
331 p->nAplCur = CostCurrent;
333 p->nNodesCur = (int)CostBest;
337 for ( v = 0; v <
p->nSupp; v++ )
338 p->pPlanes[v].fSifted = 0;