Skip to content

Commit

Permalink
Add examples in docs for updating vectors and matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
gbanjac committed May 8, 2019
1 parent c60bb3c commit 4192f47
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 179 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion 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.

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -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
Expand Down
154 changes: 0 additions & 154 deletions docs/examples/demo.rst

This file was deleted.

15 changes: 14 additions & 1 deletion docs/examples/index.rst
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docs/solver/index.rst
@@ -1,5 +1,5 @@
The solver
===========
==========

Problem statement
-----------------
Expand All @@ -21,7 +21,7 @@ and vectors :math:`l \in \mathbf{R}^{m} \cup \{-\infty\}^{m}`,


Algorithm
-------------------------
---------

The solver runs the following `ADMM algorithm <http://web.stanford.edu/~boyd/papers/admm_distr_stats.html>`_ (for more details see the related papers at the :ref:`citing` section):

Expand All @@ -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.

Expand Down Expand Up @@ -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`.
Expand Down
20 changes: 5 additions & 15 deletions 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));

Expand All @@ -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);

Expand All @@ -59,6 +50,5 @@ int main(int argc, char **argv) {
c_free(data);
c_free(settings);


return 0;
}
6 changes: 4 additions & 2 deletions src/util.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 4192f47

Please sign in to comment.