Skip to content
This repository has been archived by the owner on Mar 6, 2018. It is now read-only.

Commit

Permalink
faster solver for semigroups
Browse files Browse the repository at this point in the history
  • Loading branch information
saraedum committed Nov 28, 2016
1 parent 6a3126c commit ff01e8e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion value_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,22 @@ def _solve_linear_program(self, target):
else:
return None

if len(self._generators) == 1:
from sage.rings.all import NN
exp = target / self._generators[0]
if exp not in NN:
return None
return {0 : exp}

if len(self._generators) == 2 and self._generators[0] == - self._generators[1]:
from sage.rings.all import ZZ
exp = target / self._generators[0]
if exp not in ZZ:
return None
return {0: exp, 1: 0}

from sage.numerical.mip import MixedIntegerLinearProgram, MIPSolverException
P = MixedIntegerLinearProgram(maximization=False, solver = "ppl")
P = MixedIntegerLinearProgram(maximization=False, solver="ppl")
x = P.new_variable(integer=True, nonnegative=True)
constraint = sum([g*x[i] for i,g in enumerate(self._generators)]) == target
P.add_constraint(constraint)
Expand Down

0 comments on commit ff01e8e

Please sign in to comment.