optimization

Optimizing Calculations with numpy and numba Python

不打扰是莪最后的温柔 提交于 2021-01-29 15:08:13
问题 I am trying to make python run standard deviation functions faster with numba and numpy. However the problem is the for loop is very slow and I need alternatives so that I could make the code much faster. I iterated numba to the already existing numpy version however there is not much of a gain in performance. My original list_ has million of values within it thus it is taking a very long time to compute the standard deviation function. The list_ function down below is a very short numpy

Interaction and Deletion among widgets on Python + KivyMD and Code Optimization

北城余情 提交于 2021-01-29 14:58:56
问题 I am currently building an app that serves as a travel expenses manager. I have a system in which the user writes the desired amount of the expense on an MDTextField, such expense will be recorded in an MDList and the total amount of requested expenses will be added to an MDTextField. For clarity I will post a screen shot: All this system works correctly so far. However, there can be mistakes made by the user. I want the user to be able to delete an item from the MDList when the trash-can

Portfolio Optimize in R with ONLY a vector of mean returns and covariance matrix

ε祈祈猫儿з 提交于 2021-01-29 14:20:09
问题 Every package that I look at seems to require time series returns for my assets. For example I like the PortfolioAnalytics package, and I require many of the constraints offered (box constraints, group constraints, etc.). However, as far as I can tell it requires some sort of time series of returns, even if I specify my own moments (I could be wrong). All I have are the expected returns of each of my 14 assets and the covariance matrix. How can I do various forms of optimizations with that as

AVX intrinsics for tiled matrix multiplication [closed]

我怕爱的太早我们不能终老 提交于 2021-01-29 13:18:23
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 1 year ago . Improve this question I was trying to use AVX512 intrinsics to vectorize my loop of matrix multiplication (tiled). I used __mm256d as variables to store intermediate results and store them in my results. However, somehow this triggers memory corruption. I've got no hint why this is the case, as the non

Calculating optimized weights to maximize correlation

旧城冷巷雨未停 提交于 2021-01-29 09:20:33
问题 I have two time series data, columns A and B. I am computing rolling moving averages of different duration on column A. For example (5,10,15,20). I want to assign weights to each of these average columns so that the sumproduct of weights and average columns has maximum correlation with column B. In other words, how to implement excel like optimization in Python. Please have a look at the sample code and suggest the way forward. import pandas as pd import numpy as np dates = pd.date_range(

Calculating optimized weights to maximize correlation

倾然丶 夕夏残阳落幕 提交于 2021-01-29 09:07:11
问题 I have two time series data, columns A and B. I am computing rolling moving averages of different duration on column A. For example (5,10,15,20). I want to assign weights to each of these average columns so that the sumproduct of weights and average columns has maximum correlation with column B. In other words, how to implement excel like optimization in Python. Please have a look at the sample code and suggest the way forward. import pandas as pd import numpy as np dates = pd.date_range(

torch.optim returns “ValueError: can't optimize a non-leaf Tensor” for multidimensional tensor

梦想的初衷 提交于 2021-01-29 08:42:16
问题 I am trying to optimize the translations of the vertices of a scene with torch.optim.adam . It is a code piece from the redner tutorial series, which works fine with the initial setting. It tries to optimize a scene with shifting all the vertices by the same value called translation . Here is the original code: vertices = [] for obj in base: vertices.append(obj.vertices.clone()) def model(translation): for obj, v in zip(base, vertices): obj.vertices = v + translation # Assemble the 3D scene.

Correct way to offset headers while looping through a filtered list?

此生再无相见时 提交于 2021-01-29 08:33:15
问题 In the below code i'm trying to use a for loop through a filtered list. Without the offset the loop is going through each field and copying the data multiple times. With the offset its skipping rows. How can I rephrase this to only loop through each row once, and skip the header row? 'Offset Placement Wrong Set rngVisible = activeSheet.AutoFilter.Range.SpecialCells(xlCellTypeVisible).Offset(1, 0) For Each rngCell In rngVisible Rows(rngCell.Row).Select Selection.Copy Sheets(2).Select 'Skip

How to multiprocess for loops in python where each calculation is independent?

血红的双手。 提交于 2021-01-29 08:32:51
问题 I'm trying to learn something a little new in each mini-project I do. I've made a Game of Life( https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life ) program. This involves a numpy array where each point in the array (a "cell") has an integer value. To evolve the state of the game, you have to compute for each cell the sum of all its neighbour values (8 neighbours). The relevant class in my code is as follows, where evolve() takes in one of the xxx_method methods. It works fine for conv

TypeError: 'float' object cannot be interpreted as an integer with solve_qp in python

ε祈祈猫儿з 提交于 2021-01-29 08:28:14
问题 I am new to optimization using python and I have a problem with using the predefined function solve_qp from qpsolvers to find the optimize solution of my problems here is my code: import numpy as np X = np.array([1., 2., 4., 6., 9.]).reshape(5, 1) y = 0.5 + (0.3*X) + np.random.randn(5,1) from qpsolvers import solve_qp P = np.dot(X.T,X) q = np.transpose(-2*np.dot(X.T,y))[0] G = None h = None A = None b = None sol = solve_qp(P, q, G, h, A, b) I got error with the predefined function TypeError: