180 {
181
182
185
187
188
189 for( unsigned int whichIndex( 0 );
191 ++whichIndex )
192 {
193 positiveWeight = (*weightGetter)( vectorToBeSorted[ whichIndex ] );
195 {
197 }
199 {
203 }
204 }
205
206 double const halfTotalWeight( 0.5 *
weightSum );
208
209 {
210
213 }
214 else
215 {
217
218
219
221
222
223 {
224
230 }
232
233
234 {
235
236
237
243 }
244 else
245
246
247
248
249
250 {
251
252
260
261
262
263
264
265
266
267
269 ++listIterator;
270
272
273
277
279
280
282 = (
orderedList.front().second + listIterator->second );
283
284
285
288
290
291
292 {
293
296
298 }
299
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317 ++listIterator;
319
320 {
324 ++candidateIterator )
325 {
326 if( ( 2 * ( (*candidateIterator)->getVector().size() + 1 ) )
328
329
330 {
332 + listIterator->second );
333
335
336
337
338
339
340
341 {
343
344
345
346
347
348 {
349
352
355
357 listIterator->first,
360 }
361
362
363
364
365
366 candidateIterator
368 }
369 else
370
371
372
373
374 {
376
377 {
378
381
384
386 listIterator->first,
389
390 if( ( 2 * ( (*candidateIterator)->getVector().size() + 2 ) )
392
393
394 {
396 }
397 }
398 else if( ( 2 * ( (*candidateIterator)->getVector().size()
399 + 2 ) )
401
402
403
404
405 {
406
410
412 listIterator->first,
414
416 }
417 }
418
419
420
421
422 }
423
424 }
425
426
427
430
431
432
433
434
436 while( listIterator != lowerWeightIterator )
437 {
439 = ( listIterator->second + lowerWeightIterator->second );
441
442
443
444 {
446
447 {
448
451
454
456 lowerWeightIterator->first );
460 }
461
462
463
464
465 lowerWeightIterator = listIterator;
466 }
467 else
468
469
470 {
471
474
476 lowerWeightIterator->first );
482
483 {
484
487
489 }
490
491
492 ++lowerWeightIterator;
493 }
494
495
496
497 }
498
499
500
501
502 ++listIterator;
503 }
504
505
506
507
509 {
513 }
514 else
515 {
519 }
520 }
521 }
522
523
524 }
void setWeight(double const candidateWeight)
void buildFrom(BalancedPartitionCandidate const &basePartition, unsigned int const extraIndex, double const candidateWeight, double const inverseWeight)
void setInverseWeight(double const inverseWeight)
std::pair< unsigned int, double > IndexWithWeight
static bool orderByDouble(IndexWithWeight const &firstPair, IndexWithWeight const &secondPair)
std::list< BalancedPartitionCandidate * >::iterator CandidateListIterator
void makeOtherPartition(std::vector< unsigned int > &partitionToBeMade, std::vector< unsigned int > &partitionAlreadyMade)
std::list< IndexWithWeight >::const_iterator IndexWithWeightListConstIterator
void fillVectorFromBestCandidate(std::vector< unsigned int > &partitionToBeMade)
void clearSavedCandidates()