Skip to content
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

Fixes for examples and solutions notebook #183

Merged
merged 14 commits into from
Sep 14, 2015
Merged

Fixes for examples and solutions notebook #183

merged 14 commits into from
Sep 14, 2015

Conversation

mmcky
Copy link
Contributor

@mmcky mmcky commented Sep 10, 2015

This branch is applying fixes for broken examples and solutions notebooks.

Broken

  1. examples/paths_and_hist.py
  2. examples/robust_monopolist.oy
  3. examples/lakemodel_example.py
  4. solutions/lakemodel_solutions.ipynb

Fixed

  1. examples/lakemodel_example.py => Added lakemodel.py to quantecon library for use by this example and the related solutions notebook.
  2. solutions/lakemodel_solutions.ipynb => Same as above.

In addition this PR improves the reporting on the command line.

@mmcky
Copy link
Contributor Author

mmcky commented Sep 10, 2015

@cc7768 Any ideas why robust_monopolist.py is failing to converge? I looked at the history of the robust_monopolist.py but it isn't immediately apparent to me.

Traceback (most recent call last):
  File "robust_monopolist.py", line 130, in <module>
    Po, Fo, do = optimal_lq.stationary_values()
  File "/home/matthewmckay/anaconda/lib/python2.7/site-packages/quantecon/lqcontrol.py", line 209, in stationary_values
    P = solve_discrete_riccati(A0, B0, R, Q, N)
  File "/home/matthewmckay/anaconda/lib/python2.7/site-packages/quantecon/matrix_eqn.py", line 197, in solve_discrete_riccati
    raise ValueError(fail_msg.format(i))
ValueError: Convergence failed after 501 iterations.

@cc7768
Copy link
Member

cc7768 commented Sep 10, 2015

@mmcky I looked around, but nothing changed within that file should break it -- At some point we may have changed the order of arguments for solve_discrete_riccati. Could that be it?

Notice:

This may have been on purpose; I don't remember whether Q and R are the same in LQ and solve_discrete_riccati (I remember being confused at one point about them). Off the top of my head that's best suggestion I have. I can look into it more later if it turns out to not be the problem.

@mmcky
Copy link
Contributor Author

mmcky commented Sep 11, 2015

@cc7768 That is a little odd. I had a quick look into this and tried swapping them but then you get a linalg problem. So it doesn't immedietly seem like a quick fix.

Traceback (most recent call last):
  File "examples/robust_monopolist.py", line 130, in <module>
    Po, Fo, do = optimal_lq.stationary_values()
  File "/home/matthewmckay/anaconda/lib/python2.7/site-packages/quantecon/lqcontrol.py", line 209, in stationary_values
    P = solve_discrete_riccati(A0, B0, Q, R, N)
  File "/home/matthewmckay/anaconda/lib/python2.7/site-packages/quantecon/matrix_eqn.py", line 166, in solve_discrete_riccati
    Q_tilde = - Q + dot(N.T, solve(Z, N + gamma * BTA)) + gamma * I
  File "/home/matthewmckay/anaconda/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 381, in solve
    r = gufunc(a, b, signature=signature, extobj=extobj)
  File "/home/matthewmckay/anaconda/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 90, in _raise_linalgerror_singular
    raise LinAlgError("Singular matrix")
numpy.linalg.linalg.LinAlgError: Singular matrix

@mmcky
Copy link
Contributor Author

mmcky commented Sep 11, 2015

Introduced dimension checking on input for lss.py picked up two other files where the C vector should be column and not row. Fixes for tsh_hg.py and paths_and_stationarity.py submitted.

@mmcky
Copy link
Contributor Author

mmcky commented Sep 14, 2015

With only one example left to fix example/robust_monopolist.py I propose we merge this branch to incorporate current fixes and open an issue to track the last item.

@jstac
Copy link
Contributor

jstac commented Sep 14, 2015

@mmcky Many thanks.

jstac added a commit that referenced this pull request Sep 14, 2015
Fixes for examples and solutions notebook
@jstac jstac merged commit 6fc257c into master Sep 14, 2015
@jstac jstac deleted the fix-eg-sol branch September 14, 2015 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants