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

Fix the rosenbrock function #98

Merged
merged 2 commits into from
Apr 14, 2018
Merged

Fix the rosenbrock function #98

merged 2 commits into from
Apr 14, 2018

Conversation

mamadyonline
Copy link
Contributor

Resolve the issue of no matching shape between
the input and the output of the function.

Resolve the issue of no matching shape between
the input and the output of the function.
j = []
for e in x:
r = np.sum(100*(e[1:] - e[:-1]**2.0)**2 + (1-e[:-1])**2.0, axis=0)
j.append(r)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for this @mamadyonline

Hmmm, as an added challenge, do you think you can do this without for-loops? (i.e., just using vectorization techniques). This is so that we can reduce overhead complexity when given for-loops. Imagine if we run this in 10k particles, the changes might be more pronounced. I'm thinking of something like this:

sum(100.0* np.square(x[1:] - x[:-1]**2.0) + (1 - x[:-1])**2.0)

Would you mind checking if this is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 👍

Vectorized version to reduce computation
overhead for higher dimensions.
@ljvmiranda921
Copy link
Owner

Awesome! @mamadyonline I will merge this now

@ljvmiranda921 ljvmiranda921 merged commit 68b8d13 into ljvmiranda921:master Apr 14, 2018
@mamadyonline mamadyonline deleted the fix-rosenbrock branch April 14, 2018 17:16
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.

2 participants