783 return term, sourceterms.pop(term) |
783 return term, sourceterms.pop(term) |
784 secondchoice = term |
784 secondchoice = term |
785 if secondchoice is not None: |
785 if secondchoice is not None: |
786 return secondchoice, sourceterms.pop(secondchoice) |
786 return secondchoice, sourceterms.pop(secondchoice) |
787 # priority to variable with the less solutions supported and with the |
787 # priority to variable with the less solutions supported and with the |
788 # most valuable refs |
788 # most valuable refs. Add variable name for test predictability |
789 variables = sorted([(var, sols) for (var, sols) in sourceterms.items() |
789 variables = sorted([(var, sols) for (var, sols) in sourceterms.items() |
790 if isinstance(var, Variable)], |
790 if isinstance(var, Variable)], |
791 key=lambda (v, s): (len(s), -v.valuable_references())) |
791 key=lambda (v, s): (len(s), -v.valuable_references(), v.name)) |
792 if variables: |
792 if variables: |
793 var = variables[0][0] |
793 var = variables[0][0] |
794 return var, sourceterms.pop(var) |
794 return var, sourceterms.pop(var) |
795 # priority to constant |
795 # priority to constant |
796 for term in sourceterms: |
796 for term in sourceterms: |