-
-
Notifications
You must be signed in to change notification settings - Fork 23
[amss*] Build Warnings Issued by SciPy #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Using the latest environment the <ipython-input-8-0cc001bf9680>:18: RuntimeWarning: invalid value encountered in log
return np.log(c) + self.ψ * np.log(1 - n)
<ipython-input-8-0cc001bf9680>:18: RuntimeWarning: divide by zero encountered in log
return np.log(c) + self.ψ * np.log(1 - n)
<ipython-input-8-0cc001bf9680>:22: RuntimeWarning: divide by zero encountered in true_divide
return 1 / c
<ipython-input-4-cc6b33fcda51>:235: RuntimeWarning: invalid value encountered in true_divide
x * u_c / Eu_c - u_c * (c - T) - Un(c, n) * n - β * xprime,
<ipython-input-4-cc6b33fcda51>:235: RuntimeWarning: invalid value encountered in multiply
x * u_c / Eu_c - u_c * (c - T) - Un(c, n) * n - β * xprime,
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-9-764875dee216> in <module>
2 log_example.transfers = True # Government can use transfers
3 log_sequential = SequentialAllocation(log_example) # Solve sequential problem
----> 4 log_bellman = RecursiveAllocationAMSS(log_example, μ_grid)
5
6 T = 20
<ipython-input-4-cc6b33fcda51> in __init__(self, model, μgrid, tol_diff, tol)
15
16 # Find the first best allocation
---> 17 self.solve_time1_bellman()
18 self.T.time_0 = True # Bellman equation now solves time 0 problem
19
<ipython-input-4-cc6b33fcda51> in solve_time1_bellman(self)
62 PF = T(Vf)
63
---> 64 Vfnew, policies = self.fit_policy_function(PF)
65 diff = np.abs((Vf(xgrid) - Vfnew(xgrid)) / Vf(xgrid)).max()
66
<ipython-input-4-cc6b33fcda51> in fit_policy_function(self, PF)
81 cf, nf, xprimef, Tf, Vf = [], [], [], [], []
82 for s_ in range(S):
---> 83 PFvec = np.vstack([PF(x, s_) for x in self.xgrid]).T
84 Vf.append(interp(xgrid, PFvec[0, :]))
85 cf.append(interp(xgrid, PFvec[1:1 + S]))
<ipython-input-4-cc6b33fcda51> in <listcomp>(.0)
81 cf, nf, xprimef, Tf, Vf = [], [], [], [], []
82 for s_ in range(S):
---> 83 PFvec = np.vstack([PF(x, s_) for x in self.xgrid]).T
84 Vf.append(interp(xgrid, PFvec[0, :]))
85 cf.append(interp(xgrid, PFvec[1:1 + S]))
<ipython-input-4-cc6b33fcda51> in PF(x, s)
207 '''
208 if not self.time_0:
--> 209 def PF(x, s): return self.get_policies_time1(x, s, Vf)
210 else:
211 def PF(B_, s0): return self.get_policies_time0(B_, s0, Vf)
<ipython-input-4-cc6b33fcda51> in get_policies_time1(self, x, s_, Vf)
242 bounds = [(0., 100)] * S + [(0., 100)] * S + \
243 [self.xbar] * S + [(0., 0.)] * S
--> 244 out, fx, _, imode, smode = fmin_slsqp(objf, self.z0[x, s_],
245 f_eqcons=cons, bounds=bounds,
246 full_output=True, iprint=0,
~/anaconda3/envs/quantecon/lib/python3.8/site-packages/scipy/optimize/slsqp.py in fmin_slsqp(func, x0, eqcons, f_eqcons, ieqcons, f_ieqcons, bounds, fprime, fprime_eqcons, fprime_ieqcons, args, iter, acc, iprint, disp, full_output, epsilon, callback)
203 'args': args}, )
204
--> 205 res = _minimize_slsqp(func, x0, args, jac=fprime, bounds=bounds,
206 constraints=cons, **opts)
207 if full_output:
~/anaconda3/envs/quantecon/lib/python3.8/site-packages/scipy/optimize/slsqp.py in _minimize_slsqp(func, x0, args, jac, bounds, constraints, maxiter, ftol, iprint, disp, eps, callback, finite_diff_rel_step, **unknown_options)
424
425 if mode == -1: # gradient evaluation required
--> 426 g = append(sf.grad(x), 0.0)
427 a = _eval_con_normals(x, cons, la, n, m, meq, mieq)
428
~/anaconda3/envs/quantecon/lib/python3.8/site-packages/scipy/optimize/_differentiable_functions.py in grad(self, x)
186 if not np.array_equal(x, self.x):
187 self._update_x_impl(x)
--> 188 self._update_grad()
189 return self.g
190
~/anaconda3/envs/quantecon/lib/python3.8/site-packages/scipy/optimize/_differentiable_functions.py in _update_grad(self)
169 def _update_grad(self):
170 if not self.g_updated:
--> 171 self._update_grad_impl()
172 self.g_updated = True
173
~/anaconda3/envs/quantecon/lib/python3.8/site-packages/scipy/optimize/_differentiable_functions.py in update_grad()
89 self._update_fun()
90 self.ngev += 1
---> 91 self.g = approx_derivative(fun_wrapped, self.x, f0=self.f,
92 **finite_diff_options)
93
~/anaconda3/envs/quantecon/lib/python3.8/site-packages/scipy/optimize/_numdiff.py in approx_derivative(fun, x0, method, rel_step, abs_step, f0, bounds, sparsity, as_linear_operator, args, kwargs)
389
390 if np.any((x0 < lb) | (x0 > ub)):
--> 391 raise ValueError("`x0` violates bound constraints.")
392
393 if as_linear_operator:
ValueError: `x0` violates bound constraints. |
Hi @mmcky this looks exact as the issue I helped to solve in |
ah @shizejin you're a genius I wonder if I have migrated the associated |
this 17898f1 updates the to use the latest |
Thanks @shizejin -- this is now fixed. |
@shizejin these lectures are now running but they do have a number of warnings issued https://60a31e5802cc6d17a5a6d6f7--wonderful-lalande-528d1c.netlify.app/amss.html |
@mmcky thanks for this message. I am working on refactoring the code and probably I can solve these warnings. Might you let me know if this is in hurry? We plan to wrap up the changes by the end of May. |
@shizejin -- no problem. No hurry. But when you're ready I think the site will be powered by this repo using |
Closing this as warnings may be addressed by upcoming rework of |
The AMSS lectures are not currently executing through
github actions
The text was updated successfully, but these errors were encountered: