Austin Schuh | 9049e20 | 2022-02-20 17:34:16 -0800 | [diff] [blame^] | 1 | import numpy as np |
| 2 | from scipy import sparse |
| 3 | import utils.codegen_utils as cu |
| 4 | |
| 5 | P = sparse.triu([[4., 1.], [1., 2.]], format='csc') |
| 6 | q = np.ones(2) |
| 7 | |
| 8 | A = sparse.csc_matrix(np.array([[1., 1.], [1., 0.], [0., 1.], [0., 1.]])) |
| 9 | l = np.array([1., 0., 0., -np.inf]) |
| 10 | u = np.array([1., 0.7, 0.7, np.inf]) |
| 11 | |
| 12 | n = P.shape[0] |
| 13 | m = A.shape[0] |
| 14 | |
| 15 | # New data |
| 16 | q_new = np.array([2.5, 3.2]) |
| 17 | l_new = np.array([0.8, -3.4, -np.inf, 0.5]) |
| 18 | u_new = np.array([1.6, 1.0, np.inf, 0.5]) |
| 19 | |
| 20 | # Generate problem solutions |
| 21 | sols_data = {'x_test': np.array([0.3, 0.7]), |
| 22 | 'y_test': np.array([-2.9, 0.0, 0.2, 0.0]), |
| 23 | 'obj_value_test': 1.88, |
| 24 | 'status_test': 'optimal', |
| 25 | 'q_new': q_new, |
| 26 | 'l_new': l_new, |
| 27 | 'u_new': u_new} |
| 28 | |
| 29 | # Generate problem data |
| 30 | cu.generate_problem_data(P, q, A, l, u, 'basic_qp', sols_data) |