auxil.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #ifndef AUXIL_H
  2. # define AUXIL_H
  3. # ifdef __cplusplus
  4. extern "C" {
  5. # endif // ifdef __cplusplus
  6. # include "types.h"
  7. /***********************************************************
  8. * Auxiliary functions needed to compute ADMM iterations * *
  9. ***********************************************************/
  10. # if EMBEDDED != 1
  11. /**
  12. * Compute rho estimate from residuals
  13. * @param work Workspace
  14. * @return rho estimate
  15. */
  16. c_float compute_rho_estimate(OSQPWorkspace *work);
  17. /**
  18. * Adapt rho value based on current unscaled primal/dual residuals
  19. * @param work Workspace
  20. * @return Exitflag
  21. */
  22. c_int adapt_rho(OSQPWorkspace *work);
  23. /**
  24. * Set values of rho vector based on constraint types
  25. * @param work Workspace
  26. */
  27. void set_rho_vec(OSQPWorkspace *work);
  28. /**
  29. * Update values of rho vector based on updated constraints.
  30. * If the constraints change, update the linear systems solver.
  31. *
  32. * @param work Workspace
  33. * @return Exitflag
  34. */
  35. c_int update_rho_vec(OSQPWorkspace *work);
  36. # endif // EMBEDDED
  37. /**
  38. * Swap c_float vector pointers
  39. * @param a first vector
  40. * @param b second vector
  41. */
  42. void swap_vectors(c_float **a,
  43. c_float **b);
  44. /**
  45. * Cold start workspace variables xz and y
  46. * @param work Workspace
  47. */
  48. void cold_start(OSQPWorkspace *work);
  49. /**
  50. * Update x_tilde and z_tilde variable (first ADMM step)
  51. * @param work [description]
  52. */
  53. void update_xz_tilde(OSQPWorkspace *work);
  54. /**
  55. * Update x (second ADMM step)
  56. * Update also delta_x (For for dual infeasibility)
  57. * @param work Workspace
  58. */
  59. void update_x(OSQPWorkspace *work);
  60. /**
  61. * Update z (third ADMM step)
  62. * @param work Workspace
  63. */
  64. void update_z(OSQPWorkspace *work);
  65. /**
  66. * Update y variable (fourth ADMM step)
  67. * Update also delta_y to check for primal infeasibility
  68. * @param work Workspace
  69. */
  70. void update_y(OSQPWorkspace *work);
  71. /**
  72. * Compute objective function from data at value x
  73. * @param work OSQPWorkspace structure
  74. * @param x Value x
  75. * @return Objective function value
  76. */
  77. c_float compute_obj_val(OSQPWorkspace *work,
  78. c_float *x);
  79. /**
  80. * Check whether QP has solution
  81. * @param info OSQPInfo
  82. */
  83. c_int has_solution(OSQPInfo *info);
  84. /**
  85. * Store the QP solution
  86. * @param work Workspace
  87. */
  88. void store_solution(OSQPWorkspace *work);
  89. /**
  90. * Update solver information
  91. * @param work Workspace
  92. * @param iter Iteration number
  93. * @param compute_objective Boolean (if compute the objective or not)
  94. * @param polish Boolean (if called from polish)
  95. */
  96. void update_info(OSQPWorkspace *work,
  97. c_int iter,
  98. c_int compute_objective,
  99. c_int polish);
  100. /**
  101. * Reset solver information (after problem updates)
  102. * @param info Information structure
  103. */
  104. void reset_info(OSQPInfo *info);
  105. /**
  106. * Update solver status (value and string)
  107. * @param info OSQPInfo
  108. * @param status_val new status value
  109. */
  110. void update_status(OSQPInfo *info,
  111. c_int status_val);
  112. /**
  113. * Check if termination conditions are satisfied
  114. * If the boolean flag is ON, it checks for approximate conditions (10 x larger
  115. * tolerances than the ones set)
  116. *
  117. * @param work Workspace
  118. * @param approximate Boolean
  119. * @return Residuals check
  120. */
  121. c_int check_termination(OSQPWorkspace *work,
  122. c_int approximate);
  123. # ifndef EMBEDDED
  124. /**
  125. * Validate problem data
  126. * @param data OSQPData to be validated
  127. * @return Exitflag to check
  128. */
  129. c_int validate_data(const OSQPData *data);
  130. /**
  131. * Validate problem settings
  132. * @param settings OSQPSettings to be validated
  133. * @return Exitflag to check
  134. */
  135. c_int validate_settings(const OSQPSettings *settings);
  136. # endif // #ifndef EMBEDDED
  137. # ifdef __cplusplus
  138. }
  139. # endif // ifdef __cplusplus
  140. #endif // ifndef AUXIL_H