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([[11., 0.], [0., 0.]], format='csc') |
| 6 | q = np.array([3., 4.]) |
| 7 | |
| 8 | A = sparse.csc_matrix(np.array([[-1., 0.], [0., -1.], [-1., 3.], |
| 9 | [2., 5.], [3., 4]])) |
| 10 | l = -np.inf * np.ones(A.shape[0]) |
| 11 | u = np.array([0., 0., -15., 100., 80.]) |
| 12 | |
| 13 | n = P.shape[0] |
| 14 | m = A.shape[0] |
| 15 | |
| 16 | # New data |
| 17 | q_new = np.array([1., 1.]) |
| 18 | u_new = np.array([-2., 0., -20., 100., 80.]) |
| 19 | |
| 20 | # Generate problem solutions |
| 21 | sols_data = {'x_test': np.array([15., -0.]), |
| 22 | 'y_test': np.array([0., 508., 168., 0., 0.]), |
| 23 | 'obj_value_test': 1282.5, |
| 24 | 'status_test': 'optimal', |
| 25 | 'q_new': q_new, |
| 26 | 'u_new': u_new, |
| 27 | 'x_test_new': np.array([20., -0.]), |
| 28 | 'y_test_new': np.array([0., 664., 221., 0., 0.]), |
| 29 | 'obj_value_test_new': 2220.0, |
| 30 | 'status_test_new': 'optimal'} |
| 31 | |
| 32 | |
| 33 | # Generate problem data |
| 34 | cu.generate_problem_data(P, q, A, l, u, 'basic_qp2', sols_data) |