mathematical-optimization

Sorting points such that the minimal Euclidean distance between consecutive points would be maximized

自古美人都是妖i 提交于 2019-12-07 07:43:20
问题 Given a set of points in a 3D Cartesian space, I am looking for an algorithm that will sort these points, such that the minimal Euclidean distance between two consecutive points would be maximized. It would also be beneficial if the algorithm tends to maximize the average Euclidean distance between consecutive points. Edit: I've crossposted on https://cstheory.stackexchange.com/ and got a good answer. See https://cstheory.stackexchange.com/questions/8609/sorting-points-such-that-the-minimal

Find the Discrete Pair of {x,y} that Satisfy Inequality Constriants

走远了吗. 提交于 2019-12-07 05:30:42
问题 I have a few inequalities regarding {x,y} , that satisfies the following equations: x>=0 y>=0 f(x,y)=x^2+y^2>=100 g(x,y)=x^2+y^2<=200 Note that x and y must be integer. Graphically it can be represented as follows, the blue region is the region that satisfies the above inequalities: The question now is, is there any function in Matlab that finds every admissible pair of {x,y} ? If there is an algorithm to do this kind of thing I would be glad to hear about it as well. Of course, one approach

Parallel / Multicore Processing in R for an Integer Program?

こ雲淡風輕ζ 提交于 2019-12-06 14:56:07
问题 Are there any packages specifically to let R run faster via parallel computing? I have made a very large IP that needs to run for a while, so I was wondering if there was a specific package in R that could help me run my IP. Currently, I have a function that returns the solution of an IP and the primary line that R gets stuck on (for a very...very long time) is when I use lp (....all.int = TRUE). My CPU is around 12.5% (8 cores) on my Windows computer, and I want it to near 100 Edit: I tried

How do I specify multiple variable constraints using Integer Programming in PuLP?

旧巷老猫 提交于 2019-12-06 14:53:44
I am trying to solve the Bin Packing Problem using the Integer Programming Formulation in Python PuLP. The model for the problem is as follows: I have written the following Python Code using the PuLP library from pulp import * #knapsack problem def knapsolve(bins, binweight, items, weight): prob = LpProblem('BinPacking', LpMinimize) y = [LpVariable("y{0}".format(i+1), cat="Binary") for i in range(bins)] xs = [LpVariable("x{0}{1}".format(i+1, j+1), cat="Binary") for i in range(items) for j in range(bins)] #minimize objective nbins = sum(y) prob += nbins print(nbins) #constraints prob += nbins >

How can I adjust parameters for image processing algorithm in an efficient way?

天大地大妈咪最大 提交于 2019-12-06 14:41:33
Before starting implementation of solution for my problem I just want to be sure if I will not “reinvent wheel” and if I can reuse work that someone have done before. So my problem is: I have made image matcher using OpenCV library. This matcher receives a set of image files and trying to find similar images in database. At the end it returns statistical results according to ROC Curves definition (True Positive, True Negative, False Positive and False Negative number of matches). These results can vary because of OpenCV’s library algorithm parameters values, which are about 10. This means that

Java Optimizing arithmetic and Assignment Operators for large input

天大地大妈咪最大 提交于 2019-12-06 13:21:27
I have a piece of code that must run extremely fast in terms of clock speed. The algorithm is already in O(N). It takes 2seconds, it needs to take 1s. For most A.length inputs ~ 100,000 it takes .3s unless a particular line of code is invoked an extreme number of times. (For an esoteric programming challenge) It uses a calculation of the arithmetic series that 1,2,..N -> 1,3,4,10,15.. that can be represented by n*(n+1)/2 I loop through this equation hundreds of thousands of times. I do not have access to the input, nor can I display it. The only information I am able to get returned is the

Minimizing functions with large gradients using `scipy.optimize.minimize`

拟墨画扇 提交于 2019-12-06 13:14:34
I need to optimize a scalar function in a high-dimensional space. The function varies quickly with changing arguments such that the (absolute value of) gradients are large. The optimizers in scipy.optimize.minimize fail because the minimization procedure takes steps that are too large. The following code illustrates the problem using a simple quadratic function. from scipy.optimize import minimize def objective(x, scalar=1): """ Quadratic objective function with optional scalar. """ # Report function call for debugging print "objective({}, scalar={})".format(x, scalar) # Return function value

Solve for maximum likelihood with two parameters under constraints

佐手、 提交于 2019-12-06 12:58:15
I'm trying to implement a beta-geometric probability model in R (as described in this whitepaper ) which involves solving an equation with two unknown parameters. In the example, they use Excel to do this, starting the values off at alpha = beta = 1 and constraining them to alpha > 0.0001 < beta . I've nearly implemented this in R , but I can't seem to make any solver work for me. Please help. RFiddle here # probability mass function P = function (alpha, beta, t) { out = numeric(length=length(t)) for (i in seq_along(t)) { if (t[i]==1) { out[i] = alpha / (alpha + beta) } else { out[i] = ((beta

How to quantitatively measure goodness of fit in SciPy?

早过忘川 提交于 2019-12-06 10:56:53
问题 I am tying to find out the best fit for data given. What I did is I loop through various values of n and calculate the residual at each p using the formula ((y_fit - y_actual) / y_actual) x 100. Then I calculate the average of this for each n and then find the minimum residual mean and the corresponding n value and fit using this value. A reproducible code included: import numpy as np import matplotlib.pyplot as plt from scipy import optimize x = np.array([12.4, 18.2, 20.3, 22.9, 27.7, 35.5,

Number of Sides Required to draw a circle in OpenGL

馋奶兔 提交于 2019-12-06 08:14:10
Does anyone know some algorithm to calculate the number of sides required to approximate a circle using polygon, if radius, r of the circle and maximum departure of the polygon from circularity, D is given? I really need to find the number of sides as I need to draw the approximated circle in OpenGL. Also, we have the resolution of the screen in NDC coordinates per pixel given by P and solving D = P/2, we could guarantee that our circle is within half-pixel of accuracy. What you're describing here is effectively a quality factor, which often goes hand-in-hand with error estimates. A common way