Skip to content

Commit 6669861

Browse files
authored
Update solve_model.py
1 parent 5c514ef commit 6669861

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lectures/_static/lecture_specific/optgrowth/solve_model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ def solve_model(og,
44
verbose=True,
55
print_skip=25):
66
"""
7-
Solve model by iterating with the Bellman operator.
7+
通过迭代贝尔曼算子求解
88
99
"""
1010

11-
# Set up loop
12-
v = og.u(og.grid) # Initial condition
11+
# 设置迭代循环
12+
v = og.u(og.grid) # 初始条件
1313
i = 0
1414
error = tol + 1
1515

@@ -18,12 +18,12 @@ def solve_model(og,
1818
error = np.max(np.abs(v - v_new))
1919
i += 1
2020
if verbose and i % print_skip == 0:
21-
print(f"Error at iteration {i} is {error}.")
21+
print(f"{i} 次迭代的误差为 {error}")
2222
v = v_new
2323

2424
if error > tol:
25-
print("Failed to converge!")
25+
print("未能收敛!")
2626
elif verbose:
27-
print(f"\nConverged in {i} iterations.")
27+
print(f"\n{i} 次迭代后收敛。")
2828

2929
return v_greedy, v_new

0 commit comments

Comments
 (0)