- tpl = 'Solution failed with error "{:s}".\n' \
- '{!s}\n' \
- 'CVXOPT returned:\n{!s}'
- # TODO: dont convert the solution to a string, we need
- # to output the two values as well.
- self.message = tpl.format(status,
- solution,
- self.pretty_print_dict(solution_dict))
+ self._solution_dict = solution_dict
+
+
+ def _pretty_print_dict(self, solution_dict):
+ """
+ Return a pretty-printed string representation of a CVXOPT
+ solution dictionary.
+ """
+ result = ''
+ for (k,v) in solution_dict.items():
+ if isinstance(v, matrix):
+ # Display matrices on their own lines, indented.
+ result += ' {:s}:'.format(k)
+ colvec = '\n{!s}'.format(v)
+ result += '\n '.join(colvec.splitlines())
+ result += '\n'
+ else:
+ result += ' {:s}: {!s}\n'.format(k,v)
+
+ return result