I’m writing optimised Floyd-Warshall algorithm on GPU using numba. I need it to work in a few seconds in case of 10k matricies. Right now the processing is done in around 60s. Here is my code: To be honest I’m pretty new to writing scripts on GPU, so do you have any ideas how to make this code even faster?
Tag: optimization
How could constraints be dynamically constructed in gekko?
I’m a newbie in gekko, and want to use it in my linear programming problems. I have variable names, costs, minimum and maximum bounds in separate dictionaries (my_vars, Cost, Min and Max) with variable names as their keys, and the objective is minimizing total cost with determining the amount of variables satisfying the constraints. I did as below; Here I’d
What are ‘population energies’?
In scipy.optimize.differential_evolution, the convergence criteria are that: This begs the question, what are ‘population energies’ please? This could be a follow up question to: Explain the intuition for the tol paramer in scipy differential evolution I tried looking in the code, but I got: So a follow up question would be what does that do please? Answer As you wrote
Problem: Squares of a Sorted Array | Can anyone lookout this code [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question Can anyone recorrect this code? Code is not working properly. The output should
Manipulating 2D matrix using numpy boolean indexing takes a long time
I’ve generated a huge amount of random data like so: which is a 100,000 by 1000 matrix(!) I’m generating new matrix where for each row, each column is true if the mean of all the columns beforehand (minus the expectancy of bernoulli RV with p=0.25) is greater than equal some epsilon. like so: After doing so I’m generating a 1-d
Min swaps for sorting list of consecutive integers
The problem: You are given an unordered array consisting of consecutive integers [1, 2, 3, …, n] without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the array in ascending order. My solution/issue: My code does what it is supposed to; however, for large arrays it
Python: porting to cvxopt quadratic programming from MATLAB’s quadprog
I am porting a MATLAB script to Python that uses the quadprog function. The best equivalent seems to be qp. I can work out the equivalent notation with the doc and a bit of time, but I’m lazy and it would be nice to just copy-paste some code instead of thinking about it. So: Which of the parameters in the
Efficiently accumulating a collection of sparse scipy matrices
I’ve got a collection of O(N) NxN scipy.sparse.csr_matrix, and each sparse matrix has on the order of N elements set. I want to add all these matrices together to get a regular NxN numpy array. (N is on the order of 1000). The arrangement of non-zero elements within the matrices is such that the resulting sum certainly isn’t sparse (virtually
Fast way to remove a few items from a list/queue
This is a follow up to a similar question which asked the best way to write and it seems the consensus was on something like However, I think if you are only removing a few items, most of the items are being copied into the same object, and perhaps that is slow. In an answer to another related question, someone
Finding the most frequent character in a string
I found this programming problem while looking at a job posting on SO. I thought it was pretty interesting and as a beginner Python programmer I attempted to tackle it. However I feel my solution is quite…messy…can anyone make any suggestions to optimize it or make it cleaner? I know it’s pretty trivial, but I had fun writing it. Note: