mathematical-optimization

Algorithm for matching point sets

房东的猫 提交于 2019-12-06 07:06:10
问题 I have two sets of points A and B , whereas the points can be 2D or 3D. Both sets have the same size n , which is rather low (5 - 20). I would like to know how well these sets agree. That is, ideally I would find pairings between the points such that the sum of all Euclidean pair distances d(A,B) is minimal. So d(A,B) = \sum_{i=1}^n ||A_i - B_i||_2 The final outcome is used to compare with other point sets. So, for example: A = (1,1), (1,2), (1,3) B = (1,1), (2,2), (1,3) would give me d(A,B)

R: (How) can the nlm function be used for optimization with multiple variables

故事扮演 提交于 2019-12-06 05:28:08
Can the nlm function be used for optimization with multiple variables? How would that work? For instance: I want to find x and y so that f(x,y) is minimized. How would the nlm function work? something like that?: nlm(f,c(0.1,0.1)) Make a function that receives a vector: f <- function(X) { x <- X[1] y <- X[2] (x-3.14)^2 + (y-6.28)^2 } nlm(f,c(0.1,0.1)) 来源: https://stackoverflow.com/questions/40620277/r-how-can-the-nlm-function-be-used-for-optimization-with-multiple-variables

Nonlinear optimization with R for grouped variables

自古美人都是妖i 提交于 2019-12-06 05:22:41
I am trying to find maximum values for below objective function: objective <-function(bid,revenue,click,cost) { revenue_2 <- sum((revenue / cost)* (bid*click*bid*(cost/click) / cost)^(-0.2*revenue/cost)* (bid*click)*bid*(cost/click)) return(-revenue_2) } subject to roas_2 <- function(bid, revenue,click,cost) { revenue_2 <- ((revenue / cost)* (bid*click*bid*(cost/click) / cost)^(-0.2*revenue/cost))* (bid*click)*bid*(cost/click) cost_2 <- (bid*click)*bid*(cost/click) roas_2 <- (sum(revenue_2)/sum(cost_2)) -1.2 return(-roas_2) } where my values are as follows: click <- c(123565, 94434, 79345,

Statsmodels logistic regression convergence problems

谁都会走 提交于 2019-12-06 05:21:55
I'm trying to run a logistic regression in statsmodels on a large design matrix (~200 columns). The features include a number of interactions, categorical features and semi-sparse (70%) integer features. Although my design matrix is not actually ill-conditioned, it seems to be somewhat close (according to numpy.linalg.matrix_rank , it is full-rank with tol=1e-3 but not with tol=1e-2 ). As a result, I'm struggling to get logistic regression to converge with any of the methods in statsmodels. Here's what I've tried so far: method='newton' : Did not converge after 1000 iterations; raised a

scipy.optimize.minimize (COBYLA and SLSQP) ignores constraints initiated within for loop

给你一囗甜甜゛ 提交于 2019-12-06 03:43:53
I'm using scipy.optimize.minimize to solve a complex reservoir optimization model (SQSLP and COBYLA as the problem is constrained by both bounds and constraint equations). There is one decision variable per day (storage), and releases from the reservoir are calculated as a function of change in storage, within the objective function. Penalties based on releases and storage penalties are then applied with the goal of minimizing penalties (the objective function is a summation of all penalties). I've added some constraints within this model to limit the change in storage to the physical system

Resuming an optimization in scipy.optimize?

[亡魂溺海] 提交于 2019-12-06 01:50:42
问题 scipy.optimize presents many different methods for local and global optimization of multivariate systems. However, I have a very long optimization run needed that may be interrupted (and in some cases I may want to interrupt it deliberately). Is there any way to restart... well, any of them? I mean, clearly one can provide the last, most optimized set of parameters found as the initial guess, but that's not the only parameter in play - for example, there are also gradients (jacobians, for

Minimize function in adjacent items of an array

笑着哭i 提交于 2019-12-06 00:14:06
I have an array ( arr ) of elements, and a function ( f ) that takes 2 elements and returns a number. I need a permutation of the array, such that f(arr[i], arr[i+1]) is as little as possible for each i in arr . (and it should loop, ie. it should also minimize f(arr[arr.length - 1], arr[0]) ) Also, f works sort of like a distance, so f(a,b) == f(b,a) I don't need the optimum solution if it's too inefficient, but one that works reasonable well and is fast since I need to calculate them pretty much in realtime (I don't know what to length of arr is, but I think it could be something around 30)

Minimize sum of distances in point pairs

回眸只為那壹抹淺笑 提交于 2019-12-06 00:06:09
问题 I have a bunch of points on a 2-dimensional Grid. I want to group the Points into pairs, while minimizing the sum of the euclidean distances between the points of the pairs. Example: Given the points: p1: (1,1) p2: (5,5) p3: (1,3) p4: (6,6) Best solution: pair1 = (p1,p3), distance = 2 pair2 = (p2,p4), distance = 1 Minimized total distance: 1+2 = 3 I suspect this problem might be solvable with a variant of the Hungarian Algorithm?! What is the fastest way to solve the problem? (Little Remark:

Minimize quadratic function subject to linear equality constraints with SciPy

混江龙づ霸主 提交于 2019-12-05 21:54:39
问题 I have a reasonably simple constrained optimization problem but get different answers depending on how I do it. Let's get the import and a pretty print function out of the way first: import numpy as np from scipy.optimize import minimize, LinearConstraint, NonlinearConstraint, SR1 def print_res( res, label ): print("\n\n ***** ", label, " ***** \n") print(res.message) print("obj func value at solution", obj_func(res.x)) print("starting values: ", x0) print("ending values: ", res.x.astype(int)

k-shortest (alternative) path algorithm, java implementations

别说谁变了你拦得住时间么 提交于 2019-12-05 20:09:40
问题 Could you recommend any java library which implements k-shortest algorithm -> searching for alternative ways, not the only shortest one in directed multigraph ? I found only JGraphT but there is actually bug (which i submitted) but it will take a lot of time to fix it i guess, are there any other available implementations ? Except JGraphT i found only small one-man projects :/ OR would be hard to modify Disjktra shortest path alg to show alternative paths ? Thanks 回答1: 2 Possible Options: