optimization

Scipy minimize: How to pass args to both the objective and the constraint

♀尐吖头ヾ 提交于 2020-01-04 09:21:46
问题 My MWE is as follows def obj(e, p): S = f(e) + g(p) return S I would like to minimize this function over only e and pass p as an argument to the function. However, I also would like a constraint that depends on p and e that is of the form p + e < 1 I tried cons = {'type': 'ineq', 'fun': lambda e, p: -e -p + 1, 'args': (p)} And then, I try to minimize this for the case of p = 0.5 minimize(obj, initial_guess, method = 'SLSQP', args = 0.5, constraints = cons) but this doesn't work. I get the

Scipy minimize: How to pass args to both the objective and the constraint

徘徊边缘 提交于 2020-01-04 09:21:28
问题 My MWE is as follows def obj(e, p): S = f(e) + g(p) return S I would like to minimize this function over only e and pass p as an argument to the function. However, I also would like a constraint that depends on p and e that is of the form p + e < 1 I tried cons = {'type': 'ineq', 'fun': lambda e, p: -e -p + 1, 'args': (p)} And then, I try to minimize this for the case of p = 0.5 minimize(obj, initial_guess, method = 'SLSQP', args = 0.5, constraints = cons) but this doesn't work. I get the

Can I make a variable temporarily volatile?

守給你的承諾、 提交于 2020-01-04 09:16:08
问题 In PSoC, one can declare variables in memory space mapped to flash. Since flash reads are slower than RAM reads, the program would benefit from compiler optimizations - allow the values to be stored in registers or otherwise cached. Except for when one modifies the value of the flash. This can be done on the fly and the programmer knows the precise moments that happens. This also is done relatively rarely (to protect flash from write wear) and takes relatively long time. In case of such a

Can I make a variable temporarily volatile?

浪尽此生 提交于 2020-01-04 09:16:02
问题 In PSoC, one can declare variables in memory space mapped to flash. Since flash reads are slower than RAM reads, the program would benefit from compiler optimizations - allow the values to be stored in registers or otherwise cached. Except for when one modifies the value of the flash. This can be done on the fly and the programmer knows the precise moments that happens. This also is done relatively rarely (to protect flash from write wear) and takes relatively long time. In case of such a

General Minimum RESidual (GMRES) with ILU preconditioner

痞子三分冷 提交于 2020-01-04 09:06:17
问题 I'm trying to implement the ILU preconditioner in this GMRES code I wrote (in order to solve the linear sistem Ax = b. I'm trying with an easy tridiagonal SPD matrix of dimension 25x25. As you can see I'm calculating the preconditioner with spilu method. The code is running without error, but the solution is clearly wrong since, at the end of the code, I'm printing the norm of b and the norm of the product A*x. They are not nearly the same.. The code Run fine without preconditioner and

IPOPT options for reducing constraint violation after fewer iterations

扶醉桌前 提交于 2020-01-04 06:57:09
问题 I am using IPOPT implemented through OpenMDAO and am having some trouble understanding and controlling the stopping criteria. Here is what I'm experiencing specifically: Initially, IPOPT is able to find a solution that appears to be much better, although constraints are violated slightly (intuition tells me that adjusting a few parameters would likely bring it into the feasible region). From this discussion I understand that "linear or nonlinear equality or inequality constraint will not

Oracle SQL technique to avoid filling trans log

女生的网名这么多〃 提交于 2020-01-04 06:46:09
问题 Newish to Oracle programming (from Sybase and MS SQL Server). What is the "Oracle way" to avoid filling the trans log with large updates? In my specific case, I'm doing an update of potentially a very large number of rows. Here's my approach: UPDATE my_table SET a_col = null WHERE my_table_id IN (SELECT my_table_id FROM my_table WHERE some_col < some_val and rownum < 1000) ...where I execute this inside a loop until the updated row count is zero, Is this the best approach? Thanks, 回答1: The

Oracle SQL technique to avoid filling trans log

£可爱£侵袭症+ 提交于 2020-01-04 06:45:48
问题 Newish to Oracle programming (from Sybase and MS SQL Server). What is the "Oracle way" to avoid filling the trans log with large updates? In my specific case, I'm doing an update of potentially a very large number of rows. Here's my approach: UPDATE my_table SET a_col = null WHERE my_table_id IN (SELECT my_table_id FROM my_table WHERE some_col < some_val and rownum < 1000) ...where I execute this inside a loop until the updated row count is zero, Is this the best approach? Thanks, 回答1: The

Excel VBA Optimization

自作多情 提交于 2020-01-04 06:27:49
问题 I was asked by a user to run a macro from within an Excel book they created in order to automate a process. I call the macro from Java via cscript. I am no VBA programmer by any stretch of the imagination, but the code is inefficient and is simple copy/paste over and over. When I run the macro from Java I get the following error: Run-Time Error '1004': CopyPicture method of range class failed This error does not happen when I enter the workbook and manually click the button which launches

Faster way to compute likelihood of sequence?

跟風遠走 提交于 2020-01-04 06:15:16
问题 This is my second question of previous one Faster way to do multi dimensional matrix addition? After follow the advice of @Peter Cordes i vectorize my code and now the speed has been up by 50X. Then i again did the gprof and found this function is taking most of the time. Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls Ts/call Ts/call name 69.97 1.53 1.53 cal_score(int, std::string, int const*, int, double) double cal_score(int l, string seq, const