Notebook
In [1]:
import quantopian.research as qr
import numpy as np
import matplotlib.pyplot as plt
import cvxopt as opt
from cvxopt import blas, solvers
import pandas as pd
In [2]:
#Specify the assets and the timeframe
stocks = ['MSFT','IBM','GE','MCD']
start_dt = '2013-01-01'
end_dt = '2017-10-31'
In [3]:
#Get Prices
price_data = qr.prices(stocks,start_dt,end_dt,frequency='daily',price_field='price')
price_data.head()
Out[3]:
Equity(5061 [MSFT]) Equity(3766 [IBM]) Equity(3149 [GE]) Equity(4707 [MCD])
2013-01-02 00:00:00+00:00 24.240 170.551 18.220 77.564
2013-01-03 00:00:00+00:00 24.007 169.586 18.015 78.029
2013-01-04 00:00:00+00:00 23.549 168.491 18.101 77.358
2013-01-07 00:00:00+00:00 23.505 167.814 18.032 78.262
2013-01-08 00:00:00+00:00 23.355 167.484 17.844 78.253
In [4]:
#Get Returns
return_data = qr.returns(stocks,start_dt,end_dt,periods=1,frequency='daily',price_field='price')
return_data.head()
Out[4]:
Equity(5061 [MSFT]) Equity(3766 [IBM]) Equity(3149 [GE]) Equity(4707 [MCD])
2013-01-02 00:00:00+00:00 0.030875 0.024903 0.016174 0.020955
2013-01-03 00:00:00+00:00 -0.009612 -0.005658 -0.011251 0.005995
2013-01-04 00:00:00+00:00 -0.019078 -0.006457 0.004774 -0.008599
2013-01-07 00:00:00+00:00 -0.001868 -0.004018 -0.003812 0.011686
2013-01-08 00:00:00+00:00 -0.006382 -0.001966 -0.010426 -0.000115
In [5]:
return_vector = return_data.T.as_matrix()
return_vector
Out[5]:
array([[ 0.03087522, -0.00961221, -0.01907777, ...,  0.06438095,
         0.00023861, -0.00787214],
       [ 0.0249028 , -0.00565813, -0.0064569 , ...,  0.0004557 ,
         0.00435971, -0.00168448],
       [ 0.01617401, -0.01125137,  0.0047738 , ..., -0.02485929,
        -0.01827802, -0.0122489 ],
       [ 0.02095509,  0.00599505, -0.00859937, ...,  0.00832292,
         0.00520046,  0.00403056]])
In [6]:
plt.plot(return_vector.T, alpha=.4);
plt.xlabel('time')
plt.ylabel('returns')
Out[6]:
<matplotlib.text.Text at 0x7f9cd7551b90>
In [7]:
#Functions for generating random weights
def rand_weights(n):
    k = np.random.rand(n)
    return k / sum(k)
In [8]:
def random_portfolio(returns):

    p = np.asmatrix(np.mean(returns, axis=1))
    w = np.asmatrix(rand_weights(returns.shape[0]))
    C = np.asmatrix(np.cov(returns))
    
    mu = w * p.T
    sigma = np.sqrt(w * C * w.T)
    
    # This recursion reduces outliers to keep plots pretty
    if sigma > 2:
        return random_portfolio(returns)
    return mu, sigma
In [9]:
n_portfolios = 5000
means, stds = np.column_stack([
    random_portfolio(return_vector) 
    for _ in xrange(n_portfolios)
])
In [10]:
plt.plot(stds, means, 'o', markersize=5)
plt.xlabel('Standard Deviation of Returns')
plt.ylabel('Average Return')
plt.title('Risk and Reward of Randomly Generated Portfolios')
Out[10]:
<matplotlib.text.Text at 0x7f9cd6af8f50>
In [11]:
def optimal_portfolio(returns):
    n = len(returns)
    returns = np.asmatrix(returns)
    
    N = 100
    mus = [10**(5.0 * t/N - 1.0) for t in range(N)]
    
    # Convert to cvxopt matrices
    S = opt.matrix(np.cov(returns))
    pbar = opt.matrix(np.mean(returns, axis=1))
    
    # Create constraint matrices
    G = -opt.matrix(np.eye(n))   # negative n x n identity matrix
    h = opt.matrix(0.0, (n ,1))
    A = opt.matrix(1.0, (1, n))
    b = opt.matrix(1.0)
    
    # Calculate efficient frontier weights using quadratic programming
    portfolios = [solvers.qp(mu*S, -pbar, G, h, A, b)['x'] 
                  for mu in mus]
    ## CALCULATE RISKS AND RETURNS FOR FRONTIER
    returns = [blas.dot(pbar, x) for x in portfolios]
    risks = [np.sqrt(blas.dot(x, S*x)) for x in portfolios]
    ## CALCULATE THE 2ND DEGREE POLYNOMIAL OF THE FRONTIER CURVE
    m1 = np.polyfit(returns, risks, 2)
    x1 = np.sqrt(m1[2] / m1[0])
    # CALCULATE THE OPTIMAL PORTFOLIO
    wt = solvers.qp(opt.matrix(x1 * S), -pbar, G, h, A, b)['x']
    return np.asarray(wt), returns, risks

weights, returns, risks = optimal_portfolio(return_vector)

