# optimization

##### Scipy Newton Krylov Expects Square Matrix

I am trying to use scipy.optimize.newton_krylov() to solve a least-squares optimization problem, i.e. finding x such that (Ax - b)**2 = 0. My understanding is that A has to be mxn with m>n, b has to be mx1, and x will be nx1. When I try to run the optimization, I get an error: ValueError: expected square matrix, but got shape=(40, 6) Presumably this error concerns the computation of the Jacobian and not my input matrix A? But if so, how can I change the values I am providing to the functions to resolve this problem? Any advice would be appreciated. The following code reproduces the error

2021-09-24 16:11:21    分类:问答    python   numpy   optimization   scipy

##### MongoDB [Index Optimization] perfomance during aggregation stage

I have around 50M document in my Mongo database called dma and I use this aggregation to obtain necessary data res and then manipulate with it. async function FormContract(ownerRealm, id) { try { const res = await collection.aggregate([ { \$match: { date: {\$gt:moment.utc().subtract(1, 'days').toDate(), \$lt:moment.utc().toDate()}, id: id, //45 values one by one ownerRealm: {\$in: ownerRealm} //20 values one-by-one } }, { \$group: { _id: "\$lastModified", open_interest: {\$sum: "\$buyout"}, min: {\$min: "\$price"}, min_size: {\$min: {\$cond: [{\$gte: ["\$quantity", 200]}, "\$price", "\$min:\$price"]}}, avg: {

2021-09-24 02:08:13    分类:问答    javascript   mongodb   performance   optimization   mongoose

##### 如何在 Linux 中的核心 i3/i7 中击败硬件预取器(How to defeat hardware prefetcher in core i3/i7 in linux)

2021-09-24 01:48:09    分类:技术分享    c   linux   optimization   assembly

##### MySQL INSERT 语句在大表中是否较慢？(are MySQL INSERT statements slower in huge tables?)

2021-09-23 22:42:18    分类:技术分享    mysql   optimization

##### 优化接近重复的值搜索(Optimizing near-duplicate value search)

2021-09-23 21:11:04    分类:技术分享    php   optimization   string-matching

##### Understanding performance impacts for mysql tuple search

I am working on a table structure like this (emp_data) id dept_id emp_id emp_name role 1 101 1001 Tom Good Worker 2 101 1002 Dick Smart Worker 3 102 1001 Harry Hard Worker 4 103 1001 Kate Nice Worker 5 101 1003 Lucy Great Worker id is the uncontested primary key :) (dept_id, emp_id) is a multi column index Now, I need to do some really big search on combinations on (dept_id, emp_id). I use tuple search which goes like this. select * from emp_data where (dept_id, emp_id) in ((101, 1001), (101, 1002), (103, 1001)); This takes quite some time when the table is quite long. But if i do this, select

2021-09-23 20:08:19    分类:问答    mysql   database   search   optimization   indexing

##### 为什么最自然的查询（即使用 INNER JOIN（而不是 LEFT JOIN））非常慢(Why the most natural query(I.e. using INNER JOIN (instead of LEFT JOIN)) is very slow)

2021-09-23 19:14:25    分类:技术分享    sql   postgresql   optimization

##### No performance gain after using multiprocessing for a queue-oriented function

The real code I want to optimize is too complicated to be included here, so here is a simplified example: def enumerate_paths(n, k): """ John want to go up a flight of stairs that has N steps. He can take up to K steps each time. This function enumerate all different ways he can go up this flight of stairs. """ paths = [] to_analyze = [(0,)] while to_analyze: path = to_analyze.pop() last_step = path[-1] if last_step >= n: # John has reach the top paths.append(path) continue for i in range(1, k + 1): # possible paths from this point extended_path = path + (last_step + i,) to_analyze.append

2021-09-23 18:07:20    分类:问答    python   performance   optimization   queue   multiprocessing

##### what makes Jsoup faster than HttpURLConnection & HttpClient in most cases

I want to compare performances for the three implementations mentioned in the title, I wrote a little JAVA program to help me doing this. The main method contains three blocks of testing, each block looks like this : nb=0; time=0; for (int i = 0; i < 7; i++) { double v = methodX(url); if(v>0){ nb++; time+=v; } } if(nb==0) nb=1; System.out.println("HttpClient : "+(time/ ((double) nb))+". Tries "+nb+"/7"); Variable nb is used to avoid failed requests. Now method methodX is one of : private static double testWithNativeHUC(String url){ try { HttpURLConnection httpURLConnection= (HttpURLConnection)

2021-09-23 16:16:31    分类:问答    java   optimization   jsoup   httpclient   httpurlconnection

##### 有没有办法优化我的 Powershell 函数以从大文件中删除模式匹配？(Is there a way to optimise my Powershell function for removing pattern matches from a large file?)

2021-09-23 14:59:20    分类:技术分享    regex   powershell   optimization   powershell-4.0