[simplex] Fix display of variables like x_12 in latex.
This commit is contained in:
parent
349caaff6b
commit
e42e97064a
@ -110,6 +110,18 @@ class simplex_dictionary:
|
|||||||
|
|
||||||
return super().__setattr__(key, value)
|
return super().__setattr__(key, value)
|
||||||
|
|
||||||
|
def name_latex(self, name):
|
||||||
|
""" Convert the given variable name. """
|
||||||
|
name = str(name)
|
||||||
|
|
||||||
|
s = name.split('_')
|
||||||
|
|
||||||
|
# We only handle special case:
|
||||||
|
if len(s) == 1 or len(s) > 2:
|
||||||
|
return name
|
||||||
|
|
||||||
|
return s[0] + '_{' + s[1] + '}'
|
||||||
|
|
||||||
def value_latex(self, value):
|
def value_latex(self, value):
|
||||||
if value.denominator == 1:
|
if value.denominator == 1:
|
||||||
return str(value)
|
return str(value)
|
||||||
@ -125,10 +137,10 @@ class simplex_dictionary:
|
|||||||
"""
|
"""
|
||||||
d = (r'\begin{{array}}{{r||{}}}'.format(
|
d = (r'\begin{{array}}{{r||{}}}'.format(
|
||||||
'r|' * (1 + len(self.B)))
|
'r|' * (1 + len(self.B)))
|
||||||
+ r' & b & ' + ' & '.join(str(v) for v in self.N) + r'\\\hline '
|
+ r' & b & ' + ' & '.join(self.name_latex(v) for v in self.N) + r'\\\hline '
|
||||||
+ r'\\'.join(
|
+ r'\\'.join(
|
||||||
'{} & {} &'.format(
|
'{} & {} &'.format(
|
||||||
b,
|
self.name_latex(b),
|
||||||
self.value_latex(self.b[b])
|
self.value_latex(self.b[b])
|
||||||
)
|
)
|
||||||
+ ' & '.join(self.value_latex(-self.a[b][n]) for n in self.N)
|
+ ' & '.join(self.value_latex(-self.a[b][n]) for n in self.N)
|
||||||
|
Loading…
Reference in New Issue
Block a user