diff --git a/LICENSE b/LICENSE index cef7ff59b..5a568288d 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2018 Bartolomeo Stellato, Goran Banjac, Paul Goulart, Stephen Boyd + Copyright 2019 Bartolomeo Stellato, Goran Banjac, Paul Goulart, Stephen Boyd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE b/NOTICE index 4b040db84..dd7c53fc4 100644 --- a/NOTICE +++ b/NOTICE @@ -1,5 +1,5 @@ OSQP -Copyright (c) 2018 Bartolomeo Stellato, Goran Banjac, Paul Goulart, Stephen Boyd +Copyright (c) 2019 Bartolomeo Stellato, Goran Banjac, Paul Goulart, Stephen Boyd This product includes software developed at Stanford University and at the University of Oxford. diff --git a/docs/conf.py b/docs/conf.py index deb5290b6..edead0ec3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,7 +51,7 @@ # General information about the project. project = 'OSQP' -copyright = '2018, Bartolomeo Stellato, Goran Banjac' +copyright = '2019, Bartolomeo Stellato, Goran Banjac' author = 'Bartolomeo Stellato, Goran Banjac' # The version info for the project you're documenting, acts as replacement for diff --git a/docs/examples/demo.rst b/docs/examples/demo.rst deleted file mode 100644 index 6ed6f4c08..000000000 --- a/docs/examples/demo.rst +++ /dev/null @@ -1,154 +0,0 @@ -Demo -==== - - -Consider the following QP - - -.. math:: - \begin{array}{ll} - \mbox{minimize} & \frac{1}{2} x^T \begin{bmatrix}4 & 1\\ 1 & 2 \end{bmatrix} x + \begin{bmatrix}1 \\ 1\end{bmatrix}^T x \\ - \mbox{subject to} & \begin{bmatrix}1 \\ 0 \\ 0\end{bmatrix} \leq \begin{bmatrix} 1 & 1\\ 1 & 0\\ 0 & 1\end{bmatrix} x \leq \begin{bmatrix}1 \\ 0.7 \\ 0.7\end{bmatrix} - \end{array} - - - -We show below how to solve the problem in Python, Matlab, Julia and C. - - - -Python ------- - -.. code:: python - - import osqp - import scipy.sparse as sparse - import numpy as np - - # Define problem data - P = sparse.csc_matrix([[4, 1], [1, 2]]) - q = np.array([1, 1]) - A = sparse.csc_matrix([[1, 1], [1, 0], [0, 1]]) - l = np.array([1, 0, 0]) - u = np.array([1, 0.7, 0.7]) - - # Create an OSQP object - prob = osqp.OSQP() - - # Setup workspace and change alpha parameter - prob.setup(P, q, A, l, u, alpha=1.0) - - # Solve problem - res = prob.solve() - - - -Matlab ------- - -.. code:: matlab - - % Define problem data - P = sparse([4, 1; 1, 2]); - q = [1; 1]; - A = sparse([1, 1; 1, 0; 0, 1]); - l = [1; 0; 0]; - u = [1; 0.7; 0.7]; - - % Create an OSQP object - prob = osqp; - - % Setup workspace and change alpha parameter - prob.setup(P, q, A, l, u, 'alpha', 1); - - % Solve problem - res = prob.solve(); - - - -Julia ------- - -.. code:: julia - - import OSQP - - # Define problem data - P = sparse([4. 1.; 1. 2.]) - q = [1.; 1.] - A = sparse([1. 1.; 1. 0.; 0. 1.]) - u = [1.; 0.7; 0.7] - l = [1.; 0.; 0.] - - # Crate OSQP object - prob = OSQP.Model() - - # Setup workspace and change alpha parameter - OSQP.setup!(prob; P=P, q=q, A=A, l=l, u=u, alpha=1) - - # Solve problem - results = OSQP.solve!(prob) - - - -C -- - -.. code:: c - - #include "osqp.h" - - int main(int argc, char **argv) { - // Load problem data - c_float P_x[4] = {4.00, 1.00, 1.00, 2.00, }; - c_int P_nnz = 4; - c_int P_i[4] = {0, 1, 0, 1, }; - c_int P_p[3] = {0, 2, 4, }; - c_float q[2] = {1.00, 1.00, }; - c_float A_x[4] = {1.00, 1.00, 1.00, 1.00, }; - c_int A_nnz = 4; - c_int A_i[4] = {0, 1, 0, 2, }; - c_int A_p[3] = {0, 2, 4, }; - c_float l[3] = {1.00, 0.00, 0.00, }; - c_float u[3] = {1.00, 0.70, 0.70, }; - c_int n = 2; - c_int m = 3; - - // Problem settings - OSQPSettings * settings = (OSQPSettings *)c_malloc(sizeof(OSQPSettings)); - - // Structures - OSQPWorkspace * work; // Workspace - OSQPData * data; // OSQPData - - // Populate data - data = (OSQPData *)c_malloc(sizeof(OSQPData)); - data->n = n; - data->m = m; - data->P = csc_matrix(data->n, data->n, P_nnz, P_x, P_i, P_p); - data->q = q; - data->A = csc_matrix(data->m, data->n, A_nnz, A_x, A_i, A_p); - data->l = l; - data->u = u; - - - // Define Solver settings as default - osqp_set_default_settings(settings); - settings->alpha = 1.0; // Change alpha parameter - - // Setup workspace - work = osqp_setup(data, settings); - - // Solve Problem - osqp_solve(work); - - // Cleanup - osqp_cleanup(work); - c_free(data->A); - c_free(data->P); - c_free(data); - c_free(settings); - - return 0; - }; diff --git a/docs/examples/index.rst b/docs/examples/index.rst index 6aa368f89..86cd66ef3 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -2,10 +2,23 @@ Examples ======== +Demo +---- + +.. toctree:: + :maxdepth: 1 + + setup-and-solve.rst + update-vectors.rst + update-matrices.rst + + +Applications +------------ + .. toctree:: :maxdepth: 1 - demo.rst huber.rst lasso.rst least-squares.rst diff --git a/docs/solver/index.rst b/docs/solver/index.rst index 94ff48f60..2cace48e1 100644 --- a/docs/solver/index.rst +++ b/docs/solver/index.rst @@ -1,5 +1,5 @@ The solver -=========== +========== Problem statement ----------------- @@ -21,7 +21,7 @@ and vectors :math:`l \in \mathbf{R}^{m} \cup \{-\infty\}^{m}`, Algorithm -------------------------- +--------- The solver runs the following `ADMM algorithm `_ (for more details see the related papers at the :ref:`citing` section): @@ -38,7 +38,7 @@ where :math:`\Pi` is the projection onto the hyperbox :math:`[l,u]`. Linear system solution -^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^ The linear system solution is the core part of the algorithm. It can be done using a **direct** or **indirect** method. @@ -94,7 +94,7 @@ We set the tolerance levels as .. _rho_step_size : :math:`\rho` step-size -^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^ To ensure quick convergence of the algorithm we adapt :math:`\rho` by balancing the residuals. In default mode, the inteval (*i.e.*, number of iterations) at which we update :math:`\rho` is defined by a time measurement. When the iterations time becomes greater than a certain fraction of the setup time, *i.e.* :code:`adaptive_rho_fraction`, we set the current number of iterations as the interval to update :math:`\rho`. diff --git a/examples/osqp_demo.c b/examples/osqp_demo.c index 355b1cb21..635e559d0 100644 --- a/examples/osqp_demo.c +++ b/examples/osqp_demo.c @@ -1,30 +1,22 @@ -#include "stdio.h" #include "osqp.h" int main(int argc, char **argv) { // Load problem data - c_float P_x[4] = - { 4.00000000000000000000, 1.00000000000000000000, 1.00000000000000000000, - 2.00000000000000000000, }; + c_float P_x[4] = { 4.0, 1.0, 1.0, 2.0, }; c_int P_nnz = 4; c_int P_i[4] = { 0, 1, 0, 1, }; c_int P_p[3] = { 0, 2, 4, }; - c_float q[2] = { 1.00000000000000000000, 1.00000000000000000000, }; - c_float A_x[4] = - { 1.00000000000000000000, 1.00000000000000000000, 1.00000000000000000000, - 1.00000000000000000000, }; + c_float q[2] = { 1.0, 1.0, }; + c_float A_x[4] = { 1.0, 1.0, 1.0, 1.0, }; c_int A_nnz = 4; c_int A_i[4] = { 0, 1, 0, 2, }; c_int A_p[3] = { 0, 2, 4, }; - c_float l[3] = - { 1.00000000000000000000, 0.00000000000000000000, 0.00000000000000000000, }; - c_float u[3] = - { 1.00000000000000000000, 0.69999999999999995559, 0.69999999999999995559, }; + c_float l[3] = { 1.0, 0.0, 0.0, }; + c_float u[3] = { 1.0, 0.7, 0.7, }; c_int n = 2; c_int m = 3; - // Problem settings OSQPSettings *settings = (OSQPSettings *)c_malloc(sizeof(OSQPSettings)); @@ -42,7 +34,6 @@ int main(int argc, char **argv) { data->l = l; data->u = u; - // Define Solver settings as default osqp_set_default_settings(settings); @@ -59,6 +50,5 @@ int main(int argc, char **argv) { c_free(data); c_free(settings); - return 0; } diff --git a/src/util.c b/src/util.c index d627dfeb8..bff9ed8df 100644 --- a/src/util.c +++ b/src/util.c @@ -42,7 +42,9 @@ static void print_line(void) { void print_header(void) { // Different indentation required for windows # ifdef IS_WINDOWS -# ifndef PYTHON +# ifdef PYTHON + c_print("iter "); +# else /* ifdef PYTHON */ c_print("iter "); # endif /* ifdef PYTHON */ # else /* ifdef IS_WINDOWS */ @@ -71,7 +73,7 @@ void print_setup_header(const OSQPWorkspace *work) { print_line(); c_print(" OSQP v%s - Operator Splitting QP Solver\n" " (c) Bartolomeo Stellato, Goran Banjac\n" - " University of Oxford - Stanford University 2018\n", + " University of Oxford - Stanford University 2019\n", OSQP_VERSION); print_line();