I'm the mystic
author. At first blush, it looks like a bug with named variables.
Note that you aren't using numbered variables, which the error is suggesting/assuming you do.
>>> import mystic.symbolic as ms
>>> equations = """A + B + C + D + E + F + G + H + I + J < 1000"""
>>> var = list('ABCDEFGHIJKLMNOPQ')
>>> eqns = ms.simplify(equations, variables=var, all=True)
>>> print(eqns)
A < -B - C - D - E - F - G - H - I - J + 1000
... adding in a K
produces the error you reported.
However, we can go above 10 variables if we add some numbered variables (in particular, at least B0
, as suggested by the traceback):
>>> equations = """A + B + C + D + E + F + G + H + I + J + B0 + B1 < 1000"""
>>> var = list('ABCDEFGHIJ') + ['B0','B1']
>>> eqns = ms.simplify(equations, variables=var, all=True)
>>> print(eqns)
A < -B - B0 - B1 - C - D - E - F - G - H - I - J + 1000
...or if we use all numbered variables:
>>> equations = """x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 < 1000"""
>>> var = ['x%s' % i for i in range(12)]
>>> eqns = ms.simplify(equations, variables=var, all=True)
>>> print(eqns)
x0 < -x1 - x10 - x11 - x2 - x3 - x4 - x5 - x6 - x7 - x8 - x9 + 1000
Apparently, whatever the second variable in var
is (e.g. B
or x
), then you need to include a similarly named variable (i.e. B0
or x0
). So... that is unexpected to me... thus, it looks like you found a bug.
UPDATE: the bug should be fixed now. A new release of mystic
is due out shortly, however the code is patched on GitHub.
>>> import mystic.symbolic as ms
>>> equations = """A + B + C + D + E + F + G + H + I + J + K + L < 1000"""
>>> var = list('ABCDEFGHIJKLMNOPQ')
>>> ms.simplify(equations, variables=var, all=True)
'A < -B - K - L - C - D - E - F - G - H - I - J + 1000'
>>> import mystic as my
>>> my.__version__
'0.4.1.dev0'