Pages

Wednesday 20 April 2011

UK Alternative Vote

Hi all, yesterday it occurred to me that I didn't really understand how votes are reallocated after each round in the proposed Alternative Vote system here in the UK. The Yes2AV group didn't help the case by explaining it almost as badly as the No2AV group, but after much discussion with friends I did refine it to a process that I did understand.

The basic idea is that you mark your preferences in order. This is simple enough to grasp. What isn't is when all the first preferences are added up and there is no majority (more than 50%), what happens next. The Eelctoral Reform Society has it as this:
If no candidate gains a majority on first preferences, then the second-preference votes of the candidate who finished last on the first count are redistributed. This process is repeated until someone gets over 50 per cent.
To me that is just not clear about what is going on. I spent over an hour on the phone and still did not understand. So we began our own based around Ice Cream to help demonstrate what is going on. Full details can be found on Kitty's blog. It also includes the raw data and my Python implementation amongst others. I recommend you check it out, but I'll come back to it later.

The way I found best to understand this was this:
  1. Imagine your ballot paper is a queue, you choose who is first, second, third and so on in that queue.
  2. When the votes are counted, you count ONLY the first person of each queue.
  3. If one candidate has more that 50%, that candidate wins. If not, the lowest candidate is eliminated, and removed from ALL queues, meaning anyone behind them moves forward into their place. Any that were 2nd choices have now been effectively added to the first choices. 
  4. Go to 2.
That may sound just as cryptic, but lets look at some visual examples. Say we have 3 candidates and 5 voters, and they vote the following. The votes are displayed horizontally, the preferences vertically, the green area being the first preference area.

So, blue has the least 1st preference votes, so is eliminated from the running, leaving this:


Now all the remaining votes move forward, like so:

And we now recount the votes in the green section. If there is still no majority, you continue eliminating the last place and moving votes forward until you do. In this case red wins even though all parties had the same number of votes, because it had the higher preference votes.

If a vote runs out of preferences, it is just discarded (and the quota is decreased accordingly) and the rules for tie-breaking depend upon the rules of the particular ballot you are participating in.

Hopefully you've understood that analogy. Now I'll talk some more about our test ballot. We took 70 votes for 5 candidate flavors of ice cream. Now using First Past The Post, Mint won, with 22 votes for and 44 votes against (the other 4 ballots were spoiled and invalidated). So more people would prefer not to have Mint than to have it.

This is where Alternative Vote comes in. The lowest vote was Strawberry, so we removed it from the votes, and moved the 2nd preferences forward. This was followed by the elimination of Fudge and Chocolate. What this left us with was Vanilla as the winner. It may not have had the most first preference votes, but because more people would accept it than mint (33 instead of 22), it's the least objectionable option, something the majority can enjoy.

So what does AV get us? More than one vote? No. Our first choice? Not necessarily. Someone we'd prefer over another candidate? Most definitely.

I'm not going to try sway anyone's vote for May 5th, everyone is entitled to their own opinion. Whatever your view, I hope this has helped you to understand the counting process under AV. 

Sunday 17 April 2011

DD-WRT and wide-dhcp6-server

Hi all, it's been a little while since my last DD-WRT related post, but this will help anyone trying to fit all these extra features on a space budget.

Previously, I built ISC DHCP to get DHCPv6 onto my DD-WRT router. This is all well and good, but the required files to make it run are a little on the large side, considering the small amount of flash available on consumer routers. Wide is a whole 250k, making it much more suitable. It's also a lot simpler to compile.

As I mentioned before, my Netgear died, and I now have a Buffalo, therefore the --host section from here on will be different from my previous posts. So, lets get started by downloading and extracting the source:

# wget http://downloads.sourceforge.net/project/wide-dhcpv6/wide-dhcpv6/wide-dhcpv6-20080615/wide-dhcpv6-20080615.tar.gz
# tar xzvf dhcpv6-20080615.tar.gz
# cd dhcpv6-20080615

First thing we need to do is add this line to a new file called config.cache, to sort out things the configure script cannot for itself:

ac_cv_func_setpgrp_void=yes

From here, it's pretty much a simple configure and make, then copy the binary to the router:

# ./configure --prefix=/opt --host=mips-linux-uclibc --cache-file=config.cache LDFLAGS="-L -L/opt/lib -static" --with-localdbdir=/tmp
# make

That's that! If all went well, you should have a dhcp6s binary to copy to your router. Configuring it to serve just dns details is a single line config file, mine is /opt/etc/dhcp6s.conf. Simply replace with your IPv6 DNS servers.

option domain-name-servers 2001:db8::1;

To start the server, it's just a quick

# dhcp6s -c /opt/etc/dhcp6s.conf br0

Which you can also add to your startup script. That's it, you should now have a smaller working DHCPv6 server dishing out IPv6 DNS servers!

Monday 11 April 2011

I'm still here! Also VoIP.

Again, sorry all for not keeping up with my old rate of blog posting. I recently became a father, and spent most of this weekend tidying the garden (it needed some urgent attention!).

I haven't had chance to sit down and get on with the DD-WRT stuff lately. On top of IPSEC, I also need to find a smaller DHCPv6 implementation that I can cross compile. 6MB is a bit large considering most routers have 4-8MB of flash. I've been looking at dibbler and wide-dhcpv6.

What I have done recently that may interest a number of you, is I've been getting my VoIP equipment set up again. A few friends and I started our own federated VoIP network a few years ago to call each other for free with no limitations, but I've extended my end to include DID numbers and (semi-)free international calls. I've been using asterisk to manage all my different inbound and outbound accounts as I have many VoIP devices I wish to use, although the came can be done without.

So, here's the setup for a single device:
For outbound calls, the absolute cheapest is voipcheap. They have many subsidiaries for varies countries and continents so the site you need may be different. The main two are VoipCheap.co.uk and VoipCheap.com. You set this account up on your SIP device. VoipCheap will give you 300 free minutes a week to selected destinations as long as you top up the account every 90 days. The minimum seems to be £10 for the UK one.

For a UK inbound number, try numbergroup.com. As far as I can tell, it's free for inbound numbers. Simply choose SIP as the destination and enter <voipcheap username>@sip.voipcheap.co.uk (or .com if you registered with .com). For a US inbound number (WA state), ipkall.com setup is similar, but they do make an automated call occasionally to make sure the number is still in use. If you want one in a different state, you can try Google Voice, although you need to set this up from a US IP address. This sets up a basic forwarding number, forward it to your ipkall assigned one.

That's it, you should now be able to make and receive calls to standard PSTN lines using your sip device. Remember to always dial the full number, including international and area codes. The only thing you're missing is caller ID. The first thing you need to do is verify the number with voipcheap. This will involve an automated call and typing in the digits read to you into your account settings page. You can only do this for the region you registered for VoipCheap in, mind. Once you've verified it, to actually use it you'll have to set it up on your SIP device. How to do this will vary so I'm not going to cover that here.

This setup works fine for a single user as you can only set one caller ID with voipcheap at a time, so if you're using this kind of setup to handle multiple numbers and phones, I'd consider using a paid outbound provider, numbergroup.com have very competitive rates and can often provide you with a contiguous group of numbers.

Anyway, hopefully that'll keep you all occupied for a while, with all the free international calls you'll all be making!