You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I bumped into the error "UnboundLocalError: local variable 's' referenced before assignment" when I use the following code. A full stack trace is available after it.
I run it on Ubuntu-64 using Python 2.7.13 and pulp version is 1.6.6.
import pulp
my_lp_problem = pulp.LpProblem("My LP Problem", pulp.LpMaximize)
x = pulp.LpVariable('x', lowBound=0, cat='Continuous')
y = pulp.LpVariable('y', lowBound=2, cat='Continuous')
# Objective function
my_lp_problem += 4 * x + 3 * y, "Z"
# Constraints
my_lp_problem += 2 * y <= 25 - x
my_lp_problem += 4 * y >= 2 * x - 8
my_lp_problem += y <= 2 * x - 5
my_lp_problem
---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.pyc in __call__(self, obj)
697 type_pprinters=self.type_printers,
698 deferred_pprinters=self.deferred_printers)
--> 699 printer.pretty(obj)
700 printer.flush()
701 return stream.getvalue()
/usr/local/lib/python2.7/dist-packages/IPython/lib/pretty.pyc in pretty(self, obj)
381 if callable(meth):
382 return meth(obj, self, cycle)
--> 383 return _default_pprint(obj, self, cycle)
384 finally:
385 self.end_group()
/usr/local/lib/python2.7/dist-packages/IPython/lib/pretty.pyc in _default_pprint(obj, p, cycle)
501 if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs:
502 # A user-provided repr. Find newlines and replace them with p.break_()
--> 503 _repr_pprint(obj, p, cycle)
504 return
505 p.begin_group(1, '<')
/usr/local/lib/python2.7/dist-packages/IPython/lib/pretty.pyc in _repr_pprint(obj, p, cycle)
699 """A pprint that just redirects to the normal repr function."""
700 # Find newlines and replace them with p.break_()
--> 701 output = repr(obj)
702 for idx,output_line in enumerate(output.splitlines()):
703 if idx:
/usr/local/lib/python2.7/dist-packages/pulp/pulp.pyc in __repr__(self)
1141 string += "VARIABLES\n"
1142 for v in self.variables():
-> 1143 s += v.asCplexLpVariable() + " " + LpCategories[v.cat] + "\n"
1144 return s
1145
UnboundLocalError: local variable 's' referenced before assignment
The text was updated successfully, but these errors were encountered:
I bumped into the error "UnboundLocalError: local variable 's' referenced before assignment" when I use the following code. A full stack trace is available after it.
I run it on Ubuntu-64 using Python 2.7.13 and pulp version is 1.6.6.
The text was updated successfully, but these errors were encountered: