I'm trying to constrain an overall budget using mystic, where each individual x has an associated function that is ultimately being maximized.
I have set bounds such that each individual spend can only go up or down at a maximum of 30%. I am not trying to set a constraint so the overall budget is not exceeded.
equations = """A + B + C + D + E + F + G + H + I + J < %s """%(budget)
var = list('ABCDEFGHIJKLMNOPQ')
eqns = ms.simplify(equations, variables=var, all=True)
constrain = ms.generate_constraint(ms.generate_solvers(eqns, var), join=my.constraints.and_)
The above works as expected, but as soon as I add an 11th (K) to the addition, the ms.simplify funciton throws the following error: NameError: name 'B0' is not defined.
Is there a way to constrain more than 10 values at once?
I'm the
mysticauthor. 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.
... adding in a
Kproduces 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):...or if we use all numbered variables:
Apparently, whatever the second variable in
varis (e.g.Borx), then you need to include a similarly named variable (i.e.B0orx0). 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
mysticis due out shortly, however the code is patched on GitHub.