optimization

In x86-64 asm: is there a way of optimising two adjacent 32-bit stores / writes to memory if the source operands are two immediate values?

拈花ヽ惹草 提交于 2021-01-27 03:59:22
问题 Is there a good way of optimising this code (x86-64) ? mov dword ptr[rsp], 0; mov dword ptr[rsp+4], 0 where the immediate values could be any values, not necessarily zero, but in this instance always immediate constants. Is the original pair of stores even slow? Write-combining in the hardware and parallel operation of the μops might just make everything ridiculously fast anyway? I’m wondering if there is no problem to fix. I’m thinking of something like (don’t know if the following

GCC optimization bug on weak const variable

陌路散爱 提交于 2021-01-22 06:51:11
问题 I'm getting a weird gcc behaviour when dealing with weak const variables on different optimize levels (i.e. -O0 or -O1 ). Here is the code: def.h : declarations const int var; int copy; int do_copy(void); weak.c : weak var definition, do_copy implementation doing copy = var #include "def.h" const int __attribute__((weak)) var = 1; int do_copy(void) { copy = var; return var; } main.c : strong var definition, and use of do_copy #include <stdio.h> #include "def.h" int copy = 0; int copy2 = 0;

What does eq_ref and ref types mean in MySQL explain

六月ゝ 毕业季﹏ 提交于 2021-01-20 15:31:15
问题 When we prefix an SQL query with the keyword "explain" we get a table with some columns. Please tell me what is the "type" column. What does eq_ref and ref mean in that context. 回答1: I'll try an explanation... eq_ref – imagine that you have two tables. Table A with columns (id, text) where id is a primary key. Table B with the same columns (id, text) where id is a primary key. Table A has the following data: 1, Hello 2, How are Table B has the following data: 1, world! 2, you? Imagine eq_ref

What does eq_ref and ref types mean in MySQL explain

爱⌒轻易说出口 提交于 2021-01-20 15:27:42
问题 When we prefix an SQL query with the keyword "explain" we get a table with some columns. Please tell me what is the "type" column. What does eq_ref and ref mean in that context. 回答1: I'll try an explanation... eq_ref – imagine that you have two tables. Table A with columns (id, text) where id is a primary key. Table B with the same columns (id, text) where id is a primary key. Table A has the following data: 1, Hello 2, How are Table B has the following data: 1, world! 2, you? Imagine eq_ref

fitness function for rsi using genetic algorithms

让人想犯罪 __ 提交于 2021-01-20 13:39:06
问题 This code is implementing a fitness function for rsi indicators using genetic algorithms but i have no idea what are the output for every function def strategy_return(trading_signal, asset_return): strat_ret = np.array(trading_signal[0:-1]) * np.array(asset_return[1::]) strat_ret = np.insert(strat_ret, 0, np.nan) return strat_ret def _cumulative_return(ret): cum_ret_list = [ret[0]] n = ret.shape[0] for i in range(1, n): cum_ret = (1 + ret[i]) * (1 + cum_ret_list[-1]) - 1 cum_ret_list.append

Product feature optimization with constraints

心已入冬 提交于 2021-01-07 04:12:56
问题 I have trained a Lightgbm model on learning to rank dataset. The model predicts relevance score of a sample. So higher the prediction the better it is. Now that the model has learned I would like to find the best values of some features that gives me the highest prediction score. So, lets say I have features u,v,w,x,y,z and the features I would like to optimize over are x,y,z . maximize f(u,v,w,x,y,z) w.r.t features x,y,z where f is a lightgbm model subject to constraints : y = Ax + b z = 4

Product feature optimization with constraints

不羁岁月 提交于 2021-01-07 04:10:21
问题 I have trained a Lightgbm model on learning to rank dataset. The model predicts relevance score of a sample. So higher the prediction the better it is. Now that the model has learned I would like to find the best values of some features that gives me the highest prediction score. So, lets say I have features u,v,w,x,y,z and the features I would like to optimize over are x,y,z . maximize f(u,v,w,x,y,z) w.r.t features x,y,z where f is a lightgbm model subject to constraints : y = Ax + b z = 4

Minimize cost based on purchased volume Pyomo

≯℡__Kan透↙ 提交于 2021-01-07 03:00:30
问题 I'd like to find the optimal solution for buying goods from suppliers where the shipping cost is dependent on the cost of goods bought from given supplier. I'm using Pyomo. My code so far is: model = ConcreteModel(name="(MN_2)") # products N = ['prod1', 'prod2', 'prod3'] # suppliers M = ['A', 'B'] # price p = {('prod1', 'A'): 10, ('prod2', 'A'): 9, ('prod3', 'A'): 50, ('prod1', 'B'): 16, ('prod2', 'B'): 20, ('prod3', 'B'): 35} # user quantity contraint q_u = {('prod1', 'A'): 2, ('prod2', 'A')

Minimize cost based on purchased volume Pyomo

こ雲淡風輕ζ 提交于 2021-01-07 02:59:09
问题 I'd like to find the optimal solution for buying goods from suppliers where the shipping cost is dependent on the cost of goods bought from given supplier. I'm using Pyomo. My code so far is: model = ConcreteModel(name="(MN_2)") # products N = ['prod1', 'prod2', 'prod3'] # suppliers M = ['A', 'B'] # price p = {('prod1', 'A'): 10, ('prod2', 'A'): 9, ('prod3', 'A'): 50, ('prod1', 'B'): 16, ('prod2', 'B'): 20, ('prod3', 'B'): 35} # user quantity contraint q_u = {('prod1', 'A'): 2, ('prod2', 'A')

Speed up search for the smallest x such that f(x) = target

与世无争的帅哥 提交于 2021-01-07 02:45:17
问题 Problem Given n , find the smallest positive x such that f(x) = n . f(x) is the sum of the digit sum of the factorials of the digits of x . For example, f(15) = digit_sum(1!) + digit_sum(5!) = digit_sum(1) + digit_sum(120) = (1) + (1 + 2 + 0) = 4 Breath first search can find the answer. Are there faster ways? Breath First Search def bfs(target, d_map): # Track which values of f(x) have we visited visited = set([0]) # f(x) of the current level of the search tree todo = [0] # Digits of x for