In [2]:
import quantecon as qe
import numpy as np
from gurobipy import *
import time
In [3]:
% matplotlib inline
import matplotlib.pyplot as plt
In [6]:
# Mを変更するようにする
class SimpleOG(object):
def __init__(self, B=10, M=5, alpha=0.5, beta=0.9):
self.B, self.M, self.alpha, self.beta = B, M, alpha, beta
self.n = B + M + 1
self.m = M + 1
self.R = np.empty((self.n, self.m))
self.Q = np.zeros((self.n, self.m, self.n))
self.populate_Q()
self.populate_R()
def u(self, c):
return c**self.alpha
def populate_R(self):
for s in range(self.n):
for a in range(self.m):
self.R[s, a] = self.u(s - a) if a <= s else -np.inf
def populate_Q(self):
for a in range(self.m):
self.Q[:, a, a:(a + self.B + 1)] = 1.0 / (self.B + 1)
def elapse(setting):
start = time.time()
setting.solve(method='value_iteration')
elapsed_time = time.time() - start
return elapsed_time
def LP_approach(setting):
num_state = range(1, setting.num_states + 1)
num_action = range(1, setting.num_actions + 1)
LP = Model()
x = {}
for i in num_state:
x[i ] = LP.addVar(vtype = "C", name = "x(%s)" %(i))
LP.update()
for i in num_state:
for j in num_action:
LP.addConstr((x[i] - setting.beta * quicksum(setting.Q[i-1, j-1, k-1] * x[k] for k in num_state)) >= setting.R[i-1,j-1])
LP.setObjective(quicksum(x[i] for i in num_state))
LP.optimize()
return LP.Runtime
def plot_graph(n, shock, discount):
a = [None] * (n-9)
b = [None] * (n-9)
for i in range(10, n+1):
h = SimpleOG(M = i, B = shock, beta = discount)
d = qe.markov.DiscreteDP(h.R, h.Q, h.beta)
a[i - 10] = LP_approach(d)
b[i - 10] = elapse(d)
plt.plot(a)
plt.plot(b)
In [6]:
#時間かかりすぎる
plot_graph(100, 10, discount = 0.98)
Optimize a model with 231 rows, 21 columns and 2651 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 21 rows, 231 columns, 2651 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 4.521784e+02 0s
45 2.3126988e+03 0.000000e+00 0.000000e+00 0s
Solved in 45 iterations and 0.02 seconds
Optimal objective 2.312698846e+03
Optimize a model with 264 rows, 22 columns and 3036 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.00s
Presolved: 22 rows, 264 columns, 3036 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 5.184270e+02 0s
49 2.4261898e+03 0.000000e+00 0.000000e+00 0s
Solved in 49 iterations and 0.01 seconds
Optimal objective 2.426189770e+03
Optimize a model with 299 rows, 23 columns and 3445 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.00s
Presolved: 23 rows, 299 columns, 3445 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 5.893659e+02 0s
58 2.5396402e+03 0.000000e+00 0.000000e+00 0s
Solved in 58 iterations and 0.01 seconds
Optimal objective 2.539640169e+03
Optimize a model with 336 rows, 24 columns and 3878 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.00s
Presolved: 24 rows, 336 columns, 3878 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 6.651007e+02 0s
57 2.6531564e+03 0.000000e+00 0.000000e+00 0s
Solved in 57 iterations and 0.01 seconds
Optimal objective 2.653156432e+03
Optimize a model with 375 rows, 25 columns and 4335 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 25 rows, 375 columns, 4335 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 7.457345e+02 0s
59 2.7666943e+03 0.000000e+00 0.000000e+00 0s
Solved in 59 iterations and 0.01 seconds
Optimal objective 2.766694330e+03
Optimize a model with 416 rows, 26 columns and 4816 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 26 rows, 416 columns, 4816 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 8.313683e+02 0s
68 2.8803349e+03 0.000000e+00 0.000000e+00 0s
Solved in 68 iterations and 0.01 seconds
Optimal objective 2.880334941e+03
Optimize a model with 459 rows, 27 columns and 5321 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 27 rows, 459 columns, 5321 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 9.221011e+02 0s
67 2.9940849e+03 0.000000e+00 0.000000e+00 0s
Solved in 67 iterations and 0.01 seconds
Optimal objective 2.994084919e+03
Optimize a model with 504 rows, 28 columns and 5850 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 28 rows, 504 columns, 5850 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.018030e+03 0s
73 3.1079776e+03 0.000000e+00 0.000000e+00 0s
Solved in 73 iterations and 0.02 seconds
Optimal objective 3.107977588e+03
Optimize a model with 551 rows, 29 columns and 6403 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 29 rows, 551 columns, 6403 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.119251e+03 0s
77 3.2220322e+03 0.000000e+00 0.000000e+00 0s
Solved in 77 iterations and 0.02 seconds
Optimal objective 3.222032157e+03
Optimize a model with 600 rows, 30 columns and 6980 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 30 rows, 600 columns, 6980 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.225856e+03 0s
82 3.3362520e+03 0.000000e+00 0.000000e+00 0s
Solved in 82 iterations and 0.02 seconds
Optimal objective 3.336252036e+03
Optimize a model with 651 rows, 31 columns and 7581 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 31 rows, 651 columns, 7581 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.337939e+03 0s
84 3.4506403e+03 0.000000e+00 0.000000e+00 0s
Solved in 84 iterations and 0.01 seconds
Optimal objective 3.450640281e+03
Optimize a model with 704 rows, 32 columns and 8206 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 32 rows, 704 columns, 8206 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.455590e+03 0s
82 3.5651983e+03 0.000000e+00 0.000000e+00 0s
Solved in 82 iterations and 0.01 seconds
Optimal objective 3.565198301e+03
Optimize a model with 759 rows, 33 columns and 8855 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 33 rows, 759 columns, 8855 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.578897e+03 0s
89 3.6799319e+03 0.000000e+00 0.000000e+00 0s
Solved in 89 iterations and 0.01 seconds
Optimal objective 3.679931885e+03
Optimize a model with 816 rows, 34 columns and 9528 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 34 rows, 816 columns, 9528 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.707949e+03 0s
101 3.7948375e+03 0.000000e+00 0.000000e+00 0s
Solved in 101 iterations and 0.01 seconds
Optimal objective 3.794837473e+03
Optimize a model with 875 rows, 35 columns and 10225 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 35 rows, 875 columns, 10225 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.842832e+03 0s
101 3.9099172e+03 0.000000e+00 0.000000e+00 0s
Solved in 101 iterations and 0.01 seconds
Optimal objective 3.909917235e+03
Optimize a model with 936 rows, 36 columns and 10946 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 36 rows, 936 columns, 10946 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.983631e+03 0s
110 4.0251710e+03 0.000000e+00 0.000000e+00 0s
Solved in 110 iterations and 0.01 seconds
Optimal objective 4.025171048e+03
Optimize a model with 999 rows, 37 columns and 11691 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 37 rows, 999 columns, 11691 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.130430e+03 0s
117 4.1405983e+03 0.000000e+00 0.000000e+00 0s
Solved in 117 iterations and 0.01 seconds
Optimal objective 4.140598261e+03
Optimize a model with 1064 rows, 38 columns and 12460 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 38 rows, 1064 columns, 12460 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.283312e+03 0s
119 4.2561980e+03 0.000000e+00 0.000000e+00 0s
Solved in 119 iterations and 0.01 seconds
Optimal objective 4.256197966e+03
Optimize a model with 1131 rows, 39 columns and 13253 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 39 rows, 1131 columns, 13253 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.442358e+03 0s
121 4.3719692e+03 0.000000e+00 0.000000e+00 0s
Solved in 121 iterations and 0.01 seconds
Optimal objective 4.371969183e+03
Optimize a model with 1200 rows, 40 columns and 14070 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 40 rows, 1200 columns, 14070 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.607649e+03 0s
136 4.4879109e+03 0.000000e+00 0.000000e+00 0s
Solved in 136 iterations and 0.02 seconds
Optimal objective 4.487910912e+03
Optimize a model with 1271 rows, 41 columns and 14911 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 41 rows, 1271 columns, 14911 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.779265e+03 0s
142 4.6040229e+03 0.000000e+00 0.000000e+00 0s
Solved in 142 iterations and 0.02 seconds
Optimal objective 4.604022866e+03
Optimize a model with 1344 rows, 42 columns and 15776 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 42 rows, 1344 columns, 15776 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.957284e+03 0s
137 4.7203032e+03 0.000000e+00 0.000000e+00 0s
Solved in 137 iterations and 0.02 seconds
Optimal objective 4.720303225e+03
Optimize a model with 1419 rows, 43 columns and 16665 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 43 rows, 1419 columns, 16665 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.141784e+03 0s
148 4.8367522e+03 0.000000e+00 0.000000e+00 0s
Solved in 148 iterations and 0.02 seconds
Optimal objective 4.836752193e+03
Optimize a model with 1496 rows, 44 columns and 17578 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 44 rows, 1496 columns, 17578 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.332841e+03 0s
166 4.9533690e+03 0.000000e+00 0.000000e+00 0s
Solved in 166 iterations and 0.02 seconds
Optimal objective 4.953368951e+03
Optimize a model with 1575 rows, 45 columns and 18515 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 45 rows, 1575 columns, 18515 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.530531e+03 0s
161 5.0701528e+03 0.000000e+00 0.000000e+00 0s
Solved in 161 iterations and 0.02 seconds
Optimal objective 5.070152756e+03
Optimize a model with 1656 rows, 46 columns and 19476 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 46 rows, 1656 columns, 19476 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.734930e+03 0s
190 5.1871028e+03 0.000000e+00 0.000000e+00 0s
Solved in 190 iterations and 0.02 seconds
Optimal objective 5.187102780e+03
Optimize a model with 1739 rows, 47 columns and 20461 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 47 rows, 1739 columns, 20461 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.946111e+03 0s
193 5.3042182e+03 0.000000e+00 0.000000e+00 0s
Solved in 193 iterations and 0.02 seconds
Optimal objective 5.304218210e+03
Optimize a model with 1824 rows, 48 columns and 21470 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 48 rows, 1824 columns, 21470 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 4.164147e+03 0s
207 5.4214983e+03 0.000000e+00 0.000000e+00 0s
Solved in 207 iterations and 0.02 seconds
Optimal objective 5.421498257e+03
Optimize a model with 1911 rows, 49 columns and 22503 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.01s
Presolved: 49 rows, 1911 columns, 22503 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 4.389112e+03 0s
207 5.5389421e+03 0.000000e+00 0.000000e+00 0s
Solved in 207 iterations and 0.02 seconds
Optimal objective 5.538942144e+03
Optimize a model with 2000 rows, 50 columns and 23560 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 50 rows, 2000 columns, 23560 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 4.621077e+03 0s
198 5.6565491e+03 0.000000e+00 0.000000e+00 0s
Solved in 198 iterations and 0.06 seconds
Optimal objective 5.656549128e+03
Optimize a model with 2091 rows, 51 columns and 24641 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 51 rows, 2091 columns, 24641 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 4.860112e+03 0s
192 5.7743183e+03 0.000000e+00 0.000000e+00 0s
Solved in 192 iterations and 0.03 seconds
Optimal objective 5.774318303e+03
Optimize a model with 2184 rows, 52 columns and 25746 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 52 rows, 2184 columns, 25746 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 5.106290e+03 0s
195 5.8922488e+03 0.000000e+00 0.000000e+00 0s
Solved in 195 iterations and 0.02 seconds
Optimal objective 5.892248827e+03
Optimize a model with 2279 rows, 53 columns and 26875 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 53 rows, 2279 columns, 26875 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 5.359678e+03 0s
186 6.0103409e+03 0.000000e+00 0.000000e+00 0s
Solved in 186 iterations and 0.03 seconds
Optimal objective 6.010340894e+03
Optimize a model with 2376 rows, 54 columns and 28028 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 54 rows, 2376 columns, 28028 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 5.620346e+03 0s
244 6.1285938e+03 0.000000e+00 0.000000e+00 0s
Solved in 244 iterations and 0.03 seconds
Optimal objective 6.128593790e+03
Optimize a model with 2475 rows, 55 columns and 29205 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 55 rows, 2475 columns, 29205 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 5.888363e+03 0s
228 6.2470068e+03 0.000000e+00 0.000000e+00 0s
Solved in 228 iterations and 0.03 seconds
Optimal objective 6.247006817e+03
Optimize a model with 2576 rows, 56 columns and 30406 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 56 rows, 2576 columns, 30406 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 6.163796e+03 0s
213 6.3655793e+03 0.000000e+00 0.000000e+00 0s
Solved in 213 iterations and 0.03 seconds
Optimal objective 6.365579294e+03
Optimize a model with 2679 rows, 57 columns and 31631 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 57 rows, 2679 columns, 31631 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 6.446713e+03 0s
220 6.4843106e+03 0.000000e+00 0.000000e+00 0s
Solved in 220 iterations and 0.04 seconds
Optimal objective 6.484310555e+03
Optimize a model with 2784 rows, 58 columns and 32880 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 58 rows, 2784 columns, 32880 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 6.737179e+03 0s
278 6.6032000e+03 0.000000e+00 0.000000e+00 0s
Solved in 278 iterations and 0.03 seconds
Optimal objective 6.603199951e+03
Optimize a model with 2891 rows, 59 columns and 34153 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 59 rows, 2891 columns, 34153 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 7.035261e+03 0s
316 6.7222468e+03 0.000000e+00 0.000000e+00 0s
Solved in 316 iterations and 0.03 seconds
Optimal objective 6.722246843e+03
Optimize a model with 3000 rows, 60 columns and 35450 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 60 rows, 3000 columns, 35450 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 7.341024e+03 0s
284 6.8414506e+03 0.000000e+00 0.000000e+00 0s
Solved in 284 iterations and 0.04 seconds
Optimal objective 6.841450610e+03
Optimize a model with 3111 rows, 61 columns and 36771 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 61 rows, 3111 columns, 36771 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 7.654534e+03 0s
332 6.9608106e+03 0.000000e+00 0.000000e+00 0s
Solved in 332 iterations and 0.04 seconds
Optimal objective 6.960810649e+03
Optimize a model with 3224 rows, 62 columns and 38116 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 62 rows, 3224 columns, 38116 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 7.975853e+03 0s
292 7.0803264e+03 0.000000e+00 0.000000e+00 0s
Solved in 292 iterations and 0.04 seconds
Optimal objective 7.080326373e+03
Optimize a model with 3339 rows, 63 columns and 39485 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.02s
Presolved: 63 rows, 3339 columns, 39485 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 8.305046e+03 0s
306 7.1999971e+03 0.000000e+00 0.000000e+00 0s
Solved in 306 iterations and 0.04 seconds
Optimal objective 7.199997136e+03
Optimize a model with 3456 rows, 64 columns and 40878 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 64 rows, 3456 columns, 40878 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 8.642177e+03 0s
296 7.3198223e+03 0.000000e+00 0.000000e+00 0s
Solved in 296 iterations and 0.04 seconds
Optimal objective 7.319822303e+03
Optimize a model with 3575 rows, 65 columns and 42295 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 65 rows, 3575 columns, 42295 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 8.987308e+03 0s
332 7.4398018e+03 0.000000e+00 0.000000e+00 0s
Solved in 332 iterations and 0.06 seconds
Optimal objective 7.439801817e+03
Optimize a model with 3696 rows, 66 columns and 43736 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 66 rows, 3696 columns, 43736 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 9.340501e+03 0s
288 7.5599352e+03 0.000000e+00 0.000000e+00 0s
Solved in 288 iterations and 0.04 seconds
Optimal objective 7.559935157e+03
Optimize a model with 3819 rows, 67 columns and 45201 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 67 rows, 3819 columns, 45201 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 9.701817e+03 0s
297 7.6802218e+03 0.000000e+00 0.000000e+00 0s
Solved in 297 iterations and 0.05 seconds
Optimal objective 7.680221761e+03
Optimize a model with 3944 rows, 68 columns and 46690 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 68 rows, 3944 columns, 46690 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.007132e+04 0s
311 7.8006611e+03 0.000000e+00 0.000000e+00 0s
Solved in 311 iterations and 0.05 seconds
Optimal objective 7.800661078e+03
Optimize a model with 4071 rows, 69 columns and 48203 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 69 rows, 4071 columns, 48203 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.044907e+04 0s
337 7.9212526e+03 0.000000e+00 0.000000e+00 0s
Solved in 337 iterations and 0.04 seconds
Optimal objective 7.921252568e+03
Optimize a model with 4200 rows, 70 columns and 49740 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 70 rows, 4200 columns, 49740 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.083512e+04 0s
372 8.0419957e+03 0.000000e+00 0.000000e+00 0s
Solved in 372 iterations and 0.05 seconds
Optimal objective 8.041995698e+03
Optimize a model with 4331 rows, 71 columns and 51301 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 71 rows, 4331 columns, 51301 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.122955e+04 0s
367 8.1628899e+03 0.000000e+00 0.000000e+00 0s
Solved in 367 iterations and 0.05 seconds
Optimal objective 8.162889948e+03
Optimize a model with 4464 rows, 72 columns and 52886 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.03s
Presolved: 72 rows, 4464 columns, 52886 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.163239e+04 0s
375 8.2839348e+03 0.000000e+00 0.000000e+00 0s
Solved in 375 iterations and 0.05 seconds
Optimal objective 8.283934805e+03
Optimize a model with 4599 rows, 73 columns and 54495 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.04s
Presolved: 73 rows, 4599 columns, 54495 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.204373e+04 0s
373 8.4051298e+03 0.000000e+00 0.000000e+00 0s
Solved in 373 iterations and 0.05 seconds
Optimal objective 8.405129764e+03
Optimize a model with 4736 rows, 74 columns and 56128 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.04s
Presolved: 74 rows, 4736 columns, 56128 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.246360e+04 0s
394 8.5264743e+03 0.000000e+00 0.000000e+00 0s
Solved in 394 iterations and 0.06 seconds
Optimal objective 8.526474327e+03
Optimize a model with 4875 rows, 75 columns and 57785 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.04s
Presolved: 75 rows, 4875 columns, 57785 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.289208e+04 0s
396 8.6479680e+03 0.000000e+00 0.000000e+00 0s
Solved in 396 iterations and 0.06 seconds
Optimal objective 8.647968011e+03
Optimize a model with 5016 rows, 76 columns and 59466 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.04s
Presolved: 76 rows, 5016 columns, 59466 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.332922e+04 0s
369 8.7696103e+03 0.000000e+00 0.000000e+00 0s
Solved in 369 iterations and 0.06 seconds
Optimal objective 8.769610344e+03
Optimize a model with 5159 rows, 77 columns and 61171 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.04s
Presolved: 77 rows, 5159 columns, 61171 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.377508e+04 0s
411 8.8914008e+03 0.000000e+00 0.000000e+00 0s
Solved in 411 iterations and 0.05 seconds
Optimal objective 8.891400819e+03
Optimize a model with 5304 rows, 78 columns and 62900 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.04s
Presolved: 78 rows, 5304 columns, 62900 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.422971e+04 0s
423 9.0133389e+03 0.000000e+00 0.000000e+00 0s
Solved in 423 iterations and 0.05 seconds
Optimal objective 9.013338931e+03
Optimize a model with 5451 rows, 79 columns and 64653 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.04s
Presolved: 79 rows, 5451 columns, 64653 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.469318e+04 0s
408 9.1354245e+03 0.000000e+00 0.000000e+00 0s
Solved in 408 iterations and 0.06 seconds
Optimal objective 9.135424518e+03
Optimize a model with 5600 rows, 80 columns and 66430 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 80 rows, 5600 columns, 66430 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.516553e+04 0s
413 9.2576572e+03 0.000000e+00 0.000000e+00 0s
Solved in 413 iterations and 0.07 seconds
Optimal objective 9.257657241e+03
Optimize a model with 5751 rows, 81 columns and 68231 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 81 rows, 5751 columns, 68231 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.564683e+04 0s
441 9.3800366e+03 0.000000e+00 0.000000e+00 0s
Solved in 441 iterations and 0.07 seconds
Optimal objective 9.380036631e+03
Optimize a model with 5904 rows, 82 columns and 70056 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 82 rows, 5904 columns, 70056 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.613712e+04 0s
519 9.5025622e+03 0.000000e+00 0.000000e+00 0s
Solved in 519 iterations and 0.08 seconds
Optimal objective 9.502562239e+03
Optimize a model with 6059 rows, 83 columns and 71905 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 83 rows, 6059 columns, 71905 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.663648e+04 0s
483 9.6252336e+03 0.000000e+00 0.000000e+00 0s
Solved in 483 iterations and 0.07 seconds
Optimal objective 9.625233624e+03
Optimize a model with 6216 rows, 84 columns and 73778 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 84 rows, 6216 columns, 73778 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.714494e+04 0s
498 9.7480503e+03 0.000000e+00 0.000000e+00 0s
Solved in 498 iterations and 0.07 seconds
Optimal objective 9.748050348e+03
Optimize a model with 6375 rows, 85 columns and 75675 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 85 rows, 6375 columns, 75675 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.766257e+04 0s
555 9.8710120e+03 0.000000e+00 0.000000e+00 0s
Solved in 555 iterations and 0.08 seconds
Optimal objective 9.871011981e+03
Optimize a model with 6536 rows, 86 columns and 77596 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.06s
Presolved: 86 rows, 6536 columns, 77596 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.818941e+04 0s
513 9.9941181e+03 0.000000e+00 0.000000e+00 0s
Solved in 513 iterations and 0.08 seconds
Optimal objective 9.994118098e+03
Optimize a model with 6699 rows, 87 columns and 79541 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.06s
Presolved: 87 rows, 6699 columns, 79541 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.872553e+04 0s
553 1.0117368e+04 0.000000e+00 0.000000e+00 0s
Solved in 553 iterations and 0.08 seconds
Optimal objective 1.011736828e+04
Optimize a model with 6864 rows, 88 columns and 81510 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.06s
Presolved: 88 rows, 6864 columns, 81510 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.927098e+04 0s
483 1.0240762e+04 0.000000e+00 0.000000e+00 0s
Solved in 483 iterations and 0.09 seconds
Optimal objective 1.024076212e+04
Optimize a model with 7031 rows, 89 columns and 83503 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.06s
Presolved: 89 rows, 7031 columns, 83503 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 1.982581e+04 0s
524 1.0364299e+04 0.000000e+00 0.000000e+00 0s
Solved in 524 iterations and 0.08 seconds
Optimal objective 1.036429920e+04
Optimize a model with 7200 rows, 90 columns and 85520 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.05s
Presolved: 90 rows, 7200 columns, 85520 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.039007e+04 0s
538 1.0487979e+04 0.000000e+00 0.000000e+00 0s
Solved in 538 iterations and 0.08 seconds
Optimal objective 1.048797913e+04
Optimize a model with 7371 rows, 91 columns and 87561 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.06s
Presolved: 91 rows, 7371 columns, 87561 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.096382e+04 0s
596 1.0611802e+04 0.000000e+00 0.000000e+00 0s
Solved in 596 iterations and 0.09 seconds
Optimal objective 1.061180151e+04
Optimize a model with 7544 rows, 92 columns and 89626 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.06s
Presolved: 92 rows, 7544 columns, 89626 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.154711e+04 0s
535 1.0735766e+04 0.000000e+00 0.000000e+00 0s
Solved in 535 iterations and 0.08 seconds
Optimal objective 1.073576593e+04
Optimize a model with 7719 rows, 93 columns and 91715 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.06s
Presolved: 93 rows, 7719 columns, 91715 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.213999e+04 0s
555 1.0859872e+04 0.000000e+00 0.000000e+00 0s
Solved in 555 iterations and 0.09 seconds
Optimal objective 1.085987197e+04
Optimize a model with 7896 rows, 94 columns and 93828 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.06s
Presolved: 94 rows, 7896 columns, 93828 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.274252e+04 0s
577 1.0984119e+04 0.000000e+00 0.000000e+00 0s
Solved in 577 iterations and 0.10 seconds
Optimal objective 1.098411947e+04
Optimize a model with 8075 rows, 95 columns and 95965 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.07s
Presolved: 95 rows, 8075 columns, 95965 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.335474e+04 0s
585 1.1108508e+04 0.000000e+00 0.000000e+00 0s
Solved in 585 iterations and 0.10 seconds
Optimal objective 1.110850817e+04
Optimize a model with 8256 rows, 96 columns and 98126 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.07s
Presolved: 96 rows, 8256 columns, 98126 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.397671e+04 0s
595 1.1233038e+04 0.000000e+00 0.000000e+00 0s
Solved in 595 iterations and 0.10 seconds
Optimal objective 1.123303768e+04
Optimize a model with 8439 rows, 97 columns and 100311 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.07s
Presolved: 97 rows, 8439 columns, 100311 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.460847e+04 0s
602 1.1357708e+04 0.000000e+00 0.000000e+00 0s
Solved in 602 iterations and 0.09 seconds
Optimal objective 1.135770761e+04
Optimize a model with 8624 rows, 98 columns and 102520 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.08s
Presolved: 98 rows, 8624 columns, 102520 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.525008e+04 0s
630 1.1482518e+04 0.000000e+00 0.000000e+00 0s
Solved in 630 iterations and 0.11 seconds
Optimal objective 1.148251759e+04
Optimize a model with 8811 rows, 99 columns and 104753 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.08s
Presolved: 99 rows, 8811 columns, 104753 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.590160e+04 0s
619 1.1607467e+04 0.000000e+00 0.000000e+00 0s
Solved in 619 iterations and 0.11 seconds
Optimal objective 1.160746725e+04
Optimize a model with 9000 rows, 100 columns and 107010 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.08s
Presolved: 100 rows, 9000 columns, 107010 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.656306e+04 0s
613 1.1732556e+04 0.000000e+00 0.000000e+00 0s
Solved in 613 iterations and 0.11 seconds
Optimal objective 1.173255623e+04
Optimize a model with 9191 rows, 101 columns and 109291 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.08s
Presolved: 101 rows, 9191 columns, 109291 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.723452e+04 0s
636 1.1857784e+04 0.000000e+00 0.000000e+00 0s
Solved in 636 iterations and 0.10 seconds
Optimal objective 1.185778417e+04
Optimize a model with 9384 rows, 102 columns and 111596 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.07s
Presolved: 102 rows, 9384 columns, 111596 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.791604e+04 0s
655 1.1983151e+04 0.000000e+00 0.000000e+00 0s
Solved in 655 iterations and 0.10 seconds
Optimal objective 1.198315072e+04
Optimize a model with 9579 rows, 103 columns and 113925 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.08s
Presolved: 103 rows, 9579 columns, 113925 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.860765e+04 0s
638 1.2108656e+04 0.000000e+00 0.000000e+00 0s
Solved in 638 iterations and 0.12 seconds
Optimal objective 1.210865554e+04
Optimize a model with 9776 rows, 104 columns and 116278 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.15s
Presolved: 104 rows, 9776 columns, 116278 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 2.930941e+04 0s
654 1.2234298e+04 0.000000e+00 0.000000e+00 0s
Solved in 654 iterations and 0.19 seconds
Optimal objective 1.223429827e+04
Optimize a model with 9975 rows, 105 columns and 118655 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.09s
Presolved: 105 rows, 9975 columns, 118655 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.002137e+04 0s
763 1.2360079e+04 0.000000e+00 0.000000e+00 0s
Solved in 763 iterations and 0.12 seconds
Optimal objective 1.236007856e+04
Optimize a model with 10176 rows, 106 columns and 121056 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.19s
Presolved: 106 rows, 10176 columns, 121056 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.074357e+04 0s
664 1.2485996e+04 0.000000e+00 0.000000e+00 0s
Solved in 664 iterations and 0.24 seconds
Optimal objective 1.248599610e+04
Optimize a model with 10379 rows, 107 columns and 123481 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.08s
Presolved: 107 rows, 10379 columns, 123481 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.147608e+04 0s
656 1.2612051e+04 0.000000e+00 0.000000e+00 0s
Solved in 656 iterations and 0.11 seconds
Optimal objective 1.261205054e+04
Optimize a model with 10584 rows, 108 columns and 125930 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.12s
Presolved: 108 rows, 10584 columns, 125930 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.221892e+04 0s
686 1.2738242e+04 0.000000e+00 0.000000e+00 0s
Solved in 686 iterations and 0.16 seconds
Optimal objective 1.273824154e+04
Optimize a model with 10791 rows, 109 columns and 128403 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.09s
Presolved: 109 rows, 10791 columns, 128403 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.297216e+04 0s
701 1.2864569e+04 0.000000e+00 0.000000e+00 0s
Solved in 701 iterations and 0.11 seconds
Optimal objective 1.286456874e+04
Optimize a model with 11000 rows, 110 columns and 130900 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.10s
Presolved: 110 rows, 11000 columns, 130900 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.373584e+04 0s
692 1.2991032e+04 0.000000e+00 0.000000e+00 0s
Solved in 692 iterations and 0.13 seconds
Optimal objective 1.299103205e+04
Optimize a model with 11211 rows, 111 columns and 133421 nonzeros
Coefficient statistics:
Matrix range [9e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.09s
Presolved: 111 rows, 11211 columns, 133421 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 3.451001e+04 0s
680 1.3117631e+04 0.000000e+00 0.000000e+00 0s
Solved in 680 iterations and 0.12 seconds
Optimal objective 1.311763121e+04
In [37]:
# value function iterationだけ表示
def plot_graph_value(n, discount):
b = [None] * (n-9)
for i in range(10, n+1):
h = SimpleOG(M = i, beta = discount)
d = qe.markov.DiscreteDP(h.R, h.Q, h.beta)
b[i - 10] = elapse(d)
plt.plot(b)
In [38]:
plot_graph_value(100, 0.98)
In [39]:
# stateが大きいときのみ
g = SimpleOG(B = 100, M = 10, beta = 0.98)
d = qe.markov.DiscreteDP(g.R, g.Q, g.beta)
LP_approach(d)
Optimize a model with 1221 rows, 111 columns and 123431 nonzeros
Coefficient statistics:
Matrix range [1e-02, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+100]
Presolve time: 0.10s
Presolved: 111 rows, 1221 columns, 123431 nonzeros
Iteration Objective Primal Inf. Dual Inf. Time
0 -0.0000000e+00 0.000000e+00 7.946946e+03 0s
165 3.7639807e+04 0.000000e+00 0.000000e+00 0s
Solved in 165 iterations and 0.20 seconds
Optimal objective 3.763980695e+04
Out[39]:
0.2029280662536621
In [12]:
e = qe.markov.DiscreteDP(g.R, g.Q, g.beta)
elapse(e)
Out[12]:
0.001987934112548828
In [13]:
# iterationの回数ではvalue functionの方が多い
e.solve("vi")
Out[13]:
mc: Markov chain with transition matrix
P =
[[ 0.00990099 0.00990099 0.00990099 ..., 0. 0. 0. ]
[ 0.00990099 0.00990099 0.00990099 ..., 0. 0. 0. ]
[ 0.00990099 0.00990099 0.00990099 ..., 0. 0. 0. ]
...,
[ 0. 0. 0. ..., 0.00990099 0.00990099
0.00990099]
[ 0. 0. 0. ..., 0.00990099 0.00990099
0.00990099]
[ 0. 0. 0. ..., 0.00990099 0.00990099
0.00990099]]
v: array([ 329.84923113, 330.84923113, 331.26344469, 331.58128194,
331.84923113, 332.08529911, 332.29872087, 332.49498244,
332.67765825, 332.84923113, 333.01150879, 333.16585592,
333.31333274, 333.4547824 , 333.59088852, 333.72221447,
333.84923113, 333.97233675, 334.09187182, 334.20813007,
334.32136708, 334.43180682, 334.53964689, 334.64506265,
334.74821061, 334.84923113, 334.94996663, 335.04898614,
335.14611905, 335.24146925, 335.33513143, 335.4271922 ,
335.51873192, 335.6092707 , 335.69836059, 335.78638564,
335.87409403, 335.96048328, 336.04592609, 336.13105398,
336.2149742 , 336.29831617, 336.3810787 , 336.46273018,
336.54427804, 336.62486204, 336.70483295, 336.78439027,
336.86295919, 336.94151711, 337.01913357, 337.09640782,
337.17310565, 337.2492015 , 337.32501256, 337.39996691,
337.47409296, 337.54741758, 337.61996621, 337.69176298,
337.76283079, 337.8331914 , 337.90286553, 337.97187287,
338.0402322 , 338.10796146, 338.17507775, 338.24159741,
338.30753608, 338.37290872, 338.43772967, 338.50201265,
338.56577085, 338.62901691, 338.69176298, 338.75402072,
338.81580138, 338.87711575, 338.93797423, 338.99838684,
339.05836324, 339.11791275, 339.17704435, 339.23576672,
339.29408824, 339.35201701, 339.40956086, 339.46672736,
339.52352384, 339.57995739, 339.63603489, 339.69176298,
339.74714811, 339.80219656, 339.85691437, 339.91130743,
339.96538147, 340.01914203, 340.0725945 , 340.12574411,
340.17859596, 340.23115499, 340.28342602, 340.33541374,
340.38712269, 340.43855732, 340.48972195, 340.54062078,
340.59125791, 340.64163735, 340.69176298])
epsilon: 0.001
max_iter: 250
sigma: array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2,
2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8,
9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10])
num_iter: 250
method: 'value iteration'
In [1]:
# Mを増やす、Bを増やすなどは速度比較の話としてはナンセンス?
# より細かく貯蓄、消費出来るようになるにつれて計算が大変になってくる、というのを観測しないといけない?
# MとかBはあくまで最大値、間隔についてはdiscreteで有る限りいじれない ?
# とはいえ数を大きくしたら間隔は相対的に小さくなる
In [4]:
# stateの数をもっと増やし、betaを1に近づける
#まずはbetaをいじくれるようにする
import quantecon as qe
import numpy as np
from gurobipy import *
import time
% matplotlib inline
import matplotlib.pyplot as plt
def plot_variable_beta(shock, state, b):
n = [None] * len(b)
count = 0
for i in b:
model = SimpleOG(B = shock, M = state, beta = i)
ddp = qe.markov.DiscreteDP(model.R, model.Q, model.beta)
n[count] = elapse(ddp)
count = count +1
for j in n:
if j > 200:
del j
plt.plot(n)
In [41]:
#プロットする
# ちょっと時間伸びる
betas = np.linspace(0.9, 0.9999, 1000)
plot_variable_beta(20,50,betas)
In [9]:
betas
Out[9]:
array([ 0.9 , 0.9001, 0.9002, 0.9003, 0.9004, 0.9005, 0.9006,
0.9007, 0.9008, 0.9009, 0.901 , 0.9011, 0.9012, 0.9013,
0.9014, 0.9015, 0.9016, 0.9017, 0.9018, 0.9019, 0.902 ,
0.9021, 0.9022, 0.9023, 0.9024, 0.9025, 0.9026, 0.9027,
0.9028, 0.9029, 0.903 , 0.9031, 0.9032, 0.9033, 0.9034,
0.9035, 0.9036, 0.9037, 0.9038, 0.9039, 0.904 , 0.9041,
0.9042, 0.9043, 0.9044, 0.9045, 0.9046, 0.9047, 0.9048,
0.9049, 0.905 , 0.9051, 0.9052, 0.9053, 0.9054, 0.9055,
0.9056, 0.9057, 0.9058, 0.9059, 0.906 , 0.9061, 0.9062,
0.9063, 0.9064, 0.9065, 0.9066, 0.9067, 0.9068, 0.9069,
0.907 , 0.9071, 0.9072, 0.9073, 0.9074, 0.9075, 0.9076,
0.9077, 0.9078, 0.9079, 0.908 , 0.9081, 0.9082, 0.9083,
0.9084, 0.9085, 0.9086, 0.9087, 0.9088, 0.9089, 0.909 ,
0.9091, 0.9092, 0.9093, 0.9094, 0.9095, 0.9096, 0.9097,
0.9098, 0.9099, 0.91 , 0.9101, 0.9102, 0.9103, 0.9104,
0.9105, 0.9106, 0.9107, 0.9108, 0.9109, 0.911 , 0.9111,
0.9112, 0.9113, 0.9114, 0.9115, 0.9116, 0.9117, 0.9118,
0.9119, 0.912 , 0.9121, 0.9122, 0.9123, 0.9124, 0.9125,
0.9126, 0.9127, 0.9128, 0.9129, 0.913 , 0.9131, 0.9132,
0.9133, 0.9134, 0.9135, 0.9136, 0.9137, 0.9138, 0.9139,
0.914 , 0.9141, 0.9142, 0.9143, 0.9144, 0.9145, 0.9146,
0.9147, 0.9148, 0.9149, 0.915 , 0.9151, 0.9152, 0.9153,
0.9154, 0.9155, 0.9156, 0.9157, 0.9158, 0.9159, 0.916 ,
0.9161, 0.9162, 0.9163, 0.9164, 0.9165, 0.9166, 0.9167,
0.9168, 0.9169, 0.917 , 0.9171, 0.9172, 0.9173, 0.9174,
0.9175, 0.9176, 0.9177, 0.9178, 0.9179, 0.918 , 0.9181,
0.9182, 0.9183, 0.9184, 0.9185, 0.9186, 0.9187, 0.9188,
0.9189, 0.919 , 0.9191, 0.9192, 0.9193, 0.9194, 0.9195,
0.9196, 0.9197, 0.9198, 0.9199, 0.92 , 0.9201, 0.9202,
0.9203, 0.9204, 0.9205, 0.9206, 0.9207, 0.9208, 0.9209,
0.921 , 0.9211, 0.9212, 0.9213, 0.9214, 0.9215, 0.9216,
0.9217, 0.9218, 0.9219, 0.922 , 0.9221, 0.9222, 0.9223,
0.9224, 0.9225, 0.9226, 0.9227, 0.9228, 0.9229, 0.923 ,
0.9231, 0.9232, 0.9233, 0.9234, 0.9235, 0.9236, 0.9237,
0.9238, 0.9239, 0.924 , 0.9241, 0.9242, 0.9243, 0.9244,
0.9245, 0.9246, 0.9247, 0.9248, 0.9249, 0.925 , 0.9251,
0.9252, 0.9253, 0.9254, 0.9255, 0.9256, 0.9257, 0.9258,
0.9259, 0.926 , 0.9261, 0.9262, 0.9263, 0.9264, 0.9265,
0.9266, 0.9267, 0.9268, 0.9269, 0.927 , 0.9271, 0.9272,
0.9273, 0.9274, 0.9275, 0.9276, 0.9277, 0.9278, 0.9279,
0.928 , 0.9281, 0.9282, 0.9283, 0.9284, 0.9285, 0.9286,
0.9287, 0.9288, 0.9289, 0.929 , 0.9291, 0.9292, 0.9293,
0.9294, 0.9295, 0.9296, 0.9297, 0.9298, 0.9299, 0.93 ,
0.9301, 0.9302, 0.9303, 0.9304, 0.9305, 0.9306, 0.9307,
0.9308, 0.9309, 0.931 , 0.9311, 0.9312, 0.9313, 0.9314,
0.9315, 0.9316, 0.9317, 0.9318, 0.9319, 0.932 , 0.9321,
0.9322, 0.9323, 0.9324, 0.9325, 0.9326, 0.9327, 0.9328,
0.9329, 0.933 , 0.9331, 0.9332, 0.9333, 0.9334, 0.9335,
0.9336, 0.9337, 0.9338, 0.9339, 0.934 , 0.9341, 0.9342,
0.9343, 0.9344, 0.9345, 0.9346, 0.9347, 0.9348, 0.9349,
0.935 , 0.9351, 0.9352, 0.9353, 0.9354, 0.9355, 0.9356,
0.9357, 0.9358, 0.9359, 0.936 , 0.9361, 0.9362, 0.9363,
0.9364, 0.9365, 0.9366, 0.9367, 0.9368, 0.9369, 0.937 ,
0.9371, 0.9372, 0.9373, 0.9374, 0.9375, 0.9376, 0.9377,
0.9378, 0.9379, 0.938 , 0.9381, 0.9382, 0.9383, 0.9384,
0.9385, 0.9386, 0.9387, 0.9388, 0.9389, 0.939 , 0.9391,
0.9392, 0.9393, 0.9394, 0.9395, 0.9396, 0.9397, 0.9398,
0.9399, 0.94 , 0.9401, 0.9402, 0.9403, 0.9404, 0.9405,
0.9406, 0.9407, 0.9408, 0.9409, 0.941 , 0.9411, 0.9412,
0.9413, 0.9414, 0.9415, 0.9416, 0.9417, 0.9418, 0.9419,
0.942 , 0.9421, 0.9422, 0.9423, 0.9424, 0.9425, 0.9426,
0.9427, 0.9428, 0.9429, 0.943 , 0.9431, 0.9432, 0.9433,
0.9434, 0.9435, 0.9436, 0.9437, 0.9438, 0.9439, 0.944 ,
0.9441, 0.9442, 0.9443, 0.9444, 0.9445, 0.9446, 0.9447,
0.9448, 0.9449, 0.945 , 0.9451, 0.9452, 0.9453, 0.9454,
0.9455, 0.9456, 0.9457, 0.9458, 0.9459, 0.946 , 0.9461,
0.9462, 0.9463, 0.9464, 0.9465, 0.9466, 0.9467, 0.9468,
0.9469, 0.947 , 0.9471, 0.9472, 0.9473, 0.9474, 0.9475,
0.9476, 0.9477, 0.9478, 0.9479, 0.948 , 0.9481, 0.9482,
0.9483, 0.9484, 0.9485, 0.9486, 0.9487, 0.9488, 0.9489,
0.949 , 0.9491, 0.9492, 0.9493, 0.9494, 0.9495, 0.9496,
0.9497, 0.9498, 0.9499, 0.95 , 0.9501, 0.9502, 0.9503,
0.9504, 0.9505, 0.9506, 0.9507, 0.9508, 0.9509, 0.951 ,
0.9511, 0.9512, 0.9513, 0.9514, 0.9515, 0.9516, 0.9517,
0.9518, 0.9519, 0.952 , 0.9521, 0.9522, 0.9523, 0.9524,
0.9525, 0.9526, 0.9527, 0.9528, 0.9529, 0.953 , 0.9531,
0.9532, 0.9533, 0.9534, 0.9535, 0.9536, 0.9537, 0.9538,
0.9539, 0.954 , 0.9541, 0.9542, 0.9543, 0.9544, 0.9545,
0.9546, 0.9547, 0.9548, 0.9549, 0.955 , 0.9551, 0.9552,
0.9553, 0.9554, 0.9555, 0.9556, 0.9557, 0.9558, 0.9559,
0.956 , 0.9561, 0.9562, 0.9563, 0.9564, 0.9565, 0.9566,
0.9567, 0.9568, 0.9569, 0.957 , 0.9571, 0.9572, 0.9573,
0.9574, 0.9575, 0.9576, 0.9577, 0.9578, 0.9579, 0.958 ,
0.9581, 0.9582, 0.9583, 0.9584, 0.9585, 0.9586, 0.9587,
0.9588, 0.9589, 0.959 , 0.9591, 0.9592, 0.9593, 0.9594,
0.9595, 0.9596, 0.9597, 0.9598, 0.9599, 0.96 , 0.9601,
0.9602, 0.9603, 0.9604, 0.9605, 0.9606, 0.9607, 0.9608,
0.9609, 0.961 , 0.9611, 0.9612, 0.9613, 0.9614, 0.9615,
0.9616, 0.9617, 0.9618, 0.9619, 0.962 , 0.9621, 0.9622,
0.9623, 0.9624, 0.9625, 0.9626, 0.9627, 0.9628, 0.9629,
0.963 , 0.9631, 0.9632, 0.9633, 0.9634, 0.9635, 0.9636,
0.9637, 0.9638, 0.9639, 0.964 , 0.9641, 0.9642, 0.9643,
0.9644, 0.9645, 0.9646, 0.9647, 0.9648, 0.9649, 0.965 ,
0.9651, 0.9652, 0.9653, 0.9654, 0.9655, 0.9656, 0.9657,
0.9658, 0.9659, 0.966 , 0.9661, 0.9662, 0.9663, 0.9664,
0.9665, 0.9666, 0.9667, 0.9668, 0.9669, 0.967 , 0.9671,
0.9672, 0.9673, 0.9674, 0.9675, 0.9676, 0.9677, 0.9678,
0.9679, 0.968 , 0.9681, 0.9682, 0.9683, 0.9684, 0.9685,
0.9686, 0.9687, 0.9688, 0.9689, 0.969 , 0.9691, 0.9692,
0.9693, 0.9694, 0.9695, 0.9696, 0.9697, 0.9698, 0.9699,
0.97 , 0.9701, 0.9702, 0.9703, 0.9704, 0.9705, 0.9706,
0.9707, 0.9708, 0.9709, 0.971 , 0.9711, 0.9712, 0.9713,
0.9714, 0.9715, 0.9716, 0.9717, 0.9718, 0.9719, 0.972 ,
0.9721, 0.9722, 0.9723, 0.9724, 0.9725, 0.9726, 0.9727,
0.9728, 0.9729, 0.973 , 0.9731, 0.9732, 0.9733, 0.9734,
0.9735, 0.9736, 0.9737, 0.9738, 0.9739, 0.974 , 0.9741,
0.9742, 0.9743, 0.9744, 0.9745, 0.9746, 0.9747, 0.9748,
0.9749, 0.975 , 0.9751, 0.9752, 0.9753, 0.9754, 0.9755,
0.9756, 0.9757, 0.9758, 0.9759, 0.976 , 0.9761, 0.9762,
0.9763, 0.9764, 0.9765, 0.9766, 0.9767, 0.9768, 0.9769,
0.977 , 0.9771, 0.9772, 0.9773, 0.9774, 0.9775, 0.9776,
0.9777, 0.9778, 0.9779, 0.978 , 0.9781, 0.9782, 0.9783,
0.9784, 0.9785, 0.9786, 0.9787, 0.9788, 0.9789, 0.979 ,
0.9791, 0.9792, 0.9793, 0.9794, 0.9795, 0.9796, 0.9797,
0.9798, 0.9799, 0.98 , 0.9801, 0.9802, 0.9803, 0.9804,
0.9805, 0.9806, 0.9807, 0.9808, 0.9809, 0.981 , 0.9811,
0.9812, 0.9813, 0.9814, 0.9815, 0.9816, 0.9817, 0.9818,
0.9819, 0.982 , 0.9821, 0.9822, 0.9823, 0.9824, 0.9825,
0.9826, 0.9827, 0.9828, 0.9829, 0.983 , 0.9831, 0.9832,
0.9833, 0.9834, 0.9835, 0.9836, 0.9837, 0.9838, 0.9839,
0.984 , 0.9841, 0.9842, 0.9843, 0.9844, 0.9845, 0.9846,
0.9847, 0.9848, 0.9849, 0.985 , 0.9851, 0.9852, 0.9853,
0.9854, 0.9855, 0.9856, 0.9857, 0.9858, 0.9859, 0.986 ,
0.9861, 0.9862, 0.9863, 0.9864, 0.9865, 0.9866, 0.9867,
0.9868, 0.9869, 0.987 , 0.9871, 0.9872, 0.9873, 0.9874,
0.9875, 0.9876, 0.9877, 0.9878, 0.9879, 0.988 , 0.9881,
0.9882, 0.9883, 0.9884, 0.9885, 0.9886, 0.9887, 0.9888,
0.9889, 0.989 , 0.9891, 0.9892, 0.9893, 0.9894, 0.9895,
0.9896, 0.9897, 0.9898, 0.9899, 0.99 , 0.9901, 0.9902,
0.9903, 0.9904, 0.9905, 0.9906, 0.9907, 0.9908, 0.9909,
0.991 , 0.9911, 0.9912, 0.9913, 0.9914, 0.9915, 0.9916,
0.9917, 0.9918, 0.9919, 0.992 , 0.9921, 0.9922, 0.9923,
0.9924, 0.9925, 0.9926, 0.9927, 0.9928, 0.9929, 0.993 ,
0.9931, 0.9932, 0.9933, 0.9934, 0.9935, 0.9936, 0.9937,
0.9938, 0.9939, 0.994 , 0.9941, 0.9942, 0.9943, 0.9944,
0.9945, 0.9946, 0.9947, 0.9948, 0.9949, 0.995 , 0.9951,
0.9952, 0.9953, 0.9954, 0.9955, 0.9956, 0.9957, 0.9958,
0.9959, 0.996 , 0.9961, 0.9962, 0.9963, 0.9964, 0.9965,
0.9966, 0.9967, 0.9968, 0.9969, 0.997 , 0.9971, 0.9972,
0.9973, 0.9974, 0.9975, 0.9976, 0.9977, 0.9978, 0.9979,
0.998 , 0.9981, 0.9982, 0.9983, 0.9984, 0.9985, 0.9986,
0.9987, 0.9988, 0.9989, 0.999 , 0.9991, 0.9992, 0.9993,
0.9994, 0.9995, 0.9996, 0.9997, 0.9998, 0.9999])
In [ ]:
#このサイズはメモリが死ぬ
plot_variable_beta(50,500,betas)
In [42]:
# betaに応じて時間が延びていく
# ただし、一定値を超えると延びにくくなるみたい
plot_variable_beta(20, 100,betas)
In [7]:
# 200秒超えたらカットするようにしてやり直す
betas = np.linspace(0.9, 0.9999, 1000)
plot_variable_beta(20, 200,betas)
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-7-8988ee62e34f> in <module>()
1 # 200秒超えたらカットするようにしてやり直す
2 betas = np.linspace(0.9, 0.9999, 1000)
----> 3 plot_variable_beta(20, 200,betas)
<ipython-input-4-0949ddf92f06> in plot_variable_beta(shock, state, b)
15 model = SimpleOG(B = shock, M = state, beta = i)
16 ddp = qe.markov.DiscreteDP(model.R, model.Q, model.beta)
---> 17 n[count] = elapse(ddp)
18 count = count +1
19 for j in n:
<ipython-input-6-ba6df988245b> in elapse(setting)
30 def elapse(setting):
31 start = time.time()
---> 32 setting.solve(method='value_iteration')
33 elapsed_time = time.time() - start
34 return elapsed_time
/Users/susu/anaconda/lib/python2.7/site-packages/quantecon/markov/ddp.pyc in solve(self, method, v_init, epsilon, max_iter, k)
664 res = self.value_iteration(v_init=v_init,
665 epsilon=epsilon,
--> 666 max_iter=max_iter)
667 elif method in ['policy_iteration', 'pi']:
668 res = self.policy_iteration(v_init=v_init,
/Users/susu/anaconda/lib/python2.7/site-packages/quantecon/markov/ddp.pyc in value_iteration(self, v_init, epsilon, max_iter)
705 num_iter = self.operator_iteration(T=self.bellman_operator,
706 v=v, max_iter=max_iter, tol=tol,
--> 707 Tv=Tv)
708 sigma = self.compute_greedy(v)
709
/Users/susu/anaconda/lib/python2.7/site-packages/quantecon/markov/ddp.pyc in operator_iteration(self, T, v, max_iter, tol, *args, **kwargs)
613
614 for i in range(max_iter):
--> 615 new_v = T(v, *args, **kwargs)
616 if tol is not None and np.abs(new_v - v).max() < tol:
617 v[:] = new_v
/Users/susu/anaconda/lib/python2.7/site-packages/quantecon/markov/ddp.pyc in bellman_operator(self, v, Tv, sigma)
504
505 """
--> 506 vals = self.R + self.beta * self.Q.dot(v) # Shape: (L,) or (n, m)
507
508 if Tv is None:
KeyboardInterrupt:
In [61]:
# PuLPを使って書き換える
import pulp
import quantecon as qe
import numpy as np
import time
from gurobipy import *
% matplotlib inline
import matplotlib.pyplot as plt
class SimpleOG(object):
def __init__(self, B=10, M=5, alpha=0.5, beta=0.9):
self.B, self.M, self.alpha, self.beta = B, M, alpha, beta
self.n = B + M + 1
self.m = M + 1
self.R = np.empty((self.n, self.m))
self.Q = np.zeros((self.n, self.m, self.n))
self.populate_Q()
self.populate_R()
def u(self, c):
return c**self.alpha
def populate_R(self):
for s in range(self.n):
for a in range(self.m):
self.R[s, a] = self.u(s - a) if a <= s else -np.inf
def populate_Q(self):
for a in range(self.m):
self.Q[:, a, a:(a + self.B + 1)] = 1.0 / (self.B + 1)
def elapse(setting):
start = time.time()
setting.solve(method='value_iteration')
elapsed_time = time.time() - start
return elapsed_time
def LP_approach(setting):
num_state = range(1, setting.num_states + 1)
num_action = range(1, setting.num_actions + 1)
LP = pulp.LpProblem('LP_Approach', pulp.LpMinimize)
value_functions = pulp.LpVariable.dicts('value', num_state, 0, 50000, 'Continuous')
# 順番通りに
# 行列として加える
for i in num_state:
for j in num_action:
LP += value_functions[i] - setting.beta * (pulp.lpSum(setting.Q[i-1, j-1, k-1] * value_functions[k] for k in num_state)) >= setting.R[i-1,j-1]
LP += pulp.lpSum(value_functions[i] for i in num_state)
LP.solve(pulp.GUROBI(msg = False))
v = np.empty(setting.num_states)
for i, value in enumerate(value_functions.values()):
v[i] = value.value()
res = qe.markov.ddp.DPSolveResult(v=v)
return res
def plot_graph(n, discount):
a = [None] * (n-9)
b = [None] * (n-9)
for i in range(10, n+1):
h = SimpleOG(M = i, beta = discount)
d = qe.markov.DiscreteDP(h.R, h.Q, h.beta)
a[i - 10] = LP_approach(d)
b[i - 10] = elapse(d)
plt.plot(a)
plt.plot(b)
In [62]:
h = SimpleOG()
d = qe.markov.DiscreteDP(h.R, h.Q, h.beta)
res = LP_approach(d)
In [63]:
res['v']
Out[63]:
array([ 19.01740222, 20.01740222, 20.43161578, 20.74945302,
21.04078099, 21.30873018, 21.54479816, 21.76928181,
21.98270358, 22.18824323, 22.3845048 , 22.57807736,
22.76109127, 22.94376708, 23.11533996, 23.27761762])
In [38]:
# お試し
problem = pulp.LpProblem('sample', pulp.LpMinimize)
a = pulp.LpVariable('a', 0, 1)
b = pulp.LpVariable('b', 0, 1)
problem += a + b
problem += a >= 0
problem += b >= 0.1
c = a + b == 0.5
problem += c
status = problem.solve(pulp.GUROBI(msg = False))
print problem
sample:
MINIMIZE
1*a + 1*b + 0
SUBJECT TO
_C1: a >= 0
_C2: b >= 0.1
_C3: a + b = 0.5
VARIABLES
a <= 1 Continuous
b <= 1 Continuous
In [36]:
problem2 = pulp.LpProblem('sample', pulp.LpMinimize)
a = pulp.LpVariable('a', 0, 1)
b = pulp.LpVariable('b', 0, 1)
problem2 += a + b
problem2 += a >= 0
problem2 += b >= 0.1
c = a + b == 0.5
problem2 += c
status = problem2.solve(pulp.GUROBI(msg = False))
print a.value()
print b.value()
0.4
0.1
In [ ]:
In [37]:
c.pi
Out[37]:
1.0
In [1]:
import pulp
pulp.pulpTestAll()
Testing zero subtraction
Testing inconsistant lp solution
Testing continuous LP solution
Testing maximize continuous LP solution
Testing unbounded continuous LP solution
Testing Long Names
Testing repeated Names
Testing zero constraint
Testing zero objective
Testing LpVariable (not LpAffineExpression) objective
Testing Long lines in LP
Testing LpAffineExpression divide
Testing MIP solution
Testing MIP solution with floats in objective
Testing MIP relaxation
Testing feasibility problem (no objective)
Testing an infeasible problem
Testing an integer infeasible problem
Testing column based modelling
Testing dual variables and slacks reporting
Testing fractional constraints
Testing elastic constraints (no change)
Testing elastic constraints (freebound)
Testing elastic constraints (penalty unchanged)
Testing elastic constraints (penalty unbounded)
* Solver pulp.solvers.PULP_CBC_CMD passed.
Solver pulp.solvers.CPLEX_DLL unavailable
Solver pulp.solvers.CPLEX_CMD unavailable
Solver pulp.solvers.CPLEX_PY unavailable
Solver pulp.solvers.COIN_CMD unavailable
Solver pulp.solvers.COINMP_DLL unavailable
Solver pulp.solvers.GLPK_CMD unavailable
Solver pulp.solvers.XPRESS unavailable
Testing zero subtraction
Testing inconsistant lp solution
Testing continuous LP solution
Testing maximize continuous LP solution
Testing unbounded continuous LP solution
Testing Long Names
Testing repeated Names
Testing zero constraint
Testing zero objective
Testing LpVariable (not LpAffineExpression) objective
Testing LpAffineExpression divide
Testing MIP solution
Testing MIP solution with floats in objective
Testing MIP relaxation
Testing feasibility problem (no objective)
Testing an infeasible problem
Testing an integer infeasible problem
Testing column based modelling
Testing Sequential Solves
Testing fractional constraints
Testing elastic constraints (no change)
Testing elastic constraints (freebound)
Testing elastic constraints (penalty unchanged)
Testing elastic constraints (penalty unbounded)
* Solver pulp.solvers.GUROBI passed.
Testing zero subtraction
Testing inconsistant lp solution
Testing continuous LP solution
Testing maximize continuous LP solution
Testing unbounded continuous LP solution
Testing Long Names
Testing repeated Names
Testing zero constraint
Testing zero objective
Testing LpVariable (not LpAffineExpression) objective
Testing LpAffineExpression divide
Testing MIP solution
/Users/susu/anaconda/lib/python2.7/site-packages/pulp/solvers.py:1957: UserWarning: GUROBI_CMD does provide good solution status of non optimal solutions
warnings.warn('GUROBI_CMD does provide good solution status of non optimal solutions')
/Users/susu/anaconda/lib/python2.7/site-packages/pulp/solvers.py:1918: UserWarning: GUROBI_CMD does not allow a problem to be relaxed
warnings.warn('GUROBI_CMD does not allow a problem to be relaxed')
Testing MIP solution with floats in objective
Testing MIP relaxation
Testing feasibility problem (no objective)
Testing an infeasible problem
Testing an integer infeasible problem
Testing column based modelling
Testing fractional constraints
Testing elastic constraints (no change)
Testing elastic constraints (freebound)
Testing elastic constraints (penalty unchanged)
Testing elastic constraints (penalty unbounded)
* Solver pulp.solvers.GUROBI_CMD passed.
Solver pulp.solvers.PYGLPK unavailable
Solver pulp.solvers.YAPOSIB unavailable
In [69]:
# random_stateで固定
ddp = qe.markov.random_discrete_dp(10,5,0.95, random_state=10)
In [70]:
LP_approach(ddp)
Out[70]:
v: array([ 24.90650054, 23.94646349, 24.90288023, 25.2223787 ,
26.12533269, 25.3660638 , 25.14553884, 24.97833818,
24.47872606, 24.40586476])
In [71]:
ddp.solve()
Out[71]:
mc: Markov chain with transition matrix
P =
[[ 0.03928177 0.21209237 0.20493041 0.0782534 0.05564341 0.00717029
0.2287512 0.07670892 0.08479371 0.01237453]
[ 0.05047767 0.0575861 0.05112996 0.01970908 0.12082706 0.03808601
0.17451827 0.16113277 0.21236017 0.1141729 ]
[ 0.03068484 0.00687284 0.16054298 0.09780311 0.14021449 0.01698674
0.11202135 0.02422136 0.21072104 0.19993125]
[ 0.02443264 0.0446007 0.06117845 0.05441505 0.07284859 0.14599442
0.05437967 0.35204215 0.10369007 0.08641827]
[ 0.04673923 0.14651451 0.40568272 0.08163793 0.1473288 0.03074584
0.09399492 0.01125659 0.01091198 0.0251875 ]
[ 0.05882237 0.07135317 0.20757911 0.0463672 0.01199594 0.0092615
0.49190066 0.00074436 0.04268273 0.05929296]
[ 0.08712836 0.04434324 0.14105457 0.08493702 0.18036924 0.19496283
0.0219283 0.01634769 0.00214037 0.22678838]
[ 0.23671088 0.01646827 0.15905826 0.03053224 0.07927991 0.14920734
0.03507398 0.06678471 0.08003981 0.14684459]
[ 0.05889401 0.03305527 0.08225066 0.07622399 0.17950217 0.00932825
0.09809967 0.2735802 0.02791236 0.16115341]
[ 0.01973246 0.01856094 0.14504515 0.11173734 0.13860378 0.09346721
0.21617435 0.06106168 0.02770185 0.16791524]]
v: array([ 24.90650054, 23.94646349, 24.90288023, 25.2223787 ,
26.12533269, 25.3660638 , 25.14553884, 24.97833818,
24.47872606, 24.40586476])
max_iter: 250
sigma: array([0, 1, 1, 3, 3, 0, 4, 3, 0, 3])
num_iter: 1
method: 'policy iteration'
In [68]:
ddp.controlled_mc([0, 4, 2, 3, 4, 2, 0, 1, 4, 2])
Out[68]:
Markov chain with transition matrix
P =
[[ 0.16782 0.12696193 0.09032819 0.04281228 0.12393955 0.17671779
0.05967387 0.11868314 0.00334126 0.08972199]
[ 0.04597117 0.20524265 0.19117263 0.04771229 0.05212154 0.22519911
0.11984219 0.0207287 0.03414344 0.05786627]
[ 0.09841414 0.19993101 0.0577203 0.20213123 0.04715059 0.00040787
0.15744139 0.06480928 0.12116256 0.05083163]
[ 0.0270752 0.22374387 0.01954761 0.14261422 0.01051968 0.11806244
0.23853822 0.0101653 0.01209942 0.19763404]
[ 0.06986435 0.17077758 0.02853657 0.1426529 0.00062258 0.09765898
0.02125019 0.00546029 0.0984123 0.36476427]
[ 0.12540914 0.26383707 0.17612476 0.03477701 0.05952332 0.03411563
0.11057969 0.01499996 0.08136703 0.09926639]
[ 0.07706997 0.2183956 0.10177841 0.10160283 0.00247895 0.02878472
0.16715544 0.22790927 0.0658949 0.00892991]
[ 0.09738881 0.23044221 0.0411637 0.04774205 0.11443574 0.15890881
0.03104322 0.07969942 0.08896716 0.11020889]
[ 0.09398309 0.00474594 0.10875691 0.04117221 0.05581124 0.32906979
0.04856064 0.06025388 0.22328005 0.03436625]
[ 0.01804454 0.10424327 0.00913306 0.17830528 0.25547 0.03896724
0.07295273 0.09538295 0.14251988 0.08498104]]
In [ ]:
Content source: keiikegami/DP
Similar notebooks: