Package elections :: Module cplex_ilp
[frames] | no frames]

Module cplex_ilp

source code

This module implements the integer-linear programming methods for computing the IRV margin exactly using the CPLEX library.

Functions
number
distance_to(root, ranks, elim_order, timeout)
Compute the distance_to function from Magrino et al.
source code
Variables
  __package__ = 'elections'
Function Details

distance_to(root, ranks, elim_order, timeout)

source code 

Compute the distance_to function from Magrino et al.

This formulation differs from Magrino et al. in three ways.

  1. The y_S variables are all removed so all that remains are p_S and m_S;
  2. The constraints on the p_S and m_S are replaced with simple bounds; and
  3. The objective function changed for the new definition of margin.

3 is the most important. The original objective function was sum_S p_S. We want sum_{S != ()} (p_S + m_S). This works, but seems to be horribly inefficient. Using sum_S p_S = sum_S m_S, we can rewrite this as 2*sum_{S != ()} m_S - p_{()} + m_{()}.

Parameters:
  • root (Node) - Root of the ballot tree.
  • ranks (number) - The maximum number of candidates a voter can rank.
  • elim_order (list) - The elimination order we would like.
  • timeout (number) - The computation timeout.
Returns: number
Returns -1 on timeout. Otherwise, it returns the margin.