I currently have a list of id’s approx. of size 10,000. I need to update all rows in the mySQL table which have an id in the inactive_ids list that you see below. I need to change their active status to ‘No’ which is a column in the mySQL table. I am using mysql.connector python library. When I run the
Tag: optimization
Scipy Optimise (minimize) not giving correct results
I am trying to do a simple minimisation as below using SciPy optimise, but the expected results are NOT matching the optimiser output: I would expect the final results to be close to “x_expected”… but that is not the case.. any ideas ? Answer SLSQP solver failed to find the optimal value for your problem. Therefore, inequality constraint does not
Scipy BasinHopping not returning correct global minima
I’m working with the following scipy code. The global minimum of this function is at 0, but this isn’t what basin hopping returns. Depending on the start position x0, it returns different local minima – not the global one at 0. If we set x_0 = -6, it returns a minima at -7.7, if we set x0 = 1, then
Fast way to get items removed from a list and items appended to a list based on an old version and a new version
I have a class in python that contains a list, that can be updated by calling a function. This list has several associated lists, which are all updated whenever the list is updated. However, one of the lists has roughly 40,000 items, and so when it is updated and all the related lists are updated, and it takes a very
mixed integer programming optimization
I am trying to understand how gekko and its different types of custom variables work. So I wrote a very simple optimization problem, but it won’t find the optimal solution, at least this is what i think the error message means. The code is a simple set switch combination (braco_gas and braco_eh, both binaries) multiplied by some weights (vazao and
Pyomo find minimal sum of list values
I want to have an indexed binary variable so pyomo optimises it to minimise the total sum of the list while picking at least 2 elements. When I remove the (imo redundant) model.q I receive: ValueError: No variables appear in the Pyomo model constraints or objective. This is not supported by the NL file interface and the solution pyomo gives
I have written this function to get the size of a string, can it be optimized?
I don’t want to use python functions to calculate but I want to implement a function myself. The problem comes when the chain is very long. The program starts to take about 5 minutes. Answer Why don’t you use len()? I think what you’re trying to do is just len(‘holaaaaaa’) and I don’t think that it can be more optimized
making multiple request at the same time with the module requests and print the output on excel(python)
Hi this is quite a complicated question From this script: The code by itself do what is supposed to do (getting the data:foward eps,peg ratio,sector and paste them on an excel file)but the issue is that it takes a lot of time and the list stock is quite long(2531 elements) is there a way to make this code more efficent
Python count amount of cells forming a line with random shape in an array
Context: I work with satellite images that I filter to transform to arrays of 1s and 0s, based on the presence of snow (0 for snow, 1 for non-snow). My code creates an array of NaNs, searches for each snow pixel if at least one of the neighbor is non-snow (in a cross patter, cells painted red in the picture
Algorithm for ordering data so that neighbor elements are as identical as possible
I have a (potentially large) list data of 3-tuples of small non-negative integers, like I want to order the tuples within data so that neighboring tuples (data[i] and data[i+1]) are “as similar as possible”. Define the dissimilarity of two 3-tuples as the number of elements which are unequal between them. E.g. (0, 1, 2) vs. (0, 1, 2): Dissimilarity 0.