|
Lines 556-577
RETRY:
Link Here
|
| 556 |
# end. |
556 |
# end. |
| 557 |
$inf = $max * $num_tasks + 1; |
557 |
$inf = $max * $num_tasks + 1; |
| 558 |
|
558 |
|
|
|
559 |
my @m0 = map {[(undef) x $num_tasks]} (1..$num_agents); |
| 559 |
for ( my $i = 0 ; $i < $num_agents ; $i++ ) { |
560 |
for ( my $i = 0 ; $i < $num_agents ; $i++ ) { |
| 560 |
for ( my $j = 0 ; $j < $num_tasks ; $j++ ) { |
561 |
for ( my $j = 0 ; $j < $num_tasks ; $j++ ) { |
| 561 |
if ( $m[$i][$j] < 0 ) { |
562 |
if ( $m[$i][$j] < 0 ) { |
| 562 |
|
|
|
| 563 |
# Bias towards not allocating items to holds closer to |
563 |
# Bias towards not allocating items to holds closer to |
| 564 |
# the end of the queue in the queue if not all holds |
564 |
# the end of the queue in the queue if not all holds |
| 565 |
# can be filled by representing infinity with |
565 |
# can be filled by representing infinity with |
| 566 |
# different values. |
566 |
# different values. |
| 567 |
$m[$i][$j] = $inf + ( $num_tasks - $j ); |
567 |
$m0[$i][$j] = $inf + ( $num_tasks - $j ); |
|
|
568 |
} else { |
| 569 |
$m0[$i][$j] = $m[$i][$j]; |
| 568 |
} |
570 |
} |
| 569 |
} |
571 |
} |
| 570 |
} |
572 |
} |
| 571 |
|
573 |
|
| 572 |
my $res = [ (undef) x $num_agents ]; |
574 |
my $res = [ (undef) x $num_agents ]; |
| 573 |
|
575 |
|
| 574 |
Algorithm::Munkres::assign( \@m, $res ); |
576 |
Algorithm::Munkres::assign( \@m0, $res ); |
| 575 |
|
577 |
|
| 576 |
my @unallocated = (); |
578 |
my @unallocated = (); |
| 577 |
@allocated = (); |
579 |
@allocated = (); |
|
Lines 584-590
RETRY:
Link Here
|
| 584 |
# allocated to nonexisting items ($j >= 0). We just ignore these. |
586 |
# allocated to nonexisting items ($j >= 0). We just ignore these. |
| 585 |
next; |
587 |
next; |
| 586 |
} |
588 |
} |
| 587 |
if ( $m[$i][$j] > $max ) { |
589 |
if ( $m0[$i][$j] > $max ) { |
| 588 |
|
590 |
|
| 589 |
# No finite cost item was assigned to this hold. |
591 |
# No finite cost item was assigned to this hold. |
| 590 |
push @unallocated, $j; |
592 |
push @unallocated, $j; |
| 591 |
- |
|
|