mathematical-optimization

Find first root of a black box function, or any negative value of same function

橙三吉。 提交于 2019-11-30 20:24:17
问题 I have a black box function, f(x) and a range of values for x. I need to find the lowest value of x for which f(x) = 0. I know that for the start of the range of x, f(x) > 0, and if I had a value for which f(x) < 0 I could use regula falsi, or similar root finding methods, to try determine f(x)=0. I know f(x) is continuous, and should only have 0,1 or 2 roots for the range in question, but it might have a local minimum. f(x) is somewhat computationally expensive, and I'll have to find this

Pareto optimization - non-dominated points

萝らか妹 提交于 2019-11-30 18:32:38
问题 I wrote an algorithm that returns a list similar to that which nsga2 returns. (nsga2 of package "mco" (pdf)) The algorithm can not itself recognize if a point is non-dominated. Some of the points it returns are dominated and it only contains the points and their values, not the logic-vector that nsga2 returns. I am trying to get the non-dominated points (not their values). With nsga2's result you can use paretoSet() to get the values, however that depends on that the logic-vector has been

Using scipy to minimize a function that also takes non variational parameters

自作多情 提交于 2019-11-30 18:11:59
问题 I want to use the scipy.optimize module to minimize a function. Let's say my function is f(x,a) : def f(x,a): return a*x**2 For a fixed a , I want to minimize f(x,a) with respect to x . With scipy I can import for example the fmin function (I have an old scipy: v.0.9.0), give an initial value x0 and then optimize (documentation): from scipy.optimize import fmin x0 = [1] xopt = fmin(f, x0, xtol=1e-8) which fails because f takes two arguments and fmin is passing only one (actually, I haven't

Integer linear programming: example and good tools?

三世轮回 提交于 2019-11-30 17:49:01
问题 Find a vector x which minimizes c . x subject to the constraint m . x >= b, x integer. Here's a sample input set: c : {1,2,3} m : {{1,0,0}, {0,1,0}, {1,0,1}} b : {1,1,1} With output: x = {1,1,0} What are good tools for solving this sort of problem, and examples of how to use them? 回答1: Mathematica Mathematica has this built in. (NB: Mathematica is not free software.) LinearProgramming[c, m, b, Automatic, Integers] outputs: {1, 1, 0} 回答2: GLPK I'm offering an answer using GLPK's glpsol, but I

Simulated Binary Crossover (SBX) crossover operator in Scala genetic algorithm (GA) library

佐手、 提交于 2019-11-30 17:46:09
问题 I work on a very little research team to create/adapt a Genetic Algorithm library in Scala for distributed computation with Scientific Worklow System, in our case we use the open source OpenMole software (http://www.openmole.org/). Recently, i try to understand and re-implement the SBX crossover operator written in JMetal Metaheuristics library (http://jmetal.sourceforge.net/) to adapt it in functionnal version in our Scala library. I write some code, but i need our advice or your validation

Fast inverse square root on the iPhone

﹥>﹥吖頭↗ 提交于 2019-11-30 15:27:34
问题 The fast inverse square function used by SGI/3dfx and most notably in Quake is often cited as being faster than the assembly instruction equivalent, however the posts claiming that seem quite dated. I was curious about its performance on more modern hardware, and particularly on mobile devices like the iPhone. I wouldn't be surprised if the Quake sqrt is not longer a worthwhile optimization on desktop systems, but how about for an iPhone project involving a lot of 3D math? Is it something

Understanding the error for scipy.optimize.minimize() function

僤鯓⒐⒋嵵緔 提交于 2019-11-30 09:55:49
问题 I have a simple equation that I plotted via def chernoff_bound(beta): return 0.5 * np.exp(-beta * (1-beta)) betas = np.arange(0, 1, 0.01) c_bound = chernoff_bound(betas) plt.plot(betas, c_bound) plt.title('Chernoff Bound') plt.ylabel('P(error)') plt.xlabel('parameter beta') plt.show() Now, I want to find the value where P(error) is minimum. I tried to do it via the scipy.optimize.minimize() function (honestly, I haven't used it before and there is maybe some error of thought here ...) from

What's the most efficient way to detect triangle-triangle intersections?

心已入冬 提交于 2019-11-30 07:14:30
How can I tell whether two triangles intersect in 2D Euclidean space? (i.e. classic 2D geometry) given the (X,Y) coordinates of each vertex in each triangle. One way is to check if two sides of triangle A intersect with any side of triangle B, and then check all six possibilities of a point of A inside B or a point of B inside A. For a point inside a triangle see for example: Point in triangle test. When we test collisions on polygons we also have a surrounding rectangle for our polygons. So we first test for rectangle collisions and if there is a hit we proceed with polygon collision

Create scipy curve fitting definitions for fourier series dynamically

喜你入骨 提交于 2019-11-30 05:44:48
问题 I'd like to achieve a fourier series development for a x-y-dataset using numpy and scipy . At first I want to fit my data with the first 8 cosines and plot additionally only the first harmonic . So I wrote the following two function defintions: # fourier series defintions tau = 0.045 def fourier8(x, a1, a2, a3, a4, a5, a6, a7, a8): return a1 * np.cos(1 * np.pi / tau * x) + \ a2 * np.cos(2 * np.pi / tau * x) + \ a3 * np.cos(3 * np.pi / tau * x) + \ a4 * np.cos(4 * np.pi / tau * x) + \ a5 * np

Finding the local maxima/peaks and minima/valleys of histograms

谁都会走 提交于 2019-11-30 04:13:10
Ok, so I have a histogram (represented by an array of ints), and I'm looking for the best way to find local maxima and minima. Each histogram should have 3 peaks, one of them (the first one) probably much higher than the others. I want to do several things: Find the first "valley" following the first peak (in order to get rid of the first peak altogether in the picture) Find the optimum "valley" value in between the remaining two peaks to separate the picture I already know how to do step 2 by implementing a variant of Otsu. But I'm struggling with step 1 In case the valley in between the two