Closed cvanoli closed 5 years ago
This PR adds a breakpoint in the iterative_lottery_choice
function when the maximum capacity of alternatives is less than the minimum size of choosers.
The function iterative_lottery_choices
in choicemodels/tools/simulation.py allows the choices to be constrained by capacity of alternatives and size of choosers. The while
loop works the choices' simulations sequentially, each time reducing the alternatives' available capacity.
This loop ends when all choosers are accomodated into the alternatives or when the number of iterations reach the maximum specified (if specified). There is one case that can make this loop infinite. When not all choosers are accomodated and their sizes do not fit into any of the remaining alternative capacities.
To solve this, I added an if
statement with a break
that works when the maximum capacity of the remaining alternatives in that iteration is less than the minimum size of the still-to-allocate choosers. This statements is placed after the maximum-iteration piece of code.
This PR is 0.2.dev8
Coverage decreased (-0.001%) to 75.188% when pulling d9e389c8d11ea942cf51ce1ad23634c2fc8e67a9 on iterative_lottery_add into 769800de1aa50abead0ec42e7e3e31dbe247974d on master.