generate_problem.py 1020 B

12345678910111213141516171819202122232425262728293031323334
  1. import numpy as np
  2. from scipy import sparse
  3. import utils.codegen_utils as cu
  4. P = sparse.triu([[11., 0.], [0., 0.]], format='csc')
  5. q = np.array([3., 4.])
  6. A = sparse.csc_matrix(np.array([[-1., 0.], [0., -1.], [-1., 3.],
  7. [2., 5.], [3., 4]]))
  8. l = -np.inf * np.ones(A.shape[0])
  9. u = np.array([0., 0., -15., 100., 80.])
  10. n = P.shape[0]
  11. m = A.shape[0]
  12. # New data
  13. q_new = np.array([1., 1.])
  14. u_new = np.array([-2., 0., -20., 100., 80.])
  15. # Generate problem solutions
  16. sols_data = {'x_test': np.array([15., -0.]),
  17. 'y_test': np.array([0., 508., 168., 0., 0.]),
  18. 'obj_value_test': 1282.5,
  19. 'status_test': 'optimal',
  20. 'q_new': q_new,
  21. 'u_new': u_new,
  22. 'x_test_new': np.array([20., -0.]),
  23. 'y_test_new': np.array([0., 664., 221., 0., 0.]),
  24. 'obj_value_test_new': 2220.0,
  25. 'status_test_new': 'optimal'}
  26. # Generate problem data
  27. cu.generate_problem_data(P, q, A, l, u, 'basic_qp2', sols_data)