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

Error in L11 6.2 #15

Open
pth577 opened this issue May 15, 2020 · 1 comment
Open

Error in L11 6.2 #15

pth577 opened this issue May 15, 2020 · 1 comment

Comments

@pth577
Copy link

pth577 commented May 15, 2020

We get an error running the code in L11 under 6.2. It seems that the problem is the bounds and that for the first value of m2, the upper and lower bounds are the same - [1e-8, 1e-8].

We are able to solve the problem if we add 0.001 to the upper bound but as we are not sure what implications that might have to other problems, we hope that we can get a clarification of why this problem arises.

L11,1
L11,2

@AskerNC
Copy link

AskerNC commented May 15, 2020

This is an error that appeared in the 1.4.1 version of Scipy, it is fixed in the master-version on Github so future versions shouldn't have this problem.
As you've correctly noted this happens when the bounds are the same or extremely close. In this case, the optimizer should simply return 1e-8 as the optimal x (as it is the only available option due to the bounds) but the way the code is written it throws an error.
Adding 0,001 is theoretically (if you're being very stringent) not correct as it allows the consumer to spend 0,0001 more than was saved. But it will fix the problem and be numerically close to correct.
A more stringent thing to do would be to increase the lower bound of the solved space, f.x. 1e-4:
m2_vec = np.linspace(1e-4,5,500)
This is still arbitrarily close enough to zero for the plot to look the same. Further, in this particular problem, savings can't be negative so m2 will newer be lower than y2=1-delta=0.5, so it won't cause any disturbances for the interpolater.
It's a bit unfortunate to have a version-dependent error in the Scipy package, but I hope this explanation helps

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

No branches or pull requests

2 participants