plt.plot(stds, means, 'o')
plt.xlabel('Standard Deviation of Returns')
plt.ylabel('Average Return')
plt.plot(risks, returns, 'y-o')
     pcost       dcost       gap    pres   dres
 0: -4.9608e-04 -1.0011e+00  1e+00  1e-16  3e+00
 1: -4.9647e-04 -1.1133e-02  1e-02  1e-16  3e-02
 2: -5.3234e-04 -1.2331e-03  7e-04  1e-16  2e-03
 3: -1.0848e-03 -1.3852e-03  3e-04  4e-16  4e-04
 4: -1.1264e-03 -1.1314e-03  5e-06  2e-16  7e-06
 5: -1.1288e-03 -1.1289e-03  5e-08  1e-16  7e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9564e-04 -1.0011e+00  1e+00  2e-16  3e+00
 1: -4.9604e-04 -1.1133e-02  1e-02  2e-16  3e-02
 2: -5.3190e-04 -1.2324e-03  7e-04  1e-16  2e-03
 3: -1.0844e-03 -1.3839e-03  3e-04  7e-16  4e-04
 4: -1.1252e-03 -1.1302e-03  5e-06  4e-18  6e-06
 5: -1.1276e-03 -1.1276e-03  5e-08  3e-19  6e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9516e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.9555e-04 -1.1132e-02  1e-02  1e-16  3e-02
 2: -5.3140e-04 -1.2316e-03  7e-04  8e-17  2e-03
 3: -1.0840e-03 -1.3824e-03  3e-04  4e-16  4e-04
 4: -1.1239e-03 -1.1288e-03  5e-06  1e-18  6e-06
 5: -1.1262e-03 -1.1262e-03  5e-08  1e-16  6e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9461e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.9501e-04 -1.1131e-02  1e-02  1e-16  3e-02
 2: -5.3084e-04 -1.2307e-03  7e-04  7e-17  2e-03
 3: -1.0835e-03 -1.3807e-03  3e-04  3e-16  4e-04
 4: -1.1224e-03 -1.1272e-03  5e-06  4e-18  6e-06
 5: -1.1246e-03 -1.1247e-03  5e-08  1e-16  6e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9400e-04 -1.0011e+00  1e+00  1e-16  3e+00
 1: -4.9440e-04 -1.1130e-02  1e-02  1e-16  3e-02
 2: -5.3021e-04 -1.2297e-03  7e-04  8e-17  2e-03
 3: -1.0829e-03 -1.3788e-03  3e-04  2e-16  4e-04
 4: -1.1207e-03 -1.1255e-03  5e-06  3e-16  6e-06
 5: -1.1229e-03 -1.1229e-03  5e-08  2e-16  6e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9331e-04 -1.0011e+00  1e+00  1e-16  3e+00
 1: -4.9371e-04 -1.1129e-02  1e-02  1e-16  3e-02
 2: -5.2950e-04 -1.2285e-03  7e-04  9e-17  2e-03
 3: -1.0823e-03 -1.3766e-03  3e-04  4e-16  4e-04
 4: -1.1188e-03 -1.1235e-03  5e-06  3e-18  6e-06
 5: -1.1209e-03 -1.1210e-03  5e-08  1e-19  6e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9254e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.9294e-04 -1.1128e-02  1e-02  1e-16  3e-02
 2: -5.2871e-04 -1.2273e-03  7e-04  1e-16  2e-03
 3: -1.0816e-03 -1.3742e-03  3e-04  3e-16  4e-04
 4: -1.1167e-03 -1.1213e-03  5e-06  1e-16  6e-06
 5: -1.1187e-03 -1.1188e-03  5e-08  2e-16  6e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9168e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.9207e-04 -1.1127e-02  1e-02  8e-17  3e-02
 2: -5.2782e-04 -1.2258e-03  7e-04  1e-16  2e-03
 3: -1.0809e-03 -1.3715e-03  3e-04  4e-16  4e-04
 4: -1.1143e-03 -1.1188e-03  5e-06  3e-16  6e-06
 5: -1.1163e-03 -1.1163e-03  5e-08  2e-16  6e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9071e-04 -1.0011e+00  1e+00  2e-16  3e+00
 1: -4.9110e-04 -1.1125e-02  1e-02  6e-17  3e-02
 2: -5.2683e-04 -1.2242e-03  7e-04  9e-17  2e-03
 3: -1.0800e-03 -1.3685e-03  3e-04  4e-16  3e-04
 4: -1.1116e-03 -1.1161e-03  4e-06  2e-16  5e-06
 5: -1.1135e-03 -1.1135e-03  4e-08  2e-16  5e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.8962e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.9002e-04 -1.1123e-02  1e-02  1e-16  3e-02
 2: -5.2571e-04 -1.2224e-03  7e-04  2e-16  2e-03
 3: -1.0791e-03 -1.3651e-03  3e-04  7e-16  3e-04
 4: -1.1086e-03 -1.1130e-03  4e-06  2e-16  5e-06
 5: -1.1104e-03 -1.1104e-03  4e-08  1e-16  5e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.8840e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.8880e-04 -1.1122e-02  1e-02  2e-16  3e-02
 2: -5.2446e-04 -1.2204e-03  7e-04  1e-16  2e-03
 3: -1.0781e-03 -1.3613e-03  3e-04  3e-17  3e-04
 4: -1.1053e-03 -1.1095e-03  4e-06  2e-16  5e-06
 5: -1.1069e-03 -1.1070e-03  4e-08  2e-16  5e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.8703e-04 -1.0011e+00  1e+00  1e-16  3e+00
 1: -4.8743e-04 -1.1119e-02  1e-02  1e-16  3e-02
 2: -5.2305e-04 -1.2181e-03  7e-04  7e-17  2e-03
 3: -1.0769e-03 -1.3571e-03  3e-04  4e-16  3e-04
 4: -1.1015e-03 -1.1056e-03  4e-06  2e-18  4e-06
 5: -1.1030e-03 -1.1030e-03  4e-08  1e-16  4e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.8549e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.8589e-04 -1.1117e-02  1e-02  9e-17  3e-02
 2: -5.2147e-04 -1.2156e-03  7e-04  2e-16  2e-03
 3: -1.0757e-03 -1.3523e-03  3e-04  4e-16  3e-04
 4: -1.0973e-03 -1.1012e-03  4e-06  4e-18  4e-06
 5: -1.0986e-03 -1.0987e-03  4e-08  9e-20  4e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.8377e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.8416e-04 -1.1114e-02  1e-02  8e-17  3e-02
 2: -5.1970e-04 -1.2127e-03  7e-04  2e-16  2e-03
 3: -1.0744e-03 -1.3470e-03  3e-04  2e-16  3e-04
 4: -1.0926e-03 -1.0962e-03  4e-06  2e-18  4e-06
 5: -1.0937e-03 -1.0937e-03  4e-08  2e-16  4e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.8184e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.8223e-04 -1.1111e-02  1e-02  7e-17  3e-02
 2: -5.1771e-04 -1.2095e-03  7e-04  1e-16  2e-03
 3: -1.0729e-03 -1.3410e-03  3e-04  2e-16  2e-04
 4: -1.0873e-03 -1.0907e-03  3e-06  1e-18  3e-06
 5: -1.0882e-03 -1.0882e-03  3e-08  2e-16  3e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.7967e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.8006e-04 -1.1108e-02  1e-02  2e-16  3e-02
 2: -5.1548e-04 -1.2059e-03  7e-04  2e-16  2e-03
 3: -1.0713e-03 -1.3343e-03  3e-04  2e-16  2e-04
 4: -1.0813e-03 -1.0845e-03  3e-06  2e-16  3e-06
 5: -1.0820e-03 -1.0820e-03  3e-08  1e-16  3e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.7723e-04 -1.0011e+00  1e+00  1e-16  3e+00
 1: -4.7762e-04 -1.1104e-02  1e-02  1e-16  3e-02
 2: -5.1298e-04 -1.2019e-03  7e-04  0e+00  2e-03
 3: -1.0679e-03 -1.3263e-03  3e-04  2e-16  2e-04
 4: -1.0745e-03 -1.0775e-03  3e-06  2e-16  2e-06
 5: -1.0750e-03 -1.0751e-03  3e-08  1e-16  2e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.7450e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.7489e-04 -1.1100e-02  1e-02  2e-16  3e-02
 2: -5.1018e-04 -1.1974e-03  7e-04  1e-16  2e-03
 3: -1.0595e-03 -1.3160e-03  3e-04  4e-16  2e-04
 4: -1.0665e-03 -1.0697e-03  3e-06  2e-16  2e-06
 5: -1.0672e-03 -1.0673e-03  3e-08  1e-16  2e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.7143e-04 -1.0011e+00  1e+00  1e-16  3e+00
 1: -4.7182e-04 -1.1095e-02  1e-02  1e-16  3e-02
 2: -5.0703e-04 -1.1923e-03  7e-04  8e-17  2e-03
 3: -1.0501e-03 -1.3045e-03  3e-04  3e-16  2e-04
 4: -1.0575e-03 -1.0609e-03  3e-06  2e-16  2e-06
 5: -1.0585e-03 -1.0585e-03  3e-08  1e-16  2e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.6799e-04 -1.0011e+00  1e+00  1e-16  3e+00
 1: -4.6838e-04 -1.1090e-02  1e-02  1e-16  3e-02
 2: -5.0350e-04 -1.1867e-03  7e-04  7e-17  2e-03
 3: -1.0397e-03 -1.2915e-03  3e-04  4e-16  2e-04
 4: -1.0475e-03 -1.0511e-03  4e-06  2e-16  2e-06
 5: -1.0486e-03 -1.0487e-03  4e-08  2e-16  2e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.6413e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.6452e-04 -1.1084e-02  1e-02  4e-17  3e-02
 2: -4.9954e-04 -1.1803e-03  7e-04  1e-16  2e-03
 3: -1.0272e-03 -1.2768e-03  2e-04  4e-16  1e-04
 4: -1.0361e-03 -1.0400e-03  4e-06  2e-16  2e-06
 5: -1.0376e-03 -1.0377e-03  4e-08  2e-20  2e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.5980e-04 -1.0011e+00  1e+00  2e-16  3e+00
 1: -4.6019e-04 -1.1077e-02  1e-02  2e-16  3e-02
 2: -4.9510e-04 -1.1731e-03  7e-04  7e-17  2e-03
 3: -1.0131e-03 -1.2602e-03  2e-04  7e-16  1e-04
 4: -1.0233e-03 -1.0276e-03  4e-06  2e-16  2e-06
 5: -1.0252e-03 -1.0253e-03  4e-08  4e-16  2e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.5494e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.5533e-04 -1.1070e-02  1e-02  6e-17  3e-02
 2: -4.9011e-04 -1.1651e-03  7e-04  1e-16  2e-03
 3: -9.9748e-04 -1.2415e-03  2e-04  2e-16  1e-04
 4: -1.0089e-03 -1.0137e-03  5e-06  2e-16  2e-06
 5: -1.0114e-03 -1.0114e-03  5e-08  2e-16  2e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.4949e-04 -1.0011e+00  1e+00  0e+00  3e+00
 1: -4.4988e-04 -1.1061e-02  1e-02  6e-17  3e-02
 2: -4.8453e-04 -1.1561e-03  7e-04  4e-17  2e-03
 3: -9.8027e-04 -1.2207e-03  2e-04  4e-16  8e-05
 4: -9.9281e-04 -9.9808e-04  5e-06  1e-16  2e-06
 5: -9.9578e-04 -9.9584e-04  5e-08  1e-16  2e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.4337e-04 -1.0011e+00  1e+00  2e-16  3e+00
 1: -4.4376e-04 -1.1052e-02  1e-02  1e-16  3e-02
 2: -4.7826e-04 -1.1461e-03  7e-04  6e-17  2e-03
 3: -9.6137e-04 -1.1974e-03  2e-04  2e-16  6e-05
 4: -9.7475e-04 -9.8057e-04  6e-06  3e-19  1e-06
 5: -9.7831e-04 -9.7837e-04  6e-08  1e-16  1e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.3651e-04 -1.0010e+00  1e+00  2e-16  3e+00
 1: -4.3689e-04 -1.1041e-02  1e-02  1e-16  3e-02
 2: -4.7123e-04 -1.1348e-03  7e-04  7e-17  2e-03
 3: -9.4069e-04 -1.1714e-03  2e-04  2e-16  4e-05
 4: -9.5454e-04 -9.6094e-04  6e-06  2e-16  1e-06
 5: -9.5869e-04 -9.5877e-04  8e-08  4e-16  1e-08
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.2881e-04 -1.0010e+00  1e+00  0e+00  3e+00
 1: -4.2919e-04 -1.1029e-02  1e-02  1e-16  3e-02
 2: -4.6335e-04 -1.1221e-03  7e-04  2e-16  2e-03
 3: -9.1815e-04 -1.1424e-03  2e-04  4e-16  1e-05
 4: -9.3200e-04 -9.3896e-04  7e-06  3e-16  3e-07
 5: -9.3666e-04 -9.3678e-04  1e-07  1e-16  4e-09
 6: -9.3675e-04 -9.3675e-04  1e-09  6e-20  4e-11
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.2017e-04 -1.0010e+00  1e+00  4e-16  3e+00
 1: -4.2055e-04 -1.1016e-02  1e-02  2e-16  3e-02
 2: -4.5451e-04 -1.1079e-03  7e-04  1e-16  2e-03
 3: -8.9001e-04 -1.1095e-03  2e-04  4e-16  7e-19
 4: -9.0661e-04 -9.1441e-04  8e-06  1e-16  3e-19
 5: -9.1186e-04 -9.1210e-04  2e-07  2e-16  3e-19
 6: -9.1208e-04 -9.1208e-04  2e-09  3e-16  2e-20
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.1047e-04 -1.0010e+00  1e+00  0e+00  3e+00
 1: -4.1085e-04 -1.1001e-02  1e-02  1e-16  3e-02
 2: -4.4460e-04 -1.0920e-03  6e-04  1e-16  2e-03
 3: -8.5771e-04 -1.0728e-03  2e-04  2e-17  5e-19
 4: -8.7850e-04 -8.8712e-04  9e-06  2e-16  3e-19
 5: -8.8390e-04 -8.8443e-04  5e-07  3e-16  2e-19
 6: -8.8439e-04 -8.8439e-04  7e-09  1e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -3.9960e-04 -1.0010e+00  1e+00  0e+00  3e+00
 1: -3.9997e-04 -1.0984e-02  1e-02  1e-16  3e-02
 2: -4.3349e-04 -1.0742e-03  6e-04  1e-16  2e-03
 3: -8.2405e-04 -1.0331e-03  2e-04  2e-16  2e-19
 4: -8.4829e-04 -8.5708e-04  9e-06  2e-16  2e-19
 5: -8.5274e-04 -8.5355e-04  8e-07  3e-16  3e-19
 6: -8.5325e-04 -8.5334e-04  9e-08  2e-16  3e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -3.8739e-04 -1.0010e+00  1e+00  0e+00  3e+00
 1: -3.8777e-04 -1.0965e-02  1e-02  2e-16  3e-02
 2: -4.2104e-04 -1.0542e-03  6e-04  1e-16  2e-03
 3: -7.8919e-04 -9.9030e-04  2e-04  3e-16  3e-19
 4: -8.1655e-04 -8.2454e-04  8e-06  1e-16  2e-19
 5: -8.1984e-04 -8.2032e-04  5e-07  3e-16  3e-19
 6: -8.1992e-04 -8.1993e-04  1e-08  3e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -3.7370e-04 -1.0009e+00  1e+00  2e-16  3e+00
 1: -3.7407e-04 -1.0944e-02  1e-02  1e-16  3e-02
 2: -4.0707e-04 -1.0318e-03  6e-04  7e-17  2e-03
 3: -7.5332e-04 -9.4447e-04  2e-04  1e-16  7e-19
 4: -7.8407e-04 -7.9020e-04  6e-06  2e-16  4e-19
 5: -7.8691e-04 -7.8700e-04  9e-08  2e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -3.5834e-04 -1.0009e+00  1e+00  0e+00  3e+00
 1: -3.5871e-04 -1.0920e-02  1e-02  3e-17  3e-02
 2: -3.9143e-04 -1.0067e-03  6e-04  6e-17  2e-03
 3: -7.1662e-04 -8.9581e-04  2e-04  1e-16  6e-19
 4: -7.5113e-04 -7.5644e-04  5e-06  1e-16  2e-19
 5: -7.5405e-04 -7.5410e-04  5e-08  2e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -3.4110e-04 -1.0009e+00  1e+00  2e-16  3e+00
 1: -3.4147e-04 -1.0893e-02  1e-02  6e-17  3e-02
 2: -3.7389e-04 -9.7866e-04  6e-04  8e-17  2e-03
 3: -6.7928e-04 -8.4465e-04  2e-04  2e-16  2e-19
 4: -7.1695e-04 -7.2595e-04  9e-06  2e-16  2e-19
 5: -7.2086e-04 -7.2095e-04  9e-08  2e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -3.2176e-04 -1.0009e+00  1e+00  0e+00  3e+00
 1: -3.2212e-04 -1.0863e-02  1e-02  1e-16  3e-02
 2: -3.5424e-04 -9.4722e-04  6e-04  8e-17  1e-03
 3: -6.4140e-04 -7.9146e-04  2e-04  1e-16  1e-19
 4: -6.8323e-04 -6.9116e-04  8e-06  6e-17  2e-19
 5: -6.8691e-04 -6.8699e-04  8e-08  2e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -3.0006e-04 -1.0008e+00  1e+00  0e+00  3e+00
 1: -3.0042e-04 -1.0829e-02  1e-02  8e-17  3e-02
 2: -3.3222e-04 -9.1202e-04  6e-04  0e+00  1e-03
 3: -6.0305e-04 -7.3687e-04  1e-04  1e-16  7e-19
 4: -6.4925e-04 -6.5375e-04  5e-06  1e-16  3e-20
 5: -6.5176e-04 -6.5180e-04  5e-08  2e-16  1e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -2.7571e-04 -1.0008e+00  1e+00  0e+00  3e+00
 1: -2.7607e-04 -1.0791e-02  1e-02  6e-17  3e-02
 2: -3.0755e-04 -8.7264e-04  6e-04  1e-16  1e-03
 3: -5.6412e-04 -6.8164e-04  1e-04  2e-16  6e-19
 4: -6.1291e-04 -6.1610e-04  3e-06  6e-17  2e-19
 5: -6.1492e-04 -6.1495e-04  3e-08  6e-17  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -2.4839e-04 -1.0007e+00  1e+00  0e+00  3e+00
 1: -2.4875e-04 -1.0749e-02  1e-02  7e-17  3e-02
 2: -2.7993e-04 -8.2858e-04  5e-04  8e-17  1e-03
 3: -5.2437e-04 -6.2664e-04  1e-04  6e-17  4e-19
 4: -5.7369e-04 -5.7689e-04  3e-06  1e-16  5e-19
 5: -5.7591e-04 -5.7594e-04  3e-08  2e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -2.1774e-04 -1.0007e+00  1e+00  0e+00  3e+00
 1: -2.1810e-04 -1.0702e-02  1e-02  6e-17  3e-02
 2: -2.4901e-04 -7.7932e-04  5e-04  1e-16  1e-03
 3: -4.8332e-04 -5.7264e-04  9e-05  6e-17  7e-20
 4: -5.3157e-04 -5.3498e-04  3e-06  2e-16  6e-20
 5: -5.3421e-04 -5.3424e-04  3e-08  2e-16  3e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -1.8335e-04 -1.0006e+00  1e+00  1e-16  3e+00
 1: -1.8371e-04 -1.0648e-02  1e-02  1e-16  3e-02
 2: -2.1439e-04 -7.2424e-04  5e-04  1e-16  1e-03
 3: -4.4023e-04 -5.2009e-04  8e-05  2e-16  2e-19
 4: -4.8621e-04 -4.8984e-04  4e-06  6e-17  2e-19
 5: -4.8926e-04 -4.8930e-04  4e-08  1e-16  1e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -1.4477e-04 -1.0006e+00  1e+00  2e-16  3e+00
 1: -1.4512e-04 -1.0588e-02  1e-02  2e-16  3e-02
 2: -1.7564e-04 -6.6271e-04  5e-04  2e-16  1e-03
 3: -3.9394e-04 -4.7555e-04  8e-05  1e-16  1e-19
 4: -4.3672e-04 -4.4094e-04  4e-06  2e-16  1e-19
 5: -4.4048e-04 -4.4053e-04  5e-08  2e-16  3e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -1.0148e-04 -1.0005e+00  1e+00  0e+00  3e+00
 1: -1.0183e-04 -1.0521e-02  1e-02  1e-16  3e-02
 2: -1.3227e-04 -6.0042e-04  5e-04  9e-17  1e-03
 3: -3.4282e-04 -4.3615e-04  9e-05  1e-16  1e-19
 4: -3.8198e-04 -3.8802e-04  6e-06  6e-17  9e-20
 5: -3.8718e-04 -3.8727e-04  9e-08  2e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -5.2914e-05 -1.0005e+00  1e+00  2e-16  3e+00
 1: -5.3268e-05 -1.0491e-02  1e-02  7e-17  3e-02
 2: -8.3518e-05 -5.7602e-04  5e-04  1e-16  1e-03
 3: -2.8392e-04 -3.8736e-04  1e-04  1e-16  3e-19
 4: -3.2203e-04 -3.2998e-04  8e-06  2e-16  7e-20
 5: -3.2862e-04 -3.2883e-04  2e-07  1e-16  2e-19
 6: -3.2882e-04 -3.2882e-04  2e-09  1e-16  1e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.5756e-06 -1.0005e+00  1e+00  0e+00  3e+00
 1:  1.2189e-06 -1.0467e-02  1e-02  8e-17  3e-02
 2: -2.8986e-05 -5.4845e-04  5e-04  9e-17  1e-03
 3: -2.2035e-04 -3.3340e-04  1e-04  1e-16  5e-19
 4: -2.5651e-04 -2.6629e-04  1e-05  1e-16  1e-19
 5: -2.6392e-04 -2.6443e-04  5e-07  1e-16  2e-19
 6: -2.6440e-04 -2.6441e-04  6e-09  2e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  6.2710e-05 -1.0004e+00  1e+00  2e-16  3e+00
 1:  6.2348e-05 -1.0440e-02  1e-02  1e-16  3e-02
 2:  3.1964e-05 -5.1715e-04  5e-04  8e-17  1e-03
 3: -1.5165e-04 -2.7392e-04  1e-04  1e-16  3e-19
 4: -1.8506e-04 -1.9635e-04  1e-05  7e-18  1e-19
 5: -1.9232e-04 -1.9332e-04  1e-06  1e-16  1e-19
 6: -1.9313e-04 -1.9318e-04  5e-08  1e-16  3e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.3130e-04 -1.0004e+00  1e+00  0e+00  3e+00
 1:  1.3093e-04 -1.0409e-02  1e-02  1e-16  3e-02
 2:  1.0007e-04 -4.8159e-04  6e-04  1e-16  1e-03
 3: -7.7202e-05 -2.0827e-04  1e-04  1e-16  1e-19
 4: -1.0725e-04 -1.1957e-04  1e-05  1e-16  2e-19
 5: -1.1358e-04 -1.1489e-04  1e-06  5e-18  1e-19
 6: -1.1424e-04 -1.1435e-04  1e-07  6e-17  1e-19
 7: -1.1427e-04 -1.1427e-04  6e-09  6e-17  1e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.0825e-04 -1.0004e+00  1e+00  0e+00  3e+00
 1:  2.0786e-04 -1.0375e-02  1e-02  2e-16  3e-02
 2:  1.7615e-04 -4.4116e-04  6e-04  6e-17  2e-03
 3:  3.7651e-06 -1.3565e-04  1e-04  6e-17  4e-19
 4: -2.2600e-05 -3.5369e-05  1e-05  2e-16  3e-19
 5: -2.7736e-05 -2.8990e-05  1e-06  1e-16  9e-20
 6: -2.8408e-05 -2.8436e-05  3e-08  1e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.9458e-04 -1.0003e+00  1e+00  4e-16  3e+00
 1:  2.9418e-04 -1.0336e-02  1e-02  1e-16  3e-02
 2:  2.6112e-04 -3.9515e-04  7e-04  1e-16  2e-03
 3:  9.2136e-05 -5.5175e-05  1e-04  1e-16  7e-19
 4:  6.9503e-05  5.6878e-05  1e-05  7e-17  4e-19
 5:  6.5564e-05  6.4467e-05  1e-06  6e-17  1e-19
 6:  6.4858e-05  6.4778e-05  8e-08  2e-16  5e-20
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  3.9143e-04 -1.0003e+00  1e+00  0e+00  3e+00
 1:  3.9100e-04 -1.0293e-02  1e-02  1e-16  3e-02
 2:  3.5599e-04 -3.4275e-04  7e-04  1e-16  2e-03
 3:  1.8893e-04  3.4177e-05  2e-04  1e-17  3e-19
 4:  1.6986e-04  1.5788e-04  1e-05  2e-16  4e-19
 5:  1.6709e-04  1.6594e-04  1e-06  1e-16  2e-19
 6:  1.6667e-04  1.6651e-04  2e-07  7e-17  2e-19
 7:  1.6662e-04  1.6659e-04  2e-08  1e-16  4e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  5.0009e-04 -1.0002e+00  1e+00  2e-16  3e+00
 1:  4.9962e-04 -1.0245e-02  1e-02  1e-16  3e-02
 2:  4.6189e-04 -2.8304e-04  7e-04  8e-17  2e-03
 3:  2.9530e-04  1.3353e-04  2e-04  3e-17  7e-19
 4:  2.7951e-04  2.6810e-04  1e-05  1e-16  1e-19
 5:  2.7769e-04  2.7666e-04  1e-06  5e-17  3e-19
 6:  2.7756e-04  2.7749e-04  6e-08  2e-16  4e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  6.2199e-04 -1.0002e+00  1e+00  2e-16  3e+00
 1:  6.2147e-04 -1.0190e-02  1e-02  8e-17  3e-02
 2:  5.8008e-04 -2.1493e-04  8e-04  6e-17  2e-03
 3:  4.1255e-04  2.4416e-04  2e-04  1e-16  6e-19
 4:  3.9961e-04  3.8901e-04  1e-05  8e-17  2e-19
 5:  3.9849e-04  3.9777e-04  7e-07  1e-16  3e-19
 6:  3.9846e-04  3.9845e-04  1e-08  2e-16  3e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  7.5874e-04 -1.0001e+00  1e+00  2e-16  3e+00
 1:  7.5816e-04 -1.0129e-02  1e-02  1e-16  3e-02
 2:  7.1197e-04 -1.3720e-04  8e-04  9e-17  2e-03
 3:  5.4214e-04  3.6750e-04  2e-04  1e-16  4e-19
 4:  5.3159e-04  5.2205e-04  1e-05  2e-16  4e-19
 5:  5.3095e-04  5.3051e-04  4e-07  7e-18  4e-19
 6:  5.3094e-04  5.3094e-04  5e-09  2e-16  2e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  9.1215e-04 -1.0001e+00  1e+00  0e+00  3e+00
 1:  9.1148e-04 -1.0060e-02  1e-02  2e-16  3e-02
 2:  8.5911e-04 -4.8431e-05  9e-04  6e-17  2e-03
 3:  6.8570e-04  5.0516e-04  2e-04  2e-16  7e-19
 4:  6.7711e-04  6.6880e-04  8e-06  3e-17  6e-19
 5:  6.7675e-04  6.7651e-04  2e-07  1e-16  1e-18
 6:  6.7675e-04  6.7675e-04  2e-09  1e-16  9e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.0842e-03 -9.9998e-01  1e+00  3e-16  3e+00
 1:  1.0835e-03 -9.9830e-03  1e-02  7e-17  3e-02
 2:  1.0233e-03  5.2991e-05  1e-03  7e-17  2e-03
 3:  8.4508e-04  6.5895e-04  2e-04  1e-16  4e-19
 4:  8.3801e-04  8.3105e-04  7e-06  1e-16  5e-19
 5:  8.3782e-04  8.3769e-04  1e-07  4e-17  3e-19
 6:  8.3782e-04  8.3782e-04  1e-09  3e-17  4e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.2773e-03 -9.9990e-01  1e+00  0e+00  3e+00
 1:  1.2764e-03 -9.8962e-03  1e-02  1e-16  3e-02
 2:  1.2064e-03  1.6893e-04  1e-03  6e-17  3e-03
 3:  1.0223e-03  8.3092e-04  2e-04  1e-16  2e-19
 4:  1.0164e-03  1.0108e-03  6e-06  4e-17  4e-19
 5:  1.0163e-03  1.0162e-03  8e-08  1e-16  5e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.4939e-03 -9.9980e-01  1e+00  2e-16  3e+00
 1:  1.4927e-03 -9.7987e-03  1e-02  6e-17  3e-02
 2:  1.4107e-03  3.0152e-04  1e-03  8e-17  3e-03
 3:  1.2197e-03  1.0234e-03  2e-04  9e-17  1e-18
 4:  1.2146e-03  1.2096e-03  5e-06  1e-16  5e-19
 5:  1.2145e-03  1.2145e-03  6e-08  3e-17  4e-19
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.7368e-03 -9.9969e-01  1e+00  2e-16  3e+00
 1:  1.7354e-03 -9.6891e-03  1e-02  2e-16  3e-02
 2:  1.6385e-03  4.5321e-04  1e-03  1e-16  3e-03
 3:  1.4398e-03  1.2389e-03  2e-04  4e-17  1e-18
 4:  1.4352e-03  1.4307e-03  4e-06  3e-17  7e-19
 5:  1.4352e-03  1.4351e-03  5e-08  1e-17  1e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.0092e-03 -9.9957e-01  1e+00  1e-16  3e+00
 1:  2.0075e-03 -9.5659e-03  1e-02  6e-17  3e-02
 2:  1.8927e-03  6.2679e-04  1e-03  1e-16  3e-03
 3:  1.6855e-03  1.4804e-03  2e-04  1e-16  7e-19
 4:  1.6811e-03  1.6770e-03  4e-06  1e-16  1e-18
 5:  1.6811e-03  1.6811e-03  4e-08  1e-16  2e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.3148e-03 -9.9943e-01  1e+00  1e-16  3e+00
 1:  2.3127e-03 -9.4273e-03  1e-02  8e-17  3e-02
 2:  2.1764e-03  8.2545e-04  1e-03  1e-16  3e-03
 3:  1.9600e-03  1.7512e-03  2e-04  2e-16  5e-19
 4:  1.9557e-03  1.9514e-03  4e-06  1e-16  6e-19
 5:  1.9557e-03  1.9557e-03  4e-08  1e-16  1e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.6576e-03 -9.9928e-01  1e+00  0e+00  3e+00
 1:  2.6549e-03 -9.2713e-03  1e-02  1e-16  3e-02
 2:  2.4929e-03  1.0529e-03  1e-03  1e-16  3e-03
 3:  2.2669e-03  2.0550e-03  2e-04  5e-17  1e-18
 4:  2.2625e-03  2.2581e-03  4e-06  1e-16  1e-18
 5:  2.2625e-03  2.2624e-03  4e-08  3e-17  2e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  3.0420e-03 -9.9910e-01  1e+00  2e-16  3e+00
 1:  3.0386e-03 -9.0959e-03  1e-02  2e-16  3e-02
 2:  2.8461e-03  1.3132e-03  2e-03  4e-17  4e-03
 3:  2.6102e-03  2.3957e-03  2e-04  1e-16  7e-19
 4:  2.6056e-03  2.6011e-03  4e-06  1e-16  2e-18
 5:  2.6056e-03  2.6055e-03  4e-08  1e-16  2e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  3.4731e-03 -9.9891e-01  1e+00  1e-16  3e+00
 1:  3.4688e-03 -8.8984e-03  1e-02  1e-16  3e-02
 2:  3.2405e-03  1.6112e-03  2e-03  1e-16  4e-03
 3:  2.9945e-03  2.7781e-03  2e-04  2e-16  2e-18
 4:  2.9895e-03  2.9849e-03  5e-06  2e-16  5e-19
 5:  2.9895e-03  2.9895e-03  5e-08  1e-16  1e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  3.9565e-03 -9.9869e-01  1e+00  4e-16  3e+00
 1:  3.9512e-03 -8.6760e-03  1e-02  1e-16  3e-02
 2:  3.6808e-03  1.9523e-03  2e-03  8e-17  4e-03
 3:  3.4248e-03  3.2072e-03  2e-04  1e-16  1e-18
 4:  3.4195e-03  3.4147e-03  5e-06  1e-16  1e-18
 5:  3.4194e-03  3.4194e-03  5e-08  4e-17  2e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  4.4986e-03 -9.9844e-01  1e+00  0e+00  3e+00
 1:  4.4919e-03 -8.4255e-03  1e-02  1e-16  3e-02
 2:  4.1726e-03  2.3428e-03  2e-03  8e-17  4e-03
 3:  3.9069e-03  3.6890e-03  2e-04  1e-16  1e-18
 4:  3.9010e-03  3.8960e-03  5e-06  1e-17  2e-18
 5:  3.9010e-03  3.9010e-03  5e-08  1e-16  1e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  5.1064e-03 -9.9816e-01  1e+00  0e+00  3e+00
 1:  5.0980e-03 -8.1432e-03  1e-02  1e-16  3e-02
 2:  4.7220e-03  2.7896e-03  2e-03  1e-16  4e-03
 3:  4.4470e-03  4.2297e-03  2e-04  1e-16  1e-18
 4:  4.4406e-03  4.4355e-03  5e-06  1e-16  2e-18
 5:  4.4406e-03  4.4406e-03  5e-08  1e-16  2e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  5.7879e-03 -9.9785e-01  1e+00  0e+00  3e+00
 1:  5.7772e-03 -7.8249e-03  1e-02  2e-16  3e-02
 2:  5.3359e-03  3.3009e-03  2e-03  8e-17  5e-03
 3:  5.0523e-03  4.8367e-03  2e-04  9e-17  2e-18
 4:  5.0455e-03  5.0400e-03  5e-06  1e-16  2e-18
 5:  5.0454e-03  5.0454e-03  6e-08  1e-16  2e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  6.5519e-03 -9.9750e-01  1e+00  0e+00  3e+00
 1:  6.5384e-03 -7.4658e-03  1e-02  1e-16  3e-02
 2:  6.0220e-03  3.8859e-03  2e-03  1e-16  5e-03
 3:  5.7309e-03  5.5180e-03  2e-04  8e-17  4e-18
 4:  5.7235e-03  5.7178e-03  6e-06  2e-16  3e-18
 5:  5.7235e-03  5.7234e-03  6e-08  1e-16  1e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  7.4083e-03 -9.9710e-01  1e+00  0e+00  3e+00
 1:  7.3913e-03 -7.0605e-03  1e-02  2e-16  4e-02
 2:  6.7891e-03  4.5550e-03  2e-03  5e-17  5e-03
 3:  6.4916e-03  6.2827e-03  2e-04  2e-16  2e-18
 4:  6.4838e-03  6.4779e-03  6e-06  5e-17  2e-18
 5:  6.4838e-03  6.4837e-03  6e-08  3e-17  2e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  8.3682e-03 -9.9665e-01  1e+00  0e+00  3e+00
 1:  8.3469e-03 -6.6027e-03  1e-02  3e-17  4e-02
 2:  7.6469e-03  5.3200e-03  2e-03  2e-16  5e-03
 3:  7.3446e-03  7.1408e-03  2e-04  1e-16  6e-18
 4:  7.3364e-03  7.3304e-03  6e-06  1e-16  4e-18
 5:  7.3364e-03  7.3363e-03  6e-08  1e-16  3e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  9.4440e-03 -9.9615e-01  1e+00  2e-16  3e+00
 1:  9.4172e-03 -6.0853e-03  2e-02  6e-17  4e-02
 2:  8.6064e-03  6.1947e-03  2e-03  1e-16  5e-03
 3:  8.3012e-03  8.1039e-03  2e-04  1e-16  8e-18
 4:  8.2926e-03  8.2867e-03  6e-06  1e-16  3e-18
 5:  8.2926e-03  8.2925e-03  6e-08  6e-17  3e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.0649e-02 -9.9557e-01  1e+00  0e+00  3e+00
 1:  1.0616e-02 -5.5001e-03  2e-02  1e-16  4e-02
 2:  9.6799e-03  7.1942e-03  2e-03  7e-17  5e-03
 3:  9.3739e-03  9.1844e-03  2e-04  1e-16  5e-18
 4:  9.3652e-03  9.3594e-03  6e-06  1e-16  4e-18
 5:  9.3652e-03  9.3651e-03  6e-08  6e-17  4e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.2000e-02 -9.9493e-01  1e+00  1e-16  3e+00
 1:  1.1958e-02 -4.8377e-03  2e-02  1e-16  4e-02
 2:  1.0881e-02  8.3361e-03  3e-03  1e-16  4e-03
 3:  1.0577e-02  1.0397e-02  2e-04  1e-16  5e-18
 4:  1.0568e-02  1.0563e-02  6e-06  3e-17  7e-18
 5:  1.0568e-02  1.0568e-02  6e-08  1e-16  5e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.3513e-02 -9.9420e-01  1e+00  0e+00  3e+00
 1:  1.3461e-02 -4.0872e-03  2e-02  1e-16  4e-02
 2:  1.2226e-02  9.6401e-03  3e-03  1e-16  4e-03
 3:  1.1927e-02  1.1756e-02  2e-04  4e-17  5e-18
 4:  1.1918e-02  1.1913e-02  5e-06  5e-17  6e-18
 5:  1.1918e-02  1.1918e-02  5e-08  2e-16  5e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.5208e-02 -9.9338e-01  1e+00  2e-16  3e+00
 1:  1.5142e-02 -3.2362e-03  2e-02  6e-17  5e-02
 2:  1.3732e-02  1.1129e-02  3e-03  1e-16  4e-03
 3:  1.3440e-02  1.3281e-02  2e-04  1e-16  4e-18
 4:  1.3432e-02  1.3427e-02  5e-06  1e-16  4e-18
 5:  1.3432e-02  1.3432e-02  5e-08  1e-16  4e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.7106e-02 -9.9245e-01  1e+00  1e-16  3e+00
 1:  1.7024e-02 -2.2703e-03  2e-02  8e-17  5e-02
 2:  1.5420e-02  1.2826e-02  3e-03  4e-17  3e-03
 3:  1.5139e-02  1.4991e-02  1e-04  6e-17  1e-17
 4:  1.5131e-02  1.5126e-02  4e-06  3e-17  8e-18
 5:  1.5131e-02  1.5130e-02  4e-08  4e-17  5e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.9231e-02 -9.9140e-01  1e+00  0e+00  3e+00
 1:  1.9129e-02 -1.1729e-03  2e-02  1e-16  5e-02
 2:  1.7311e-02  1.4761e-02  3e-03  7e-17  2e-03
 3:  1.7044e-02  1.6907e-02  1e-04  1e-16  2e-06
 4:  1.7036e-02  1.7033e-02  4e-06  4e-17  2e-08
 5:  1.7036e-02  1.7036e-02  4e-08  1e-16  2e-10
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.1610e-02 -9.9020e-01  1e+00  0e+00  3e+00
 1:  2.1484e-02  7.5260e-05  2e-02  2e-16  5e-02
 2:  1.9431e-02  1.6965e-02  2e-03  2e-16  1e-03
 3:  1.9181e-02  1.9047e-02  1e-04  1e-16  8e-06
 4:  1.9174e-02  1.9171e-02  3e-06  2e-16  5e-08
 5:  1.9174e-02  1.9174e-02  3e-08  1e-16  5e-10
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.4272e-02 -9.8885e-01  1e+00  1e-16  3e+00
 1:  2.4116e-02  1.4964e-03  2e-02  8e-17  6e-02
 2:  2.1808e-02  1.9471e-02  2e-03  1e-16  9e-05
 3:  2.1579e-02  2.1448e-02  1e-04  1e-16  1e-06
 4:  2.1573e-02  2.1570e-02  3e-06  2e-16  7e-09
 5:  2.1573e-02  2.1573e-02  3e-08  1e-16  7e-11
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.7251e-02 -9.8732e-01  1e+00  4e-16  3e+00
 1:  2.7058e-02  3.1163e-03  2e-02  1e-16  6e-02
 2:  2.4501e-02  2.1911e-02  3e-03  7e-17  2e-17
 3:  2.4271e-02  2.4130e-02  1e-04  2e-16  2e-17
 4:  2.4264e-02  2.4261e-02  3e-06  2e-16  1e-17
 5:  2.4264e-02  2.4264e-02  3e-08  3e-17  1e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  3.0583e-02 -9.8557e-01  1e+00  1e-16  3e+00
 1:  3.0346e-02  4.9648e-03  3e-02  6e-17  6e-02
 2:  2.7525e-02  2.4644e-02  3e-03  1e-16  2e-17
 3:  2.7290e-02  2.7139e-02  2e-04  2e-16  1e-17
 4:  2.7283e-02  2.7280e-02  3e-06  1e-16  7e-18
 5:  2.7283e-02  2.7283e-02  3e-08  2e-16  1e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  3.4311e-02 -9.8359e-01  1e+00  0e+00  3e+00
 1:  3.4020e-02  7.0766e-03  3e-02  1e-16  7e-02
 2:  3.0919e-02  2.7740e-02  3e-03  9e-17  2e-17
 3:  3.0679e-02  3.0515e-02  2e-04  2e-16  1e-17
 4:  3.0671e-02  3.0668e-02  3e-06  1e-16  1e-17
 5:  3.0671e-02  3.0671e-02  3e-08  1e-16  9e-18
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  3.8478e-02 -9.8133e-01  1e+00  2e-16  3e+00
 1:  3.8122e-02  9.4918e-03  3e-02  7e-17  7e-02
 2:  3.4727e-02  3.1250e-02  3e-03  8e-17  9e-18
 3:  3.4480e-02  3.4305e-02  2e-04  3e-17  2e-17
 4:  3.4472e-02  3.4469e-02  4e-06  1e-16  2e-17
 5:  3.4472e-02  3.4472e-02  4e-08  4e-17  1e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  4.3136e-02 -9.7875e-01  1e+00  0e+00  3e+00
 1:  4.2702e-02  1.2257e-02  3e-02  8e-17  8e-02
 2:  3.9000e-02  3.5227e-02  4e-03  1e-16  2e-17
 3:  3.8745e-02  3.8559e-02  2e-04  8e-17  2e-17
 4:  3.8737e-02  3.8733e-02  4e-06  1e-16  1e-17
 5:  3.8737e-02  3.8737e-02  4e-08  1e-16  2e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  4.8342e-02 -9.7582e-01  1e+00  0e+00  3e+00
 1:  4.7814e-02  1.5427e-02  3e-02  1e-16  8e-02
 2:  4.3793e-02  3.9734e-02  4e-03  8e-17  2e-17
 3:  4.3530e-02  4.3333e-02  2e-04  1e-17  1e-17
 4:  4.3522e-02  4.3518e-02  4e-06  1e-16  2e-17
 5:  4.3522e-02  4.3522e-02  4e-08  3e-17  2e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  5.4159e-02 -9.7247e-01  1e+00  2e-16  3e+00
 1:  5.3520e-02  1.9063e-02  3e-02  6e-17  9e-02
 2:  4.9171e-02  4.4838e-02  4e-03  2e-16  2e-17
 3:  4.8899e-02  4.8691e-02  2e-04  1e-16  8e-18
 4:  4.8891e-02  4.8887e-02  4e-06  6e-17  1e-17
 5:  4.8891e-02  4.8891e-02  4e-08  1e-16  3e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  6.0656e-02 -9.6864e-01  1e+00  0e+00  3e+00
 1:  5.9885e-02  2.3238e-02  4e-02  6e-17  9e-02
 2:  5.5204e-02  5.0615e-02  5e-03  6e-17  4e-17
 3:  5.4923e-02  5.4706e-02  2e-04  3e-17  3e-17
 4:  5.4915e-02  5.4911e-02  4e-06  1e-16  2e-17
 5:  5.4915e-02  5.4915e-02  4e-08  6e-17  3e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  6.7912e-02 -9.6426e-01  1e+00  2e-16  3e+00
 1:  6.6987e-02  2.8035e-02  4e-02  2e-16  1e-01
 2:  6.1972e-02  5.7150e-02  5e-03  1e-16  5e-17
 3:  6.1681e-02  6.1456e-02  2e-04  2e-16  2e-17
 4:  6.1674e-02  6.1670e-02  4e-06  1e-16  1e-17
 5:  6.1674e-02  6.1674e-02  4e-08  1e-16  2e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  7.6013e-02 -9.5925e-01  1e+00  0e+00  3e+00
 1:  7.4908e-02  3.3551e-02  4e-02  6e-17  1e-01
 2:  6.9563e-02  6.4537e-02  5e-03  1e-16  4e-17
 3:  6.9264e-02  6.9033e-02  2e-04  1e-16  2e-17
 4:  6.9257e-02  6.9254e-02  4e-06  1e-16  3e-17
 5:  6.9257e-02  6.9257e-02  4e-08  1e-16  3e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  8.5056e-02 -9.5351e-01  1e+00  0e+00  3e+00
 1:  8.3743e-02  3.9896e-02  4e-02  8e-17  1e-01
 2:  7.8077e-02  7.2881e-02  5e-03  1e-16  2e-17
 3:  7.7773e-02  7.7537e-02  2e-04  4e-17  2e-17
 4:  7.7766e-02  7.7762e-02  4e-06  1e-16  1e-17
 5:  7.7766e-02  7.7766e-02  4e-08  3e-17  1e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  9.5151e-02 -9.4693e-01  1e+00  2e-16  3e+00
 1:  9.3599e-02  4.7196e-02  5e-02  6e-17  1e-01
 2:  8.7629e-02  8.2300e-02  5e-03  1e-16  3e-17
 3:  8.7319e-02  8.7081e-02  2e-04  4e-17  2e-17
 4:  8.7313e-02  8.7310e-02  4e-06  0e+00  1e-17
 5:  8.7313e-02  8.7313e-02  4e-08  1e-16  3e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.0642e-01 -9.3939e-01  1e+00  2e-16  3e+00
 1:  1.0459e-01  5.5596e-02  5e-02  6e-17  1e-01
 2:  9.8342e-02  9.2924e-02  5e-03  8e-17  3e-17
 3:  9.8031e-02  9.7792e-02  2e-04  1e-16  6e-17
 4:  9.8025e-02  9.8022e-02  3e-06  1e-17  4e-17
 5:  9.8025e-02  9.8025e-02  3e-08  3e-17  4e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.1899e-01 -9.3074e-01  1e+00  0e+00  3e+00
 1:  1.1686e-01  6.5261e-02  5e-02  9e-17  1e-01
 2:  1.1036e-01  1.0490e-01  5e-03  8e-17  4e-17
 3:  1.1005e-01  1.0981e-01  2e-04  1e-16  4e-17
 4:  1.1004e-01  1.1004e-01  3e-06  0e+00  3e-17
 5:  1.1004e-01  1.1004e-01  3e-08  1e-16  5e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.3303e-01 -9.2082e-01  1e+00  0e+00  3e+00
 1:  1.3055e-01  7.6375e-02  5e-02  1e-16  1e-01
 2:  1.2384e-01  1.1838e-01  5e-03  8e-17  6e-17
 3:  1.2353e-01  1.2330e-01  2e-04  9e-17  5e-17
 4:  1.2353e-01  1.2353e-01  3e-06  1e-16  3e-17
 5:  1.2353e-01  1.2353e-01  3e-08  2e-16  5e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.4869e-01 -9.0945e-01  1e+00  2e-16  3e+00
 1:  1.4584e-01  8.9150e-02  6e-02  7e-17  1e-01
 2:  1.3896e-01  1.3356e-01  5e-03  1e-16  9e-17
 3:  1.3866e-01  1.3844e-01  2e-04  6e-17  8e-17
 4:  1.3866e-01  1.3866e-01  3e-06  6e-17  5e-17
 5:  1.3866e-01  1.3866e-01  3e-08  1e-16  3e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.6618e-01 -8.9640e-01  1e+00  0e+00  3e+00
 1:  1.6291e-01  1.0382e-01  6e-02  1e-16  1e-01
 2:  1.5593e-01  1.5063e-01  5e-03  1e-16  1e-16
 3:  1.5564e-01  1.5543e-01  2e-04  3e-17  8e-17
 4:  1.5564e-01  1.5563e-01  2e-06  1e-16  3e-17
 5:  1.5564e-01  1.5564e-01  2e-08  3e-17  1e-16
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  1.8571e-01 -8.8144e-01  1e+00  2e-16  3e+00
 1:  1.8199e-01  1.2065e-01  6e-02  2e-16  2e-01
 2:  1.7496e-01  1.6982e-01  5e-03  8e-17  8e-17
 3:  1.7469e-01  1.7449e-01  2e-04  6e-17  7e-17
 4:  1.7469e-01  1.7468e-01  2e-06  9e-17  7e-17
 5:  1.7469e-01  1.7469e-01  2e-08  1e-16  1e-16
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.0752e-01 -8.6431e-01  1e+00  2e-16  3e+00
 1:  2.0333e-01  1.3994e-01  6e-02  1e-16  2e-01
 2:  1.9632e-01  1.9138e-01  5e-03  2e-16  8e-17
 3:  1.9606e-01  1.9588e-01  2e-04  1e-16  7e-17
 4:  1.9606e-01  1.9606e-01  2e-06  6e-17  8e-17
 5:  1.9606e-01  1.9606e-01  2e-08  1e-16  8e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.3189e-01 -8.4469e-01  1e+00  2e-16  3e+00
 1:  2.2720e-01  1.6200e-01  7e-02  8e-17  2e-01
 2:  2.2028e-01  2.1559e-01  5e-03  1e-16  1e-16
 3:  2.2004e-01  2.1988e-01  2e-04  1e-16  1e-16
 4:  2.2004e-01  2.2004e-01  2e-06  2e-16  1e-16
 5:  2.2004e-01  2.2004e-01  2e-08  1e-16  7e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.5912e-01 -8.2224e-01  1e+00  0e+00  3e+00
 1:  2.5393e-01  1.8721e-01  7e-02  3e-17  2e-01
 2:  2.4716e-01  2.4276e-01  4e-03  1e-16  5e-17
 3:  2.4695e-01  2.4680e-01  1e-04  4e-17  1e-16
 4:  2.4695e-01  2.4694e-01  1e-06  2e-16  1e-16
 5:  2.4695e-01  2.4695e-01  1e-08  1e-16  9e-17
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0:  2.8957e-01 -7.9658e-01  1e+00  0e+00  3e+00
 1:  2.8387e-01  2.1595e-01  7e-02  6e-17  2e-01
 2:  2.7733e-01  2.7325e-01  4e-03  1e-16  1e-16
 3:  2.7714e-01  2.7701e-01  1e-04  1e-16  1e-16
 4:  2.7714e-01  2.7713e-01  1e-06  3e-17  7e-17
 5:  2.7714e-01  2.7714e-01  1e-08  1e-16  1e-16
Optimal solution found.
     pcost       dcost       gap    pres   dres
 0: -4.9959e-04 -1.0011e+00  1e+00  1e-16  3e+00
 1: -4.9999e-04 -1.1139e-02  1e-02  7e-17  3e-02
 2: -5.3596e-04 -1.2389e-03  7e-04  8e-17  2e-03
 3: -1.0882e-03 -1.3962e-03  3e-04  4e-16  4e-04
 4: -1.1362e-03 -1.1415e-03  5e-06  1e-16  7e-06
 5: -1.1389e-03 -1.1389e-03  5e-08  1e-16  7e-08
Optimal solution found.
Out[11]:
[<matplotlib.lines.Line2D at 0x7f9cd7550490>]
In [12]:
print(weights)
[[  9.99971971e-01]
 [  1.19323452e-05]
 [  1.22631268e-05]
 [  3.83359490e-06]]