Difference between revisions of "Talk:770: All the Girls"
(Created page with "The reasons why this algorithm wouldn't work so well in producing stable marriages are * the people preferences may change (especially if they know someone better) * people ma...") |
|||
Line 3: | Line 3: | ||
* people may prefer not having marriage at all (when rejected by some of their choices) | * people may prefer not having marriage at all (when rejected by some of their choices) | ||
Still, it's not like there is better algorithm. -- [[User:Hkmaly|Hkmaly]] ([[User talk:Hkmaly|talk]]) 10:02, 17 April 2013 (UTC) | Still, it's not like there is better algorithm. -- [[User:Hkmaly|Hkmaly]] ([[User talk:Hkmaly|talk]]) 10:02, 17 April 2013 (UTC) | ||
+ | |||
+ | sub BetterThanNothing ( my (@everyone,@m,@f,@o,@r,@Ps) = @_; while (my $person = shift @everyone) { push(@m, $person)&&next if _isMale($person); push(@f, $person)&&next if _isFemale($person); push @o, $person } my $priority =(@m>=@f)?[\@f,\@m]:[\@m,\@f]; while (@{$priority[0]}) { push @Ps, [splice(@{$priority[0]},rnd(@{$priority[0]}),1), splice(@{$priority[1]},rnd(@{$priority[1]}),1)] } } @r = (@m,@f,@o); while (@r>1) { push @Ps, [splice(@r,rnd(@r),1), splice(@r,rnd(@r),1)] } } @r && push @Ps, [(shift @r) x 2]; return @Ps } # Totally untested Perl for when you /really/ don't care too much... ;) [[Special:Contributions/31.110.88.49|31.110.88.49]] 04:34, 4 May 2013 (UTC) |
Revision as of 04:34, 4 May 2013
The reasons why this algorithm wouldn't work so well in producing stable marriages are
- the people preferences may change (especially if they know someone better)
- people may prefer not having marriage at all (when rejected by some of their choices)
Still, it's not like there is better algorithm. -- Hkmaly (talk) 10:02, 17 April 2013 (UTC)
sub BetterThanNothing ( my (@everyone,@m,@f,@o,@r,@Ps) = @_; while (my $person = shift @everyone) { push(@m, $person)&&next if _isMale($person); push(@f, $person)&&next if _isFemale($person); push @o, $person } my $priority =(@m>=@f)?[\@f,\@m]:[\@m,\@f]; while (@{$priority[0]}) { push @Ps, [splice(@{$priority[0]},rnd(@{$priority[0]}),1), splice(@{$priority[1]},rnd(@{$priority[1]}),1)] } } @r = (@m,@f,@o); while (@r>1) { push @Ps, [splice(@r,rnd(@r),1), splice(@r,rnd(@r),1)] } } @r && push @Ps, [(shift @r) x 2]; return @Ps } # Totally untested Perl for when you /really/ don't care too much... ;) 31.110.88.49 04:34, 4 May 2013 (UTC)