Skip to content

Instantly share code, notes, and snippets.

@PyDataBlog
Last active March 17, 2021 21:48
Show Gist options
  • Save PyDataBlog/1b56799a4160e63a087a7c3dc811730b to your computer and use it in GitHub Desktop.
Save PyDataBlog/1b56799a4160e63a087a7c3dc811730b to your computer and use it in GitHub Desktop.
cost = [10, 10, 10, 10, 1, 1, 1]
function count_no_improvements(x)
counter = 0
for i in 1:size(x, 1)
if (i > 1) && abs(x[i] - x[i-1]) < (1e-6 * x[i])
counter += 1
else
counter = 0
end
end
return counter
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment