mathematical-optimization

Parallel / Multicore Processing in R for an Integer Program?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 20:43:18
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 using the doParallel package, library('doParallel') cl <- makeCluster(8) registerDoParallel(cl) But my

C# - Finding Peaks within a Given Width via Quadratic Fit

核能气质少年 提交于 2019-12-04 20:16:40
I'm working on an algorithm to find peaks in a List object. I'd thought up what I thought was a good (or good enough) algorithm for doing this by looking at a point and it's neighbors and, if it was a peak, adding it to the results list. However, given some recent results, I don't think this method works as well as I'd initially hoped. (I've included the code I'm currently using, and hope to replace, below). I've done a little work with LabView before and I know that the way their module finds peaks/valleys works for what I need to do. I did some research into how LabView does this and found

How to quantitatively measure goodness of fit in SciPy?

荒凉一梦 提交于 2019-12-04 17:16:28
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, 53.9]) y = np.array([1, 50, 60, 70, 80, 90, 100]) y_residual = np.empty(shape=(1, len(y))) residual

Setting up a linear optimizer with an “or” constraint

荒凉一梦 提交于 2019-12-04 14:48:03
问题 I have a big linear optimizer I'm running and need some help setting up the constraints to get what I want. It's hard for me to express it in words exactly (hence the vague post-title), so I've written an example, details: Select a total of 5 items, maximizing value and keeping the cost under 5k. Each item has 2 "types". They are either labeled type1 = A, B, C, D, or E, and either type2 = X or Y. 4 items must be type X, 1 must be type Y The below example works great, but I want to add two

Pratition rectangle into smaller ones containig exactly 1 point, maximize wastelands area

荒凉一梦 提交于 2019-12-04 14:31:25
问题 Given a rectangle R containing P points, orthogonal with axes, points are natural numbers. Parcel is a rectangle which: is totally inside R sides are orthgonal with axes contains exactly ONE point inside its sides must be adjacent to sides of R or contain point(s) from P Find an algorithm to find all possible parcels inside R, so their total area is minimal (maximize wastelands area). Example: One of many ways of division, 5 points(*), 2 parcels R |--------------------------------------------

sum of absolute values constraint in semi definite programming

纵然是瞬间 提交于 2019-12-04 13:33:16
问题 I want to further my real world semi definite programming optimization problem with a constraint on sum of absolute values. For example: abs(x1) + abs(x2) + abs(x3) <= 10. I have searched internet and documentation but could not find a way to represent this. I am using python and cvxopt module. 回答1: Your constraint is equivalent to the following eight constraints: x1 + x2 + x3 <= 10 x1 + x2 - x3 <= 10 x1 - x2 + x3 <= 10 x1 - x2 - x3 <= 10 -x1 + x2 + x3 <= 10 -x1 + x2 - x3 <= 10 -x1 - x2 + x3

Linear programming library for .NET / C# [closed]

强颜欢笑 提交于 2019-12-04 12:02:36
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I need to solve an under-determined linear system of equations and constraints, then find the particular solution that minimises a cost function. This needs to be done in purely portable managed code that will run in .NET and Mono. What freely available libraries are there that I can use to implement this? All

How to use constraint programming for optimizing shopping baskets?

☆樱花仙子☆ 提交于 2019-12-04 07:23:32
I have a list of items I want to buy. The items are offered by different shops and different prices. The shops have individual delivery costs. I'm looking for an optimal shopping strategy (and a java library supporting it) to purchase all of the items with a minimal total price. Example: Item1 is offered at Shop1 for $100, at Shop2 for $111. Item2 is offered at Shop1 for $90, at Shop2 for $85. Delivery cost of Shop1: $10 if total order < $150; $0 otherwise Delivery cost of Shop2: $5 if total order < $50; $0 otherwise If I buy Item1 and Item2 at Shop1 the total cost is $100 + $90 +$0 = $190. If

Non Linear Integer Programming

两盒软妹~` 提交于 2019-12-04 06:35:05
I would like to know if there is a package in R handling non linear integer optimization. "Basically", I would like to solve the following problem: max f(x) s.t x in (0,10) and x is integer . I know that some branching algorithms are able to handle the linear version of this problem, but here my function f() might be more complicated. (I can't even make sure it would be quadratic of the form f(x)=xQx ). I guess there is always the brute force solution to test all the possibilities as long as they are bounded, but I was wondering if there wasn't anything smarter. I have a few options for you,

Resuming an optimization in scipy.optimize?

為{幸葍}努か 提交于 2019-12-04 05:24:03
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 example), populations in differential evolution, etc. I obviously don't want these to have to start over