A solution to an optimization problem. Attributes ---------- status : str The status code. opt_val : float The optimal value. primal_vars : dict of id to NumPy ndarray A map from variable ids to optimal values. dual_vars : dict of id to NumPy ndarray
| 60 | |
| 61 | |
| 62 | class Solution: |
| 63 | """A solution to an optimization problem. |
| 64 | |
| 65 | Attributes |
| 66 | ---------- |
| 67 | status : str |
| 68 | The status code. |
| 69 | opt_val : float |
| 70 | The optimal value. |
| 71 | primal_vars : dict of id to NumPy ndarray |
| 72 | A map from variable ids to optimal values. |
| 73 | dual_vars : dict of id to NumPy ndarray |
| 74 | A map from constraint ids to dual values. |
| 75 | attr : dict |
| 76 | Miscellaneous information propagated up from a solver. |
| 77 | """ |
| 78 | def __init__(self, status, opt_val, primal_vars, dual_vars, attr) -> None: |
| 79 | self.status = status |
| 80 | self.opt_val = opt_val |
| 81 | self.primal_vars = primal_vars |
| 82 | self.dual_vars = dual_vars |
| 83 | self.attr = attr |
| 84 | |
| 85 | def copy(self) -> "Solution": |
| 86 | return Solution(self.status, |
| 87 | self.opt_val, |
| 88 | self.primal_vars, |
| 89 | self.dual_vars, |
| 90 | self.attr) |
| 91 | |
| 92 | def __str__(self) -> str: |
| 93 | return "Solution(status=%s, opt_val=%s, primal_vars=%s, dual_vars=%s, attr=%s)" % ( |
| 94 | self.status, self.opt_val, self.primal_vars, self.dual_vars, self.attr) |
| 95 | |
| 96 | def __repr__(self) -> str: |
| 97 | return "Solution(%s, %s, %s, %s)" % (self.status, |
| 98 | self.primal_vars, |
| 99 | self.dual_vars, |
| 100 | self.attr) |
no outgoing calls