Skip to content

Commit

Permalink
Merge b864a0e into 13c02dc
Browse files Browse the repository at this point in the history
  • Loading branch information
gbanjac committed May 25, 2019
2 parents 13c02dc + b864a0e commit 4d937e7
Show file tree
Hide file tree
Showing 24 changed files with 643 additions and 167 deletions.
10 changes: 5 additions & 5 deletions docs/examples/huber.rst
Expand Up @@ -49,14 +49,14 @@ Python
+ np.multiply(10.*np.random.rand(m), 1. - ind95)
# OSQP data
Im = sparse.eye(m).tocsc()
P = sparse.block_diag((sparse.csc_matrix((n, n)), 2*Im,
sparse.csc_matrix((m, m)))).tocsc()
Im = sparse.eye(m)
P = sparse.block_diag([sparse.csc_matrix((n, n)), 2*Im,
sparse.csc_matrix((m, m))],
format='csc')
q = np.append(np.zeros(m+n), 2*np.ones(m))
A = sparse.vstack([
sparse.hstack([Ad, -Im, Im]),
sparse.hstack([Ad, -Im, -Im])
]).tocsc()
sparse.hstack([Ad, -Im, -Im])], format='csc')
l = np.hstack([b, -np.inf*np.ones(m)])
u = np.hstack([np.inf*np.ones(m), b])
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/lasso.rst
Expand Up @@ -54,11 +54,11 @@ Python
Onm = sparse.csc_matrix((n, m))
# OSQP data
P = sparse.block_diag((On, sparse.eye(m), On), format='csc')
P = sparse.block_diag([On, sparse.eye(m), On], format='csc')
q = np.zeros(2*n + m)
A = sparse.vstack([sparse.hstack([Ad, -Im, Onm.T]),
sparse.hstack([In, Onm, -In]),
sparse.hstack([In, Onm, In])]).tocsc()
sparse.hstack([In, Onm, In])], format='csc')
l = np.hstack([b, -np.inf * np.ones(n), np.zeros(n)])
u = np.hstack([b, np.zeros(n), np.inf * np.ones(n)])
Expand Down
5 changes: 2 additions & 3 deletions docs/examples/least-squares.rst
Expand Up @@ -38,12 +38,11 @@ Python
b = np.random.randn(m)
# OSQP data
P = sparse.block_diag((sparse.csc_matrix((n, n)), sparse.eye(m)), format='csc')
P = sparse.block_diag([sparse.csc_matrix((n, n)), sparse.eye(m)], format='csc')
q = np.zeros(n+m)
A = sparse.vstack([
sparse.hstack([Ad, -sparse.eye(m)]),
sparse.hstack((sparse.eye(n), sparse.csc_matrix((n, m))))
]).tocsc()
sparse.hstack([sparse.eye(n), sparse.csc_matrix((n, m))])], format='csc')
l = np.hstack([b, np.zeros(n)])
u = np.hstack([b, np.ones(n)])
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/mpc.rst
Expand Up @@ -81,7 +81,7 @@ Python
# Cast MPC problem to a QP: x = (x(0),x(1),...,x(N),u(0),...,u(N-1))
# - quadratic objective
P = sparse.block_diag([sparse.kron(sparse.eye(N), Q), QN,
sparse.kron(sparse.eye(N), R)]).tocsc()
sparse.kron(sparse.eye(N), R)], format='csc')
# - linear objective
q = np.hstack([np.kron(np.ones(N), -Q.dot(xr)), -QN.dot(xr),
np.zeros(N*nu)])
Expand All @@ -96,7 +96,7 @@ Python
lineq = np.hstack([np.kron(np.ones(N+1), xmin), np.kron(np.ones(N), umin)])
uineq = np.hstack([np.kron(np.ones(N+1), xmax), np.kron(np.ones(N), umax)])
# - OSQP constraints
A = sparse.vstack([Aeq, Aineq]).tocsc()
A = sparse.vstack([Aeq, Aineq], format='csc')
l = np.hstack([leq, lineq])
u = np.hstack([ueq, uineq])
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/portfolio.rst
Expand Up @@ -54,13 +54,13 @@ Python
gamma = 1
# OSQP data
P = sparse.block_diag((D, sparse.eye(k)), format='csc')
P = sparse.block_diag([D, sparse.eye(k)], format='csc')
q = np.hstack([-mu / (2*gamma), np.zeros(k)])
A = sparse.vstack([
sparse.hstack([F.T, -sparse.eye(k)]),
sparse.hstack([sparse.csc_matrix(np.ones((1, n))), sparse.csc_matrix((1, k))]),
sparse.hstack((sparse.eye(n), sparse.csc_matrix((n, k))))
]).tocsc()
], format='csc')
l = np.hstack([np.zeros(k), 1., np.zeros(n)])
u = np.hstack([np.zeros(k), 1., np.ones(n)])
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/svm.rst
Expand Up @@ -45,16 +45,16 @@ Python
Ad = sparse.vstack([
A_upp / np.sqrt(n) + (A_upp != 0.).astype(float) / n,
A_low / np.sqrt(n) - (A_low != 0.).astype(float) / n
]).tocsc()
], format='csc')
# OSQP data
Im = sparse.eye(m)
P = sparse.block_diag((sparse.eye(n), sparse.csc_matrix((m, m))), format='csc')
P = sparse.block_diag([sparse.eye(n), sparse.csc_matrix((m, m))], format='csc')
q = np.hstack([np.zeros(n), gamma*np.ones(m)])
A = sparse.vstack([
sparse.hstack([sparse.diags(b).dot(Ad), -Im]),
sparse.hstack([sparse.csc_matrix((m, n)), Im])
]).tocsc()
], format='csc')
l = np.hstack([-np.inf*np.ones(m), np.zeros(m)])
u = np.hstack([-np.ones(m), np.inf*np.ones(m)])
Expand Down Expand Up @@ -126,7 +126,7 @@ CVXPY
A = sparse.vstack([
A_upp / np.sqrt(n) + (A_upp != 0.).astype(float) / n,
A_low / np.sqrt(n) - (A_low != 0.).astype(float) / n
]).tocsc()
], format='csc')
# Define problem
x = Variable(n)
Expand Down
40 changes: 15 additions & 25 deletions include/constants.h
Expand Up @@ -31,14 +31,14 @@ extern "C" {
# define OSQP_SOLVED_INACCURATE (2)
# define OSQP_SOLVED (1)
# define OSQP_MAX_ITER_REACHED (-2)
# define OSQP_PRIMAL_INFEASIBLE (-3) /* primal infeasible */
# define OSQP_DUAL_INFEASIBLE (-4) /* dual infeasible */
# define OSQP_SIGINT (-5) /* interrupted by user */
# define OSQP_PRIMAL_INFEASIBLE (-3) /* primal infeasible */
# define OSQP_DUAL_INFEASIBLE (-4) /* dual infeasible */
# define OSQP_SIGINT (-5) /* interrupted by user */
# ifdef PROFILING
# define OSQP_TIME_LIMIT_REACHED (-6)
# endif // ifdef PROFILING
# define OSQP_NON_CVX (-7) /* problem non convex */
# define OSQP_UNSOLVED (-10) /* Unsolved. Only setup function has been called */
# define OSQP_NON_CVX (-7) /* problem non convex */
# define OSQP_UNSOLVED (-10) /* Unsolved. Only setup function has been called */


/*************************
Expand Down Expand Up @@ -66,8 +66,7 @@ static const char *LINSYS_SOLVER_NAME[] = {
# define RHO_MIN (1e-06)
# define RHO_MAX (1e06)
# define RHO_EQ_OVER_RHO_INEQ (1e03)
# define RHO_TOL (1e-04) ///< Tolerance for detecting if an inequality is set to
// equality
# define RHO_TOL (1e-04) ///< tolerance for detecting if an inequality is set to equality


# ifndef EMBEDDED
Expand All @@ -82,43 +81,34 @@ static const char *LINSYS_SOLVER_NAME[] = {
# define WARM_START (1)
# define SCALING (10)

# define MIN_SCALING (1e-04) ///< Minimum scaling value
# define MAX_SCALING (1e+04) ///< Maximum scaling value
# define MIN_SCALING (1e-04) ///< minimum scaling value
# define MAX_SCALING (1e+04) ///< maximum scaling value


# ifndef OSQP_NULL
# define OSQP_NULL 0
# endif /* ifndef OSQP_NULL */

# ifndef OSQP_NAN
# define OSQP_NAN ((c_float)0x7fc00000UL) // Not a Number
# define OSQP_NAN ((c_float)0x7fc00000UL) // not a number
# endif /* ifndef OSQP_NAN */

# ifndef OSQP_INFTY
# define OSQP_INFTY ((c_float)1e20) // Infinity
# define OSQP_INFTY ((c_float)1e20) // infinity
# endif /* ifndef OSQP_INFTY */


# if EMBEDDED != 1
# define ADAPTIVE_RHO (1)
# define ADAPTIVE_RHO_INTERVAL (0)
# define ADAPTIVE_RHO_FRACTION (0.4) ///< Fraction of setup time
// after which we update rho
# define ADAPTIVE_RHO_MULTIPLE_TERMINATION (4) ///< Multiple of termination
// check time we update rho if
// profiling disabled
# define ADAPTIVE_RHO_FIXED (100) ///< Number of iterations after
// which we update rho if
// termination check if disabled
// and profiling disabled
# define ADAPTIVE_RHO_TOLERANCE (5) ///< Tolerance for adopting new
// rho. Number of times the new
// rho is larger or smaller than
// the current one
# define ADAPTIVE_RHO_FRACTION (0.4) ///< fraction of setup time after which we update rho
# define ADAPTIVE_RHO_MULTIPLE_TERMINATION (4) ///< multiple of check_termination after which we update rho (if PROFILING disabled)
# define ADAPTIVE_RHO_FIXED (100) ///< number of iterations after which we update rho if termination_check and PROFILING are disabled
# define ADAPTIVE_RHO_TOLERANCE (5) ///< tolerance for adopting new rho; minimum ratio between new rho and the current one
# endif // if EMBEDDED != 1

# ifdef PROFILING
# define TIME_LIMIT (0) ///< Disable time limit as default
# define TIME_LIMIT (0) ///< Disable time limit as default
# endif // ifdef PROFILING

/* Printing */
Expand Down

0 comments on commit 4d937e7

Please sign in to comment.